[PHP-users 31004] Re: Fatal error: Cannot redeclare

Kumapoo kumapoo @ zf7.so-net.ne.jp
2006年 12月 12日 (火) 19:56:55 JST


kumapooです。

デバッグの案が出ているのですが、ソースいじれる実力もなく。。。

とりあえず、できるとこやってみます。

> この class.inc の中で config.inc を require してませんか.
$ cat -n class.inc | grep config.inc
→class.incでは呼んでいないみたいです。

> あるいは本当に別のファイルを読んでいて,
> 中身で configuration_data() を定義しているとか.
全ソースに対して、grepしてみました。
$ grep -R configuration_data ../agency/*
../agency/lib/config.inc:function configuration_data() {
../agency/lib/fork.php:  $agency = new AGENCY(configuration_data(),$page,"FORK");
../agency/lib/lib.php:    $agency = new AGENCY(configuration_data(),$_GET["page"],$mode);

ちょっと長いですが、class.inc出してみます。(すいません)

$ cat -n ../agency/lib/class.inc
     1  <?php
     2  /* *** Class AGENCY *** */
     3  class AGENCY {
     4    function AGENCY($_conf, $_page = "list", $_mode = "DEFAULT") {
     5      $this->mode    = $_mode;
     6      $this->cmndata = $this->set_data(CMN_CSV);
     7      $this->agcdata = $this->set_data(AGC_CSV);
     8      $this->flag    = (count($this->agcdata["id"]) == 4) ? 1 : 0;
     9      $this->page    = (!preg_match("/^list|car|bike|medical$/",$_page)) ? "list" : $_page;
    10      $this->num     = (
    11        ($this->page == "car")     ? 1 : (
    12        ($this->page == "bike")    ? 2 : (
    13        ($this->page == "medical") ? 3 : 0
    14      )));
    15      switch($this->mode) {
    16        case "DEFAULT" :
    17          $this->template = (
    18            $this->set_template($_conf["header"]).
    19            $this->set_template($_conf["main"]).
    20            $this->set_template($_conf["sub"]).
    21            $this->set_template($_conf["footer"])
    22          );
    23          break;
    24        case "FORK" :
    25          $this->template = $this->set_template($_conf["fork"]);
    26          break;
    27        case "REDIRECT" :
    28          $this->template = $this->set_template($_conf["redirect"]);
    29          break;
    30      }
    31    }
    32  /* Convert Ampersand */
    33    function convert_amp($str) {
    34      return preg_replace("/&/","&amp;",$str);
    35    }
    36  /* Get CSV Data */
    37    function set_data($csv) {
    38      $tmp = array();
    39      $fp = fopen($csv,"r");
    40      while($data = fgetcsv($fp,1000)) {
    41        $tmp[$data[0]] = array();
    42        for($i = 2; $i < count($data); $i++) {
    43          $tmp[$data[0]][$i - 2] = ($data[$i] == "{{COPY}}") ? $data[1] : $data[$i];
    44        }
    45      }
    46      fclose($fp);
    47      return $tmp;
    48    }
    49  /* Get Area Template */
    50    function set_template($_file) {
    51      $agc  = $this->agcdata; extract($agc);
    52      $cmn  = $this->cmndata; extract($cmn);
    53      $page = $this->page;
    54      $num  = $this->num;
    55      $flag = $this->flag;
    56      $_file = preg_replace("/{{PAGE}}/",$this->page,$_file);
    57      if(!file_exists(TMP_DIR."/".$_file)) return "";
    58      ob_start();
    59      include TMP_DIR."/".$_file;
    60      $tmp = ob_get_contents();
    61      ob_end_clean();
    62      return $tmp;
    63    }
    64  /* Get PageID */
    65    function pageid($_type,$_no) {
    66      $cmn = $this->cmndata; extract($cmn);
    67      $num = $this->num;
    68      return ${$_type."id"}[$num].$_no;
    69    }
    70  /* Get Campaign */
    71    function campaign() {
    72      $agc = $this->agcdata; extract($agc);
    73      $cmn = $this->cmndata; extract($cmn);
    74      $num = $this->num;
    75      $tmp = "";
    76      $cam = (
    77        ($camid[$num] == "")           ? $defcamid[$num] : (
    78        ($camid[$num] != "{{DELETE}}") ? $camid[$num]    : ""
    79      ));
    80      if(!$cam) { return ""; }
    81      $day = ($camday[$num] != "") ? $camday[$num] : $defcamday[$num];
    82      if(file_exists(INC_DIR."/campaign/".$cam.".inc")) {
    83        ob_start();
    84        include INC_DIR."/campaign/".$cam.".inc";
    85        $tmp .= ob_get_contents();
    86        ob_end_clean();
    87      }
    88      return $tmp;
    89    }
    90  /* Get Block */
    91    function block() {
    92      $agc  = $this->agcdata; extract($agc);
    93      $cmn  = $this->cmndata; extract($cmn);
    94      $page = $this->page;
    95      $num  = $this->num;
    96      $flag = $this->flag;
    97      $bnm = (
    98        (!is_numeric($block[$num]))    ? $defblock[$num] : (
    99        ($block[$num] != "{{DELETE}}") ? $block[$num]    : ""
   100      ));
   101      if(!$bnm) { return ""; }
   102      $bnm = ((int) $bnm < 10) ? "0".$bnm : $bnm;
   103      $inc = INC_DIR."/block/".$page."_".$bnm.".inc";
   104      if(file_exists($inc)) {
   105        ob_start();
   106        include $inc;
   107        $tmp = ob_get_contents();
   108        ob_end_clean();
   109      }
   110      return $tmp;
   111    }
   112  /* Get Caution */
   113    function caution() {
   114      $agc = $this->agcdata; extract($agc);
   115      $cmn = $this->cmndata; extract($cmn);
   116      $num = $this->num;
   117      $tmp = "";
   118      $sbj = (
   119        ($cautionsbj[$num] == "")           ? $defcautionsbj[$num] : (
   120        ($cautionsbj[$num] != "{{DELETE}}") ? $cautionsbj[$num]    : ""
   121      ));
   122      if(!$sbj) { return ""; }
   123      $bdy = ($cautionbdy[$num] != "") ? $cautionbdy[$num] : $defcautionbdy[$num];
   124      ob_start();
   125      include INC_DIR."/caution_01.inc";
   126      $tmp .= ob_get_contents();
   127      ob_end_clean();
   128      return $tmp;
   129    }
   130  /* Get Sub Banner */
   131    function banner() {
   132      $agc  = $this->agcdata; extract($agc);
   133      $cmn  = $this->cmndata; extract($cmn);
   134      $page = $this->page;
   135      $num  = $this->num;
   136      $flag = $this->flag;
   137      $tmp = "";
   138      $arr = explode("|",(
   139        ($banner[$num] == "")           ? $defbanner[$num] : (
   140        ($banner[$num] != "{{DELETE}}") ? $banner[$num]    : ""
   141      )));
   142      if(!$arr) { return ""; }
   143      for($i = 0; $i < count($arr); $i++) {
   144        if(file_exists(INC_DIR."/banner/".$arr[$i].".inc")) {
   145          ob_start();
   146          include INC_DIR."/banner/".$arr[$i].".inc";
   147          $tmp .= ob_get_contents();
   148          ob_end_clean();
   149        }
   150      }
   151      return $tmp;
   152    }
   153  /* Get Logo Image */
   154    function logo($_file,$_agency) {
   155      if(file_exists(AGC_DIR."/img/".$_file)) {
   156        $size = getimagesize(AGC_DIR."/img/".$_file);
   157        return '<img src="./img/'.$_file.'" '.$size[3].' alt="'.$_agency.'" />';
   158      } else {
   159        return "<br />";
   160      }
   161    }
   162  /* Get Location */
   163    function loc($_id) {
   164      $ua  = $_SERVER["HTTP_USER_AGENT"];
   165      $uri = "";
   166      if(preg_match("/DoCoMo|UP\.Browser|PDXGW/",$ua)) {
   167        $uri = "https://www.nttif.com/iasp/carstage/cr_insurance/mcmd/IASMD00_00Entrance.jsp?aspGroupId=00000010&campaignno=".$_id;
   168      } elseif(preg_match("/Mozilla|iCab/",$ua)) {
   169        $uri = "./".$this->page.".shtml";
   170      }
   171      if($uri != "") { header("Location: ".$uri); }
   172    }
   173  /* Output HTML */
   174    function output() { return $this->template; }
   175  }
   176  /* *** /Class AGENCY *** */
   177  ?>







PHP-users メーリングリストの案内