Ejemplo n.º 1
0
 /**
  * データphp形式のファイルをラインで読み込む
  * 文字列のアンエスケープも行う
  *
  * @static
  * @access  public
  * @return  array|false
  */
 function fileDataPhp($data_php)
 {
     if (!($cont = DataPhp::getDataPhpCont($data_php))) {
         // 読み込みエラーならfalse、空っぽなら空配列を返す
         if ($cont === false) {
             return false;
         } else {
             return array();
         }
     } else {
         // 行データに変換
         $lines = array();
         $lines = explode("\n", $cont);
         $count = count($lines);
         $i = 1;
         foreach ($lines as $l) {
             if ($i != $count) {
                 $newlines[] = $l . "\n";
                 // 最終行なら
             } else {
                 // 空っぽでなければ追加
                 if ($l !== "") {
                     $newlines[] = $l;
                 }
                 break;
             }
             $i++;
         }
         /*
         if ($lines) {
             // 末尾の空行は特別に削除する
             $count = count($lines);
             if (rtrim($lines[$count-1]) == "") {
                 array_pop($lines);
             }
         }
         */
         return $newlines;
     }
 }
Ejemplo n.º 2
0
 /**
  * データPHP形式(TAB)の書き込み履歴をdat形式(TAB)に変換する
  *
  * 最初は、dat形式(<>)だったのが、データPHP形式(TAB)になり、そしてまた v1.6.0 でdat形式(<>)に戻った
  */
 public static function transResHistLogPhpToDat()
 {
     global $_conf;
     // 書き込み履歴を記録しない設定の場合は何もしない
     if ($_conf['res_write_rec'] == 0) {
         return true;
     }
     // p2_res_hist.dat.php が読み込み可能であったら
     if (is_readable($_conf['res_hist_dat_php'])) {
         // 読み込んで
         if ($cont = DataPhp::getDataPhpCont($_conf['res_hist_dat_php'])) {
             // タブ区切りから<>区切りに変更する
             $cont = str_replace("\t", "<>", $cont);
             // p2_res_hist.dat があれば、名前を変えてバックアップ。(もう要らない)
             if (file_exists($_conf['res_hist_dat'])) {
                 $bak_file = $_conf['res_hist_dat'] . '.bak';
                 if (P2_OS_WINDOWS && file_exists($bak_file)) {
                     unlink($bak_file);
                 }
                 rename($_conf['res_hist_dat'], $bak_file);
             }
             // 保存
             FileCtl::make_datafile($_conf['res_hist_dat'], $_conf['res_write_perm']);
             FileCtl::file_write_contents($_conf['res_hist_dat'], $cont);
             // p2_res_hist.dat.php を名前を変えてバックアップ。(もう要らない)
             $bak_file = $_conf['res_hist_dat_php'] . '.bak';
             if (P2_OS_WINDOWS && file_exists($bak_file)) {
                 unlink($bak_file);
             }
             rename($_conf['res_hist_dat_php'], $bak_file);
         }
     }
     return true;
 }
Ejemplo n.º 3
0
Archivo: P2Util.php Proyecto: poppen/p2
 /**
  * データPHP形式(TAB)の書き込み履歴をdat形式(TAB)に変換する
  *
  * 最初は、dat形式(<>)だったのが、データPHP形式(TAB)になり、そしてまた v1.6.0 でdat形式(<>)に戻った
  *
  * @access  public
  */
 function transResHistLogPhpToDat()
 {
     global $_conf;
     // 書き込み履歴を記録しない設定の場合は何もしない
     if ($_conf['res_write_rec'] == 0) {
         return true;
     }
     if (is_readable($_conf['p2_res_hist_dat_php'])) {
         require_once P2_LIB_DIR . '/DataPhp.php';
         if ($cont = DataPhp::getDataPhpCont($_conf['p2_res_hist_dat_php'])) {
             // タブ区切りから<>区切りに変更する
             $cont = str_replace("\t", "<>", $cont);
             // p2_res_hist.dat があれば、名前を変えてバックアップ。(もう要らない)
             if (file_exists($_conf['p2_res_hist_dat'])) {
                 $bak_file = $_conf['p2_res_hist_dat'] . '.bak';
                 if (strstr(PHP_OS, 'WIN') and file_exists($bak_file)) {
                     unlink($bak_file);
                 }
                 rename($_conf['p2_res_hist_dat'], $bak_file);
             }
             // 保存
             FileCtl::make_datafile($_conf['p2_res_hist_dat'], $_conf['res_write_perm']);
             if (false === file_put_contents($_conf['p2_res_hist_dat'], $cont, LOCK_EX)) {
                 trigger_error("file_put_contents(" . $_conf['p2_res_hist_dat'] . ")", E_USER_WARNING);
             }
             // p2_res_hist.dat.php を名前を変えてバックアップ。(もう要らない)
             $bak_file = $_conf['p2_res_hist_dat_php'] . '.bak';
             if (strstr(PHP_OS, 'WIN') and file_exists($bak_file)) {
                 unlink($bak_file);
             }
             rename($_conf['p2_res_hist_dat_php'], $bak_file);
         }
     }
     return true;
 }
    $line = explode('<>', rtrim($lines[0]));
    $hd['FROM'] = htmlspecialchars($line[7], ENT_QUOTES);
    $hd['mail'] = htmlspecialchars($line[8], ENT_QUOTES);
} else {
    $hd['FROM'] = null;
    $hd['mail'] = null;
}
// 空白はユーザ設定値に変換
$hd['FROM'] = $hd['FROM'] == '' ? htmlspecialchars($_conf['my_FROM'], ENT_QUOTES) : $hd['FROM'];
$hd['mail'] = $hd['mail'] == '' ? htmlspecialchars($_conf['my_mail'], ENT_QUOTES) : $hd['mail'];
// P2NULLは空白に変換
$hd['FROM'] = $hd['FROM'] == 'P2NULL' ? '' : $hd['FROM'];
$hd['mail'] = $hd['mail'] == 'P2NULL' ? '' : $hd['mail'];
// 前回のPOST失敗があれば呼び出し
$failed_post_file = P2Util::getFailedPostFilePath($host, $bbs, $key);
if ($cont_srd = DataPhp::getDataPhpCont($failed_post_file)) {
    $last_posted = unserialize($cont_srd);
    // まとめてサニタイズ
    $last_posted = array_map(create_function('$n', 'return htmlspecialchars($n, ENT_QUOTES);'), $last_posted);
    //$addslashesS = create_function('$str', 'return str_replace("\'", "\\\'", $str);');
    //$last_posted = array_map($addslashesS, $last_posted);
    $hd['FROM'] = $last_posted['FROM'];
    $hd['mail'] = $last_posted['mail'];
    $MESSAGE_hs = $last_posted['MESSAGE'];
    $hd['subject'] = $last_posted['subject'];
} else {
    $MESSAGE_hs = '';
    $hd['subject'] = '';
}
// 表示指定
// 参考 クラシック COLS='60' ROWS='8'
Ejemplo n.º 5
0
/**
 * 2006-02-27 旧形式ファイルがあれば変換してコピー
 *
 * @return  void
 */
function _copyOldConfUserFileIfExists()
{
    global $_conf;
    $conf_user_file_old = $_conf['pref_dir'] . '/conf_user.inc.php';
    if (!file_exists($_conf['conf_user_file']) && file_exists($conf_user_file_old)) {
        $old_cont = DataPhp::getDataPhpCont($conf_user_file_old);
        FileCtl::make_datafile($_conf['conf_user_file'], $_conf['conf_user_perm']);
        file_put_contents($_conf['conf_user_file'], $old_cont);
    }
}