Ejemplo n.º 1
0
 private function plusUploader($para)
 {
     //return status,file,msg
     $attaches = self::plusUploaderFilter($para);
     if ($attaches['status']) {
         //上传目录设置
         if ($this->_uploader_datepath) {
             $this->_uploader_path .= date("Ymd", time()) . '/';
         }
         XiiFolder::Run($this->_uploader_path);
         $feedback = array();
         foreach ($attaches['file'] as $v) {
             $tmp_name = $this->_uploader_path . md5($v->name) . '.' . $v->extensionName;
             if ($v->saveAs($tmp_name)) {
                 $feedback[] = $tmp_name;
             }
         }
         $files_num = count($feedback);
         if ($files_num > 0) {
             if ($files_num == 1) {
                 return array('status' => true, 'file' => reset($feedback));
             } else {
                 return array('status' => true, 'file' => $feedback);
             }
         } else {
             return array('status' => false, 'msg' => 'Errores occurred during file upload!');
         }
     } else {
         return array('status' => false, 'msg' => $attaches['msg']);
     }
 }
Ejemplo n.º 2
0
 public function saveData($data, $errorCode = 200, $errorMessage = null)
 {
     if (self::$_Json_Use_History) {
         self::$_YiiCache_Switch = false;
         $timeofcache = self::$_Json_History_Time;
     } else {
         $timeofcache = time();
     }
     $response_json = array('errorCode' => $errorCode, 'errorMessage' => self::getErrorMessage($errorCode) . '_J_' . date('md_H_i_s', $timeofcache), 'data' => $data);
     $response_yii = array('errorCode' => $errorCode, 'errorMessage' => self::getErrorMessage($errorCode) . '_Y_' . date('md_H_i_s', $timeofcache), 'data' => $data);
     if (self::$_Yii_Json) {
         $output_json = CJSON::encode($response_json);
         $output_yii = CJSON::encode($response_yii);
     } else {
         $tmp = array_pop(self::$_PHP_para);
         if (!empty(self::$_PHP_para)) {
             foreach (self::$_PHP_para as $v) {
                 $tmp |= $v;
             }
         }
         $output_json = json_encode($response_json, $tmp);
         $output_yii = json_encode($response_yii, $tmp);
     }
     if (self::$_Jsonp_Switch) {
         $callback = isset(self::$_Data_Request[self::$_Jsonp_Callback]) ? self::$_Data_Request[self::$_Jsonp_Callback] : self::$_Jsonp_Default_Func;
         $output_json = $callback . '(' . $output_json . ')';
         $output_yii = $callback . '(' . $output_yii . ')';
     }
     $Yii_save = true;
     if (self::$_YiiCache_Switch) {
         $tmp = self::$_YiiCache_Component;
         $Yii_save = Yii::app()->{$tmp}->set(self::$_YiiCache_ID, $output_yii, self::$_YiiCache_Life);
         if (!$Yii_save && !self::$_Json_Switch) {
             return -609;
         }
     }
     if (self::$_Json_Switch) {
         XiiFolder::Run(self::$_Json_Path);
         if (self::$_Json_File != '') {
             $tmp_file = self::$_Json_Path . self::$_Json_File . '.json';
         } else {
             $tmp_file = self::$_Json_Path . date(self::$_Time_Type, time()) . '.json';
         }
         clearstatcache();
         if (file_exists($tmp_file)) {
             if (is_writable($tmp_file)) {
                 return file_put_contents($tmp_file, $output_json, LOCK_EX);
             } else {
                 if ($Yii_save) {
                     return -607;
                 } else {
                     return -610;
                 }
             }
         } else {
             if (is_writable(self::$_Json_Path)) {
                 return file_put_contents($tmp_file, $output_json, LOCK_EX);
             } else {
                 if ($Yii_save) {
                     return -608;
                 } else {
                     return -611;
                 }
             }
         }
     }
 }