Commit 18dd666f91c19e5e853e4582722e4a770c6e260a
1 parent
880ee16c
Added new members and function to Owl_DB class for use with visual patterns
git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@66 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
1 changed file
with
169 additions
and
70 deletions
lib/owl.lib.php
| @@ -24,30 +24,30 @@ | @@ -24,30 +24,30 @@ | ||
| 24 | 24 | ||
| 25 | class Owl_DB extends DB_Sql { | 25 | class Owl_DB extends DB_Sql { |
| 26 | 26 | ||
| 27 | - //declare member variables | ||
| 28 | - var $classname = "Owl_DB"; | 27 | + /** Class name */ |
| 28 | + var $classname = "Owl_DB"; | ||
| 29 | 29 | ||
| 30 | - // BEGIN wes changes -- moved these settings to config/owl.php | ||
| 31 | - // Server where the database resides | ||
| 32 | - var $Host = ""; | ||
| 33 | - | ||
| 34 | - // Database name | ||
| 35 | - var $Database = ""; | ||
| 36 | - | ||
| 37 | - // User to access database | ||
| 38 | - var $User = ""; | ||
| 39 | - | ||
| 40 | - // Password for database | ||
| 41 | - var $Password = ""; | ||
| 42 | -//------------------------------------------------------------ | ||
| 43 | -/** | ||
| 44 | - * Function Owl_DB | ||
| 45 | - * | ||
| 46 | - * Default Constructor | ||
| 47 | - * | ||
| 48 | -*/ | ||
| 49 | -//------------------------------------------------------------ | ||
| 50 | -// Usable | 30 | + // BEGIN wes changes -- moved these settings to config/owl.php |
| 31 | + // Server where the database resides | ||
| 32 | + | ||
| 33 | + /** Host name. Retrieved from config/owl.php */ | ||
| 34 | + var $Host = ""; | ||
| 35 | + /** Database name */ | ||
| 36 | + var $Database = ""; | ||
| 37 | + /** Database user */ | ||
| 38 | + var $User = ""; | ||
| 39 | + /** Database user password */ | ||
| 40 | + var $Password = ""; | ||
| 41 | + /** Query to execute */ | ||
| 42 | + var $sQuery; | ||
| 43 | + /** Name of table last query was executed on*/ | ||
| 44 | + var $sLastTableName; | ||
| 45 | + /** Where clause last used in query execution */ | ||
| 46 | + var $sLastWhereClause; | ||
| 47 | + /** Order by clause last used in query execution */ | ||
| 48 | + var $sLastOrderByClause; | ||
| 49 | + | ||
| 50 | + /** Default Constructor */ | ||
| 51 | function Owl_DB() { | 51 | function Owl_DB() { |
| 52 | global $default; | 52 | global $default; |
| 53 | $this->Host = $default->owl_db_host; | 53 | $this->Host = $default->owl_db_host; |
| @@ -56,22 +56,121 @@ class Owl_DB extends DB_Sql { | @@ -56,22 +56,121 @@ class Owl_DB extends DB_Sql { | ||
| 56 | $this->Password = $default->owl_db_pass; | 56 | $this->Password = $default->owl_db_pass; |
| 57 | } | 57 | } |
| 58 | // END wes changes | 58 | // END wes changes |
| 59 | - | ||
| 60 | -//------------------------------------------------------------ | ||
| 61 | -/** | ||
| 62 | - * Function haltmsg | ||
| 63 | - * | ||
| 64 | - * Error Handling | ||
| 65 | - * | ||
| 66 | -*/ | ||
| 67 | -//------------------------------------------------------------ | ||
| 68 | -//usable | ||
| 69 | - function haltmsg($msg) | ||
| 70 | - { | ||
| 71 | - printf("</td></table><b>Database error:</b> %s<br>\n", $msg); | ||
| 72 | - printf("<b>SQL Error</b>: %s (%s)<br>\n", | ||
| 73 | - $this->Errno, $this->Error); | ||
| 74 | - } | 59 | + |
| 60 | + /** | ||
| 61 | + * Create a query from the provided paramaters. The ID column | ||
| 62 | + * is seleted by default | ||
| 63 | + * | ||
| 64 | + * @param $sTableName Table to query | ||
| 65 | + * @param $aColumns Columns in table | ||
| 66 | + * @param $sWhereClause Where clause (optional) | ||
| 67 | + * @param $sOrderByClause Order by clause (optional) | ||
| 68 | + */ | ||
| 69 | + function createSQLQuery($sTableName, $aColumns, $sWhereClause = null, $sOrderByClause = null) { | ||
| 70 | + $this->sLastTableName = $sTableName; | ||
| 71 | + $this->sLastWhereCluase = $sWhereClause; | ||
| 72 | + $this->sLastOrderByClause = $sOrderByClause; | ||
| 73 | + | ||
| 74 | + $this->sQuery = "SELECT ID, "; | ||
| 75 | + | ||
| 76 | + for( $i = 0; $i < count($aColumns) - 1; $i++ ) { | ||
| 77 | + $this->sQuery = $this->sQuery . $aColumns[$i] . ","; | ||
| 78 | + } | ||
| 79 | + | ||
| 80 | + $this->sQuery .= $aColumns[count($aColumns) - 1] . " "; | ||
| 81 | + $this->sQuery .= "FROM " . $sTableName . " "; | ||
| 82 | + | ||
| 83 | + if (isset($sWhereClause)) { | ||
| 84 | + $this->sQuery .= "WHERE " . $sWhereClause . " "; | ||
| 85 | + } | ||
| 86 | + | ||
| 87 | + if (isset($sOrderByClause)) { | ||
| 88 | + $this->sQuery .= "ORDER BY " . $sOrderByClause . " "; | ||
| 89 | + } | ||
| 90 | + | ||
| 91 | + } | ||
| 92 | + | ||
| 93 | + /** | ||
| 94 | + Create a query from the provided paramaters, specifying a limit and an offset. | ||
| 95 | + The ID column is selected by default | ||
| 96 | + | ||
| 97 | + @param $sTableName Table to query | ||
| 98 | + @param $aColumns Columns in table | ||
| 99 | + @param $iOffset Offset | ||
| 100 | + @param $iLimit Limit | ||
| 101 | + @param $sWhereClause Where clause (optional) | ||
| 102 | + @param $sOrderByClause Order by clause (optional) | ||
| 103 | + */ | ||
| 104 | + | ||
| 105 | + function createSQLQueryWithOffset($sTableName, $aColumns, $iOffset, $iLimit, $sWhereClause = null, $sOrderByClause = null) { | ||
| 106 | + $this->sLastTableName = $sTableName; | ||
| 107 | + $this->sLastWhereCluase = $sWhereClause; | ||
| 108 | + $this->sLastOrderByClause = $sOrderByClause; | ||
| 109 | + | ||
| 110 | + $this->sQuery = "SELECT ID, "; | ||
| 111 | + | ||
| 112 | + for( $i = 0; $i < count($aColumns) - 1; $i++ ) { | ||
| 113 | + $this->sQuery = $this->sQuery . $aColumns[$i] . ","; | ||
| 114 | + } | ||
| 115 | + | ||
| 116 | + $this->sQuery .= $aColumns[count($aColumns) - 1] . " "; | ||
| 117 | + $this->sQuery .= "FROM " . $sTableName . " "; | ||
| 118 | + | ||
| 119 | + | ||
| 120 | + | ||
| 121 | + if (isset($sWhereClause)) { | ||
| 122 | + $this->sQuery .= "WHERE " . $sWhereClause . " "; | ||
| 123 | + } | ||
| 124 | + | ||
| 125 | + if (isset($sOrderByClause)) { | ||
| 126 | + $this->sQuery .= "ORDER BY " . $sOrderByClause . " "; | ||
| 127 | + } | ||
| 128 | + | ||
| 129 | + $this->sQuery .= "LIMIT " . $iOffset . ", " . $iLimit; | ||
| 130 | + } | ||
| 131 | + | ||
| 132 | + /** | ||
| 133 | + * Get the result count for the previously executed query. Meant | ||
| 134 | + * to be used in conjuction with createSSQLQueryWithOffset so that | ||
| 135 | + * the total number of results can be calculated | ||
| 136 | + * | ||
| 137 | + * @return int row count | ||
| 138 | + */ | ||
| 139 | + function & getLastQueryResultCount() { | ||
| 140 | + if (isset($this->sLastTableName) { | ||
| 141 | + $sCountResultQuery = "SELECT COUNT(*) AS ResultCount FROM " . $this->sLastTableName; | ||
| 142 | + | ||
| 143 | + if (isset($this->sLastWhereClause)) { | ||
| 144 | + sCountResultQuery . " WHERE " . $this->sLastWhereClause; | ||
| 145 | + } | ||
| 146 | + $sql = & $this->query($sCountResultQuery); | ||
| 147 | + $sql->next_record(); | ||
| 148 | + return $sql->f("ResultCount"); | ||
| 149 | + } else { | ||
| 150 | + return 0; | ||
| 151 | + } | ||
| 152 | + } | ||
| 153 | + | ||
| 154 | + /** | ||
| 155 | + * Execute the query and return the results | ||
| 156 | + * | ||
| 157 | + * @returns Results of query | ||
| 158 | + */ | ||
| 159 | + function & getQueryResults() { | ||
| 160 | + $result = null; | ||
| 161 | + if (isset($this->sQuery)) { | ||
| 162 | + $result = $this->query($this->sQuery); | ||
| 163 | + } | ||
| 164 | + return $result; | ||
| 165 | + } | ||
| 166 | + | ||
| 167 | + /** | ||
| 168 | + * Display any database errors encountered | ||
| 169 | + */ | ||
| 170 | + function haltmsg($msg) { | ||
| 171 | + printf("</td></table><b>Database error:</b> %s<br>\n", $msg); | ||
| 172 | + printf("<b>SQL Error</b>: %s (%s)<br>\n",$this->Errno, $this->Error); | ||
| 173 | + } | ||
| 75 | } | 174 | } |
| 76 | 175 | ||
| 77 | /** | 176 | /** |
| @@ -115,7 +214,7 @@ class Owl_Session { | @@ -115,7 +214,7 @@ class Owl_Session { | ||
| 115 | $current = time(); | 214 | $current = time(); |
| 116 | $random = $this->sessuid . $current; | 215 | $random = $this->sessuid . $current; |
| 117 | $this->sessid = md5($random); | 216 | $this->sessid = md5($random); |
| 118 | - $sql = new Owl_DB; | 217 | + $sql = ; |
| 119 | 218 | ||
| 120 | if(getenv("HTTP_CLIENT_IP")) | 219 | if(getenv("HTTP_CLIENT_IP")) |
| 121 | { | 220 | { |
| @@ -140,7 +239,7 @@ class Owl_Session { | @@ -140,7 +239,7 @@ class Owl_Session { | ||
| 140 | } | 239 | } |
| 141 | 240 | ||
| 142 | // else we have a session id, try to validate it... | 241 | // else we have a session id, try to validate it... |
| 143 | - $sql = new Owl_DB; | 242 | + $sql = ; |
| 144 | $sql->query("select * from $default->owl_sessions_table where sessid = '$this->sessid'"); | 243 | $sql->query("select * from $default->owl_sessions_table where sessid = '$this->sessid'"); |
| 145 | 244 | ||
| 146 | // any matching session ids? | 245 | // any matching session ids? |
| @@ -182,7 +281,7 @@ function notify_users($groupid, $flag, $parent, $filename, $title, $desc, $type) | @@ -182,7 +281,7 @@ function notify_users($groupid, $flag, $parent, $filename, $title, $desc, $type) | ||
| 182 | global $default; | 281 | global $default; |
| 183 | global $lang_notif_subject_new, $lang_notif_subject_upd, $lang_notif_msg; | 282 | global $lang_notif_subject_new, $lang_notif_subject_upd, $lang_notif_msg; |
| 184 | global $lang_title, $lang_description; | 283 | global $lang_title, $lang_description; |
| 185 | - $sql = new Owl_DB; | 284 | + $sql = ; |
| 186 | // BEGIN BUG 548994 | 285 | // BEGIN BUG 548994 |
| 187 | // get the fileid | 286 | // get the fileid |
| 188 | $path = find_path($parent); | 287 | $path = find_path($parent); |
| @@ -247,7 +346,7 @@ function notify_users($groupid, $flag, $parent, $filename, $title, $desc, $type) | @@ -247,7 +346,7 @@ function notify_users($groupid, $flag, $parent, $filename, $title, $desc, $type) | ||
| 247 | unlink("$default->owl_FileDir/$filename"); | 346 | unlink("$default->owl_FileDir/$filename"); |
| 248 | } | 347 | } |
| 249 | $file = fopen("$default->owl_FileDir$filename", 'wb'); | 348 | $file = fopen("$default->owl_FileDir$filename", 'wb'); |
| 250 | - $getfile = new Owl_DB; | 349 | + $getfile = ; |
| 251 | $getfile->query("select data,compressed from $default->owl_files_data_table where id='$fileid'"); | 350 | $getfile->query("select data,compressed from $default->owl_files_data_table where id='$fileid'"); |
| 252 | while ($getfile->next_record()) | 351 | while ($getfile->next_record()) |
| 253 | { | 352 | { |
| @@ -329,7 +428,7 @@ function notify_users($groupid, $flag, $parent, $filename, $title, $desc, $type) | @@ -329,7 +428,7 @@ function notify_users($groupid, $flag, $parent, $filename, $title, $desc, $type) | ||
| 329 | } | 428 | } |
| 330 | 429 | ||
| 331 | $file = fopen("$default->owl_FileDir$filename", 'wb'); | 430 | $file = fopen("$default->owl_FileDir$filename", 'wb'); |
| 332 | - $getfile = new Owl_DB; | 431 | + $getfile = ; |
| 333 | $getfile->query("select data,compressed from $default->owl_files_data_table where id='$fileid'"); | 432 | $getfile->query("select data,compressed from $default->owl_files_data_table where id='$fileid'"); |
| 334 | 433 | ||
| 335 | // get file check if compressed, if so uncompress | 434 | // get file check if compressed, if so uncompress |
| @@ -412,7 +511,7 @@ function notify_users($groupid, $flag, $parent, $filename, $title, $desc, $type) | @@ -412,7 +511,7 @@ function notify_users($groupid, $flag, $parent, $filename, $title, $desc, $type) | ||
| 412 | function verify_login($username, $password) | 511 | function verify_login($username, $password) |
| 413 | { | 512 | { |
| 414 | global $default; | 513 | global $default; |
| 415 | - $sql = new Owl_DB; | 514 | + $sql = ; |
| 416 | $query = "select * from $default->owl_users_table where username = '$username' and password = '" . md5($password) . "'"; | 515 | $query = "select * from $default->owl_users_table where username = '$username' and password = '" . md5($password) . "'"; |
| 417 | $sql->query("select * from $default->owl_users_table where username = '$username' and password = '" . md5($password) . "'"); | 516 | $sql->query("select * from $default->owl_users_table where username = '$username' and password = '" . md5($password) . "'"); |
| 418 | $numrows = $sql->num_rows($sql); | 517 | $numrows = $sql->num_rows($sql); |
| @@ -457,11 +556,11 @@ function verify_login($username, $password) | @@ -457,11 +556,11 @@ function verify_login($username, $password) | ||
| 457 | // that is signing on. | 556 | // that is signing on. |
| 458 | // | 557 | // |
| 459 | $time = time() - $default->owl_timeout; | 558 | $time = time() - $default->owl_timeout; |
| 460 | - $sql = new Owl_DB; $sql->query("delete from $default->owl_sessions_table where uid = '".$verified["uid"]."' and lastused <= $time "); | 559 | + $sql = ; $sql->query("delete from $default->owl_sessions_table where uid = '".$verified["uid"]."' and lastused <= $time "); |
| 461 | // Check if Maxsessions has been reached | 560 | // Check if Maxsessions has been reached |
| 462 | // | 561 | // |
| 463 | 562 | ||
| 464 | - $sql = new Owl_DB; | 563 | + $sql = ; |
| 465 | $sql->query("select * from $default->owl_sessions_table where uid = '".$verified["uid"]."'"); | 564 | $sql->query("select * from $default->owl_sessions_table where uid = '".$verified["uid"]."'"); |
| 466 | 565 | ||
| 467 | if ($sql->num_rows($sql) >= $maxsessions && $verified["bit"] != 0) { | 566 | if ($sql->num_rows($sql) >= $maxsessions && $verified["bit"] != 0) { |
| @@ -493,7 +592,7 @@ function verify_session($sess) { | @@ -493,7 +592,7 @@ function verify_session($sess) { | ||
| 493 | $sess = ltrim($sess); | 592 | $sess = ltrim($sess); |
| 494 | $verified["bit"] = 0; | 593 | $verified["bit"] = 0; |
| 495 | 594 | ||
| 496 | - $sql = new Owl_DB; | 595 | + $sql = ; |
| 497 | $sql->query("select * from $default->owl_sessions_table where sessid = '$sess'"); | 596 | $sql->query("select * from $default->owl_sessions_table where sessid = '$sess'"); |
| 498 | $numrows = $sql->num_rows($sql); | 597 | $numrows = $sql->num_rows($sql); |
| 499 | $time = time(); | 598 | $time = time(); |
| @@ -574,7 +673,7 @@ function verify_session($sess) { | @@ -574,7 +673,7 @@ function verify_session($sess) { | ||
| 574 | function fid_to_name($parent) | 673 | function fid_to_name($parent) |
| 575 | { | 674 | { |
| 576 | global $default; | 675 | global $default; |
| 577 | - $sql = new Owl_DB; $sql->query("select name from $default->owl_folders_table where id = $parent"); | 676 | + $sql = ; $sql->query("select name from $default->owl_folders_table where id = $parent"); |
| 578 | while($sql->next_record()) | 677 | while($sql->next_record()) |
| 579 | { | 678 | { |
| 580 | return $sql->f("name"); | 679 | return $sql->f("name"); |
| @@ -597,7 +696,7 @@ function fid_to_name($parent) | @@ -597,7 +696,7 @@ function fid_to_name($parent) | ||
| 597 | function flid_to_name($id) | 696 | function flid_to_name($id) |
| 598 | { | 697 | { |
| 599 | global $default; | 698 | global $default; |
| 600 | - $sql = new Owl_DB; $sql->query("select name from $default->owl_files_table where id = $id"); | 699 | + $sql = ; $sql->query("select name from $default->owl_files_table where id = $id"); |
| 601 | while($sql->next_record()) | 700 | while($sql->next_record()) |
| 602 | { | 701 | { |
| 603 | return $sql->f("name"); | 702 | return $sql->f("name"); |
| @@ -619,7 +718,7 @@ function flid_to_name($id) | @@ -619,7 +718,7 @@ function flid_to_name($id) | ||
| 619 | // Usable | 718 | // Usable |
| 620 | function flid_to_filename($id) { | 719 | function flid_to_filename($id) { |
| 621 | global $default; | 720 | global $default; |
| 622 | - $sql = new Owl_DB; $sql->query("select filename from $default->owl_files_table where id = $id"); | 721 | + $sql = ; $sql->query("select filename from $default->owl_files_table where id = $id"); |
| 623 | while($sql->next_record()) | 722 | while($sql->next_record()) |
| 624 | { | 723 | { |
| 625 | return $sql->f("filename"); | 724 | return $sql->f("filename"); |
| @@ -641,7 +740,7 @@ function flid_to_filename($id) { | @@ -641,7 +740,7 @@ function flid_to_filename($id) { | ||
| 641 | function owlusergroup($userid) | 740 | function owlusergroup($userid) |
| 642 | { | 741 | { |
| 643 | global $default; | 742 | global $default; |
| 644 | - $sql = new Owl_DB; $sql->query("select groupid from $default->owl_users_table where id = '$userid'"); | 743 | + $sql = ; $sql->query("select groupid from $default->owl_users_table where id = '$userid'"); |
| 645 | while($sql->next_record()) | 744 | while($sql->next_record()) |
| 646 | { | 745 | { |
| 647 | $groupid = $sql->f("groupid"); | 746 | $groupid = $sql->f("groupid"); |
| @@ -663,7 +762,7 @@ function owlusergroup($userid) | @@ -663,7 +762,7 @@ function owlusergroup($userid) | ||
| 663 | // Usable | 762 | // Usable |
| 664 | function owlfilecreator($fileid) { | 763 | function owlfilecreator($fileid) { |
| 665 | global $default; | 764 | global $default; |
| 666 | - $sql = new Owl_DB; $sql->query("select creatorid from ".$default->owl_files_table." where id = '$fileid'"); | 765 | + $sql = ; $sql->query("select creatorid from ".$default->owl_files_table." where id = '$fileid'"); |
| 667 | while($sql->next_record()) | 766 | while($sql->next_record()) |
| 668 | { | 767 | { |
| 669 | $filecreator = $sql->f("creatorid"); | 768 | $filecreator = $sql->f("creatorid"); |
| @@ -686,7 +785,7 @@ function owlfilecreator($fileid) { | @@ -686,7 +785,7 @@ function owlfilecreator($fileid) { | ||
| 686 | function owlfoldercreator($folderid) | 785 | function owlfoldercreator($folderid) |
| 687 | { | 786 | { |
| 688 | global $default; | 787 | global $default; |
| 689 | - $sql = new Owl_DB; $sql->query("select creatorid from ".$default->owl_folders_table." where id = '$folderid'"); | 788 | + $sql = ; $sql->query("select creatorid from ".$default->owl_folders_table." where id = '$folderid'"); |
| 690 | while($sql->next_record()) | 789 | while($sql->next_record()) |
| 691 | { | 790 | { |
| 692 | $foldercreator = $sql->f("creatorid"); | 791 | $foldercreator = $sql->f("creatorid"); |
| @@ -709,7 +808,7 @@ function owlfoldercreator($folderid) | @@ -709,7 +808,7 @@ function owlfoldercreator($folderid) | ||
| 709 | function owlfilegroup($fileid) | 808 | function owlfilegroup($fileid) |
| 710 | { | 809 | { |
| 711 | global $default; | 810 | global $default; |
| 712 | - $sql = new Owl_DB; $sql->query("select groupid from $default->owl_files_table where id = '$fileid'"); | 811 | + $sql = ; $sql->query("select groupid from $default->owl_files_table where id = '$fileid'"); |
| 713 | while($sql->next_record()) | 812 | while($sql->next_record()) |
| 714 | { | 813 | { |
| 715 | $filegroup = $sql->f("groupid"); | 814 | $filegroup = $sql->f("groupid"); |
| @@ -732,7 +831,7 @@ function owlfilegroup($fileid) | @@ -732,7 +831,7 @@ function owlfilegroup($fileid) | ||
| 732 | // Usable | 831 | // Usable |
| 733 | function owlfoldergroup($folderid) { | 832 | function owlfoldergroup($folderid) { |
| 734 | global $default; | 833 | global $default; |
| 735 | - $sql = new Owl_DB; $sql->query("select groupid from $default->owl_folders_table where id = '$folderid'"); | 834 | + $sql = ; $sql->query("select groupid from $default->owl_folders_table where id = '$folderid'"); |
| 736 | while($sql->next_record()) | 835 | while($sql->next_record()) |
| 737 | { | 836 | { |
| 738 | $foldergroup = $sql->f("groupid"); | 837 | $foldergroup = $sql->f("groupid"); |
| @@ -756,7 +855,7 @@ function owlfoldergroup($folderid) { | @@ -756,7 +855,7 @@ function owlfoldergroup($folderid) { | ||
| 756 | function owlfolderparent($folderid) | 855 | function owlfolderparent($folderid) |
| 757 | { | 856 | { |
| 758 | global $default; | 857 | global $default; |
| 759 | - $sql = new Owl_DB; $sql->query("select parent from $default->owl_folders_table where id = '$folderid'"); | 858 | + $sql = ; $sql->query("select parent from $default->owl_folders_table where id = '$folderid'"); |
| 760 | while($sql->next_record()) | 859 | while($sql->next_record()) |
| 761 | { | 860 | { |
| 762 | $folderparent = $sql->f("parent"); | 861 | $folderparent = $sql->f("parent"); |
| @@ -780,7 +879,7 @@ function owlfolderparent($folderid) | @@ -780,7 +879,7 @@ function owlfolderparent($folderid) | ||
| 780 | function owlfileparent($fileid) | 879 | function owlfileparent($fileid) |
| 781 | { | 880 | { |
| 782 | global $default; | 881 | global $default; |
| 783 | - $sql = new Owl_DB; $sql->query("select parent from $default->owl_files_table where id = '$fileid'"); | 882 | + $sql = ; $sql->query("select parent from $default->owl_files_table where id = '$fileid'"); |
| 784 | while($sql->next_record()) | 883 | while($sql->next_record()) |
| 785 | { | 884 | { |
| 786 | $fileparent = $sql->f("parent"); | 885 | $fileparent = $sql->f("parent"); |
| @@ -804,9 +903,9 @@ function owlfileparent($fileid) | @@ -804,9 +903,9 @@ function owlfileparent($fileid) | ||
| 804 | function fid_to_creator($id) { | 903 | function fid_to_creator($id) { |
| 805 | 904 | ||
| 806 | global $default; | 905 | global $default; |
| 807 | - $sql = new Owl_DB; | 906 | + $sql = ; |
| 808 | $sql->query("select creatorid from ".$default->owl_files_table." where id = '$id'"); | 907 | $sql->query("select creatorid from ".$default->owl_files_table." where id = '$id'"); |
| 809 | - $sql2 = new Owl_DB; | 908 | + $sql2 = ; |
| 810 | while($sql->next_record()) | 909 | while($sql->next_record()) |
| 811 | { | 910 | { |
| 812 | $creatorid = $sql->f("creatorid"); | 911 | $creatorid = $sql->f("creatorid"); |
| @@ -832,7 +931,7 @@ function fid_to_creator($id) { | @@ -832,7 +931,7 @@ function fid_to_creator($id) { | ||
| 832 | function group_to_name($id) | 931 | function group_to_name($id) |
| 833 | { | 932 | { |
| 834 | global $default; | 933 | global $default; |
| 835 | - $sql = new Owl_DB; | 934 | + $sql = ; |
| 836 | $sql->query("select name from $default->owl_groups_table where id = '$id'"); | 935 | $sql->query("select name from $default->owl_groups_table where id = '$id'"); |
| 837 | while($sql->next_record()) | 936 | while($sql->next_record()) |
| 838 | { | 937 | { |
| @@ -855,7 +954,7 @@ function group_to_name($id) | @@ -855,7 +954,7 @@ function group_to_name($id) | ||
| 855 | function uid_to_name($id) | 954 | function uid_to_name($id) |
| 856 | { | 955 | { |
| 857 | global $default; | 956 | global $default; |
| 858 | - $sql = new Owl_DB; | 957 | + $sql = ; |
| 859 | $sql->query("select name from $default->owl_users_table where id = '$id'"); | 958 | $sql->query("select name from $default->owl_users_table where id = '$id'"); |
| 860 | while($sql->next_record()) | 959 | while($sql->next_record()) |
| 861 | { | 960 | { |
| @@ -884,7 +983,7 @@ function uid_to_name($id) | @@ -884,7 +983,7 @@ function uid_to_name($id) | ||
| 884 | function prefaccess($id) { | 983 | function prefaccess($id) { |
| 885 | global $default; | 984 | global $default; |
| 886 | $prefaccess = 1; | 985 | $prefaccess = 1; |
| 887 | - $sql = new Owl_DB; $sql->query("select noprefaccess from $default->owl_users_table where id = '$id'"); | 986 | + $sql = ; $sql->query("select noprefaccess from $default->owl_users_table where id = '$id'"); |
| 888 | while($sql->next_record()) | 987 | while($sql->next_record()) |
| 889 | { | 988 | { |
| 890 | $prefaccess = !($sql->f("noprefaccess")); | 989 | $prefaccess = !($sql->f("noprefaccess")); |
| @@ -913,7 +1012,7 @@ function gen_navbar($parent) | @@ -913,7 +1012,7 @@ function gen_navbar($parent) | ||
| 913 | $new = $parent; | 1012 | $new = $parent; |
| 914 | while ($new != "1") | 1013 | while ($new != "1") |
| 915 | { | 1014 | { |
| 916 | - $sql = new Owl_DB; $sql->query("select parent from $default->owl_folders_table where id = '$new'"); | 1015 | + $sql = ; $sql->query("select parent from $default->owl_folders_table where id = '$new'"); |
| 917 | while($sql->next_record()) $newparentid = $sql->f("parent"); | 1016 | while($sql->next_record()) $newparentid = $sql->f("parent"); |
| 918 | $name = fid_to_name($newparentid); | 1017 | $name = fid_to_name($newparentid); |
| 919 | $navbar = "<A HREF='browse.php?sess=$sess&parent=$newparentid&expand=$expand&order=$order&$sortorder=$sort'>$name</A>/" . $navbar; | 1018 | $navbar = "<A HREF='browse.php?sess=$sess&parent=$newparentid&expand=$expand&order=$order&$sortorder=$sort'>$name</A>/" . $navbar; |
| @@ -942,7 +1041,7 @@ function get_dirpath($parent) { | @@ -942,7 +1041,7 @@ function get_dirpath($parent) { | ||
| 942 | $navbar = "$name"; | 1041 | $navbar = "$name"; |
| 943 | $new = $parent; | 1042 | $new = $parent; |
| 944 | while ($new != "1") { | 1043 | while ($new != "1") { |
| 945 | - $sql = new Owl_DB; $sql->query("select parent from $default->owl_folders_table where id = '$new'"); | 1044 | + $sql = ; $sql->query("select parent from $default->owl_folders_table where id = '$new'"); |
| 946 | while($sql->next_record()) $newparentid = $sql->f("parent"); | 1045 | while($sql->next_record()) $newparentid = $sql->f("parent"); |
| 947 | $name = fid_to_name($newparentid); | 1046 | $name = fid_to_name($newparentid); |
| 948 | $navbar = "$name/" . $navbar; | 1047 | $navbar = "$name/" . $navbar; |
| @@ -1133,7 +1232,7 @@ function printError($message, $submessage) { | @@ -1133,7 +1232,7 @@ function printError($message, $submessage) { | ||
| 1133 | include("./lib/header.inc"); | 1232 | include("./lib/header.inc"); |
| 1134 | 1233 | ||
| 1135 | if(check_auth($parent, "folder_view", $userid) != "1") { | 1234 | if(check_auth($parent, "folder_view", $userid) != "1") { |
| 1136 | - $sql = new Owl_DB; | 1235 | + $sql = ; |
| 1137 | $sql->query("select * from $default->owl_folders_table where id = '$parent'"); | 1236 | $sql->query("select * from $default->owl_folders_table where id = '$parent'"); |
| 1138 | $sql->next_record(); | 1237 | $sql->next_record(); |
| 1139 | $parent = $sql->f("parent"); | 1238 | $parent = $sql->f("parent"); |
| @@ -1168,7 +1267,7 @@ function getprefs ( ) | @@ -1168,7 +1267,7 @@ function getprefs ( ) | ||
| 1168 | { | 1267 | { |
| 1169 | global $default; | 1268 | global $default; |
| 1170 | 1269 | ||
| 1171 | - $sql = new Owl_DB; | 1270 | + $sql = ; |
| 1172 | //$sql->query("select * from $default->owl_prefs_table"); | 1271 | //$sql->query("select * from $default->owl_prefs_table"); |
| 1173 | $sql->query("select * from prefs"); | 1272 | $sql->query("select * from prefs"); |
| 1174 | $sql->next_record(); | 1273 | $sql->next_record(); |
| @@ -1212,7 +1311,7 @@ function gethtmlprefs ( ) | @@ -1212,7 +1311,7 @@ function gethtmlprefs ( ) | ||
| 1212 | { | 1311 | { |
| 1213 | global $default; | 1312 | global $default; |
| 1214 | 1313 | ||
| 1215 | - $sql = new Owl_DB; | 1314 | + $sql = ; |
| 1216 | $sql->query("select * from $default->owl_html_table"); | 1315 | $sql->query("select * from $default->owl_html_table"); |
| 1217 | $sql->next_record(); | 1316 | $sql->next_record(); |
| 1218 | 1317 | ||
| @@ -1550,7 +1649,7 @@ if(isset($default->owl_lang)) { | @@ -1550,7 +1649,7 @@ if(isset($default->owl_lang)) { | ||
| 1550 | die("$lang_err_lang_1 $langdir $lang_err_lang_2"); | 1649 | die("$lang_err_lang_1 $langdir $lang_err_lang_2"); |
| 1551 | } else { | 1650 | } else { |
| 1552 | 1651 | ||
| 1553 | - $sql = new Owl_DB; | 1652 | + $sql = ; |
| 1554 | $sql->query("select * from $default->owl_sessions_table where sessid = '$sess'"); | 1653 | $sql->query("select * from $default->owl_sessions_table where sessid = '$sess'"); |
| 1555 | $sql->next_record(); | 1654 | $sql->next_record(); |
| 1556 | $numrows = $sql->num_rows($sql); | 1655 | $numrows = $sql->num_rows($sql); |
| @@ -1598,7 +1697,7 @@ if ($sess) { | @@ -1598,7 +1697,7 @@ if ($sess) { | ||
| 1598 | exit; | 1697 | exit; |
| 1599 | } else { | 1698 | } else { |
| 1600 | $lastused = time(); | 1699 | $lastused = time(); |
| 1601 | - $sql = new Owl_DB; | 1700 | + $sql = ; |
| 1602 | $sql->query("update $default->owl_sessions_table set lastused = '$lastused' where uid = '$userid'"); | 1701 | $sql->query("update $default->owl_sessions_table set lastused = '$lastused' where uid = '$userid'"); |
| 1603 | } | 1702 | } |
| 1604 | } | 1703 | } |