Beispiel #1
0
function vbseo_check_url($format_name, $vbseo_url_, $allow_part = false, $strict_check = false)
{
    global $vbseo_url_formats, $vbseo_url_suggest;
    $expr = $vbseo_url_formats[$format_name];
    if (!$expr) {
        $replace = vbseo_prep_format_replacements(VBSEO_FILTER_FOREIGNCHARS, VBSEO_SPACER, VBSEO_REWRITE_MEMBER_MORECHARS);
        $format = preg_quote(defined($format_name) ? constant($format_name) : '', '#');
        $format = preg_replace(array_keys($replace), $replace, $format);
        $expr = preg_replace('#%' . $validset . '+%#', '[^/]+', $format);
    }
    if ($expr[strlen($expr) - 1] == '/' && $vbseo_url_[strlen($vbseo_url_) - 1] != '/' && !file_exists($vbseo_url_)) {
        $folder_type = true;
        $expr .= '?';
    } else {
        $folder_type = false;
    }
    $expr = $allow_part ? '#' . $expr . '#' : '#^' . $expr . '$#';
    $u2check = $vbseo_url_;
    if (strstr($expr, 'http\\://') && !strstr($u2check, 'http:') && !strstr(VBSEO_REQURL_FULL, VBSEO_TOPREL_FULL)) {
        $u2check = VBSEO_HTTP_DOMAIN . '/' . $vbseo_url_;
    }
    if (preg_match($expr, $u2check, $matches)) {
        if ($folder_type) {
            $vbseo_url_suggest = $vbseo_url_ . '/';
            if ($strict_check) {
                return null;
            }
        }
        $format1 = defined($format_name) ? constant($format_name) : '';
        if (preg_match_all('#%([a-z_]+)%#', $format1, $matches2, PREG_PATTERN_ORDER)) {
            $fields = array_values(array_unique($matches2[1]));
        } else {
            $fields = array();
        }
        $fieldCount = count($fields);
        $results = array(1);
        for ($i = 0; $i < $fieldCount; $i++) {
            $results[$fields[$i]] = $matches[$i + 1];
        }
        return $results;
    }
    return null;
}
Beispiel #2
0
function vbseo_cp_put_options($setm, $noninc = array())
{
    global $vbseo_filename, $fcontent;
    $fcontent = @implode('', file($vbseo_filename));
    $def_values = array();
    for ($i = 0; $i < count($setm); $i++) {
        if (!in_array($setm[$i][1], $noninc)) {
            $sk = $setm[$i];
            switch ($sk[1]) {
                case 'images_dim':
                    $v = unserialize($sk[2]);
                    $va = '';
                    if ($v) {
                        foreach ($v as $k2 => $v2) {
                            $va .= "\n'{$k2}' => array({$v2['0']},{$v2['1']}),";
                        }
                        $va .= "\n";
                    }
                    $v = 'array(' . $va . ')';
                    $fcontent = preg_replace('#(\\$vbseo_images_dim\\s*=\\s*)array\\s*\\(\\s*.*?\\s*\\)(;)#s', "\$1" . $v . "\$2", $fcontent);
                    break;
                case 'relev_repl':
                    $v = unserialize($sk[2]);
                    $v = vbseo_check_arr_nonassoc($v);
                    $fcontent = preg_replace('#(\\$vbseo_relev_replace = array\\s*\\()\\s*.*?\\s*(\\);)#s', '$1' . $v . '$2', $fcontent);
                    break;
                case 'relev_repl_t':
                    $v = unserialize($sk[2]);
                    $v = vbseo_check_arr_nonassoc($v);
                    $fcontent = preg_replace('#(\\$vbseo_relev_replace_t = array\\s*\\()\\s*.*?\\s*(\\);)#s', '$1' . $v . '$2', $fcontent);
                    break;
                case 'char_repl':
                    $v = unserialize($sk[2]);
                    $v = vbseo_check_arr_assoc($v);
                    $fcontent = preg_replace('#(\\$vbseo_custom_char_replacement = array\\s*\\()\\s*.*?\\s*(\\);)#s', '$1' . $v . '$2', $fcontent);
                    break;
                case 'forum_slugs':
                    $v = unserialize($sk[2]);
                    $v = vbseo_check_arr_assoc($v);
                    $fcontent = preg_replace('#(\\$vbseo_forum_slugs = array\\s*\\()\\s*.*?\\s*(\\);)#s', '$1' . $v . '$2', $fcontent);
                    break;
                case 'acronyms':
                    $v = preg_replace('#[\\r\\n]+#', ",\n", trim($sk[2]));
                    $fcontent = preg_replace('#(\\$seo_replacements\\s*=\\s*array\\(\\s*).*?(\\s*\\);)#s', "\$1" . $v . "\$2", $fcontent);
                    break;
                case 'custom_rules':
                    $v = vbseocp_unhtmlentities(preg_replace('#[\\r\\n]+#', ",\n", trim($sk[2])));
                    $fcontent = preg_replace('#(\\$vbseo_custom_rules\\s*=\\s*array\\(\\s*).*?(\\s*\\);)#s', "\$1" . str_replace('$', '\\$', $v) . "\$2", $fcontent);
                    break;
                case 'custom_rules_text':
                    $v = vbseocp_unhtmlentities($sk[2]);
                    $fcontent = preg_replace('#(\\$vbseo_custom_rules_text = \').*?(\';)#s', '$1' . str_replace(array("'", '$'), array("\\'", '\\$'), $v) . '$2', $fcontent);
                    break;
                case 'custom_301':
                    $v = vbseocp_unhtmlentities(preg_replace('#[\\r\\n]+#', ",\n", trim($sk[2])));
                    $fcontent = preg_replace('#(\\$vbseo_custom_301\\s*=\\s*array\\(\\s*).*?(\\s*\\);)#s', "\$1" . str_replace('$', '\\$', $v) . "\$2", $fcontent);
                    break;
                case 'custom_301_text':
                    $v = vbseocp_unhtmlentities($sk[2]);
                    $fcontent = preg_replace('#(\\$vbseo_custom_301_text = \').*?(\';)#s', '$1' . str_replace(array("'", '$'), array("\\'", '\\$'), $v) . '$2', $fcontent);
                    break;
                default:
                    $sk[2] = stripslashes($sk[2]);
                    $def_values[$sk[1]] = $sk[2];
                    vbseocp_change_setting($sk[1], $sk[2], $sk[0][strlen($sk[0]) - 1] == "'" || !preg_match('#^\\d+$#', $sk[2]) ? 0 : 2);
                    break;
            }
        }
    }
    global $url_formats;
    $urlformats_arr = '';
    include_once dirname(__FILE__) . '/includes/functions_vbseo_url.php';
    $pre_replace = vbseo_prep_format_replacements(vbseocp_get_setting('VBSEO_FILTER_FOREIGNCHARS', 1), vbseocp_get_setting('VBSEO_SPACER', 0), vbseocp_get_setting('VBSEO_REWRITE_MEMBER_MORECHARS', 1));
    foreach ($url_formats as $uformat => $udefinition) {
        $ff = vbseocp_get_setting($udefinition, 0);
        $ff = preg_quote($ff, '#');
        $ff = preg_replace(array_keys($pre_replace), $pre_replace, $ff);
        $urlformats_arr[] = "'" . $udefinition . "' => '" . $ff . "'";
    }
    $urlformats_list = implode(",\n", $urlformats_arr);
    $fcontent = preg_replace('#(\\$vbseo_url_formats = array\\()\\s*.*?(\\);)#s', '$1' . $urlformats_list . '$2', $fcontent);
    if (file_exists($vbseo_filename) && $fcontent) {
        $pf = fopen($vbseo_filename, 'w');
        fwrite($pf, $fcontent);
        fclose($pf);
    }
}