Example #1
0
 public function getPublic($password)
 {
     # Functions checks if photo or parent album is public
     # Returns the following:
     # (int) 0 = Photo private and parent album private
     # (int) 1 = Album public, but password incorrect
     # (int) 2 = Photo public or album public and password correct
     # Check dependencies
     self::dependencies(isset($this->database, $this->photoIDs));
     # Call plugins
     $this->plugins(__METHOD__, 0, func_get_args());
     # Get photo
     $query = Database::prepare($this->database, "SELECT public, album FROM ? WHERE id = '?' LIMIT 1", array(LYCHEE_TABLE_PHOTOS, $this->photoIDs));
     $photos = $this->database->query($query);
     $photo = $photos->fetch_object();
     # Check if public
     if ($photo->public === '1') {
         # Photo public
         return 2;
     } else {
         # Check if album public
         $album = new Album($this->database, null, null, $photo->album);
         $agP = $album->getPublic();
         $acP = $album->checkPassword($password);
         # Album public and password correct
         if ($agP === true && $acP === true) {
             return 2;
         }
         # Album public, but password incorrect
         if ($agP === true && $acP === false) {
             return 1;
         }
     }
     # Call plugins
     $this->plugins(__METHOD__, 1, func_get_args());
     # Photo private
     return 0;
 }
Example #2
0
 public function getPublic($password)
 {
     # Check dependencies
     self::dependencies(isset($this->database, $this->photoIDs));
     # Call plugins
     $this->plugins(__METHOD__, 0, func_get_args());
     # Get photo
     $query = Database::prepare($this->database, "SELECT public, album FROM ? WHERE id = '?' LIMIT 1", array(LYCHEE_TABLE_PHOTOS, $this->photoIDs));
     $photos = $this->database->query($query);
     $photo = $photos->fetch_object();
     # Check if public
     if ($photo->public == 1) {
         return true;
     } else {
         $album = new Album($this->database, null, null, $photo->album);
         $acP = $album->checkPassword($password);
         $agP = $album->getPublic();
         if ($acP === true && $agP === true) {
             return true;
         }
     }
     # Call plugins
     $this->plugins(__METHOD__, 1, func_get_args());
     return false;
 }
Example #3
0
 private function getAlbumArchive()
 {
     Module::dependencies(isset($_GET['albumID'], $_GET['password']));
     $album = new Album($this->database, $this->plugins, $this->settings, $_GET['albumID']);
     if ($album->getPublic() && $album->getDownloadable()) {
         # Album Public
         if ($album->checkPassword($_GET['password'])) {
             $album->getArchive();
         } else {
             exit('Warning: Wrong password!');
         }
     } else {
         # Album Private
         exit('Warning: Album private or not downloadable!');
     }
 }
Example #4
0
 public function getPublic($password)
 {
     Log::notice($this->database, __METHOD__, __LINE__, "Checking public for " . $this->photoIDs);
     # Functions checks if photo or parent album is public
     # Returns the following:
     # (int) 0 = Photo private and parent album private
     # (int) 1 = Album public, but password incorrect
     # (int) 2 = Photo public or album public and password correct
     # Check dependencies
     self::dependencies(isset($this->database, $this->photoIDs));
     # Call plugins
     $this->plugins(__METHOD__, 0, func_get_args());
     # Get photo
     $stmt = $this->database->prepare("SELECT public, album FROM " . LYCHEE_TABLE_PHOTOS . " WHERE id = ? LIMIT 1");
     $result = $stmt->execute(array($this->photoIDs));
     $photo = $stmt->fetchObject();
     # Check if public
     if ($photo->public == 1) {
         # Photo public
         return 2;
     } else {
         # Check if album public
         $album = new Album($this->database, null, null, $photo->album);
         $agP = $album->getPublic();
         $acP = $album->checkPassword($password);
         # Album public and password correct
         if ($agP === true && $acP === true) {
             return 2;
         }
         # Album public, but password incorrect
         if ($agP === true && $acP === false) {
             return 1;
         }
     }
     # Call plugins
     $this->plugins(__METHOD__, 1, func_get_args());
     # Photo private
     return 0;
 }
Example #5
0
 public function getPublic($password)
 {
     # Functions checks if photo or parent album is public
     # Returns the following:
     # (int) 0 = Photo private and parent album private
     # (int) 1 = Album public, but password incorrect
     # (int) 2 = Photo public or album public and password correct
     # Check dependencies
     self::dependencies(isset($this->photoIDs));
     # Get photo
     $sql = "SELECT public, album FROM photos WHERE id = " . pg_escape_literal($this->photoIDs);
     $res = pg_query($db, $sql);
     $row = pg_fetch_array($res);
     # Check if public
     if ($row['public'] === '1') {
         # Photo public
         pg_free_result($res);
         return 2;
     } else {
         # Check if album public
         $album = new Album(null, null, $row['album']);
         $agP = $album->getPublic();
         $acP = $album->checkPassword($password);
         # Album public and password correct
         if ($agP === true && $acP === true) {
             pg_free_result($res);
             return 2;
         }
         # Album public, but password incorrect
         if ($agP === true && $acP === false) {
             pg_free_result($res);
             return 1;
         }
     }
     pg_free_result($res);
     # Photo private
     return 0;
 }