/[health_html]/inc/Smarty.local.php
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /inc/Smarty.local.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (hide annotations)
Mon Sep 3 15:52:15 2001 UTC (22 years, 7 months ago) by ravilov
Branch: MAIN
Changes since 1.1: +7 -9 lines
Made the menu on the left into images. More bugfixes.

1 ravilov 1.1 <?php
2    
3     //-----------------------------------------
4     // Custom made by Dobrica Pavlinusic <dpavlin@rot13.org>
5    
6     // helper function to make full path of relative dir
7     function dir2path($dir) {
8     if (substr($dir,0,1) != "/") {
9     return dirname($GLOBALS[SCRIPT_FILENAME])."/$dir";
10     } else {
11     return $dir;
12     }
13     }
14    
15     function smarty_func_img() {
16     extract(func_get_arg(0));
17    
18     $f=Array();
19    
20     global $img_time;
21     if (!isset($img_time)) {
22     $img_time=time();
23     }
24    
25    
26     if (isset($dir)) {
27     $tdir=dir2path($dir);
28     $h=opendir($dir);
29     $pics=0;
30     while ($tmp = readdir($h)) {
31     if (is_file("$tdir/$tmp") && substr($tmp,0,1)!=".") {
32     // print "$tdir/$tmp<br>\n";
33     $f[]=$tmp;
34     $pics++;
35     }
36     }
37     closedir($h);
38     // $f=shuffle($f);
39     $ord=($img_time+$nr) % $pics;
40     $src="$dir/$f[$ord]";
41     }
42    
43     $add="";
44     if (isset($border)) {
45     $add.=" border=\"$border\"";
46     }
47     if (isset($alt)) {
48     $add.=" alt=\"$alt\"";
49     }
50     if (isset($align)) {
51     $add.=" align=\"$align\"";
52     }
53     if (isset($hspace)) {
54     $add.=" hspace=\"$hspace\"";
55     }
56     if (isset($vspace)) {
57     $add.=" vspace=\"$vspace\"";
58     }
59    
60     $out="";
61     $product_link = array (
62     "andol.gif"=>"http://www.pliva.hr/human_health.php?search=andol&show_description=on#results",
63     "andol_c.jpg"=>"http://www.pliva.hr/human_health.php?search=andol%25c&show_description=on#results",
64     "bisolex.jpg"=>"http://www.pliva.hr/human_health.php?search=bisolex&show_description=on#results",
65     "plibex.gif"=>"http://www.pliva.hr/human_health.php?search=plibex&show_description=on#results",
66     "plivit_b.gif"=>"http://www.pliva.hr/human_health.php?search=plivit%25b&show_description=on#results",
67     "plivit_b6.gif"=>"http://www.pliva.hr/human_health.php?search=plivit%25b6&show_description=on#results",
68     "plivit_c.gif"=>"http://www.pliva.hr/human_health.php?search=plivit%25c&show_description=on#results",
69     );
70    
71     $pic=basename($src);
72     if ($product_link[$pic]) {
73     $out.="<a href=\"$product_link[$pic]\">";
74     $add.=" border=\"0\"";
75     }
76    
77     $size = GetImageSize(dir2path($src));
78     $out.="<img src=\"$src\" $size[3]$add>";
79     if ($product_link[$pic]) {
80     $out.="</a>";
81     }
82     print $out;
83     }
84    
85     // checkboxes
86    
87     function smarty_func_html_checkboxes()
88     {
89     $print_result = true;
90    
91     extract(func_get_arg(0));
92    
93     settype($output, 'array');
94     settype($values, 'array');
95    
96     $html_result = "";
97    
98     for ($i = 0; $i < count($output); $i++) {
99     /* By default, check value against $selected */
100     $sel_check = $values[$i];
101     if (isset($before)) $html_result.=$before;
102     $html_result .= "<input type=checkbox name=\"".$values[$i]."\"";
103     if (isset($GLOBALS[$values[$i]])) {
104     $html_result .= " checked";
105     }
106     $html_result .= ">".$output[$i]."\n";
107     if (isset($after)) $html_result.=$after;
108     }
109    
110     if ($print_result)
111     print $html_result;
112     else
113     return $html_result;
114     }
115    
116     // $filename|filesize:"dir":"unit"
117     //
118     // dir -- path to file (or "")
119     // unit -- Mb|Kb|auto
120    
121     function smarty_mod_filesize($file,$dir,$unit="")
122     {
123     $path=dir2path("$dir/$file");
124     $ext=explode(".",$file);
125     $ext=strtoupper(array_pop($ext));
126    
127     if ($size=filesize($path)) {
128 ravilov 1.2 switch (strtoupper($unit)) {
129     case 'MB':
130     return sprintf("%s, %2.1f MB",$ext,$size/(1024*1024));
131     case 'KB':
132     return sprintf("%s, %2.1f kB",$ext,$size/1024);
133 ravilov 1.1 case 'auto':
134     $size=$size/1024; # Kb
135     if ($size > 1024) {
136 ravilov 1.2 return sprintf("%s, %2.1f MB",$ext,$size/1024);
137 ravilov 1.1 } else {
138 ravilov 1.2 return sprintf("%s, %2.1f kB",$ext,$size);
139 ravilov 1.1 }
140    
141     }
142     return $size;
143     }
144     }
145    
146     // input functions (input, rinput)
147    
148     function smarty_func_input() {
149     extract(func_get_arg(0));
150     print "<input name=\"$name\" size=\"$size\" value=\"".$GLOBALS[$name]."\">";
151     print "<input type=\"hidden\" name=\"inputs_required[]\" value=\"$name\">";
152     if ($type) print "<input type=\"hidden\" name=\"inputs_required_type[$name]\" value=\"$type\">";
153     }
154    
155     function smarty_func_rinput() {
156     extract(func_get_arg(0));
157     global $inputs_required_type;
158     $ok=1;
159     if (! isset($GLOBALS[$name]) || $GLOBALS[$name] == "") {
160     $ok=0;
161     } else {
162     switch($inputs_required_type[$name]) {
163     case 'email':
164     if (!strstr($GLOBALS[$name],'@')) $ok=0;
165     }
166     }
167     if ($ok) {
168     print "$desc";
169     } else {
170     print "<b>$desc</b>";
171     }
172     }
173     ?>

  ViewVC Help
Powered by ViewVC 1.1.26