예제 #1
0
 /**
  * @NoAdminRequired
  * @NoCSRFRequired
  */
 public function Pause()
 {
     \OCP\JSON::setContentTypeHeader('application/json');
     try {
         if ($this->WhichDownloader == 0) {
             if (isset($_POST['GID']) && strlen(trim($_POST['GID'])) > 0) {
                 $Status = Aria2::TellStatus($_POST['GID']);
                 $Pause['result'] = $_POST['GID'];
                 if (!isset($Status['error']) && strcmp($Status['result']['status'], 'error') != 0 && strcmp($Status['result']['status'], 'complete') != 0 && strcmp($Status['result']['status'], 'active') == 0) {
                     $Pause = Aria2::Pause($_POST['GID']);
                 }
                 if (strcmp($Pause['result'], $_POST['GID']) == 0) {
                     $SQL = 'UPDATE `*PREFIX*ocdownloader_queue` SET `STATUS` = ? WHERE `UID` = ? AND `GID` = ?';
                     if ($this->DbType == 1) {
                         $SQL = 'UPDATE *PREFIX*ocdownloader_queue SET "STATUS" = ? WHERE "UID" = ? AND "GID" = ?';
                     }
                     $Query = \OCP\DB::prepare($SQL);
                     $Result = $Query->execute(array(3, $this->CurrentUID, $_POST['GID']));
                     return new JSONResponse(array('ERROR' => false, 'MESSAGE' => (string) $this->L10N->t('The download has been paused')));
                 } else {
                     return new JSONResponse(array('ERROR' => true, 'MESSAGE' => (string) $this->L10N->t('An error occurred while pausing the download')));
                 }
             } else {
                 return new JSONResponse(array('ERROR' => true, 'MESSAGE' => (string) $this->L10N->t('Bad GID')));
             }
         }
     } catch (Exception $E) {
         return new JSONResponse(array('ERROR' => true, 'MESSAGE' => $E->getMessage()));
     }
 }