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