Beispiel #1
0
/**
 * 指定したアクションにリダイレクトする
 *
 * 引数 $tail は文字列と配列の両方を許容する。
 * 文字列を指定した場合、URLに $tail がそのまま付加される。
 * 配列を指定した場合、キーと要素を元にパラメータを生成し、URLに付加する。
 *
 * @param string $p    リダイレクト先のページ
 * @param string $msg    エラーメッセージ
 * @param mixied $tail    URLに付加する文字列かパラメータ
 */
function admin_client_redirect($p, $msg = '', $tail = '')
{
    if (is_array($tail)) {
        $_tail_list = array();
        foreach ($tail as $key => $value) {
            $_tail_list[] = $key . '=' . urlencode($value);
        }
        $tail = '';
        $tail = implode('&', $_tail_list);
    }
    if (OPENPNE_ADMIN_URL) {
        $url = OPENPNE_ADMIN_URL;
    } else {
        $url = openpne_gen_url_head('admin', 'page_' . $p, true);
    }
    if (need_ssl_param('admin', 'page_' . $p)) {
        if ($tail) {
            $tail .= '&';
        }
        $tail .= 'ssl_param=1';
    }
    $hash_tbl =& AdminHashTable::singleton();
    $m = ADMIN_MODULE_NAME;
    $p = $hash_tbl->hash($p);
    $url .= "?m={$m}&a=page_{$p}";
    if ($tail) {
        $url .= "&{$tail}";
    }
    if ($msg) {
        $url .= '&msg=' . urlencode($msg);
    }
    client_redirect_absolute($url);
}
Beispiel #2
0
/**
 * URLを生成
 */
function openpne_gen_url($module, $action = '', $params = array(), $absolute = true, $force = false)
{
    switch ($force) {
        case 'ssl':
            $url = OPENPNE_SSL_URL;
            break;
        case 'nonssl':
            $url = OPENPNE_URL;
            break;
        default:
            $url = openpne_gen_url_head($module, $action, $absolute);
            break;
    }
    $p = array('m' => $module, 'a' => $action) + (array) $params;
    if (need_ssl_param($module, $action, $force)) {
        $p['ssl_param'] = 1;
    } else {
        unset($p['ssl_param']);
    }
    if ($p['m'] == 'admin') {
        $p['m'] = ADMIN_MODULE_NAME;
    }
    if ($q = http_build_query($p)) {
        $url .= '?' . $q;
    }
    return $url;
}
/**
 * @copyright 2005-2008 OpenPNE Project
 * @license   http://www.php.net/license/3_01.txt PHP License 3.01
 */
function smarty_block_t_form_block($params, $content, &$smarty, &$repeat)
{
    if ($repeat) {
        // 開始タグでは実行しない
        return null;
    }
    $method = 'post';
    if (isset($params['_method'])) {
        if ($params['_method'] == 'get') {
            $method = 'get';
        }
        unset($params['_method']);
    }
    $enctype = '';
    if (isset($params['_enctype'])) {
        if ($params['_enctype'] == 'file' || $params['_enctype'] == 'multipart') {
            $enctype = 'multipart/form-data';
            $params['MAX_FILE_SIZE'] = max(IMAGE_MAX_FILESIZE * 1024, FILE_MAX_FILESIZE * 1024);
        }
        unset($params['_enctype']);
    }
    $attr = '';
    if (isset($params['_attr'])) {
        $attr = $params['_attr'];
        unset($params['_attr']);
    }
    $form_action = openpne_gen_url_head($params['m'], $params['a'], false);
    if (isset($params['_form_action'])) {
        $form_action .= $params['_form_action'];
        unset($params['_form_action']);
    }
    if (need_ssl_param($params['m'], $params['a'])) {
        $params['ssl_param'] = 1;
    }
    if (@session_id() && strpos($params['a'], 'do') === 0) {
        $params['sessid'] = md5(session_id());
    }
    $html = sprintf('<form action="%s" method="%s"', $form_action, $method);
    if ($enctype) {
        $html .= sprintf(' enctype="%s"', $enctype);
    }
    if ($attr) {
        $html .= sprintf(' %s', $attr);
    }
    $html .= ">";
    foreach ($params as $key => $value) {
        $html .= "\n";
        $html .= sprintf('<input type="hidden" name="%s" value="%s" />', htmlspecialchars($key, ENT_QUOTES, 'UTF-8'), htmlspecialchars($value, ENT_QUOTES, 'UTF-8'));
    }
    $html .= "\n";
    $html .= $content;
    $html .= "</form>\n";
    return $html;
}
 function execute($requests)
 {
     $v = array();
     $v['DAILY_NEWS_DAY'] = explode(',', DAILY_NEWS_DAY);
     $this->set($v);
     //外部ログインフォーム用HTML内のアドレス生成
     //PC版ログインフォーム
     $login_url = openpne_gen_url_head('pc', 'do_o_login');
     $this->set('login_url', $login_url);
     //携帯版ログインフォーム
     $ktai_login_url = openpne_gen_url_head('ktai', 'do_o_login');
     $ktai_easy_login_url = openpne_gen_url_head('ktai', 'do_o_easy_login');
     $this->set('ktai_login_url', $ktai_login_url);
     $this->set('ktai_easy_login_url', $ktai_easy_login_url);
     return 'success';
 }
