/[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

Diff of /inc/Smarty.local.php

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3 by dpavlin, Sat Mar 17 15:46:05 2001 UTC revision 1.9 by dpavlin, Mon Jul 9 14:28:04 2001 UTC
# Line 3  Line 3 
3  //-----------------------------------------  //-----------------------------------------
4  // Custom made by Dobrica Pavlinusic <dpavlin@rot13.org>  // 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() {  function smarty_func_img() {
16          extract(func_get_arg(0));          extract(func_get_arg(0));
17    
# Line 15  function smarty_func_img() { Line 24  function smarty_func_img() {
24                                    
25    
26          if (isset($dir)) {          if (isset($dir)) {
27                  $tdir=dirname($GLOBALS[SCRIPT_FILENAME])."/$dir";                  $tdir=dir2path($dir);
28                  $h=opendir($dir);                  $h=opendir($dir);
29                  $pics=0;                  $pics=0;
30                  while ($tmp = readdir($h)) {                  while ($tmp = readdir($h)) {
# Line 50  function smarty_func_img() { Line 59  function smarty_func_img() {
59    
60          $out="";          $out="";
61          $product_link = array (          $product_link = array (
62  "andol.gif"=>"human_health.php?search=andol&show_description=on#results",  "andol.gif"=>"http://www.pliva.hr/human_health.php?search=andol&show_description=on#results",
63  "andol_c.jpg"=>"human_health.php?search=andol%25c&show_description=on#results",  "andol_c.jpg"=>"http://www.pliva.hr/human_health.php?search=andol%25c&show_description=on#results",
64  "bisolex.jpg"=>"human_health.php?search=bisolex&show_description=on#results",  "bisolex.jpg"=>"http://www.pliva.hr/human_health.php?search=bisolex&show_description=on#results",
65  "plibex.gif"=>"human_health.php?search=plibex&show_description=on#results",  "plibex.gif"=>"http://www.pliva.hr/human_health.php?search=plibex&show_description=on#results",
66  "plivit_b.gif"=>"human_health.php?search=plivit%25b&show_description=on#results",  "plivit_b.gif"=>"http://www.pliva.hr/human_health.php?search=plivit%25b&show_description=on#results",
67  "plivit_b6.gif"=>"human_health.php?search=plivit%25b6&show_description=on#results",  "plivit_b6.gif"=>"http://www.pliva.hr/human_health.php?search=plivit%25b6&show_description=on#results",
68  "plivit_c.gif"=>"human_health.php?search=plivit%25c&show_description=on#results",  "plivit_c.gif"=>"http://www.pliva.hr/human_health.php?search=plivit%25c&show_description=on#results",
69          );          );
70    
71          $pic=basename($src);          $pic=basename($src);
# Line 65  function smarty_func_img() { Line 74  function smarty_func_img() {
74                  $add.=" border=\"0\"";                  $add.=" border=\"0\"";
75          }          }
76    
77          $size = GetImageSize(dirname($GLOBALS[SCRIPT_FILENAME])."/$src");          $size = GetImageSize(dir2path($src));
78          $out.="<img src=\"$src\" $size[3]$add>";          $out.="<img src=\"$src\" $size[3]$add>";
79          if ($product_link[$pic]) {          if ($product_link[$pic]) {
80                  $out.="</a>";                  $out.="</a>";
# Line 104  function smarty_func_html_checkboxes() Line 113  function smarty_func_html_checkboxes()
113                  return $html_result;                  return $html_result;
114  }  }
115    
116  // filesize  // $filename|filesize:"dir":"unit"
117    //
118    // dir -- path to file (or "")
119    // unit -- Mb|Kb|auto
120    
121  function smarty_mod_filesize($file,$unit)  function smarty_mod_filesize($file,$dir,$unit="")
122  {  {
123          $path=dirname($GLOBALS[SCRIPT_FILENAME])."/$file";          $path=dir2path("$dir/$file");
124          print "-- $path --";          $ext=explode(".",$file);
125            $ext=strtoupper(array_pop($ext));
126    
127          if ($size=filesize($path)) {          if ($size=filesize($path)) {
128                  switch ($unit) {                  switch ($unit) {
129                          case 'Mb':                          case 'Mb':
130                          case 'mb':                          case 'mb':
131                                  return sprintf("%02.1d Mb",$size/(1024*1024));                                  return sprintf("%s, %2.1f Mb",$ext,$size/(1024*1024));
132                          case 'Kb':                          case 'Kb':
133                          case 'kb':                          case 'kb':
134                                  return sprintf("%02.1d Mb",$size/1024);                                  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;                  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    ?>

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.9

  ViewVC Help
Powered by ViewVC 1.1.26