/**
  * Main class method. Return a fake recordset.
  * @var string 
  * @access private
  */
 function Execute()
 {
     $relFolder = KT_DynamicData($this->folder, '', '', false, array(), false);
     $relFolder = KT_TransformToUrlPath($relFolder, true);
     if (substr($relFolder, 0, 1) == '/') {
         $relFolder = substr($relFolder, 1);
     }
     $fullFolderPath = KT_realpath($this->baseFolder . $relFolder, true);
     if (substr($fullFolderPath, 0, strlen($this->baseFolder)) != $this->baseFolder) {
         if (isset($GLOBALS['tNG_debug_mode']) && $GLOBALS['tNG_debug_mode'] == "DEVELOPMENT") {
             die("Security error. The folder '" . $fullFolderPath . "' is out of base folder '" . $this->baseFolder . "'");
         } else {
             die("Security error. Access to this folder is forbidden.");
         }
     }
     $this->path = $fullFolderPath;
     $noOfEntries = 0;
     $startCountEntries = $this->page * $this->recordsPerPage;
     $this->totalNo = 0;
     if (file_exists($this->path)) {
         //read folders
         $folder = new KT_folder();
         $entries = $folder->readFolder($this->path, true);
         if ($folder->hasError()) {
             $err = $folder->getError();
             if (isset($GLOBALS['tNG_debug_mode']) && $GLOBALS['tNG_debug_mode'] == "DEVELOPMENT") {
                 $this->error = $err[1];
             } else {
                 $this->error = $err[0];
             }
         }
         $this->filesArr = $entries['files'];
         $tmpFilesArr = array();
         $tmpArr = array();
         for ($i = 0; $i < count($this->filesArr); $i++) {
             $this->filesArr[$i]['fullname'] = $relFolder . $this->filesArr[$i]['name'];
             $path_info = KT_pathinfo($this->filesArr[$i]['name']);
             $this->filesArr[$i]['extension'] = $path_info['extension'];
             $filetime = filectime($this->path . $this->filesArr[$i]['name']);
             $this->filesArr[$i]['date'] = $filetime;
             if (in_array(strtolower($this->filesArr[$i]['extension']), $this->allowedExtensions) || in_array("*", $this->allowedExtensions)) {
                 $tmpArr[] = $this->filesArr[$i][$this->orderField];
                 $tmpFilesArr[] = $this->filesArr[$i];
             }
         }
         $this->filesArr = $tmpFilesArr;
         $this->Sort($tmpArr);
         $this->totalNo = count($this->filesArr);
         if ($this->recordsPerPage > 0) {
             $from = $this->page * $this->recordsPerPage;
             $this->filesArr = array_slice($this->filesArr, $from, $this->recordsPerPage);
         }
         for ($i = 0; $i < count($this->filesArr); $i++) {
             $this->filesArr[$i]['date'] = KT_convertDate(date("Y-m-d H:i:s", $this->filesArr[$i]['date']), "yyyy-mm-dd HH:ii:ss", $GLOBALS['KT_screen_date_format'] . ' ' . $GLOBALS['KT_screen_time_format_internal']);
         }
         // create fake recordset
         $this->filesArr = $this->formatData($this->filesArr);
     }
     $KT_FakeRecordset = new KT_FakeRecordset($this->conn);
     $ret = $KT_FakeRecordset->getFakeRecordset($this->filesArr);
     if ($ret === NULL) {
         if (isset($GLOBALS['tNG_debug_mode']) && $GLOBALS['tNG_debug_mode'] == "DEVELOPMENT") {
             die("Internal error: cannot create fake recordset. " . $KT_FakeRecordset->getError());
         } else {
             die("Internal error: cannot create fake recordset.");
         }
     }
     return $ret;
 }
Exemplo n.º 2
0
 /**
  * Creates a fake recordset from the given columns associative array
  * This function is called on error or for the insert default values.
  * @param array $fakeArr The associative array
  * @return object resource Recordset resource
  * @access protected
  */
 function getFakeRecordset($fakeArr)
 {
     tNG_log::log('tNG' . $this->transactionType, "getFakeRecordset");
     $fakeRs = new KT_FakeRecordset($this->connection);
     $KT_fakeRs = $fakeRs->getFakeRecordset($fakeArr);
     if ($fakeRs->hasError) {
         tNG_log::log('KT_ERROR');
         $this->setError(new tNG_error('FIELDS_FAKE_RS_ERROR', array(), array($fakeRs->getError())));
         $disp = $this->getDispatcher();
         die($disp->getErrorMsg());
     }
     return $KT_fakeRs;
 }
Exemplo n.º 3
0
 /**
  * Creates a fake recordset from the given columns associative array
  * This function is called ONLY on error
  * @param array $fakeArr The associative array (it has multiple rows)
  * @return object resource Recordset resource
  * @access private
  */
 function getFakeRecordset($fakeArr)
 {
     tNG_log::log('tNG' . $this->transactionType, "getFakeRecordset");
     $localFakeArr = array();
     $i = 0;
     foreach ($fakeArr as $fakeKey => $fakeA) {
         foreach ($fakeA as $key => $value) {
             if (!isset($localFakeArr[$key])) {
                 $localFakeArr[$key] = array();
             }
             $localFakeArr[$key][$i] = $value;
         }
         $i++;
     }
     $fakeRs = new KT_FakeRecordset($this->connection);
     $KT_fakeRs = $fakeRs->getFakeRecordset($localFakeArr);
     if ($fakeRs->hasError) {
         tNG_log::log('KT_ERROR');
         $this->setError(new tNG_error('MULTIPLE_FAKE_RS_ERROR', array(), array($fakeRs->getError())));
         $disp = $this->getDispatcher();
         die($disp->getErrorMsg());
     }
     return $KT_fakeRs;
 }