예제 #1
0
 private function extractTplZipFile($zipFile, $directory)
 {
     $zipFp = zip_open($zipFile);
     if (!is_resource($zipFp)) {
         //打开zip文件失败
         self::$errMsg = 'zip文件损坏!';
         return FALSE;
     }
     if (!is_dir($directory)) {
         //目录不存在 则创建之
         if (!mkdir($directory)) {
             self::$errMsg = '创建解压目录失败!';
             return FALSE;
         }
     } else {
         //目录存在 则删除目录中的全部普通文件
         $dirFp = opendir($directory);
         while (FALSE !== ($enties = readdir($dirFp))) {
             if (is_file($directory . $enties)) {
                 unlink($directory . $enties);
             }
         }
     }
     //解压文件到文件夹
     while (is_resource($entry = zip_read($zipFp))) {
         $content = '';
         while ($d = zip_entry_read($entry)) {
             $content .= $d;
         }
         $name = zip_entry_name($entry);
         $name = strtolower($name);
         file_put_contents($directory . $name, $content, LOCK_EX);
     }
     zip_close($zipFp);
     return true;
 }
예제 #2
0
 public function view_setAccountsTpl()
 {
     $id = isset($_GET['id']) ? intval($_GET['id']) : FALSE;
     //模板id
     $account = isset($_GET['account']) ? trim($_GET['account']) : FALSE;
     //账号
     $returnData = array('code' => 0, 'msg' => '');
     if (empty($id)) {
         //缺少模板
         $returnData['code'] = 800;
         $returnData['msg'] = '缺少参数';
         echo json_encode($returnData);
         exit;
     }
     if (empty($returnData)) {
         //缺少账号
         $returnData['code'] = 801;
         $returnData['msg'] = '缺少账号!';
         echo json_encode($returnData);
         exit;
     }
     $aliTplmodel_obj = new AliShipTemplateModel();
     if ($aliTplmodel_obj->isTplExists($id) == FALSE) {
         //不存在的模板
         $returnData['code'] = 802;
         $returnData['msg'] = '模板不存在!';
         echo json_encode($returnData);
         exit;
     }
     $aliAccount_obj = new AliAccountModel();
     if (!$aliAccount_obj->aliAccountExists($account)) {
         $returnData['code'] = 803;
         $returnData['msg'] = '不存在的账号!';
         echo json_encode($returnData);
         exit;
     }
     $result = $aliTplmodel_obj->setAccountsTpl($account, $id);
     if ($result) {
         $returnData['code'] = 805;
         $returnData['msg'] = '成功!';
         echo json_encode($returnData);
         exit;
     } else {
         $returnData['code'] = 804;
         $returnData['msg'] = '设置失败!';
         echo json_encode($returnData);
         exit;
     }
 }
예제 #3
0
 public function culculateCountdown($account, $shippingType, $country)
 {
     $country_obj = new CountryNameManageModel();
     $countryInfo = $country_obj->getRealCountryNameWithCountryCode($country);
     if (empty($countryInfo)) {
         self::$errMsg = 'no exists!';
         return FALSE;
     }
     //var_dump($countryInfo);exit;
     $realCountryName = $countryInfo['countryname'];
     //国家全称
     //echo $realCountryName;exit;
     $aliship_obj = new AliShipTemplateModel();
     $tplsetinfo = $aliship_obj->getAccountSetInfo($account);
     if (empty($tplsetinfo)) {
         self::$errMsg = 'no setting';
         return FALSE;
     }
     $tplinfo = $aliship_obj->getTplInfoById($tplsetinfo['tplid']);
     if ($tplinfo == FALSE) {
         //不存在的模板
         self::$errMsg = 'tpl not exists';
         return FALSE;
     }
     $tplFilePath = $tplinfo['filepath'];
     $fileName = basename($tplFilePath);
     //文件名
     $dirName = dirname($tplFilePath);
     //目录
     $exdirName = substr($fileName, 0, strlen($fileName) - 4);
     //解压目录的名称
     $exFullPath = $dirName . '/' . $exdirName;
     if (!is_dir($exFullPath)) {
         self::$errMsg = 'data not exists';
         return FALSE;
     }
     $days = FALSE;
     $fileEnties = scandir($exFullPath);
     foreach ($fileEnties as $val) {
         $entry = $exFullPath . '/' . $val;
         if (is_dir($entry)) {
             continue;
         }
         if (strrchr($val, '.') != '.txt') {
             //必须是txt文件
             continue;
         }
         $shippingType = strtolower($shippingType);
         //             echo $realCountryName;
         //             $country    = strtolower($country);
         if (strpos($val, $shippingType) !== FALSE) {
             $content = file_get_contents($entry);
             if (strpos($content, $realCountryName) !== FALSE) {
                 $days = strrchr($val, '_');
                 $days = intval(ltrim($days, '_'));
                 break;
             }
         }
     }
     if ($days === FALSE) {
         //没找到
         $default = $exFullPath . '/' . $shippingType . '_def.txt';
         if (is_file($default)) {
             $days = file_get_contents($default);
             $days = intval($days);
         } else {
             $fixfile = $exFullPath . '/' . 'fix.txt';
             if (is_file($fixfile)) {
                 $fp = fopen($fixfile, 'r');
                 if ($fp !== FALSE) {
                     while (!feof($fp)) {
                         $buffer = fgets($fp);
                         $buffer = trim($buffer);
                         $buffer = strtolower($buffer);
                         if (strpos($shippingType, $buffer) !== FALSE) {
                             $buffer = str_replace($shippingType, '', $buffer);
                             $buffer = trim($buffer);
                             $days = intval($days);
                         }
                     }
                     fclose($fp);
                 }
             }
         }
     }
     //echo $days, 'xx';exit;
     self::$errMsg = 'not found';
     return $days;
 }