Changeset 16420


Ignore:
Timestamp:
2007/10/14 22:55:13 (17 years ago)
Author:
adachi
Message:

オーナーズストア連携暫定コミット

Location:
branches/feature-module-update/data/class
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/feature-module-update/data/class/batch/SC_Batch_Update.php

    r16343 r16420  
    3737     */ 
    3838    function execute($target = ".") { 
     39        $arrLog = array(); 
    3940        $includeArray = explode(',', $this->includes); 
    4041        $excludeArray = explode(',', $this->excludes); 
     
    5556                // distinfo.php を読み込む 
    5657                if ($fileName == "distinfo.php") { 
    57                     include_once($fileName); 
     58                    include_once($path); 
    5859                } 
    5960 
    6061                // 除外ファイルをスキップ 
    6162                if (in_array($fileName, $excludeArray)) { 
    62                     echo "excludes by " . $path . "\n"; 
     63                    $arrLog[] = "excludes by " . $path . "\n"; 
    6364                    continue; 
    6465                } 
     
    6768                $sha1 = sha1_file($path); 
    6869 
    69                 echo $sha1 . " => " . $path . "\n"; 
     70                $arrLog[] = $sha1 . " => " . $path . "\n"; 
    7071 
    7172 
     
    8182                            $out = $distinfo[$sha1]; 
    8283                        } else { 
    83                             die("ハッシュ値が一致しないため, コピー先が取得できません."); 
     84                            $arrLog[] = "ハッシュ値が一致しないため, コピー先が取得できません."; 
     85                            die(); 
    8486                        } 
    8587 
    8688                        // ファイルを書き出しモードで開く 
    87                         $handle = fopen($out, "w"); 
     89                        $handle = @fopen($out, "w"); 
    8890                        if (!$handle) { 
    89                             echo "Cannot open file (". $out . ")"; 
    90                             continue; 
     91                            // ディレクトリ作成を行ってリトライ 
     92                            $this->mkdir_p($out); 
     93                            $handle = @fopen($out, "w"); 
     94                            if (!$handle) { 
     95                                $arrLog[] = "Cannot open file (". $out . ")\n"; 
     96                                continue; 
     97                            } 
    9198                        } 
    9299 
    93100                        // 取得した内容を書き込む 
    94101                        if (fwrite($handle, $contents) === false) { 
    95                             echo "Cannot write to file (" . $out . ")"; 
     102                            $arrLog[] = "Cannot write to file (" . $out . ")\n"; 
    96103                            continue; 
    97104                        } 
    98105 
    99                         echo "copyed " . $out . "\n"; 
     106                        $arrLog[] = "copyed " . $out . "\n"; 
    100107                        // ファイルを閉じる 
    101108                        fclose($handle); 
     
    104111            } 
    105112        } 
    106         echo "Finished Successful!\n"; 
     113        $arrLog[] = "Finished Successful!\n"; 
     114        return $arrLog; 
    107115    } 
    108116 
     
    123131        return $alldirs; 
    124132    } 
     133 
     134    /** 
     135     * mkdir -p 
     136     * 
     137     * @param string $path 絶対パス 
     138     */ 
     139    function mkdir_p($path){ 
     140        $path = dirname($path); 
     141        $path = str_replace ('\\', '/', $path); 
     142 
     143        $arrDirs = explode("/", $path); 
     144        $dir = ''; 
     145 
     146        foreach($arrDirs as $n){ 
     147            $dir .= $n . '/'; 
     148            if(!file_exists($dir)) { 
     149                if (!@mkdir($dir)) return; 
     150            } 
     151        } 
     152} 
    125153} 
    126154?> 
  • branches/feature-module-update/data/class/pages/upgrade/LC_Page_Upgrade_Base.php

    r16383 r16420  
    11<?php 
     2/* 
     3 * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved. 
     4 * 
     5 * http://www.lockon.co.jp/ 
     6 */ 
    27 
     8// {{{ requires 
     9require_once CLASS_PATH . 'pages/LC_Page.php'; 
     10 
     11/** 
     12 * オーナーズストア連携の基底クラス 
     13 * 
     14 * @package Page 
     15 * @author LOCKON CO.,LTD. 
     16 * @version $Id$ 
     17 */ 
     18class LC_Page_Upgrade_Base extends LC_Page { 
     19 
     20    // }}} 
     21    // {{{ functions 
     22 
     23    function LC_Page_Upgrade_Base() { 
     24        $this->objJson = new Services_Json(); 
     25    } 
     26    /** 
     27     * 配信サーバへリクエストを送信する. 
     28     * 
     29     * @param string $mode 
     30     * @param array $arrParams 追加パラメータ.連想配列で渡す. 
     31     * @return string|object レスポンスボディ|エラー時にはPEAR::Errorオブジェクトを返す. 
     32     */ 
     33    function request($mode, $arrParams = array()) { 
     34        $objReq = new HTTP_Request(); 
     35        $objReq->setUrl('http://cube-shopaccount/upgrade/index.php'); 
     36        $objReq->setMethod('POST'); 
     37        $objReq->addPostData('mode', $mode); 
     38        $objReq->addPostData('site_url', SITE_URL); 
     39        $objReq->addPostData('ssl_url', SSL_URL); 
     40        $objReq->addPostDataArray($arrParams); 
     41 
     42        $e = $objReq->sendRequest(); 
     43        if (PEAR::isError($e)) { 
     44            return $e; 
     45        } 
     46 
     47        if (($code = $objReq->getResponseCode()) !== 200) { 
     48            return PEAR::raiseError('HTTP RESPONSE CODE:' . $code); 
     49        } 
     50 
     51        return $objReq->getResponseBody(); 
     52    } 
     53 
     54    /** 
     55     * ユーザへ結果を通知する. 
     56     * 
     57     * @param integer $status ステータスコード 
     58     * @param string $message ステータスメッセージ 
     59     * @param array arrParam 追加パラメータ 
     60     * @return void 
     61     */ 
     62    function displayJson($status, $message, $arrParam = array()) { 
     63        $arrData = array( 
     64            'status'  => $status, 
     65            'body'    => $message 
     66        ); 
     67        echo $this->objJson->encode(array_merge($arrData, $arrParam)); 
     68    } 
     69 
     70    /** 
     71     * ログ出力を行う 
     72     * 
     73     * @param integer $message logメッセージ 
     74     * @param string $val debug用パラメータ 
     75     */ 
     76    function log($message, $val = null) { 
     77        $msg = sprintf("%s / debug: %s", $message, serialize($val)); 
     78        GC_Utils::gfPrintLog($msg, DATA_PATH . 'logs/ownersstore.log'); 
     79    } 
     80} 
    381?> 
  • branches/feature-module-update/data/class/pages/upgrade/LC_Page_Upgrade_ProductsList.php

    r16383 r16420  
    88// {{{ requires 
    99require_once CLASS_PATH . 'pages/LC_Page.php'; 
    10 require_once DATA_PATH  . 'module/Services/JSON.php'; 
    11 require_once DATA_PATH  . 'module/Request.php'; 
    1210 
    1311/** 
     
    3937    function process() { 
    4038        $objSess = new SC_Session(); 
    41         if ( $objSess->isSuccess() !== true) { 
     39        if ($objSess->isSuccess() !== true) { 
    4240            // TODO エラー処理 
    4341        } 
     
    7169        parent::destroy(); 
    7270    } 
    73  
    74  
    75     function createResponceHTML() {} 
    7671} 
    7772?> 
Note: See TracChangeset for help on using the changeset viewer.