/[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.1.1.1 - (hide annotations) (vendor branch)
Fri Aug 3 09:12:42 2001 UTC (22 years, 8 months ago) by ravilov
Branch: pliva
CVS Tags: r0
Changes since 1.1: +0 -0 lines
initial import

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     switch ($unit) {
129     case 'Mb':
130     case 'mb':
131     return sprintf("%s, %2.1f Mb",$ext,$size/(1024*1024));
132     case 'Kb':
133     case 'kb':
134     return sprintf("%s, %2.1f Mb",$ext,$size/1024);
135     case 'auto':
136     $size=$size/1024; # Kb
137     if ($size > 1024) {
138     return sprintf("%s, %2.1f Mb",$ext,$size/1024);
139     } else {
140     return sprintf("%s, %2.1f Kb",$ext,$size);
141     }
142    
143     }
144     return $size;
145     }
146     }
147    
148     // input functions (input, rinput)
149    
150     function smarty_func_input() {
151     extract(func_get_arg(0));
152     print "<input name=\"$name\" size=\"$size\" value=\"".$GLOBALS[$name]."\">";
153     print "<input type=\"hidden\" name=\"inputs_required[]\" value=\"$name\">";
154     if ($type) print "<input type=\"hidden\" name=\"inputs_required_type[$name]\" value=\"$type\">";
155     }
156    
157     function smarty_func_rinput() {
158     extract(func_get_arg(0));
159     global $inputs_required_type;
160     $ok=1;
161     if (! isset($GLOBALS[$name]) || $GLOBALS[$name] == "") {
162     $ok=0;
163     } else {
164     switch($inputs_required_type[$name]) {
165     case 'email':
166     if (!strstr($GLOBALS[$name],'@')) $ok=0;
167     }
168     }
169     if ($ok) {
170     print "$desc";
171     } else {
172     print "<b>$desc</b>";
173     }
174     }
175     ?>

  ViewVC Help
Powered by ViewVC 1.1.26