Пример #1
0
 static function gfPrintLog($msg, $path = '', $verbose = USE_VERBOSE_LOG)
 {
     GC_Utils::gfPrintLog($msg, $path, $verbose);
     if (strlen($path) === 0) {
         $path = GC_Utils::isAdminFunction() ? ADMIN_LOG_REALFILE : LOG_REALFILE;
     }
     // 日付を毎のログにする
     $dir = dirname($path);
     $file = basename($path);
     // {LOGDIR}/YYYY/MM/DD/AM|PM/{LOGFILE}
     $expath = sprintf("%s/%s/%s", $dir, date("Y/m/d/a"), $file);
     $exdir = dirname($expath);
     SC_Utils_Ex::recursiveMkdir($exdir);
     GC_Utils::gfPrintLog($msg, $expath, false);
 }
Пример #2
0
 function update(array $arrPlugin, SC_Plugin_Installer $installer)
 {
     require_once DOWNLOADS_TEMP_PLUGIN_UPDATE_DIR . "KisekaeTouchCore.php";
     $plugin_code = $arrPlugin["plugin_code"];
     $date = date("Ymd");
     define("KTC_PLG_ORG_DIR", PLUGIN_UPLOAD_REALDIR . "{$plugin_code}/");
     define("KTC_PLG_UPD_DIR", DOWNLOADS_TEMP_PLUGIN_UPDATE_DIR);
     define("KTC_PLG_BKU_DIR", PLUGIN_UPLOAD_REALDIR . "{$plugin_code}_{$date}/");
     if (file_exists(KTC_PLG_BKU_DIR)) {
         // nop
     } else {
         SC_Utils_Ex::recursiveMkdir(KTC_PLG_BKU_DIR);
         $log = SC_Utils_Ex::sfCopyDir(KTC_PLG_ORG_DIR, KTC_PLG_BKU_DIR, "", TRUE);
         GC_Utils_Ex::gfPrintLog($log, PLUGIN_LOG_REALFILE, FALSE);
     }
     SC_Helper_FileManager_Ex::deleteFile(KTC_PLG_ORG_DIR, FALSE);
     $log = SC_Utils_Ex::sfCopyDir(KTC_PLG_UPD_DIR, KTC_PLG_ORG_DIR, "", TRUE);
     GC_Utils_Ex::gfPrintLog($log, PLUGIN_LOG_REALFILE, FALSE);
     $installer->copyDirectory("copy/plugin_dir/", "");
     $core = new KisekaeTouchCore($arrPlugin);
     $plugin_version = $arrPlugin["plugin_version"];
     $core->update($arrPlugin, $installer, $plugin_version);
     $core->createCash();
 }
 /**
  * ファイル書込を行う.
  *
  * @param string $filename ファイルパス
  * @param string $value 書き込み内容
  * @return boolean ファイルの書き込みに成功した場合 true
  */
 function sfWriteFile($filename, $value)
 {
     if (!is_dir(dirname($filename))) {
         SC_Utils_Ex::recursiveMkdir(dirname($filename), 0777);
     }
     $fp = fopen($filename, 'w');
     if ($fp === false) {
         return false;
     }
     if (fwrite($fp, $value) === false) {
         return false;
     }
     return fclose($fp);
 }
 /**
  * DBおよびファイルシステムにテンプレートパッケージを追加する.
  *
  * エラーが発生した場合は, エラーを出力し, false を返す.
  *
  * @param  SC_FormParam  $objFormParam SC_FormParamのインスタンス
  * @param  SC_UploadFile_Ex  $objUpFile    SC_UploadFileのインスタンス
  * @return boolean 成功した場合 true; 失敗した場合 false
  */
 public function doUpload($objFormParam, $objUpFile)
 {
     $template_code = $objFormParam->getValue('template_code');
     $template_name = $objFormParam->getValue('template_name');
     $device_type_id = $objFormParam->getValue('device_type_id');
     $template_dir = SMARTY_TEMPLATES_REALDIR . $template_code;
     $compile_dir = DATA_REALDIR . 'Smarty/templates_c/' . $template_code;
     $objQuery =& SC_Query_Ex::getSingletonInstance();
     $objQuery->begin();
     $arrValues = array('template_code' => $template_code, 'device_type_id' => $device_type_id, 'template_name' => $template_name, 'create_date' => 'CURRENT_TIMESTAMP', 'update_date' => 'CURRENT_TIMESTAMP');
     $objQuery->insert('dtb_templates', $arrValues);
     // フォルダ作成
     if (!file_exists($template_dir)) {
         if (!mkdir($template_dir)) {
             $this->arrErr['err'] = '※ テンプレートフォルダが作成できませんでした。<br/>';
             $objQuery->rollback();
             return false;
         }
     }
     if (!file_exists($compile_dir)) {
         if (!mkdir($compile_dir)) {
             $this->arrErr['err'] = '※ Smarty コンパイルフォルダが作成できませんでした。<br/>';
             $objQuery->rollback();
             return false;
         }
     }
     // 一時フォルダから保存ディレクトリへ移動
     $objUpFile->moveTempFile();
     // 解凍
     if (!SC_Helper_FileManager_Ex::unpackFile($template_dir . '/' . $_FILES['template_file']['name'])) {
         $this->arrErr['err'] = '※ テンプレートファイルの解凍に失敗しました。<br/>';
         $objQuery->rollback();
         return false;
     }
     // ユーザデータの下のファイルをコピーする
     $from_dir = SMARTY_TEMPLATES_REALDIR . $template_code . '/_packages/';
     $to_dir = USER_REALDIR . 'packages/' . $template_code . '/';
     if (!SC_Utils_Ex::recursiveMkdir($to_dir)) {
         $this->arrErr['err'] = '※ ' . $to_dir . ' の作成に失敗しました。<br/>';
         $objQuery->rollback();
         return false;
     }
     SC_Utils_Ex::sfCopyDir($from_dir, $to_dir);
     $objQuery->commit();
     return true;
 }
 /**
  * ダウンロードを実行する.
  *
  * 指定のテンプレートをアーカイブし, ブラウザに出力する.
  * 失敗した場合は, エラーメッセージを出力し, false を返す.
  *
  * @param  string  $template_code テンプレートコード
  * @return boolean 成功した場合 true; 失敗した場合 false
  */
 public function doDownload($template_code)
 {
     $from_dir = USER_TEMPLATE_REALDIR . $template_code . '/';
     $to_dir = SMARTY_TEMPLATES_REALDIR . $template_code . '/_packages/';
     if (SC_Utils_Ex::recursiveMkdir($to_dir) === false) {
         $this->arrErr['err'] = '※ ディレクトリの作成に失敗しました<br />';
         return false;
     }
     SC_Utils_Ex::sfCopyDir($from_dir, $to_dir);
     if (SC_Helper_FileManager_Ex::downloadArchiveFiles(SMARTY_TEMPLATES_REALDIR . $template_code, $template_code) === false) {
         $this->arrErr['err'] = '※ アーカイブファイルの作成に失敗しました<br />';
         return false;
     }
     return true;
 }
 /**
  *
  * @deprecated 重複決済される
  * @param unknown $accountDay
  */
 function doContBillResult($accountDay)
 {
     if ($accountDay == null) {
         $accountDay = $this->getAccountDay();
     }
     $objQuery = SC_Query_Ex::getSingletonInstance();
     $curl = $this->curl_init();
     do {
         $zip_file = CSV_TEMP_REALDIR . "auone/" . date("Y/m/d/His") . ".zip";
         if (file_exists($zip_file)) {
             sleep(5);
         }
     } while (file_exists($zip_file));
     SC_Utils_Ex::recursiveMkdir(dirname($zip_file));
     $fp = fopen($zip_file, "w");
     // FIXME 決済認可
     $curl = $this->curl_init(false, true);
     // $post_history = array ();
     $post = $this->getPost("ContBillResult", $this->config, compact("accountDay"));
     curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($post));
     curl_setopt($curl, CURLOPT_HEADER, FALSE);
     curl_setopt($curl, CURLOPT_FILE, $fp);
     curl_exec($curl);
     $zip = new ZipArchive();
     if (!$zip->open($zip_file)) {
         SC_Utils_Ex::sfDispSiteError(PAGE_ERROR);
     }
     $extr = dirname($zip_file) . "/" . basename($zip_file, ".zip") . "/";
     SC_Utils_Ex::recursiveMkdir($extr);
     if (!$zip->extractTo($extr)) {
         SC_Utils_Ex::sfDispSiteError(PAGE_ERROR);
     }
     $files = glob($extr . "*.csv");
     foreach ($files as $file) {
         $enc_filepath = SC_Utils_Ex::sfEncodeFile($file, CHAR_CODE, dirname($file) . DIRECTORY_SEPARATOR);
         $fp2 = fopen($enc_filepath, "r");
         fgetcsv($fp2);
         while ($arrCsv = fgetcsv($fp2)) {
             if (count($arrCsv) == 0) {
                 // 空の列
                 continue;
             }
             if ($arrCsv[4] != $this->config["serviceId"]) {
                 // 別サービス・チェック
                 continue;
             }
             if ($arrCsv[8] != 'MPL01000') {
                 // 取消レコード
                 continue;
             }
             $pay_info_no = $arrCsv[1];
             $amount_in_tax = $arrCsv[2];
             $service_id = $arrCsv[4];
             $au_open_id = $arrCsv[5];
             $member_manage_no = $arrCsv[6];
             $process_day = $arrCsv[11];
             $cont_bill_regst_day = $arrCsv[13];
             $continue_account_id = $arrCsv[19];
             $amount = $amount_in_tax - $amount_in_tax % 100;
             $add_point = $amount;
             $where = "au_open_id =? AND status = 2 AND del_flg = 0";
             $arrWhereVal = (array) $au_open_id;
             $customer = SC_Helper_Customer_Ex::sfGetCustomerDataFromId(null, $where, $arrWhereVal);
             if (SC_Utils_Ex::isBlank($customer)) {
                 // ユーザー復旧は手動の方がいいかもしれない。
                 continue;
             }
             $name = "継続(" . $amount_in_tax . "円)";
             $customer_id = $customer["customer_id"];
             if ($add_point) {
                 $lost_point = 0;
                 // 更新後ポイント
                 $updatePoint = array("point" => min($customer["point"] + $add_point, AU_MAXPOINT));
                 // 最大ポイントへ変更している場合は失効ポイントを計算
                 if ($updatePoint["point"] == AU_MAXPOINT) {
                     $lost_point = max($customer["point"] + $add_point, AU_MAXPOINT) - AU_MAXPOINT;
                 }
                 SC_Helper_Customer_Ex::sfEditCustomerData($updatePoint, $customer_id);
                 $objQuery->insert("cp_dtb_point_history", array("id" => $objQuery->nextVal("cp_dtb_point_history_id"), "customer_id" => $customer_id, "add_point" => $add_point, "use_point" => 0, "lost_point" => $lost_point, "order_id" => 0, "name" => $name, "create_date" => "NOW()", "update_date" => "NOW()"));
                 $arrWhereVal[] = $continue_account_id;
                 if ($objQuery->exists("cp_dtb_customer_transaction", "au_open_id=? AND del_flg=0 AND continue_account_id =?", $arrWhereVal)) {
                     // 何かしらの影響で削除された場合後続処理を行う
                     continue;
                 }
                 $objQuery->insert("cp_dtb_customer_transaction", array("id" => $objQuery->nextVal("cp_dtb_customer_transaction_id"), "customer_id" => $customer_id, "au_open_id" => $au_open_id, "transaction_id" => "", "transaction_status" => "40", "pay_info_no" => $pay_info_no, "pay_status" => 20, "continue_account_id" => $continue_account_id, "member_manage_no" => $member_manage_no, "process_day" => $process_day, "process_time" => "000000", "cont_bill_regst_day" => $cont_bill_regst_day, "cont_bill_regst_time" => "000000", "ammount" => $amount, "ammount_in_tax" => $amount_in_tax, "del_flg" => 0, "contents_id" => sprintf("%05d%09d", $service_id, $add_point), "status" => 0));
             }
         }
     }
 }
