MemberShip Database port to PHP4


/include/ -> app_functions.php

1  <?php
2  /*
3  ** Function: siteHeader()
4  ** Input: Title yes or no to cache page
5  ** Output: Std HTML
6  ** Description: HTML header for all pages
7  **
8  **
9  */
10 
11  function siteHeader($title,$cache= "")
12  {
13      if($cache == "on") {
14           $LastModified = filemtime(__FILE__) + date( "Z");
15          header( "Last-Modified: " .
16          gmdate( "D, d M Y H:i:s", $LastModified) . " GMT");
17      
18           //set expiration time 24 hours (86400 seconds) from now
19          $Expires = time() + 86400;
20          header( "Expires: " .
21          gmdate( "D, d M Y H:i:s", $Expires) . " GMT");
22 
23           //tell cache to let page age for 24 hours (86400 seconds)
24          header( "Cache-Control: max-age=86400");
25      } elseif ($cache == "off") {
26           // Don't allow page to be cached
27          header( "Last-Modified: " . gmdate( "D, d M Y H:i:s") . " GMT");
28          header( "Expires: " . gmdate( "D, d M Y H:i:s") . " GMT");
29          header( "Cache-Control: no-cache, must-revalidate");
30          header( "Pragma: no-cache");
31      } else {
32           // Do nothing
33      }
34 
35 
36      print "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">\n";
37      print "<HTML>\n";
38      print "<HEAD>\n";
39      print "<TITLE>$title</TITLE>\n";
40      print "</HEAD>\n";
41 
42  }
43 
44 
45  function bodyTag()
46  {
47  global $bgcolor, $bgtext, $link;
48        print "<BODY BGCOLOR= \"#$bgcolor\"
49              TEXT=\"#$bgtext\"
50              LINK=\"#$link\"
51              VLINK=\"#$link\"
52              ALINK=\"#ffffff\">\n\n";
53 
54  }
55 
56 
57  /*
58  ** Function: siteFooter()
59  ** Input:
60  ** Output: Std HTML
61  ** Description: HTML footer for all pages
62  **
63  **
64  */
65  function siteFooter()
66  {
67      print "</BODY>\n";
68      print "</HTML>\n";
69  }
70 
71 
72  function formActionBegin($action,$method=post)
73  {
74     print "<FORM ACTION=\"$action\" METHOD=\"$method\">\n";
75  }
76 
77  function formInput($type, $name, $value="")
78  {
79    print "<INPUT TYPE=\"$type\" NAME=\"$name\" VALUE=\"$value\">\n";
80  }
81 
82  function formTextArea($name, $value="", $cols=50, $rows=5)
83  {
84    print "<TEXTAREA NAME=\"$name\" COLS=\"$cols\" ROWS=\"$rows\" VALUE=\"$value\" WRAP=\"soft\">\n";
85    print "</TEXTAREA>\n";
86  }
87 
88  function formActionEnd($name,$value,$form_reset="off")
89  {
90    print "<br>\n";
91    print "<INPUT TYPE=submit NAME=\"$name\" VALUE=\"$value\">\n";
92    if($form_reset == "on") {
93    print " <INPUT TYPE=reset VALUE=\"RESET VALUES\">\n";
94    }
95    print "<br>\n";
96  }
97 
98 
99  /*
100  ** Function: displayImage()
101  ** Input: pathto/filename.xxx ALT text
102  ** Output: Std HTML
103  ** Description: Display image and alt string
104  **
105  **
106  */
107  function displayImage($image, $text= "")
108  {
109      print "\n<IMG SRC=$image BORDER=0 ALT=\"$text\">\n";
110  }
111 
112 
113  function randomImage($dir_path)
114  {
115       $directory = array();
116       $i = 0;
117       $d = dir($dir_path);
118       while($entry=$d->read()) {
119          if ( $entry !="." && $entry !=".." ) {
120             $directory[$i]=$entry;
121             $i++;
122          }
123       }
124       $d->close();
125       srand ((double) microtime() * 10000000);
126       $key = rand ( 0,$i-1 );
127       echo $dir_path."/".$directory[$key];
128  }
129 
130 
131 
132  /*
133  ** Function: htmlHeader()
134  ** Input: Text Alignment and size
135  ** Output: Std HTML
136  ** Description: <H3>this is a htmlHeader</H3>
137  **
138  **
139  */
140  function htmlHeader($text, $align= "left", $size=3)
141  {
142      print "\n<H".$size. " align=".$align. ">" .$text. "</H".$size. ">\n";
143  }
144 
145 
146  /*
147  ** Function: pageTop()
148  ** Input: Text String, links, pageurl width
149  ** Output: Std HTML
150  ** Description: Top table of web site
151  **
152  **
153  */
154  function pageTop($text_str, $width= "500")
155  {
156   global $fcolor, $tcolor, $ttext, $ftext;
157 
158  print "
159      <center>
160 
161 
162        <table border=0 cellpadding=10 cellspacing=0 width=$width>
163 
164          <tr bgcolor=#$tcolor>
165            <td>
166              <font color=#$ttext size=4><center><b>
167           $text_str
168           <br>
169              </b></font>
170            </td>
171          </tr>
172 
173          <tr bgcolor=#$fcolor>
174            <td>
175              <font color=#$ftext>
176  ";
177 
178  }
179 
180 
181  /*
182  ** Function: pageBottom()
183  ** Input:
184  ** Output: Std HTML
185  ** Description: bottom table of web site
186  **
187  **
188  */
189  function pageBottom()
190  {
191 
192      print "
193              </font>
194            </td>
195          </tr>
196 
197        </table>
198 
199      </center>
200    ";
201  }
202 
203 
204  /*
205  ** Function: navBar()
206  ** Input: an array of links
207  ** Output: Std HTML
208  ** Description: display navigational links
209  ** e.g $link_array = array (
210  ** "About" => "about.php",
211  ** "Who We Are" =>"whoweare.php",
212  ** "What We Do" =>"whatwedo.php");
213  **
214  */
215  function navBar($link_array,$page_dir= "")
216  {
217     reset($link_array);
218     echo "<TABLE BORDER='0'><TR>\n";
219     while (list($key, $val) = each($link_array)) {
220        $label = ucfirst($key);
221        $link = $page_dir . "$val";
222           echo "<TD align='CENTER'><A HREF=$link>";
223           echo "<FONT SIZE='1' FACE='Arial'>$label</FONT></TD>\n";
224     }
225     echo "</TR></TABLE>\n";
226  }
227 
228 
229  /*
230  ** Function: printBoldtxt()
231  ** Input: test string
232  ** Output: Std HTML
233  ** Description: display text bolded
234  **
235  **
236  */
237  function printBoldtxt($text)
238  {
239     print "<B>" . $text . "</B>";
240  }
241 
242 
243  /*
244  ** Function: printColoredtxt()
245  ** Input: color of text and text string
246  ** Output: Std HTML
247  ** Description: bottom table of web site
248  **
249  **
250  */
251  function printColoredtxt($color= "black", $text)
252  {
253     print "<FONT COLOR=\"$color\">" . $text . "</FONT>";
254  }
255 
256 
257  /*
258  ** Function: printPage()
259  ** Input:
260  ** Output: Std HTML
261  ** Description: display <P>
262  **
263  **
264  */
265  function printPage()
266  {
267     print "<P>\n";
268  }
269 
270 
271  /*
272  ** Function: makeList()
273  ** Input: variable defined in page
274  ** Output: Std HTML
275  ** Description: display html list
276  **
277  **
278  */
279  function makeList()
280  {
281   global $listType;
282   
283    print "<".$listType. ">";
284    
285    for($i=0; $i < func_num_args(); $i++)
286    {
287        print "<LI>" . func_get_arg($i) . "\n";
288    }
289    print "</".$listType. ">";
290         
291  }
292 
293 
294  /*
295  ** Function: siteTheme()
296  ** Input:
297  ** Output: Std HTML
298  ** Description: background text, link color template
299  **
300  **
301  */
302  function siteTheme($scheme= "smoke")
303  {
304         include( "schemes/$scheme.scheme.php");
305         return;
306  }
307 
308 
309  function displayButtons($type, $button_array, $buttonvalue= "")
310  {
311 
312     reset($button_array);
313      for($i=0; $i < count($button_array); $i++) {
314        $question = $button_array[$i];
315        $q_id = $buttonvalue;
316        if($type == "radio") {
317        print "<input type=\"$type\" name=\"$q_id\" value=\"$q_id\" > $question <br>\n";
318        } else {
319        print "<input type=\"$type\" name=\"tt_id[]\" value=\"$question\"> $question <br>\n";
320        }
321     }
322     
323     
324  }
325 
326  function array2select($arr_str, $sel = "") {
327          while( list( $key, $val ) = each($arr_str)) {
328                  if($sel && $key == $sel) {
329                          $select_value = " selected";
330                  } else {
331                          $select_value= "";
332                  }
333                  print "<option value=\"$key\" $select_value>$val</option>\n";
334          }
335  }
336 
337  //
338  // Database functions of the php mysql functions
339  //
340  function connect() {
341          global $sys_dbhost,$sys_dbuser,$sys_dbpasswd;
342          $conn = @mysql_pconnect($sys_dbhost,$sys_dbuser,$sys_dbpasswd);
343          return $conn;
344  }
345 
346  function query($qstring,$limit='-1',$offset=0) {
347          global $sys_dbname,$conn;
348 
349          if ($limit > 0) {
350                  if (!$offset || $offset < 0) {
351                          $offset=0;
352                  }
353                  $qstring=$qstring." LIMIT $offset,$limit";
354          }
355                  return @mysql_db_query($sys_dbname,$qstring,$conn);
356  }
357 
358  function numrows($func_value) {
359          // return only if func_value exists, otherwise 0
360          if ($func_value) {
361                  return @mysql_numrows($func_value);
362          } else {
363                  return 0;
364          }
365  }
366 
367  function free_result($func_value) {
368          return @mysql_free_result($func_value);
369  }
370 
371  function data_seek($func_value,$row=0) {
372          return mysql_data_seek($func_value,$row);
373  }
374 
375  function result($func_value,$row,$field) {
376          return @mysql_result($func_value,$row,$field);
377  }
378 
379  function numfields($func_value) {
380          return @mysql_numfields($func_value);
381  }
382 
383  function db_fieldname($func_value,$fnumber) {
384           return @mysql_fieldname($func_value,$fnumber);
385  }
386 
387  function affected_rows($func_value) {
388          return @mysql_affected_rows();
389  }
390 
391  function fetch_array($func_value) {
392          return @mysql_fetch_array($func_value);
393  }
394 
395  function insertid($func_value,$table_name,$pkey_field_name) {
396          return @mysql_insert_id();
397  }
398 
399  function error() {
400          return @mysql_error();
401  }
402 
403  function close($func_value) {
404          return @mysql_close($func_value);
405  }
406  ?>
407 


Generated: Sat Jan 27 16:28:07 2001 Generated by PHPXref 0.1.2
PCCS-Linux.COM ::ource Advocate Articles catalogue
2000 2002