/**
 * @copyright 2005-2008 OpenPNE Project
 * @license   http://www.php.net/license/3_01.txt PHP License 3.01
 */
function smarty_function_t_form($params, &$smarty)
{
    $method = 'post';
    if (isset($params['_method'])) {
        if ($params['_method'] == 'get') {
            $method = 'get';
        }
        unset($params['_method']);
    }
    $enctype = '';
    if (isset($params['_enctype'])) {
        if ($params['_enctype'] == 'file' || $params['_enctype'] == 'multipart') {
            $enctype = 'multipart/form-data';
            $params['MAX_FILE_SIZE'] = max(IMAGE_MAX_FILESIZE * 1024, FILE_MAX_FILESIZE * 1024);
        }
        unset($params['_enctype']);
    }
    $attr = '';
    if (isset($params['_attr'])) {
        $attr = $params['_attr'];
        unset($params['_attr']);
    }
    $form_action = openpne_gen_url_head($params['m'], $params['a'], false);
    if (isset($params['_form_action'])) {
        $form_action .= $params['_form_action'];
        unset($params['_form_action']);
    }
    if (need_ssl_param($params['m'], $params['a'])) {
        $params['ssl_param'] = 1;
    }
    $html = sprintf('<form action="%s" method="%s"', $form_action, $method);
    if ($enctype) {
        $html .= sprintf(' enctype="%s"', $enctype);
    }
    if ($attr) {
        $html .= sprintf(' %s', $attr);
    }
    $html .= '>';
    foreach ($params as $key => $value) {
        $html .= "\n";
        $html .= sprintf('<input type="hidden" name="%s" value="%s" />', htmlspecialchars($key, ENT_QUOTES, 'UTF-8'), htmlspecialchars($value, ENT_QUOTES, 'UTF-8'));
    }
    return $html;
}
function smarty_modifier_t_url2a_ktai_callback($matches)
{
    $raw_url = $matches[0];
    $openpne_url = '';
    if (strpos($raw_url, OPENPNE_URL) === 0) {
        $openpne_url = OPENPNE_URL;
    } elseif (OPENPNE_USE_PARTIAL_SSL && strpos($raw_url, OPENPNE_SSL_URL) === 0) {
        $openpne_url = OPENPNE_SSL_URL;
    }
    if (!$openpne_url) {
        return $raw_url;
    }
    $url_pattern = sprintf('/^%s(?:index.php)?\\?m=pc&amp;a=(\\w+)((?:[a-zA-Z0-9_=]|&amp;)*)$/', preg_quote($openpne_url, '/'));
    $openpne_url_matches = array();
    if (!preg_match($url_pattern, $raw_url, $openpne_url_matches)) {
        return $raw_url;
    }
    $action = $openpne_url_matches[1];
    $param = $openpne_url_matches[2];
    //自動リンクのアクションリストにない場合は変換なし
    if (empty($GLOBALS['_OPENPNE_PC2KTAI_LINK_ACTION_LIST'][$action])) {
        return $raw_url;
    }
    $converted_action = $GLOBALS['_OPENPNE_PC2KTAI_LINK_ACTION_LIST'][$action];
    $param = str_replace('&amp;', '&', $param);
    // 携帯用URLに置換、ksid 追加
    $ktai_url = openpne_gen_url_head('ktai', $converted_action, false) . '?m=ktai&a=' . $converted_action . $param . '&' . $GLOBALS['KTAI_URL_TAIL'];
    // page_ より後ろを最大50文字に縮めて表示
    $urlstr = $converted_action . $param;
    $urlstr = preg_replace('/^page_/', '', $urlstr);
    $length = 50;
    $etc = '..';
    if (strlen($urlstr) > $length) {
        $length -= strlen($etc);
        $urlstr = substr($urlstr, 0, $length) . $etc;
    }
    $ktai_url = htmlspecialchars($ktai_url, ENT_QUOTES, 'UTF-8');
    $urlstr = htmlspecialchars($urlstr, ENT_QUOTES, 'UTF-8');
    return sprintf('<a href="%s">%s</a>', $ktai_url, $urlstr);
}