Пример #7
0
 /**
  *
  * @param string $src
  * @param string $des
  */
 public static function sfCopyDir($src, $des, $mess = '', $override = false)
 {
     $src_dir = new SplFileInfo($src);
     if ($src_dir->isDir() === false) {
         trigger_error('src is not dir', E_USER_WARNING);
         return;
     }
     $des_dir = new SplFileInfo($des);
     if ($des_dir->isDir() === false && $des_dir->isFile()) {
         trigger_error('des is not dir', E_USER_WARNING);
         return;
     }
     SC_Utils_Ex::recursiveMkdir($des_dir->getPathname());
     $src = $src_dir->getRealPath();
     $des = $des_dir->getRealPath();
     /**
      *
      * @var SplFileInfo[]
      */
     $iterator = new RecursiveDirectoryIterator($src);
     $files = new RecursiveIteratorIterator($iterator, RecursiveIteratorIterator::SELF_FIRST);
     foreach ($files as $filepath) {
         $finfo = new SplFileInfo($filepath);
         if ($finfo->isDir()) {
             continue;
         }
         $rel_file = substr($finfo->getRealPath(), strlen($src_dir->getRealPath()));
         $src_file = $finfo->getRealPath();
         $des_file = new SplFileInfo($des_dir->getRealPath() . $rel_file);
         $des_file = $des_file->getPathname();
         SC_Utils_Ex::recursiveMkdir(dirname($des_file));
         if ($override) {
             // nop
         } elseif (file_exists($des_file)) {
             trigger_error($des_file . ":ファイルが存在します", E_USER_NOTICE);
             $mess .= $des . $des_file . ":ファイルが存在します\n";
             continue;
         }
         if (@copy($src_file, $des_file)) {
             $mess .= $des_file . ":コピー成功\n";
             trigger_error($des_file . ":コピー成功", E_USER_NOTICE);
         } else {
             trigger_error($des_file . ":コピー失敗", E_USER_WARNING);
             $mess .= $des_file . ":コピー失敗\n";
         }
         GC_Utils_Ex::gfDebugLog(compact("src_file", "des_file"));
     }
     return $mess;
 }
 /**
  * ダウンロードを実行する.
  *
  * 指定のテンプレートをアーカイブし, ブラウザに出力する.
  * 失敗した場合は, エラーメッセージを出力し, false を返す.
  *
  * @param string $template_code テンプレートコード
  * @return boolean 成功した場合 true; 失敗した場合 false
  */
 function doDownload($template_code)
 {
     $from_dir = USER_TEMPLATE_REALDIR . $template_code . '/';
     $to_dir = SMARTY_TEMPLATES_REALDIR . $template_code . '/_packages/';
     if (SC_Utils_Ex::recursiveMkdir($to_dir) === false) {
         $this->arrErr['err'] = t('c_* Directory creation failed<br />_01');
         return false;
     }
     SC_Utils_Ex::sfCopyDir($from_dir, $to_dir);
     if (SC_Helper_FileManager_Ex::downloadArchiveFiles(SMARTY_TEMPLATES_REALDIR . $template_code, $template_code) === false) {
         $this->arrErr['err'] = t('c_* Archive file creation failed<br />_01');
         return false;
     }
     return true;
 }
 function copy_and_backup($s, $d, $backup = true)
 {
     if (!file_exists($s)) {
         trigger_error("{$s} が存在しません。", E_USER_WARNING);
         return;
     }
     $dest = dirname($d);
     if (!file_exists($dest)) {
         SC_Utils_Ex::recursiveMkdir($dest);
     }
     $b = $d . date(".Ymd");
     if ($backup && !file_exists($b) && file_exists($d)) {
         $this->copy_and_backup($d, $b, false);
     }
     $a = "バックアップ";
     if ($backup) {
         $a = "コピー";
     }
     if (copy($s, $d)) {
         GC_Utils_Ex::gfPrintLog($s . " の {$a} に成功", PLUGIN_LOG_REALFILE);
     } else {
         GC_Utils_Ex::gfPrintLog($s . " の {$a} に失敗", PLUGIN_LOG_REALFILE);
     }
 }
 /**
  * DBおよびファイルシステムにテンプレートパッケージを追加する.
  *
  * エラーが発生した場合は, エラーを出力し, false を返す.
  *
  * @param object $objFormParam SC_FormParamのインスタンス
  * @param object $objUpFile SC_UploadFileのインスタンス
  * @return boolean 成功した場合 true; 失敗した場合 false
  */
 function doUpload($objFormParam, $objUpFile)
 {
     $template_code = $objFormParam->getValue('template_code');
     $template_name = $objFormParam->getValue('template_name');
     $device_type_id = $objFormParam->getValue('device_type_id');
     $template_dir = SMARTY_TEMPLATES_REALDIR . $template_code;
     $compile_dir = DATA_REALDIR . 'Smarty/templates_c/' . $template_code;
     $objQuery =& SC_Query_Ex::getSingletonInstance();
     $objQuery->begin();
     $arrValues = array('template_code' => $template_code, 'device_type_id' => $device_type_id, 'template_name' => $template_name, 'create_date' => 'CURRENT_TIMESTAMP', 'update_date' => 'CURRENT_TIMESTAMP');
     $objQuery->insert('dtb_templates', $arrValues);
     $is_error = false;
     // フォルダ作成
     if (!file_exists($template_dir)) {
         if (!mkdir($template_dir)) {
             $this->arrErr['err'] = t('c_* The template folder could not be created.<br/>_01');
             $objQuery->rollback();
             return false;
         }
     }
     if (!file_exists($compile_dir)) {
         if (!mkdir($compile_dir)) {
             $this->arrErr['err'] = t('c_* Smarty compile folder could not be created.<br/>_01');
             $objQuery->rollback();
             return false;
         }
     }
     // 一時フォルダから保存ディレクトリへ移動
     $objUpFile->moveTempFile();
     // 解凍
     if (!SC_Helper_FileManager_Ex::unpackFile($template_dir . '/' . $_FILES['template_file']['name'])) {
         $this->arrErr['err'] = t('c_* Decompression of the template file failed.<br/>_01');
         $objQuery->rollback();
         return false;
     }
     // ユーザデータの下のファイルをコピーする
     $from_dir = SMARTY_TEMPLATES_REALDIR . $template_code . '/_packages/';
     $to_dir = USER_REALDIR . 'packages/' . $template_code . '/';
     if (!SC_Utils_Ex::recursiveMkdir($to_dir)) {
         $this->arrErr['err'] = t('c_* T_ARG1 creation failed.<br/>_01', array('T_ARG1' => $to_dir));
         $objQuery->rollback();
         return false;
     }
     SC_Utils_Ex::sfCopyDir($from_dir, $to_dir);
     $objQuery->commit();
     return true;
 }