Commit 800f064e6e06016f341cf65fdc0782044cbff03e

Authored by michael
1 parent a2379655

partial formatting and documentation


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@30 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing 2 changed files with 91 additions and 59 deletions
dbmodify.php
... ... @@ -10,7 +10,7 @@
10 10 * Licensed under the GNU GPL. For full terms see the file COPYING.
11 11 *
12 12 * $Id$
13   - * @todo line 50- refactor
  13 + * @todo line 28, 47, 53- refactor
14 14 */
15 15  
16 16 require("./config/owl.php");
... ...
lib/owl.lib.php
1 1 <?php
2 2  
3   -/*
  3 +/**
4 4 * owl.lib.php
5 5 *
  6 + * Main library routines, language and session handling.
  7 + *
6 8 * Copyright (c) 1999-2002 The Owl Project Team
7 9 * Licensed under the GNU GPL. For full terms see the file COPYING.
8 10 *
9 11 * $Id$
  12 + * @todo move classes to their own files (Owl_DB, Owl_Session)
  13 + * @todo refactor functions by function (authentication, session, language)
10 14 */
11 15  
12 16 // Support for reg.globals off WES
13   -
14   -if (substr(phpversion(),0,5) >= "4.1.0")
15   - import_request_variables('pgc');
16   - else {
17   - if (!EMPTY($_POST)) {
18   - extract($_POST);
19   - } else {
20   - extract($HTTP_POST_VARS);
21   - }
22   - if (!EMPTY($_GET)) {
23   - extract($_GET);
24   - } else {
25   - extract($HTTP_GET_VARS);
26   - }
27   - if (!EMPTY($_FILE)) {
28   - extract($_FILE);
29   - } else {
30   - extract($HTTP_POST_FILES);
31   - }
  17 +if (substr(phpversion(),0,5) >= "4.1.0") {
  18 + import_request_variables('pgc');
  19 +} else {
  20 + if (!EMPTY($_POST)) {
  21 + extract($_POST);
  22 + } else {
  23 + extract($HTTP_POST_VARS);
  24 + }
  25 + if (!EMPTY($_GET)) {
  26 + extract($_GET);
  27 + } else {
  28 + extract($HTTP_GET_VARS);
  29 + }
  30 + if (!EMPTY($_FILE)) {
  31 + extract($_FILE);
  32 + } else {
  33 + extract($HTTP_POST_FILES);
  34 + }
32 35 }
33 36  
  37 +if(!isset($sess)) {
  38 + $sess = 0;
  39 +}
  40 +if(!isset($loginname)) {
  41 + $loginname = 0;
  42 +}
  43 +if(!isset($login)) {
  44 + $login = 0;
  45 +}
34 46  
35   -if(!isset($sess)) $sess = 0;
36   -if(!isset($loginname)) $loginname = 0;
37   -if(!isset($login)) $login = 0;
38   -
  47 +// load appropriate language
39 48 if(isset($default->owl_lang)) {
40 49 $langdir = "$default->owl_fs_root/locale/$default->owl_lang";
41 50 if(is_dir("$langdir") != 1) {
42 51 die("$lang_err_lang_1 $langdir $lang_err_lang_2");
43 52 } else {
44 53 $sql = new Owl_DB;
45   - $sql->query("select * from $default->owl_sessions_table where sessid = '$sess'");
  54 + $sql->query("select * from $default->owl_sessions_table where sessid = '$sess'");
46 55 $sql->next_record();
47   - $numrows = $sql->num_rows($sql);
48   - $getuid = $sql->f("uid");
  56 + $numrows = $sql->num_rows($sql);
  57 + $getuid = $sql->f("uid");
49 58 if($numrows == 1) {
50   - $sql->query("select * from $default->owl_users_table where id = $getuid");
  59 + $sql->query("select * from $default->owl_users_table where id = $getuid");
51 60 $sql->next_record();
52   - $language = $sql->f("language");
  61 + $language = $sql->f("language");
53 62 // BEGIN wes fix
54 63 if(!$language) {
55   - $language = $default->owl_lang;
  64 + $language = $default->owl_lang;
56 65 }
57 66 // END wes fix
58 67 require("$default->owl_fs_root/locale/$language/language.inc");
59 68 $default->owl_lang = $language;
60   - }
61   - else
  69 + } else {
62 70 require("$default->owl_fs_root/locale/$default->owl_lang/language.inc");
  71 + }
63 72 }
64 73 } else {
65 74 die("$lang_err_lang_notfound");
66 75 }
67 76  
68 77  
  78 +/**
  79 + * Owl specific database class.
  80 + */
69 81 class Owl_DB extends DB_Sql {
70   - var $classname = "Owl_DB";
71   -
72   - // BEGIN wes changes -- moved these settings to config/owl.php
73   - // Server where the database resides
74   - var $Host = "";
75   -
76   - // Database name
77   - var $Database = "";
78   -
79   - // User to access database
80   - var $User = "";
81   -
82   - // Password for database
83   - var $Password = "";
84   -
  82 + /**
  83 + * Identifier for this class
  84 + */
  85 + var $classname = "Owl_DB";
  86 +
  87 + // BEGIN wes changes -- moved these settings to config/owl.php
  88 +
  89 + /**
  90 + * Server where the database resides
  91 + */
  92 + var $Host = "";
  93 +
  94 + /**
  95 + * Database name
  96 + */
  97 + var $Database = "";
  98 +
  99 + /**
  100 + * User to access database
  101 + */
  102 + var $User = "";
  103 +
  104 + /**
  105 + * Password for database
  106 + */
  107 + var $Password = "";
  108 +
  109 + /**
  110 + * Creates an instance of Owl_DB.
  111 + * This constructor sets the connection details
  112 + * from the global defaults defined in config/owl.php
  113 + */
85 114 function Owl_DB() {
86   - global $default;
87   - $this->Host = $default->owl_db_host;
88   - $this->Database = $default->owl_db_name;
89   - $this->User = $default->owl_db_user;
90   - $this->Password = $default->owl_db_pass;
  115 + global $default;
  116 + $this->Host = $default->owl_db_host;
  117 + $this->Database = $default->owl_db_name;
  118 + $this->User = $default->owl_db_user;
  119 + $this->Password = $default->owl_db_pass;
91 120 }
92 121 // END wes changes
93 122  
94   - function haltmsg($msg) {
95   - printf("</td></table><b>Database error:</b> %s<br>\n", $msg);
96   - printf("<b>SQL Error</b>: %s (%s)<br>\n",
97   - $this->Errno, $this->Error);
98   - }
  123 + /**
  124 + * Prints database error message
  125 + *
  126 + * @param $msg the error message
  127 + */
  128 + function haltmsg($msg) {
  129 + printf("</td></table><b>Database error:</b> %s<br>\n", $msg);
  130 + printf("<b>SQL Error</b>: %s (%s)<br>\n", $this->Errno, $this->Error);
  131 + }
99 132 }
100 133  
101   -
102 134 class Owl_Session {
103 135 var $sessid;
104 136 var $sessuid;
... ...