/** * Constructor * * Initializes the Template engine, for each instance, accepts options or * reads from PEAR::getStaticProperty('HTML_Template_Flexy','options'); * * @access public * @param array $options (Optional) */ function HTML_Template_Flexy($options = array()) { $baseoptions = array(); if (class_exists('PEAR5', false)) { $baseoptions =& PEAR5::getStaticProperty('HTML_Template_Flexy', 'options'); } if (empty($baseoptions) && class_exists('PEAR')) { $baseoptions =& PEAR::getStaticProperty('HTML_Template_Flexy', 'options'); } if ($baseoptions) { foreach ($baseoptions as $key => $aOption) { $this->options[$key] = $aOption; } } foreach ($options as $key => $aOption) { $this->options[$key] = $aOption; } $filters = $this->options['filters']; if (is_string($filters)) { $this->options['filters'] = explode(',', $filters); } if (is_string($this->options['templateDir'])) { $this->options['templateDir'] = explode(PATH_SEPARATOR, $this->options['templateDir']); } }
/** * PEAR_Error constructor * * @param string $message message * * @param int $code (optional) error code * * @param int $mode (optional) error mode, one of: PEAR_ERROR_RETURN, * PEAR_ERROR_PRINT, PEAR_ERROR_DIE, PEAR_ERROR_TRIGGER, * PEAR_ERROR_CALLBACK or PEAR_ERROR_EXCEPTION * * @param mixed $options (optional) error level, _OR_ in the case of * PEAR_ERROR_CALLBACK, the callback function or object/method * tuple. * * @param string $userinfo (optional) additional user/debug info * * @access public * */ public function __construct($message = 'unknown error', $code = null, $mode = null, $options = null, $userinfo = null) { if ($mode === null) { $mode = PEAR_ERROR_RETURN; } $this->message = $message; $this->code = $code; $this->mode = $mode; $this->userinfo = $userinfo; if (PEAR_ZE2) { $skiptrace = PEAR5::getStaticProperty('PEAR_Error', 'skiptrace'); } else { $skiptrace = PEAR::getStaticProperty('PEAR_Error', 'skiptrace'); } if (!$skiptrace) { $this->backtrace = debug_backtrace(); if (isset($this->backtrace[0]) && isset($this->backtrace[0]['object'])) { unset($this->backtrace[0]['object']); } } if ($mode & PEAR_ERROR_CALLBACK) { $this->level = E_USER_NOTICE; $this->callback = $options; } else { if ($options === null) { $options = E_USER_NOTICE; } $this->level = $options; $this->callback = null; } if ($this->mode & PEAR_ERROR_PRINT) { if (is_null($options) || is_int($options)) { $format = "%s"; } else { $format = $options; } printf($format, $this->getMessage()); } if ($this->mode & PEAR_ERROR_TRIGGER) { trigger_error($this->getMessage(), $this->level); } if ($this->mode & PEAR_ERROR_DIE) { $msg = $this->getMessage(); if (is_null($options) || is_int($options)) { $format = "%s"; if (substr($msg, -1) != "\n") { $msg .= "\n"; } } else { $format = $options; } die(sprintf($format, $msg)); } if ($this->mode & PEAR_ERROR_CALLBACK) { if (is_callable($this->callback)) { call_user_func($this->callback, $this); } } if ($this->mode & PEAR_ERROR_EXCEPTION) { trigger_error("PEAR_ERROR_EXCEPTION is obsolete, use class PEAR_Exception for exceptions", E_USER_WARNING); eval('$e = new Exception($this->message, $this->code);throw($e);'); } }
function ic2_display($url, $params) { global $_conf, $ini, $thumb, $dpr, $redirect, $id, $uri, $file, $thumbnailer; if (strncmp($url, '/', 1) === 0) { $s = empty($_SERVER['HTTPS']) ? '' : 's'; $to = 'http' . $s . '://' . $_SERVER['HTTP_HOST'] . $url; } else { $dir = dirname(P2Util::getMyUrl()); if (strncasecmp($url, './', 2) == 0) { $to = $dir . substr($url, 1); } elseif (strncasecmp($url, '../', 3) == 0) { $to = dirname($dir) . substr($url, 2); } else { $to = $dir . '/' . $url; } } $name = basename($url); $ext = strrchr($name, '.'); switch ($redirect) { case 1: header("Location: {$to}"); exit; case 2: switch ($ext) { case '.jpg': header("Content-Type: image/jpeg; name=\"{$name}\""); break; case '.png': header("Content-Type: image/png; name=\"{$name}\""); break; case '.gif': header("Content-Type: image/gif; name=\"{$name}\""); break; default: if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false || strpos($_SERVER['HTTP_USER_AGENT'], 'Opera') !== false) { header("Content-Type: application/octetstream; name=\"{$name}\""); } else { header("Content-Type: application/octet-stream; name=\"{$name}\""); } } header("Content-Disposition: inline; filename=\"{$name}\""); header('Content-Length: ' . filesize($url)); readfile($url); exit; default: if (isset($uri)) { $img_o = 'uri'; $img_p = $uri; } elseif (isset($id)) { $img_o = 'id'; $img_p = $id; } else { $img_o = 'file'; $img_p = $file; } $img_q = $img_o . '=' . rawurlencode($img_p); // QuickFormの初期化 $_size = explode('x', $thumbnailer->calc($params['width'], $params['height'])); $_constants = array('o' => sprintf('原寸 (%dx%d)', $params['width'], $params['height']), 's' => '作成', 't' => $thumb, 'd' => $dpr, 'u' => $img_p, 'v' => $img_o, 'x' => $_size[0], 'y' => $_size[1]); $_defaults = array('q' => $ini["Thumb{$thumb}"]['quality'], 'r' => '0'); $mobile = Net_UserAgent_Mobile::singleton(); $qa = 'size=3 maxlength=3'; if ($mobile->isDoCoMo()) { $qa .= ' istyle=4'; } elseif ($mobile->isEZweb()) { $qa .= ' format=*N'; } elseif ($mobile->isSoftBank()) { $qa .= ' mode=numeric'; } $_presets = array('' => 'サイズ・品質'); foreach ($ini['Dynamic']['presets'] as $_preset_name => $_preset_params) { $_presets[$_preset_name] = $_preset_name; } $qf = new HTML_QuickForm('imgmaker', 'get', 'ic2_mkthumb.php'); $qf->setConstants($_constants); $qf->setDefaults($_defaults); $qf->addElement('hidden', 't'); $qf->addElement('hidden', 'u'); $qf->addElement('hidden', 'v'); $qf->addElement('text', 'x', '高さ', $qa); $qf->addElement('text', 'y', '横幅', $qa); $qf->addElement('text', 'q', '品質', $qa); $qf->addElement('select', 'p', 'プリセット', $_presets); $qf->addElement('select', 'r', '回転', array('0' => 'なし', '90' => '右に90°', '270' => '左に90°', '180' => '180°')); $qf->addElement('checkbox', 'w', 'トリム'); $qf->addElement('checkbox', 'z', 'DL'); $qf->addElement('submit', 's'); $qf->addElement('submit', 'o'); // FlexyとQurickForm_Rendererの初期化 $_flexy_options =& PEAR5::getStaticProperty('HTML_Template_Flexy', 'options'); $_flexy_options = array('locale' => 'ja', 'charset' => 'Shift_JIS', 'compileDir' => $_conf['compile_dir'] . DIRECTORY_SEPARATOR . 'ic2', 'templateDir' => P2EX_LIB_DIR . '/ImageCache2/templates', 'numberFormat' => ''); $flexy = new HTML_Template_Flexy(); $rdr = new HTML_QuickForm_Renderer_ObjectFlexy($flexy); $qf->accept($rdr); // 表示 $flexy->setData('p2vid', P2_VERSION_ID); $flexy->setData('title', 'IC2::Cached'); $flexy->setData('pc', !$_conf['ktai']); $flexy->setData('iphone', $_conf['iphone']); if (!$_conf['ktai']) { $flexy->setData('skin', $GLOBALS['skin_name']); //$flexy->setData('stylesheets', array('css')); //$flexy->setData('javascripts', array('js')); } else { $flexy->setData('k_color', array('c_bgcolor' => !empty($_conf['mobile.background_color']) ? $_conf['mobile.background_color'] : '#ffffff', 'c_text' => !empty($_conf['mobile.text_color']) ? $_conf['mobile.text_color'] : '#000000', 'c_link' => !empty($_conf['mobile.link_color']) ? $_conf['mobile.link_color'] : '#0000ff', 'c_vlink' => !empty($_conf['mobile.vlink_color']) ? $_conf['mobile.vlink_color'] : '#9900ff')); } $rank = isset($params['rank']) ? $params['rank'] : 0; if ($_conf['iphone']) { $img_dir = 'img/iphone/'; $img_ext = '.png'; } else { $img_dir = 'img/'; $img_ext = $_conf['ktai'] ? '.gif' : '.png'; } $stars = array(); $stars[-1] = $img_dir . ($rank == -1 ? 'sn1' : 'sn0') . $img_ext; //$stars[0] = $img_dir . (($rank == 0) ? 'sz1' : 'sz0') . $img_ext; $stars[0] = $img_dir . ($_conf['iphone'] ? 'sz0' : 'sz1') . $img_ext; for ($i = 1; $i <= 5; $i++) { $stars[$i] = $img_dir . ($rank >= $i ? 's1' : 's0') . $img_ext; } $k_at_a = str_replace('&', '&', $_conf['k_at_a']); $setrank_url = "ic2.php?{$img_q}&t={$thumb}&r=0{$k_at_a}"; $flexy->setData('stars', $stars); $flexy->setData('params', $params); if ($thumb == 2 && $rank >= 0) { if ($ini['General']['inline'] == 1) { $t = 2; $link = null; } else { $t = 1; $link = $url; } $r = $ini['General']['redirect'] == 1 ? 1 : 2; $preview = "{$_SERVER['SCRIPT_NAME']}?o=1&r={$r}&t={$t}&{$img_q}{$k_at_a}"; $flexy->setData('preview', $preview); $flexy->setData('link', $link); $flexy->setData('info', null); } else { $flexy->setData('preview', null); $flexy->setData('link', $url); $flexy->setData('info', null); } if (!$_conf['ktai'] || $_conf['iphone']) { $flexy->setData('backto', null); } elseif (isset($_REQUEST['from'])) { $flexy->setData('backto', $_REQUEST['from']); $setrank_url .= '&from=' . rawurlencode($_REQUEST['from']); } elseif (isset($_SERVER['HTTP_REFERER'])) { $flexy->setData('backto', $_SERVER['HTTP_REFERER']); } else { $flexy->setData('backto', null); } $flexy->setData('stars', $stars); $flexy->setData('sertank', $setrank_url . '&rank='); if ($_conf['iphone']) { $_conf['extra_headers_ht'] .= <<<EOP <link rel="stylesheet" type="text/css" href="css/ic2_iphone.css?{$_conf['p2_version_id']}"> EOP; $_conf['extra_headers_xht'] .= <<<EOP <link rel="stylesheet" type="text/css" href="css/ic2_iphone.css?{$_conf['p2_version_id']}" /> EOP; } $flexy->setData('edit', extension_loaded('gd') && $rank >= 0); $flexy->setData('form', $rdr->toObject()); $flexy->setData('doctype', $_conf['doctype']); $flexy->setData('extra_headers', $_conf['extra_headers_ht']); $flexy->setData('extra_headers_x', $_conf['extra_headers_xht']); $flexy->compile('preview.tpl.html'); P2Util::header_nocache(); $flexy->output(); } exit; }
/** * プリペアドクエリを実行する. * * @access private * @param \MDB2_Statement_Common プリペアドステートメントインスタンス * @param array $arrVal プレースホルダに挿入する配列 * @return \MDB2_Result 結果セットのインスタンス */ public function execute(&$sth, $arrVal = array()) { // #1658 (Query の各種メソッドでプレースホルダの数に誤りがあるとメモリリークが発生する) 対応 // TODO 現状は \PEAR 内のバックトレースを抑制することで、メモリーリークの影響を小さくしている。 // 根本的には、そのバックトレースが、どこに居座っているかを特定して、対策すべき。 $pear_property =& \PEAR5::getStaticProperty('\\PEAR_Error', 'skiptrace'); $bak = $pear_property; $pear_property = true; $arrStartInfo =& $this->lfStartDbTraceLog($sth, $arrVal); $affected =& $sth->execute((array) $arrVal); $this->lfEndDbTraceLog($arrStartInfo, $sth, $arrVal); $pear_property = $bak; if (\PEAR::isError($affected)) { $sql = isset($sth->query) ? $sth->query : ''; $msg = $this->traceError($affected, $sql, $arrVal); $this->error($msg); } $this->conn->last_query = stripslashes($sth->query); return $affected; }
/** * constructor * * Just set options (no checking done) * * * @param array see options array in file. * @return none * @access public */ function HTML_Template_Flexy_Translator($options = array()) { foreach ($options as $k => $v) { $this->options[$k] = $v; } if (!in_array($this->options['baseLang'], $this->options['targetLangs'])) { $this->options['targetLangs'][] = $this->options['baseLang']; } if (class_exists('PEAR5', false)) { $o = PEAR5::getStaticProperty('HTML_Template_Flexy', 'options'); } if (empty($o)) { $o = PEAR::getStaticProperty('HTML_Template_Flexy', 'options'); } if (!strlen($this->options['templateDir'])) { $this->options['templateDir'] = $o['templateDir']; } if (!strlen($this->options['compileDir'])) { $this->options['compileDir'] = $o['compileDir']; } if (!strlen($this->options['url_rewrite'])) { $this->options['url_rewrite'] = $o['url_rewrite']; } if (empty($this->options['Translation2'])) { $this->options['Translation2'] = $o['Translation2']; } $this->appURL = $this->options['appURL']; $this->languages = $this->options['targetLangs']; }
// ライブラリ読み込み require_once P2EX_LIB_DIR . '/ImageCache2/bootstrap.php'; // 設定読み込み $ini = ic2_loadconfig(); if ($ini['Viewer']['cache'] && file_exists($_conf['iv2_cache_db_path'])) { $viewer_cache_exists = true; } else { $viewer_cache_exists = false; } // データベースに接続 $db = DB::connect($ini['General']['dsn']); if (DB::isError($db)) { p2die($db->getMessage()); } // テンプレートエンジン初期化 $_flexy_options =& PEAR5::getStaticProperty('HTML_Template_Flexy', 'options'); $_flexy_options = array('locale' => 'ja', 'charset' => 'Shift_JIS', 'compileDir' => $_conf['compile_dir'] . DIRECTORY_SEPARATOR . 'ic2', 'templateDir' => P2EX_LIB_DIR . '/ImageCache2/templates', 'numberFormat' => ''); $flexy = new HTML_Template_Flexy(); // }}} // {{{ データベース操作・ファイル削除 if (isset($_POST['action'])) { switch ($_POST['action']) { // 画像を削除する case 'dropZero': case 'dropAborn': if ($_POST['action'] == 'dropZero') { // ランク=0 の画像を削除する $where = $db->quoteIdentifier('rank') . ' = 0'; if (isset($_POST['dropZeroLimit'])) { // 取得した期間を限定 switch ($_POST['dropZeroSelectTime']) {
/** * constructor * * Just set options (no checking done) * * * @param array see options array in file. * @return none * @access public */ public function __construct(array $options = array()) { foreach ($options as $k => $v) { $this->options[$k] = $v; } if (!in_array($this->options['baseLang'], $this->options['targetLangs'])) { $this->options['targetLangs'][] = $this->options['baseLang']; } $o = PEAR5::getStaticProperty('HTML_Template_Flexy', 'options'); if (!is_array($o)) { $o = array(); } if (!strlen($this->options['templateDir'])) { $this->options['templateDir'] = $o['templateDir']; } if (!strlen($this->options['compileDir'])) { $this->options['compileDir'] = $o['compileDir']; } if (!strlen($this->options['url_rewrite'])) { $this->options['url_rewrite'] = $o['url_rewrite']; } if (empty($this->options['Translation2'])) { $this->options['Translation2'] = $o['Translation2']; } $this->appURL = $this->options['appURL']; $this->languages = $this->options['targetLangs']; }
/** * Constructor * * Initializes the Template engine, for each instance, accepts options or * reads from PEAR5::getStaticProperty('HTML_Template_Flexy', 'options'); * * @access public * @param array $options (Optional) */ public function __construct(array $options = array()) { $baseoptions = PEAR5::getStaticProperty('HTML_Template_Flexy', 'options'); if (!is_array($baseoptions)) { $baseoptions = array(); } $this->options = array_merge($this->options, $baseoptions, $options); $filters = $this->options['filters']; if (is_string($filters)) { $this->options['filters'] = explode(',', $filters); } $templateDir = $this->options['templateDir']; if (is_string($templateDir)) { $this->options['templateDir'] = explode(PATH_SEPARATOR, $templateDir); } }
/** * output a template (optionally with flexy object & element.) * * @param string name of flexy template. * @param object object as per HTML_Template_Flexy:outputObject * @param array elements array as per HTML_Template_Flexy:outputObject * * @return none * @access public */ function display($templatename, $object = null, $elements = array()) { // some standard stuff available to a smarty template.. $this->vars['SCRIPT_NAME'] = $_SERVER['SCRIPT_NAME']; if (class_exists('PEAR5', false)) { $o = PEAR5::getStaticProperty('HTML_Template_Flexy', 'options'); } if (empty($o)) { $o = PEAR::getStaticProperty('HTML_Template_Flexy', 'options'); } require_once 'HTML/Template/Flexy.php'; $t = new HTML_Template_Flexy(); $t->compile($templatename); $object = $object !== null ? $object : new StdClass(); foreach ($this->vars as $k => $v) { $object->{$k} = $v; } $t->outputObject($object, $elements); }
/** * Get character set * * @param void * * @return string */ protected function getCharset() { if (isset($GLOBALS['_HTML_TEMPLATE_FLEXY']['currentOptions'])) { $options = $GLOBALS['_HTML_TEMPLATE_FLEXY']['currentOptions']; if (is_array($options) && isset($options['charset'])) { return $options['charset']; } } $options = PEAR5::getStaticProperty('HTML_Template_Flexy', 'options'); if (is_array($options) && isset($options['charset'])) { return $options['charset']; } return 'UTF-8'; }
function _PEAR_call_destructors() { global $_PEAR_destructor_object_list; if (is_array($_PEAR_destructor_object_list) && sizeof($_PEAR_destructor_object_list)) { reset($_PEAR_destructor_object_list); $destructLifoExists = PEAR5::getStaticProperty('PEAR', 'destructlifo'); if ($destructLifoExists) { $_PEAR_destructor_object_list = array_reverse($_PEAR_destructor_object_list); } while (list($k, $objref) = each($_PEAR_destructor_object_list)) { $classname = get_class($objref); while ($classname) { $destructor = "_{$classname}"; if (method_exists($objref, $destructor)) { $objref->{$destructor}(); break; } else { $classname = get_parent_class($classname); } } } // Empty the object list to ensure that destructors are // not called more than once. $_PEAR_destructor_object_list = array(); } // Now call the shutdown functions if (isset($GLOBALS['_PEAR_shutdown_funcs']) && is_array($GLOBALS['_PEAR_shutdown_funcs']) && !empty($GLOBALS['_PEAR_shutdown_funcs'])) { foreach ($GLOBALS['_PEAR_shutdown_funcs'] as $value) { call_user_func_array($value[0], $value[1]); } } }