Changeset 505
- Timestamp:
- 07/16/07 00:36:17 (16 months ago)
- Location:
- team/michiel/remove_multi_blog/common
- Files:
-
- 3 modified
-
js/liveRequest.js (modified) (3 diffs)
-
livesearch.php (modified) (2 diffs)
-
mvblog_common.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
team/michiel/remove_multi_blog/common/js/liveRequest.js
r1 r505 1 var inputId = 'search'; 1 var inputId = 'search'; 2 2 // This is the id on the input/textarea that you want to use as the query. 3 3 4 4 var outputId = 'searchresults'; 5 5 // use this to have the results populate your own ID'd tag. 6 6 // leave it blank and a div tag will automatically be added 7 7 // with an id="liveSearchResults" 8 8 9 9 var processURI = 'common/livesearch.php'; 10 10 // this is the file that you request data from. 11 11 12 12 var emptyString = ''; 13 13 // What to display in the results field when there's nothing … … 47 47 48 48 function liveReqInit() { 49 49 50 50 inputElement = document.getElementById(inputId); 51 51 outputElement = document.getElementById(outputId); 52 53 if( inputElement == null || outputElement == null ) 52 53 if( inputElement == null || outputElement == null ) 54 54 return; 55 56 55 56 57 57 if (navigator.userAgent.indexOf("Safari") > 0) { 58 58 inputElement.addEventListener("keydown",liveReqStart,false); 59 59 60 60 } else if (navigator.product == "Gecko") { 61 61 inputElement.addEventListener("keypress",liveReqStart,false); 62 62 63 63 } else { 64 64 inputElement.attachEvent('onkeydown',liveReqStart); 65 65 isIE = true; 66 66 } 67 67 68 68 if(emptyString == '') { 69 69 // set the result field to hidden, or to default string … … 93 93 liveReq = new ActiveXObject("Microsoft.XMLHTTP"); 94 94 } 95 95 96 96 liveReq.onreadystatechange = liveReqProcessReqChange; 97 var uri = processURI + "?s=" + encodeURI(inputElement.value); 97 98 liveReq.open("GET", processURI + "?s=" + encodeURI(inputElement.value)); 98 99 liveReqLast = inputElement.value; -
team/michiel/remove_multi_blog/common/livesearch.php
r504 r505 18 18 * @copyright 2005-2007 Michiel van Baak 19 19 */ 20 function db_init() { 21 session_start();22 require("MDB2.php"); 23 require("hosts.php");20 require("mvblog.php"); 21 $mvblog = new MvBlog(); 22 //get all the authors in an array 23 $res =& $mvblog->db->query("SELECT * FROM authors"); 24 24 25 $options = array( 26 "debug" => 2, 27 "portability" => MDB2_PORTABILITY_ALL, 28 ); 25 if (PEAR::isError($res)) { 26 die($res->getMessage()); 27 } 29 28 30 $db =& MDB2::connect($dsn, $options); 31 if (PEAR::isError($db)) { 32 die($db->getMessage()); 33 } 34 $_SESSION["filepath"] = $filepath; 35 return $db; 29 while ($row = $res->fetchRow(MDB2_FETCHMODE_ASSOC)) { 30 $authors[$row["id"]]["fullname"] = $row["fullname"]; 31 $authors[$row["id"]]["email"] = $row["email"]; 36 32 } 37 ob_start();38 $db = db_init();39 40 41 33 42 34 $searchstring = urldecode($_REQUEST["s"]); … … 49 41 $query .= " ORDER BY date DESC"; 50 42 51 $ db->setLimit(5);52 $res =& $ db->query($query);43 $mvblog->db->setLimit(5); 44 $res =& $mvblog->db->query($query); 53 45 $ret = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; 54 46 $ret .= "<channel>\n"; -
team/michiel/remove_multi_blog/common/mvblog_common.php
r490 r505 258 258 protected function _init_db($settings = "") { 259 259 require_once("MDB2.php"); 260 if (!is_array($settings)) { 261 require_once("hosts.php"); 260 //sqlite has a different scheme, because it's filebased 261 if ($settings["type"] == "sqlite") { 262 if (is_dir("db")) 263 $dsn = sprintf("%s:///db/%s.db?mode=0666", $settings["type"], $settings["database"]); 264 elseif (is_dir("../db")) 265 $dsn = sprintf("%s:///../db/%s.db?mode=0666", $settings["type"], $settings["database"]); 262 266 } else { 263 //sqlite has a different scheme, because it's filebased 264 if ($settings["type"] == "sqlite") { 265 if (is_dir("db")) 266 $dsn = sprintf("%s:///db/%s.db?mode=0666", $settings["type"], $settings["database"]); 267 elseif (is_dir("../db")) 268 $dsn = sprintf("%s:///../db/%s.db?mode=0666", $settings["type"], $settings["database"]); 269 } else { 270 $dsn = $settings["type"]."://".$settings["username"].":".$settings["password"]."@tcp(".$settings["hostname"].")/".$settings["database"]; 271 $dsn = sprintf("%s://%s:%s@tcp(%s)/%s", 272 $settings["type"], $settings["username"], $settings["password"], 273 $settings["hostname"], $settings["database"]); 274 } 267 $dsn = $settings["type"]."://".$settings["username"].":".$settings["password"]."@tcp(".$settings["hostname"].")/".$settings["database"]; 268 $dsn = sprintf("%s://%s:%s@tcp(%s)/%s", 269 $settings["type"], $settings["username"], $settings["password"], 270 $settings["hostname"], $settings["database"]); 275 271 } 276 272 … … 498 494 if (array_key_exists("style", $_REQUEST)) { 499 495 /* Overwrite the style set in the session from the request */ 500 $_SESSION["style"] = $this->_sanitize($_REQUEST["style"]); 496 $_SESSION["style"] = $this->_sanitize($_REQUEST["style"]); 501 497 } 502 498 if (!array_key_exists("style", $_SESSION)) {
