Esempio n. 1
0
 /**
  * Exexutes the supplied queries.
  * @param string $q
  * @return bool
  */
 public function ExecuteMulti($q)
 {
     $this->autocommit(FALSE);
     if ($this->multi_query($q)) {
         do {
         } while ($this->next_result());
         $this->autocommit(TRUE);
         return TRUE;
     }
     $e = new Error($this->errno, $this->error);
     Error::AddError($e);
     return FALSE;
 }
Esempio n. 2
0
 /**
  * Authenticates this session's User, and returns its object.
  * @return User
  */
 public static function Authenticate()
 {
     global $lang;
     if (array_key_exists('CurrentUser', $_SESSION)) {
         /* @var $User User */
         $User = unserialize($_SESSION['CurrentUser']);
         $Users = User::GetUsers(new UserSearchParameters($User->getID(), FALSE, FALSE, $User->getPassword()));
         if ($Users) {
             $User = $Users[0];
             $User->setLastActive(time());
             User::Update($User, $User);
             $lang->setLanguages(array($User->getLanguage()));
             if ($User->hasPermission(RIGHT_ACCOUNT_LOGIN)) {
                 return $User;
             } else {
                 $e = new Error(RIGHTS_ERR_USERNOTALLOWED);
                 Error::AddError($e);
                 header('location:login.php#2');
                 exit;
             }
         } else {
             header('location:login.php#1');
             exit;
         }
     } else {
         global $argv, $argc;
         if (isset($argv) && $argc > 0) {
             foreach ($argv as $arg) {
                 $kv = explode('=', $arg);
                 if (count($kv) > 1) {
                     $_GET[$kv[0]] = $kv[1];
                 }
                 unset($kv);
             }
             /* Authenticate on the commandline as Default User */
             $Users = User::GetUsers(new UserSearchParameters(CMDLINE_USERID));
             if ($Users) {
                 $User = $Users[0];
                 return $User;
             } else {
                 return NULL;
             }
         } else {
             /* If not on the commandline, the Session expired */
             header('location:login.php?url=' . urlencode($_SERVER['REQUEST_URI']));
             exit;
         }
     }
 }
Esempio n. 3
0
<?php

