Projet

Général

Profil

Paste
Statistiques
| Branche: | Révision:

ryxeo-webphotoalbum-git / data / www / inc / funkce.inc.php @ 278d2613

Historique | Voir | Annoter | Télécharger (4,09 ko)

1 67466a8d Eric Seigne
<?php
2
3
function check($file) {
4 4fcec884 Eric Seigne
  global $gallery_dir, $page;
5 67466a8d Eric Seigne
   
6 4fcec884 Eric Seigne
  //   if (eregi("[^0-9a-z\_\-\ ]",$file) || !file_exists("$gallery_dir/$file")) {
7
  //   if (eregi("CVS",$file) || !file_exists("$gallery_dir/$file")) {
8
  if (!file_exists("$gallery_dir/$file")) {
9
    echo "funkce.inc.php/check(): Bad input";
10
    $page->footer();
11
    exit;
12
  }
13
  }
14 67466a8d Eric Seigne
15
function browserCheck() {
16 4fcec884 Eric Seigne
  global $HTTP_USER_AGENT;
17 67466a8d Eric Seigne
   
18 4fcec884 Eric Seigne
  $HTTP_USER_AGENT=$_SERVER["HTTP_USER_AGENT"];
19
  if (eregi("(MSIE.[456789]).*Mac.*",$HTTP_USER_AGENT)) {
20
    return("macie4+");
21
  } elseif (eregi("(MSIE.[678])",$HTTP_USER_AGENT)) {
22
    return("ie6+");
23
  } elseif (eregi("(MSIE.[45])",$HTTP_USER_AGENT)) {
24
    return("ie4+");
25
  } elseif (eregi("Opera",$HTTP_USER_AGENT)) {
26
    return("opera");
27
  } elseif (eregi("(Mozilla.4)",$HTTP_USER_AGENT)) {
28
    return("netscape4");
29
  } elseif (eregi("(Mozilla.[5-9])",$HTTP_USER_AGENT)) {
30
    return("mozilla");
31
  } elseif (eregi("KMeleon",$HTTP_USER_AGENT)) {
32
    return("mozilla");
33
  } else {
34
    return("Netscape3");
35
  }
36 67466a8d Eric Seigne
}
37
38
function infoParse ($infofile) {
39
        
40 4fcec884 Eric Seigne
  $info_array = file($infofile);
41
  foreach ($info_array as $line) {
42
    list($key,$value) = split("\|",$line);
43
    $result[$key]=$value;
44
  }
45
  return $result;
46 67466a8d Eric Seigne
}
47
48
function readInfo ($infofile, $file) {
49 4fcec884 Eric Seigne
  global $galerieyear, $galeriemonth, $galerieday, $galeriedesc, $galerieauthor,
50 eee84392 Eric Seigne
    $galeriename, $galerielogin, $galeriepw, $gallery_dir, $galerievideo;
51 67466a8d Eric Seigne
        
52 4fcec884 Eric Seigne
  if (file_exists($infofile)) {
53
    //read from info.txt
54
    $info_array = infoParse($infofile);
55 eee84392 Eric Seigne
56
    //video ?
57 278d2613 Eric Seigne
    if(trim($info_array["video"]) == "true") {
58
      //print_r($info_array);
59
      $galerievideo = 1;
60 eee84392 Eric Seigne
    }
61
    else {
62 278d2613 Eric Seigne
      $galerievideo = 0;
63 eee84392 Eric Seigne
    }
64
65 4fcec884 Eric Seigne
    if ($info_array["date"]) {
66
      // try to be a little smarter about format
67
      if (ereg("([0-9]{1,2})\.([0-9]{1,2})\.([0-9]{4})",
68
               $info_array["date"])) {
69
        // remain compatible - DD.MM.YYYY
70
        list($day,$month,$year) = split("\.", $info_array["date"]);
71
        $year = rtrim($year);
72
        $month = rtrim($month);
73
        $day = rtrim($day);
74
        $info_array["date"] = "$year-$month-$day"; //make it US date
75
      }
76
      // US date format at this point
77
      $tstamp = strtotime($info_array["date"]);
78
    } else {
79
      $tstamp = filemtime("$gallery_dir/$file");// Get from filesystem
80
    }
81
    $galerieyear["$file"] = date("Y", $tstamp);
82
    $galeriemonth["$file"] = date("m", $tstamp);
83
    $galerieday["$file"] = date("d", $tstamp);
84 67466a8d Eric Seigne
                
85 4fcec884 Eric Seigne
    if (@$info_array["description"]) {
86
      $galeriedesc["$file"] = rtrim($info_array["description"]);
87
    }
88 67466a8d Eric Seigne
                
89 4fcec884 Eric Seigne
    if (@$info_array["author"]) {
90
      $galerieauthor["$file"] = rtrim($info_array["author"]);
91
    }
92 67466a8d Eric Seigne
                
93 4fcec884 Eric Seigne
    if (@$info_array["name"]) {
94
      $galeriename["$file"] = rtrim($info_array["name"]);
95
    }
96 67466a8d Eric Seigne
                
97 4fcec884 Eric Seigne
    if (@$info_array["restricted_user"]) {
98
      $galerielogin["$file"] = rtrim($info_array["restricted_user"]);
99
      $galeriepw["$file"] = rtrim($info_array["restricted_password"]);
100
    }
101
  } else { // Get Dates from modification stamp
102
    $mtime = filemtime("$gallery_dir/$file");
103
    $galerieyear["$file"] = date("Y", $mtime);
104
    $galeriemonth["$file"] = date("m", $mtime); //F
105
    $galerieday["$file"] = date("d", $mtime);
106
  }
107 67466a8d Eric Seigne
}
108
109
function access_check($login, $password,$realm) {
110 4fcec884 Eric Seigne
  if (!($_SERVER['PHP_AUTH_USER']=="$login" && $_SERVER['PHP_AUTH_PW']=="$password")) {
111
    header("WWW-authenticate: Basic Realm=$realm");
112
    Header("HTTP/1.0 401 Unauthorized");
113
    $err = new C_www;
114
    $err->header("Access Denied");
115
    echo "<div class=\"error\">\n";
116
    echo "<h1>Access Denied</h1>\n";
117
    echo "<p>Sorry, this gallery is restricted</p>\n";
118
    echo "<p><a href=\"index.php\">Return to index</a></p>\n";
119
    echo "</div>\n";
120
    $err->footer();
121
    exit;
122
  }
123 67466a8d Eric Seigne
124
}
125
126
function random_digits($times) {
127 4fcec884 Eric Seigne
  $random="";
128
  for ($i=0;$i<$times;$i++) {
129
    $random .= rand(0,9);
130
  }
131
  return $random;
132 67466a8d Eric Seigne
}
133
134
function get_photo_title($galerie, $id) {
135
  global $gallery_dir;
136
  if ($title = @file_get_contents("$gallery_dir/$galerie/comments/${id}.txt")) {
137
    $title = trim(preg_replace('/[\s\n\r]+/', ' ', strip_tags($title)));
138
    if (strlen($title) > 80)
139
      $title = trim(substr($title, 0, 77)) . "...";
140
  } else 
141
    $title = "Photo ${id}";
142
  return $title;
143
}
144
145
?>
Redmine Appliance - Powered by TurnKey Linux