Projet

Général

Profil

Paste
Statistiques
| Branche: | Révision:

ryxeo-webphotoalbum-git / data / www / inc / www.class.inc.php @ 7938c308

Historique | Voir | Annoter | Télécharger (12,3 ko)

1
<?php
2
// www.class.inc.php
3
class C_www {
4
   var $background, $bgcolor, $link, $vlink, $alink, $hover, $language;
5
   var $textcol, $font, $fontsize;
6

    
7
   ////
8
   // !vykpise HTML hlavicku dokumentu
9
   // Ten CSS style jeste neni moc dodelanej
10
   function header($title) {
11
      global $gallery_dir,$root, $snimek, $galerie, $ThisScript, $themes;
12

    
13
                        header("Content-Type: text/html; charset=utf-8");// make sure we send in utf8
14
                                                                                                                                                                                                                         // and override Apache
15

    
16
                                                                                                                                                                                                                         // For some reason text/xml is
17
                                                                                                                                                                                                                         // causing trouble with stylesheets
18
                        echo "<?xml version=\"1.0\"?>\n";
19
                        /*
20
                        echo "<?xml-stylesheet type=\"text/css\" media=\"screen\""; // doesn't work yet :/
21
                        echo " href=\"inc/style/dark/dark.css\" ?>\n";
22
                        */
23
      echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\n";
24
      echo "   \"http://www.w3.org/TR/2000/REC-xhtml1-20000126/DTD/xhtml1-strict.dtd\">\n";
25
      echo "<html>\n";
26
      echo "<head>\n";
27

    
28
                        #IE hacks
29
                        echo "<!-- This makes IE6 suck less (a bit) -->\n";
30
                        echo "<!--[if lt IE 7]>\n";
31
                        echo "<link rel=\"stylesheet\" type=\"text/css\" ";
32
                        echo "href=\"inc/styles/ie6workarounds.css\" />\n";
33
                        echo "<script src=\"inc/styles/ie7/ie7-standard.js\" type=\"text/javascript\">\n";
34
                        echo "</script>\n";
35
                        echo "<![endif]-->\n";
36

    
37
      echo "   <title>$title</title>\n";
38
                        echo "<link rel=\"icon\" href=\"stock_camera-16.png\" ";
39
                        echo "type=\"image/png\" />\n";
40
                        echo "<link rel=\"shortcut icon\" href=\"favicon.ico\" ";
41
                        echo "type=\"image/x-icon\" />\n";
42
      # mozilla style links
43
                if ($snimek && $galerie) {
44
                        #Top
45
                        echo "   <link rel=\"Top\"      href=\"$ThisScript\" />\n";
46
                        #First
47
                        #Prev
48
                        $predchozi = $snimek - 1;
49
                        $dalsi = $snimek + 1;
50
                   if ($snimek > 1) {
51
                                echo "   <link rel=\"First\" ";
52
                                echo "   href=\"$ThisScript?galerie=$galerie&amp;photo=1\" />\n";
53
                                echo "   <link rel=\"Previous\" ";
54
                                echo "href=\"$ThisScript?galerie=$galerie&amp;photo=$predchozi\" />\n";
55
                        }
56
                        #Next
57
                        if (is_file("$gallery_dir/$galerie/lq/img-$dalsi.jpg")) {
58
                                echo "   <link rel=\"Next\" ";
59
                                echo "    href=\"$ThisScript?galerie=$galerie&amp;photo=$dalsi\" />\n";
60
                        }
61
                        #Last
62
                        $adr = opendir("$gallery_dir/$galerie/thumbs/");
63
                        $i = -2;
64
                        while ($file = readdir($adr)) {
65
                                $i++;
66
                        }
67
                        if ($i!=$snimek) {
68
                                echo "   <link rel=\"Last\" ";
69
                                echo "    href=\"$ThisScript?galerie=$galerie&amp;photo=$i\" />\n";
70
                        }
71
                }
72
      
73
      /* check the theme in a cookie */
74
      $theme = @$_COOKIE["theme"];
75
      if (!$theme) { //we didn't set the cookie yet
76
         // select first key of the themes array in config.inc.php as default
77
         $theme_keys = array_keys($themes);
78
         $theme = $theme_keys[0]; 
79
      }
80
      foreach ($themes as $skin => $url) {
81
         echo "<link type=\"text/css\" rel=\"";
82
         if ($skin==$theme) {
83
            echo "stylesheet";
84
         } else {
85
            echo "prefertch alternate stylesheet";
86
         }
87
         echo "\" href=\"$url\" title=\"$skin\"";
88
         echo " media=\"screen\" />\n";
89
      }
90
     
91
      //require("javascript.inc.php");
92
                        echo "<script src=\"inc/global.js\" ";
93
                        echo "type=\"text/javascript\"></script>\n";
94

    
95
                        //ryxeo
96
                        if($_GET['slideshow'] == 'play') {
97
                          echo "<link rel=\"stylesheet\" href=\"slideshow/style.css\" type=\"text/css\" />\n";
98
                          echo "<script type=\"text/javascript\" src=\"slideshow/jquery-1.7.2.min.js\"></script>\n";
99
                          echo "<script type=\"text/javascript\" src=\"slideshow/jquery.galleriffic.js\"></script>\n";
100
                        }
101

    
102
      echo "</head>\n\n";
103
      echo "<body onload=\"checkForTheme()";
104
      echo "\">\n";
105
   }
106

    
107
   ////
108
   // !zavre html stranku
109
   function footer() {
110
      echo "</body>\n";
111
      echo "</html>\n";
112
   }
113

    
114
   ////
115
   // !vypise chybovou hlasku
116
   // $title - nadpis a title HTML stranky
117
   // $message - vlastni chybova hlaska
118
   function error($title, $message) {
119
         $this->header($title);
120
         echo "<h1>$title</h1>\n";
121
         echo $message;
122
         $this->footer();
123
         exit; //vysere se na vsechno
124
   }
125

    
126
  
127
     
128
   ////
129
   // !zacatek fomrulare
130
   function form_start($action, $method, $upload) {
131
      echo "<form ";
132
      if ($upload) echo "enctype=\"multipart/form-data\" ";
133
      echo "action=\"";
134
                        echo htmlentities($action,ENT_COMPAT,"UTF-8");
135
                        echo "\" method=\"$method\">\n";
136
   }
137

    
138
   ////
139
   // !konec formulare
140
   function form_end() {
141
      echo "</form>\n";
142
   }
143
 
144
   ////
145
   // !vykresli polozku formulare
146
   // umi text, password, submit, file, hidden, textarea, select
147
   // u textarea je default pocet radku...
148
   function input($type, $name, $value, $popis, $default, $title) {
149
                        echo "<div class=\"row\">\n";
150
                        if (!$title) {
151
                                echo "        <div class=\"label\">$popis</div>\n";
152
                        } else {
153
                                echo "        <div class=\"label\"><a title=\"$title\" ";
154
                                echo "href=\"#\">$popis</a></div>\n";
155
                        }
156
                        echo "        <div class=\"control\">";
157
      switch ($type) {
158
         case "checkbox":
159
            echo "<input type=\"$type\" name=\"$name\" value=\"$value\"";
160
            if ($default) echo " checked=\"checked\"";
161
            echo " />";
162
            break;
163
         case "password": 
164
         case "text": 
165
            echo "<input type=\"$type\" size=\"30\" name=\"$name\" value=\"$value\" />";
166
            break;
167
         case "file": 
168
            echo "<input type=\"$type\" size=\"30\" name=\"$name\" />";
169
            break;
170
         case "hidden": 
171
            echo "<input type=\"$type\" name=\"$name\" value=\"$value\" />";
172
            break;
173
         case "textarea":
174
            echo "<textarea name=\"$name\" cols=\"40\"";
175
            if ($default) {
176
                echo " rows=\"$default\"";
177
            } else {
178
                echo " rows=\"10\"";
179
            }
180
            echo ">$value</textarea>";
181
            break;
182
         case "select":
183
            echo "<select name=\"$name\" size=\"1\">\n";
184
            while (list($optval, $option) = each($value)) {
185
                echo "<option value=\"$optval\"";
186
                if ($optval == $default) echo " selected";
187
                echo ">";
188
                echo $option;
189
                echo "</option>\n";
190
            }
191
            echo "</select>";
192
            break;
193
         case "submit":
194
            echo "<input type=\"$type\" name=\"$name\" value=\"$value\" />";
195
            break;
196
      }
197
                        echo "        </div>\n";
198
                        echo "</div>\n";
199
   }
200

    
201
        
202
        function navigation ($gallery, $snapshot, $image) {
203
   global $gallery_dir, $root, $ThisScript, $textnav, $img, 
204
          $show_thumbs, $exif_style, $PNthumbScale;
205

    
206
   $next = $snapshot + 1;
207
   $prev = $snapshot - 1;
208

    
209
   if (!$image) { // this will render a navigation bar - max 3 buttons
210
      echo "\n<div class=\"navbuttons\">\n";
211
      echo "<div class=\"navbuttonsshell\">\n";
212
      if ($snapshot > 1) { //previous 
213
         echo "<a id=\"previcon\" href=\"$ThisScript?galerie=$gallery&amp;photo=$prev";
214
         echo "&amp;exif_style=$exif_style&amp;show_thumbs=$show_thumbs\"";
215
                                 echo " accesskey=\"p\">";
216
         echo "&lt; <span class=\"accesskey\">P</span>revious</a>\n";
217
      }
218
      echo "&nbsp;";
219
      if (is_file("$gallery_dir/$gallery/lq/img-$next.jpg")) { //next
220
         echo "<a id=\"nexticon\" href=\"$ThisScript?galerie=$gallery&amp;photo=$next";
221
         echo "&amp;exif_style=$exif_style&amp;show_thumbs=$show_thumbs\"";
222
                                 echo " accesskey=\"n\">";
223
         echo "<span class=\"accesskey\">N</span>ext &gt;</a>\n";
224
      }
225
      echo "</div>\n</div>\n";
226
   } elseif ($image=="prev") { //previous thumbnail
227
      if ($snapshot > 1) { //previous 
228
         echo "<div class=\"prevthumb\">";
229
         echo "<a href=\"$ThisScript?galerie=$gallery&amp;photo=$prev";
230
         echo "&amp;exif_style=$exif_style&amp;show_thumbs=$show_thumbs\">";
231
         if (file_exists("$gallery_dir/$gallery/thumbs/img-$prev.png")) {
232
            $Pthumb = "$gallery_dir/$gallery/thumbs/img-$prev.png";
233
         } else {
234
            $Pthumb = "$gallery_dir/$gallery/thumbs/img-$prev.jpg";
235
         }
236
         $v = getimagesize("$root/$Pthumb");
237
         echo "<img alt=\"Previous\" src=\"";
238
         echo $Pthumb . "\" width=\"" . round($v[0]/$PNthumbScale);
239
         echo "\" height=\"" . round($v[1]/$PNthumbScale) . "\" />";
240
         echo "<br />" . __('Previous');
241
         echo "</a></div>\n";
242
      }
243
   } else { //next thumbnail
244
      if (is_file("$gallery_dir/$gallery/lq/img-$next.jpg")) {
245
         echo "<div class=\"nextthumb\">";
246
         echo "<a href=\"$ThisScript?galerie=$gallery&amp;photo=$next";
247
         echo "&amp;exif_style=$exif_style&amp;show_thumbs=$show_thumbs\">";
248
         if (file_exists("$gallery_dir/$gallery/thumbs/img-$next.png")) {
249
            $Nthumb = "$gallery_dir/$gallery/thumbs/img-$next.png";
250
         } else {
251
            $Nthumb = "$gallery_dir/$gallery/thumbs/img-$next.jpg";
252
         }
253
         $v = getimagesize("$root/$Nthumb");
254
         echo "<img alt=\"Next\" src=\"";
255
         echo $Nthumb . "\" width=\"" . round($v[0]/$PNthumbScale);
256
         echo "\" height=\"" . round($v[1]/$PNthumbScale) . "\" />";
257
         //echo "<br /><span class=\"accesskey\">N</span>ext";
258
         echo "<br />" . __('Next') ;         
259
         echo "</a> <br />\n";
260
         //Slideshow
261
         echo "   <a href=\"$ThisScript?galerie=$gallery&amp;photo=$next&amp;slideshow=play&amp;show_thumbs=yes\" target=\"_blank\">Slideshow</a>\n";
262
         echo "</div>\n";
263
      }
264
   }
265
        }
266

    
267
        function user_comments($photo) {
268
                global $root, $gallery_dir, $galerie, $comments, $picture;
269

    
270
   if ($comments) {
271
                 if (is_writable("$root/$gallery_dir/$galerie/comments")) { // needs perms
272
                         require("inc/comment_form.inc.php");
273

    
274
                         if ($picture->comments) {
275
                                        print "<div class=\"user_comment\">";
276
                                        print $picture->comments;
277
                                        print "</div>";
278
                         }
279
                 } else {
280
                         print "<!-- WARNING: comment dir not writable -->\n";
281
                 }
282
   }
283
        }
284

    
285
        function process_comment_form() { // processing of the user comment data
286
                global $comments, $root, $gallery_dir, $galerie, $snimek;
287
                
288
                if($comments && @$_POST["commentdata"]) {
289
                                $username = @$_COOKIE["username"];
290
                                $comment_name = @$_POST["commentname"];
291
                                $save_comment_name = @$_POST["savecommentname"];
292
                                $comment_data = @$_POST["commentdata"];
293
                                $comment_kolacek = @$_POST["commentkolacek"];
294
                                $comment_spamcheck = @$_POST["commentspamcheck"];
295

    
296
                                #check for HTML tags
297
                                
298
                                $comment_name = stripslashes(strip_tags($comment_name));
299
                                $allowedTags = '<a><b><i><ul><li><blockquote><br>';
300
                                $comment_data = stripslashes(strip_tags($comment_data,$allowedTags));
301
                                // thanks google: 
302
                                // http://www.google.com/googleblog/2005/01/preventing-comment-spam.html
303
                                $comment_data = eregi_replace("<a ","<a rel=\"nofollow\" ",$comment_data);
304

    
305
                                #further comment spam
306
                                $comment_blacklist = array("pharmacy", "poker", "Viagra");
307

    
308
                                foreach($comment_blacklist as $blackword) {
309
                                        $check = addslashes($blackword);
310
                                        if (eregi($check,$comment_data)) {
311
                                                #write error message
312
                                                $this->error( __('No comment spam'), __('Your comment includes blacklisted word') . __('No comment spam') );
313
                                                $this->footer();
314
                                                exit; //stop everything
315
                                        }
316
                                }
317

    
318
                                if ($comment_kolacek!=md5($comment_spamcheck)) {
319
                                                $this->error( __('No comment spam'), __('You ve written the check number wrong' ) );
320
                                                $this->footer();
321
                                                exit; //stop everything
322
                                }
323

    
324
                                if (!$comment_name) {
325
                                        $comment_name = $_COOKIE["username"];
326
                                }
327
                                
328
                                // ok so we got a comment
329
                                if ($comment_name && $save_comment_name) {
330
                                // save out name in a cookie
331
                                        if (!setcookie("username","$comment_name", 
332
                                                                                        mktime(0, 0, 0, 12, 30, 2030))) {
333
                                                print __('Could not set name cookie!');
334
                                                exit;
335
                                        }
336
                                }
337

    
338
                                // create a user_comment file if not existant or append to it
339
                                if (!$picture) {
340
                                  require_once("$root/inc/photo.class.inc.php");
341
                                        $path = "$gallery_dir/$galerie/lq";
342
                                        $file = "$path/img-$snimek.jpg";
343
                                        $picture = new C_photo($file, $snimek);
344
                                }
345
                                $picture->addcomment($comment_name, $comment_data);
346
                }
347
        }
348
}
349

    
350
# return dirs sorted
351
class SortDir {
352
   var $items;
353

    
354
   function SortDir($directory) {
355
      $handle=@opendir($directory);
356
                        if (!$handle) return;
357
      while ($file = readdir($handle)) {
358
         if ($file != "." && $file != "..") {
359
            $this->items[]=$file;
360
         }
361
      }
362
      closedir($handle);
363
            if ($this->items) {
364
         natsort($this->items);
365
            }
366
   }
367

    
368
   function Read() {
369
                        if ($this->items) {
370
                                $getback= (pos($this->items));
371
                                next($this->items);
372
                                return $getback;
373
                        }
374
   }
375
}
376

    
377
?>
Redmine Appliance - Powered by TurnKey Linux