include 'cd.php';
ini_set('max_execution_time', '3600');
$CurrentUser = Authentication::Authenticate();
if (!$CurrentUser->hasPermission(RIGHT_VIDEO_ADD) && !$CurrentUser->hasPermission(RIGHT_VIDEO_EDIT)) {
    $e = new Error(RIGHTS_ERR_USERNOTALLOWED);
    Error::AddError($e);
    HTMLstuff::RefererRedirect();
}
$ModelID = Utils::SafeIntFromQS('model_id');
$SetID = Utils::SafeIntFromQS('set_id');
$Models = Model::GetModels(new ModelSearchParameters(is_null($ModelID) ? FALSE : $ModelID));
$Sets = Set::GetSets(new SetSearchParameters(is_null($SetID) ? FALSE : $SetID));
$Videos = Video::GetVideos(new VideoSearchParameters(FALSE, FALSE, is_null($SetID) ? FALSE : $SetID, FALSE, is_null($ModelID) ? FALSE : $ModelID));
$CacheImages = CacheImage::GetCacheImages();
if ($SetID) {
    $Set = $Sets[0];
    $Models = array($Set->getModel());
}
/* @var $Model Model */
for ($i = 0; $i < count($Models); $i++) {
    $Model = $Models[$i];
    $VideoFolder = sprintf('%1$s/%2$s', CANDYPATH, $Model->GetFullName());
    if (!file_exists($VideoFolder)) {
        continue;
    }
    /* @var $it RecursiveIteratorIterator */
    $it = new RecursiveDirectoryIterator($VideoFolder, FileSystemIterator::SKIP_DOTS | FileSystemIterator::CURRENT_AS_FILEINFO);
    $itArray = array();
    foreach ($it as $file) {
Esempio n. 4
0
 /**
  * Removes the specified Videos from the database.
  * @param array(Video) $Videos
  * @param User $CurrentUser
  * @return bool
  */
 public static function DeleteMulti($Videos, $CurrentUser)
 {
     global $dbi;
     $outBool = TRUE;
     $mut_id = $CurrentUser->getID();
     $mut_deleted = time();
     if (!is_array($Videos)) {
         return FALSE;
     }
     $q = sprintf("\n\t\t\tUPDATE `Video` SET\n\t\t\t\t`mut_id` = ?,\n\t\t\t\t`mut_deleted` = ?\n\t\t\tWHERE\n\t\t\t\t`video_id` = ?\n\t\t");
     if (!($stmt = $dbi->prepare($q))) {
         $e = new SQLerror($dbi->errno, $dbi->error);
         Error::AddError($e);
         return FALSE;
     }
     $stmt->bind_param('iii', $mut_id, $mut_deleted, $id);
     foreach ($Videos as $Video) {
         $id = $Video->getID();
         $outBool = $stmt->execute();
         if (!$outBool) {
             $e = new SQLerror($dbi->errno, $dbi->error);
             Error::AddError($e);
         }
     }
     $stmt->close();
     return $outBool;
 }
Esempio n. 5
0
 /**
  * Removes multiple CacheImages from the database.
  * @param array(CacheImage) $CacheImages
  * @param User $CurrentUser
  * @return bool
  */
 public static function DeleteMulti($CacheImages, $CurrentUser)
 {
     global $dbi;
     $outBool = TRUE;
     if (!is_array($CacheImages)) {
         return FALSE;
     }
     $q = sprintf("\n\t\t\tDELETE FROM\n\t\t\t\t`CacheImage`\n\t\t\tWHERE\n\t\t\t\t`cache_id` = ?\n\t\t");
     if (!($stmt = $dbi->prepare($q))) {
         $e = new SQLerror($dbi->errno, $dbi->error);
         Error::AddError($e);
         return FALSE;
     }
     $stmt->bind_param('s', $id);
     foreach ($CacheImages as $CacheImage) {
         $id = $CacheImage->getID();
         $outBool = $stmt->execute();
         if (!$outBool) {
             $e = new SQLerror($dbi->errno, $dbi->error);
             Error::AddError($e);
         }
     }
     $stmt->close();
     return $outBool;
 }
Esempio n. 6
0
 /**
  * Gets Tag2All records from the database or NULL on failure.
  * @param Tag2AllSearchParameters $SearchParameters
  * @param string $OrderClause
  * @return array(Tag2All) | NULL
  */
 public static function GetTag2Alls($SearchParameters = NULL, $OrderClause = 'tag_name ASC')
 {
     global $dbi;
     $SearchParameters = $SearchParameters ? $SearchParameters : new Tag2AllSearchParameters();
     $OrderClause = empty($OrderClause) ? 'tag_name ASC' : $OrderClause;
     $q = sprintf("\n\t\t\tSELECT\n\t\t\t\t`tag_id`, `tag_name`, `model_id`, `set_id`, `image_id`, `video_id`\n\t\t\tFROM\n\t\t\t\t`vw_Tag2All`\n\t\t\tWHERE\n\t\t\t\t1 = 1\n\t\t\t\t%1\$s\n\t\t\tORDER BY\n\t\t\t\t%2\$s", $SearchParameters->getWhere(), $OrderClause);
     if (!($stmt = $dbi->prepare($q))) {
         $e = new SQLerror($dbi->errno, $dbi->error);
         Error::AddError($e);
         return NULL;
     }
     DBi::BindParamsToSelect($SearchParameters, $stmt);
     if ($stmt->execute()) {
         $OutArray = array();
         $stmt->bind_result($tag_id, $tag_name, $model_id, $set_id, $image_id, $video_id);
         while ($stmt->fetch()) {
             $o = new self($tag_id, $tag_name, $model_id, $set_id, $image_id, $video_id);
             $OutArray[] = $o;
         }
         $stmt->close();
         return $OutArray;
     } else {
         $e = new SQLerror($dbi->errno, $dbi->error);
         Error::AddError($e);
         return NULL;
     }
 }