Example #1
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;
}
Example #2
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);
}
/**
 * @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;
}
/**
 * @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;
}