/[corp_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.3 - (hide annotations)
Sat Mar 17 15:46:05 2001 UTC (23 years, 1 month ago) by dpavlin
Branch: MAIN
Changes since 1.2: +20 -0 lines
nukleus for filesize var modifier

1 dpavlin 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 dpavlin 1.2 $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 dpavlin 1.1 $size = GetImageSize(dirname($GLOBALS[SCRIPT_FILENAME])."/$src");
69 dpavlin 1.2 $out.="<img src=\"$src\" $size[3]$add>";
70     if ($product_link[$pic]) {
71     $out.="</a>";
72     }
73     print $out;
74 dpavlin 1.1 }
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 dpavlin 1.3 // filesize
108    
109     function smarty_mod_filesize($file,$unit)
110     {
111     $path=dirname($GLOBALS[SCRIPT_FILENAME])."/$file";
112     print "-- $path --";
113    
114     if ($size=filesize($path)) {
115     switch ($unit) {
116     case 'Mb':
117     case 'mb':
118     return sprintf("%02.1d Mb",$size/(1024*1024));
119     case 'Kb':
120     case 'kb':
121     return sprintf("%02.1d Mb",$size/1024);
122     }
123     return $size;
124     }
125     }
126    
127 dpavlin 1.1 ?>
128    

  ViewVC Help
Powered by ViewVC 1.1.26