Commit 75911002b4c891fefe375d0fd7e413c61d4f789e

Authored by michael
1 parent df6a5f28

fixed sql class bugs


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@71 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing 1 changed file with 52 additions and 41 deletions
lib/owl.lib.php
1 <?php 1 <?php
2 2
3 -  
4 -/* owl.lib.php 3 +/**
  4 + * $Id$
5 * 5 *
6 - * contains the major owl classes and functions 6 + * Contains the major owl classes and functions.
7 * 7 *
8 * Copyright (c) 1999-2002 The Owl Project Team 8 * Copyright (c) 1999-2002 The Owl Project Team
9 * Licensed under the GNU GPL. For full terms see the file COPYING. 9 * Licensed under the GNU GPL. For full terms see the file COPYING.
10 - * @version v 1.1.1.1 2002/12/04 10 + * @version $Revision$
11 * @author michael 11 * @author michael
12 * @package Owl 12 * @package Owl
13 */ 13 */
@@ -137,15 +137,15 @@ class Owl_DB extends DB_Sql { @@ -137,15 +137,15 @@ class Owl_DB extends DB_Sql {
137 * @return int row count 137 * @return int row count
138 */ 138 */
139 function & getLastQueryResultCount() { 139 function & getLastQueryResultCount() {
140 - if (isset($this->sLastTableName) { 140 + if (isset($this->sLastTableName)) {
141 $sCountResultQuery = "SELECT COUNT(*) AS ResultCount FROM " . $this->sLastTableName; 141 $sCountResultQuery = "SELECT COUNT(*) AS ResultCount FROM " . $this->sLastTableName;
142 142
143 if (isset($this->sLastWhereClause)) { 143 if (isset($this->sLastWhereClause)) {
144 sCountResultQuery . " WHERE " . $this->sLastWhereClause; 144 sCountResultQuery . " WHERE " . $this->sLastWhereClause;
145 } 145 }
146 - $sql = & $this->query($sCountResultQuery);  
147 - $sql->next_record();  
148 - return $sql->f("ResultCount"); 146 + $this->query($sCountResultQuery);
  147 + $this->next_record();
  148 + return $this->f("ResultCount");
149 } else { 149 } else {
150 return 0; 150 return 0;
151 } 151 }
@@ -214,7 +214,7 @@ class Owl_Session { @@ -214,7 +214,7 @@ class Owl_Session {
214 $current = time(); 214 $current = time();
215 $random = $this->sessuid . $current; 215 $random = $this->sessuid . $current;
216 $this->sessid = md5($random); 216 $this->sessid = md5($random);
217 - $sql = ; 217 + $sql = new Owl_DB;
218 218
219 if(getenv("HTTP_CLIENT_IP")) 219 if(getenv("HTTP_CLIENT_IP"))
220 { 220 {
@@ -239,7 +239,7 @@ class Owl_Session { @@ -239,7 +239,7 @@ class Owl_Session {
239 } 239 }
240 240
241 // else we have a session id, try to validate it... 241 // else we have a session id, try to validate it...
242 - $sql = ; 242 + $sql = new Owl_DB;
243 $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'");
244 244
245 // any matching session ids? 245 // any matching session ids?
@@ -281,7 +281,7 @@ function notify_users($groupid, $flag, $parent, $filename, $title, $desc, $type) @@ -281,7 +281,7 @@ function notify_users($groupid, $flag, $parent, $filename, $title, $desc, $type)
281 global $default; 281 global $default;
282 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;
283 global $lang_title, $lang_description; 283 global $lang_title, $lang_description;
284 - $sql = ; 284 + $sql = new Owl_DB;
285 // BEGIN BUG 548994 285 // BEGIN BUG 548994
286 // get the fileid 286 // get the fileid
287 $path = find_path($parent); 287 $path = find_path($parent);
@@ -346,7 +346,7 @@ function notify_users($groupid, $flag, $parent, $filename, $title, $desc, $type) @@ -346,7 +346,7 @@ function notify_users($groupid, $flag, $parent, $filename, $title, $desc, $type)
346 unlink("$default->owl_FileDir/$filename"); 346 unlink("$default->owl_FileDir/$filename");
347 } 347 }
348 $file = fopen("$default->owl_FileDir$filename", 'wb'); 348 $file = fopen("$default->owl_FileDir$filename", 'wb');
349 - $getfile = ; 349 + $getfile = new Owl_DB;
350 $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'");
351 while ($getfile->next_record()) 351 while ($getfile->next_record())
352 { 352 {
@@ -428,7 +428,7 @@ function notify_users($groupid, $flag, $parent, $filename, $title, $desc, $type) @@ -428,7 +428,7 @@ function notify_users($groupid, $flag, $parent, $filename, $title, $desc, $type)
428 } 428 }
429 429
430 $file = fopen("$default->owl_FileDir$filename", 'wb'); 430 $file = fopen("$default->owl_FileDir$filename", 'wb');
431 - $getfile = ; 431 + $getfile = new Owl_DB;
432 $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'");
433 433
434 // get file check if compressed, if so uncompress 434 // get file check if compressed, if so uncompress
@@ -511,7 +511,7 @@ function notify_users($groupid, $flag, $parent, $filename, $title, $desc, $type) @@ -511,7 +511,7 @@ function notify_users($groupid, $flag, $parent, $filename, $title, $desc, $type)
511 function verify_login($username, $password) 511 function verify_login($username, $password)
512 { 512 {
513 global $default; 513 global $default;
514 - $sql = ; 514 + $sql = new Owl_DB;
515 $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) . "'";
516 $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) . "'");
517 $numrows = $sql->num_rows($sql); 517 $numrows = $sql->num_rows($sql);
@@ -556,11 +556,12 @@ function verify_login($username, $password) @@ -556,11 +556,12 @@ function verify_login($username, $password)
556 // that is signing on. 556 // that is signing on.
557 // 557 //
558 $time = time() - $default->owl_timeout; 558 $time = time() - $default->owl_timeout;
559 - $sql = ; $sql->query("delete from $default->owl_sessions_table where uid = '".$verified["uid"]."' and lastused <= $time "); 559 + $sql = new Owl_DB;
  560 + $sql->query("delete from $default->owl_sessions_table where uid = '".$verified["uid"]."' and lastused <= $time ");
560 // Check if Maxsessions has been reached 561 // Check if Maxsessions has been reached
561 // 562 //
562 563
563 - $sql = ; 564 + $sql = new Owl_DB;
564 $sql->query("select * from $default->owl_sessions_table where uid = '".$verified["uid"]."'"); 565 $sql->query("select * from $default->owl_sessions_table where uid = '".$verified["uid"]."'");
565 566
566 if ($sql->num_rows($sql) >= $maxsessions && $verified["bit"] != 0) { 567 if ($sql->num_rows($sql) >= $maxsessions && $verified["bit"] != 0) {
@@ -592,8 +593,8 @@ function verify_session($sess) { @@ -592,8 +593,8 @@ function verify_session($sess) {
592 $sess = ltrim($sess); 593 $sess = ltrim($sess);
593 $verified["bit"] = 0; 594 $verified["bit"] = 0;
594 595
595 - $sql = ;  
596 - $sql->query("select * from $default->owl_sessions_table where sessid = '$sess'"); 596 + $sql = new Owl_DB;
  597 + $sql->query("select * from $default->owl_sessions_table where sessid = '$sess'");
597 $numrows = $sql->num_rows($sql); 598 $numrows = $sql->num_rows($sql);
598 $time = time(); 599 $time = time();
599 600
@@ -673,7 +674,8 @@ function verify_session($sess) { @@ -673,7 +674,8 @@ function verify_session($sess) {
673 function fid_to_name($parent) 674 function fid_to_name($parent)
674 { 675 {
675 global $default; 676 global $default;
676 - $sql = ; $sql->query("select name from $default->owl_folders_table where id = $parent"); 677 + $sql = new Owl_DB;
  678 + $sql->query("select name from $default->owl_folders_table where id = $parent");
677 while($sql->next_record()) 679 while($sql->next_record())
678 { 680 {
679 return $sql->f("name"); 681 return $sql->f("name");
@@ -696,7 +698,8 @@ function fid_to_name($parent) @@ -696,7 +698,8 @@ function fid_to_name($parent)
696 function flid_to_name($id) 698 function flid_to_name($id)
697 { 699 {
698 global $default; 700 global $default;
699 - $sql = ; $sql->query("select name from $default->owl_files_table where id = $id"); 701 + $sql = new Owl_DB;
  702 + $sql->query("select name from $default->owl_files_table where id = $id");
700 while($sql->next_record()) 703 while($sql->next_record())
701 { 704 {
702 return $sql->f("name"); 705 return $sql->f("name");
@@ -718,7 +721,8 @@ function flid_to_name($id) @@ -718,7 +721,8 @@ function flid_to_name($id)
718 // Usable 721 // Usable
719 function flid_to_filename($id) { 722 function flid_to_filename($id) {
720 global $default; 723 global $default;
721 - $sql = ; $sql->query("select filename from $default->owl_files_table where id = $id"); 724 + $sql = new Owl_DB;
  725 + $sql->query("select filename from $default->owl_files_table where id = $id");
722 while($sql->next_record()) 726 while($sql->next_record())
723 { 727 {
724 return $sql->f("filename"); 728 return $sql->f("filename");
@@ -740,7 +744,8 @@ function flid_to_filename($id) { @@ -740,7 +744,8 @@ function flid_to_filename($id) {
740 function owlusergroup($userid) 744 function owlusergroup($userid)
741 { 745 {
742 global $default; 746 global $default;
743 - $sql = ; $sql->query("select groupid from $default->owl_users_table where id = '$userid'"); 747 + $sql = new Owl_DB;
  748 + $sql->query("select groupid from $default->owl_users_table where id = '$userid'");
744 while($sql->next_record()) 749 while($sql->next_record())
745 { 750 {
746 $groupid = $sql->f("groupid"); 751 $groupid = $sql->f("groupid");
@@ -762,7 +767,8 @@ function owlusergroup($userid) @@ -762,7 +767,8 @@ function owlusergroup($userid)
762 // Usable 767 // Usable
763 function owlfilecreator($fileid) { 768 function owlfilecreator($fileid) {
764 global $default; 769 global $default;
765 - $sql = ; $sql->query("select creatorid from ".$default->owl_files_table." where id = '$fileid'"); 770 + $sql = new Owl_DB;
  771 + $sql->query("select creatorid from ".$default->owl_files_table." where id = '$fileid'");
766 while($sql->next_record()) 772 while($sql->next_record())
767 { 773 {
768 $filecreator = $sql->f("creatorid"); 774 $filecreator = $sql->f("creatorid");
@@ -785,7 +791,8 @@ function owlfilecreator($fileid) { @@ -785,7 +791,8 @@ function owlfilecreator($fileid) {
785 function owlfoldercreator($folderid) 791 function owlfoldercreator($folderid)
786 { 792 {
787 global $default; 793 global $default;
788 - $sql = ; $sql->query("select creatorid from ".$default->owl_folders_table." where id = '$folderid'"); 794 + $sql = new Owl_DB;
  795 + $sql->query("select creatorid from ".$default->owl_folders_table." where id = '$folderid'");
789 while($sql->next_record()) 796 while($sql->next_record())
790 { 797 {
791 $foldercreator = $sql->f("creatorid"); 798 $foldercreator = $sql->f("creatorid");
@@ -808,7 +815,8 @@ function owlfoldercreator($folderid) @@ -808,7 +815,8 @@ function owlfoldercreator($folderid)
808 function owlfilegroup($fileid) 815 function owlfilegroup($fileid)
809 { 816 {
810 global $default; 817 global $default;
811 - $sql = ; $sql->query("select groupid from $default->owl_files_table where id = '$fileid'"); 818 + $sql = new Owl_DB;
  819 + $sql->query("select groupid from $default->owl_files_table where id = '$fileid'");
812 while($sql->next_record()) 820 while($sql->next_record())
813 { 821 {
814 $filegroup = $sql->f("groupid"); 822 $filegroup = $sql->f("groupid");
@@ -831,7 +839,8 @@ function owlfilegroup($fileid) @@ -831,7 +839,8 @@ function owlfilegroup($fileid)
831 // Usable 839 // Usable
832 function owlfoldergroup($folderid) { 840 function owlfoldergroup($folderid) {
833 global $default; 841 global $default;
834 - $sql = ; $sql->query("select groupid from $default->owl_folders_table where id = '$folderid'"); 842 + $sql = new Owl_DB;
  843 + $sql->query("select groupid from $default->owl_folders_table where id = '$folderid'");
835 while($sql->next_record()) 844 while($sql->next_record())
836 { 845 {
837 $foldergroup = $sql->f("groupid"); 846 $foldergroup = $sql->f("groupid");
@@ -855,7 +864,8 @@ function owlfoldergroup($folderid) { @@ -855,7 +864,8 @@ function owlfoldergroup($folderid) {
855 function owlfolderparent($folderid) 864 function owlfolderparent($folderid)
856 { 865 {
857 global $default; 866 global $default;
858 - $sql = ; $sql->query("select parent from $default->owl_folders_table where id = '$folderid'"); 867 + $sql = new Owl_DB;
  868 + $sql->query("select parent from $default->owl_folders_table where id = '$folderid'");
859 while($sql->next_record()) 869 while($sql->next_record())
860 { 870 {
861 $folderparent = $sql->f("parent"); 871 $folderparent = $sql->f("parent");
@@ -879,7 +889,7 @@ function owlfolderparent($folderid) @@ -879,7 +889,7 @@ function owlfolderparent($folderid)
879 function owlfileparent($fileid) 889 function owlfileparent($fileid)
880 { 890 {
881 global $default; 891 global $default;
882 - $sql = ; $sql->query("select parent from $default->owl_files_table where id = '$fileid'"); 892 + $sql = new Owl_DB; $sql->query("select parent from $default->owl_files_table where id = '$fileid'");
883 while($sql->next_record()) 893 while($sql->next_record())
884 { 894 {
885 $fileparent = $sql->f("parent"); 895 $fileparent = $sql->f("parent");
@@ -903,9 +913,9 @@ function owlfileparent($fileid) @@ -903,9 +913,9 @@ function owlfileparent($fileid)
903 function fid_to_creator($id) { 913 function fid_to_creator($id) {
904 914
905 global $default; 915 global $default;
906 - $sql = ; 916 + $sql = new Owl_DB;
907 $sql->query("select creatorid from ".$default->owl_files_table." where id = '$id'"); 917 $sql->query("select creatorid from ".$default->owl_files_table." where id = '$id'");
908 - $sql2 = ; 918 + $sql2 = new Owl_DB;
909 while($sql->next_record()) 919 while($sql->next_record())
910 { 920 {
911 $creatorid = $sql->f("creatorid"); 921 $creatorid = $sql->f("creatorid");
@@ -931,7 +941,7 @@ function fid_to_creator($id) { @@ -931,7 +941,7 @@ function fid_to_creator($id) {
931 function group_to_name($id) 941 function group_to_name($id)
932 { 942 {
933 global $default; 943 global $default;
934 - $sql = ; 944 + $sql = new Owl_DB;
935 $sql->query("select name from $default->owl_groups_table where id = '$id'"); 945 $sql->query("select name from $default->owl_groups_table where id = '$id'");
936 while($sql->next_record()) 946 while($sql->next_record())
937 { 947 {
@@ -954,7 +964,7 @@ function group_to_name($id) @@ -954,7 +964,7 @@ function group_to_name($id)
954 function uid_to_name($id) 964 function uid_to_name($id)
955 { 965 {
956 global $default; 966 global $default;
957 - $sql = ; 967 + $sql = new Owl_DB;
958 $sql->query("select name from $default->owl_users_table where id = '$id'"); 968 $sql->query("select name from $default->owl_users_table where id = '$id'");
959 while($sql->next_record()) 969 while($sql->next_record())
960 { 970 {
@@ -983,7 +993,7 @@ function uid_to_name($id) @@ -983,7 +993,7 @@ function uid_to_name($id)
983 function prefaccess($id) { 993 function prefaccess($id) {
984 global $default; 994 global $default;
985 $prefaccess = 1; 995 $prefaccess = 1;
986 - $sql = ; $sql->query("select noprefaccess from $default->owl_users_table where id = '$id'"); 996 + $sql = new Owl_DB; $sql->query("select noprefaccess from $default->owl_users_table where id = '$id'");
987 while($sql->next_record()) 997 while($sql->next_record())
988 { 998 {
989 $prefaccess = !($sql->f("noprefaccess")); 999 $prefaccess = !($sql->f("noprefaccess"));
@@ -1012,7 +1022,7 @@ function gen_navbar($parent) @@ -1012,7 +1022,7 @@ function gen_navbar($parent)
1012 $new = $parent; 1022 $new = $parent;
1013 while ($new != "1") 1023 while ($new != "1")
1014 { 1024 {
1015 - $sql = ; $sql->query("select parent from $default->owl_folders_table where id = '$new'"); 1025 + $sql = new Owl_DB; $sql->query("select parent from $default->owl_folders_table where id = '$new'");
1016 while($sql->next_record()) $newparentid = $sql->f("parent"); 1026 while($sql->next_record()) $newparentid = $sql->f("parent");
1017 $name = fid_to_name($newparentid); 1027 $name = fid_to_name($newparentid);
1018 $navbar = "<A HREF='browse.php?sess=$sess&parent=$newparentid&expand=$expand&order=$order&$sortorder=$sort'>$name</A>/" . $navbar; 1028 $navbar = "<A HREF='browse.php?sess=$sess&parent=$newparentid&expand=$expand&order=$order&$sortorder=$sort'>$name</A>/" . $navbar;
@@ -1041,7 +1051,7 @@ function get_dirpath($parent) { @@ -1041,7 +1051,7 @@ function get_dirpath($parent) {
1041 $navbar = "$name"; 1051 $navbar = "$name";
1042 $new = $parent; 1052 $new = $parent;
1043 while ($new != "1") { 1053 while ($new != "1") {
1044 - $sql = ; $sql->query("select parent from $default->owl_folders_table where id = '$new'"); 1054 + $sql = new Owl_DB; $sql->query("select parent from $default->owl_folders_table where id = '$new'");
1045 while($sql->next_record()) $newparentid = $sql->f("parent"); 1055 while($sql->next_record()) $newparentid = $sql->f("parent");
1046 $name = fid_to_name($newparentid); 1056 $name = fid_to_name($newparentid);
1047 $navbar = "$name/" . $navbar; 1057 $navbar = "$name/" . $navbar;
@@ -1232,7 +1242,7 @@ function printError($message, $submessage) { @@ -1232,7 +1242,7 @@ function printError($message, $submessage) {
1232 include("./lib/header.inc"); 1242 include("./lib/header.inc");
1233 1243
1234 if(check_auth($parent, "folder_view", $userid) != "1") { 1244 if(check_auth($parent, "folder_view", $userid) != "1") {
1235 - $sql = ; 1245 + $sql = new Owl_DB;
1236 $sql->query("select * from $default->owl_folders_table where id = '$parent'"); 1246 $sql->query("select * from $default->owl_folders_table where id = '$parent'");
1237 $sql->next_record(); 1247 $sql->next_record();
1238 $parent = $sql->f("parent"); 1248 $parent = $sql->f("parent");
@@ -1267,7 +1277,7 @@ function getprefs ( ) @@ -1267,7 +1277,7 @@ function getprefs ( )
1267 { 1277 {
1268 global $default; 1278 global $default;
1269 1279
1270 - $sql = ; 1280 + $sql = new Owl_DB;
1271 //$sql->query("select * from $default->owl_prefs_table"); 1281 //$sql->query("select * from $default->owl_prefs_table");
1272 $sql->query("select * from prefs"); 1282 $sql->query("select * from prefs");
1273 $sql->next_record(); 1283 $sql->next_record();
@@ -1311,7 +1321,7 @@ function gethtmlprefs ( ) @@ -1311,7 +1321,7 @@ function gethtmlprefs ( )
1311 { 1321 {
1312 global $default; 1322 global $default;
1313 1323
1314 - $sql = ; 1324 + $sql = new Owl_DB;
1315 $sql->query("select * from $default->owl_html_table"); 1325 $sql->query("select * from $default->owl_html_table");
1316 $sql->next_record(); 1326 $sql->next_record();
1317 1327
@@ -1649,7 +1659,7 @@ if(isset($default-&gt;owl_lang)) { @@ -1649,7 +1659,7 @@ if(isset($default-&gt;owl_lang)) {
1649 die("$lang_err_lang_1 $langdir $lang_err_lang_2"); 1659 die("$lang_err_lang_1 $langdir $lang_err_lang_2");
1650 } else { 1660 } else {
1651 1661
1652 - $sql = ; 1662 + $sql = new Owl_DB;
1653 $sql->query("select * from $default->owl_sessions_table where sessid = '$sess'"); 1663 $sql->query("select * from $default->owl_sessions_table where sessid = '$sess'");
1654 $sql->next_record(); 1664 $sql->next_record();
1655 $numrows = $sql->num_rows($sql); 1665 $numrows = $sql->num_rows($sql);
@@ -1672,7 +1682,7 @@ if(isset($default-&gt;owl_lang)) { @@ -1672,7 +1682,7 @@ if(isset($default-&gt;owl_lang)) {
1672 } else { 1682 } else {
1673 die("$lang_err_lang_notfound"); 1683 die("$lang_err_lang_notfound");
1674 } 1684 }
1675 - 1685 +/*
1676 if ($sess) { 1686 if ($sess) {
1677 gethtmlprefs(); 1687 gethtmlprefs();
1678 $ok = verify_session($sess); 1688 $ok = verify_session($sess);
@@ -1697,7 +1707,7 @@ if ($sess) { @@ -1697,7 +1707,7 @@ if ($sess) {
1697 exit; 1707 exit;
1698 } else { 1708 } else {
1699 $lastused = time(); 1709 $lastused = time();
1700 - $sql = ; 1710 + $sql = new Owl_DB;
1701 $sql->query("update $default->owl_sessions_table set lastused = '$lastused' where uid = '$userid'"); 1711 $sql->query("update $default->owl_sessions_table set lastused = '$lastused' where uid = '$userid'");
1702 } 1712 }
1703 } 1713 }
@@ -1709,4 +1719,5 @@ if (!$sess &amp;&amp; !$loginname &amp;&amp; !$login) { @@ -1709,4 +1719,5 @@ if (!$sess &amp;&amp; !$loginname &amp;&amp; !$login) {
1709 header("Location: " . $default->owl_root_url . "/index.php?login=1&fileid=$fileid&parent=$parent"); 1719 header("Location: " . $default->owl_root_url . "/index.php?login=1&fileid=$fileid&parent=$parent");
1710 } 1720 }
1711 } 1721 }
  1722 +*/
1712 ?> 1723 ?>