/**
  * Fetch an entry by using a File's id
  */
 static function byFile(File $file)
 {
     $file_thumbnail = self::getKV('file_id', $file->getID());
     if (!$file_thumbnail instanceof File_thumbnail) {
         throw new ServerException(sprintf('No File_thumbnail entry for File id==%u', $file->getID()));
     }
     return $file_thumbnail;
 }
Example #2
0
 static function getNoticeIDsByFile(File $file)
 {
     $f2p = new File_to_post();
     $f2p->selectAdd();
     $f2p->selectAdd('post_id');
     $f2p->file_id = $file->getID();
     $ids = array();
     if (!$f2p->find()) {
         throw new NoResultException($f2p);
     }
     return $f2p->fetchAll('post_id');
 }
Example #3
0
 public function isFileSharedTo(File $toCheck, $userIDToCheck)
 {
     if (!is_numeric($userIDToCheck)) {
         return false;
     }
     $database = Database::getInstance();
     if (!$database->isConnected()) {
         return false;
     }
     $id = $database->escapeString($toCheck->getID());
     $results = $database->getData('shared', 'fileSystemShare', "referenceID={$id} AND referenceType='file' AND userID={$userIDToCheck}");
     if ($results === false) {
         return false;
     }
     if ($results === null) {
         return false;
     }
     if (count($results) > 1) {
         return false;
     }
     $shared = (int) $results[0]['shared'];
     if ($shared === 0) {
         return false;
     }
     return true;
 }
 public function makeBackupOfToday()
 {
     $this->deleteOldBackups();
     $F = new File(Util::getRootPath() . "system/Backup/.htaccess");
     $F->loadMe();
     if ($F->getA() == null) {
         file_put_contents($F->getID(), "AuthUserFile " . Util::getRootPath() . "system/Backup/.htpasswd\nAuthGroupFile /dev/null\nAuthName \"Restricted\"\nAuthType Basic\n<Limit GET>\nrequire valid-user\n</Limit>");
         file_put_contents(Util::getRootPath() . "system/Backup/.htpasswd", "Restricted:kV.RuW/ox2sc2" . mt_rand(0, 20000000));
     }
     require Util::getRootPath() . "libraries/PMBP.inc.php";
     $CONF = array();
     $CONF['sql_host'] = $_SESSION["DBData"]["host"];
     $CONF['sql_user'] = $_SESSION["DBData"]["user"];
     $CONF['sql_passwd'] = $_SESSION["DBData"]["password"];
     $CONF['date'] = "d.m.Y";
     $CONF['sql_db'] = $_SESSION["DBData"]["datab"];
     define("PMBP_EXPORT_DIR", Util::getRootPath() . "system/Backup/");
     define('PMBP_VERSION', "v.2.1");
     define('PMBP_WEBSITE', "http://www.phpMyBackupPro.net");
     $PMBP_SYS_VAR = array();
     $PMBP_SYS_VAR["except_tables"] = "";
     $filename = PMBP_dump($CONF, $PMBP_SYS_VAR, $_SESSION["DBData"]["datab"], true, true, false, false, "");
     chmod(Util::getRootPath() . "system/Backup/" . $filename, 0666);
     return $filename;
 }