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

  ViewVC Help
Powered by ViewVC 1.1.26