Özel Arama

 
Etiketler: RewriteExtensionTürkçeKarakterYaması
Author Message

G.YILDIZ 

486 posts
http://www.gokhan-yildiz.com
Location: Turkey Ünye
Occupation: Web Tasarımcısı
Age: 30
#503   25-05-2008 16:38 GMT      
Rewrite Extension eklentisi kullananların çoğunda türkçe karakterler % ve F B gibi büyük harfler olduğu gibi çıkmaktadır.Aşağıda vermiş olduğum kodları system/rewrite.php dosyasındakilerle değiştirirseniz bu sorun ortadan kalkacaktır ve düzenli bir seonuz olacaktır.
Örnek olarak bu siteye bakabilirsiniz.

Kod:
<?php
/* ====================
Copyright (c) 2007, Vladimir Sibirov.
All rights reserved. Distributed under BSD License.
[BEGIN_SED]
File=system/rewrite.php
Version=121
Updated=2008-jan-11
Type=Core
Author=Trustmaster
Description=Rewrite extension functions
[END_SED]
==================== */

if ( !defined('SED_CODE') ) { die('Wrong URL.'); }

// Getting the server-relative path
$site_uri = dirname($_SERVER['SCRIPT_NAME']);
$site_uri = str_replace('\\', '/', $site_uri);
if($site_uri[strlen($site_uri) - 1] != '/') $site_uri .= '/';

// Absolute site url
$abs_url = ($site_uri[0] == '/') ? 'http://'.$_SERVER['HTTP_HOST'].$site_uri : 'http://'.$_SERVER['HTTP_HOST'].'/'.$site_uri;

// Write a custom translit function if iconv() doesn't work for you
function rewrite_translit_win1251($text)
{
$transtable = array(
'A' => 'a',
'B' => 'b',
'C' => 'c',
'Ç' => 'c',
'ç' => 'c',
'D' => 'd',
'E' => 'e',
'F' => 'f',
'G' => 'g',
'Ğ' => 'g',
'ğ' => 'g',
'H' => 'h',
'I' => 'i',
'ı' => 'i',
'İ' => 'i',
'J' => 'j',
'K' => 'k',
'L' => 'l',
'M' => 'm',
'N' => 'n',
'O' => 'o',
'Ö' => 'o',
'ö' => 'o',
'P' => 'p',
'R' => 'r',
'S' => 's',
'Ş' => 's',
'ş' => 's',
'T' => 't',
'U' => 'u',
'Ü' => 'u',
'ü' => 'u',
'V' => 'v',
'Y' => 'y',
'Z' => 'z',
'W' => 'w',
'X' => 'x',
',' => '-',
'-' => '-',
'ÿ' => 'ya');
$text = strtr($text, $transtable);
return $text;
}

// Charset converter
function rewrite_conv($str, $src_enc, $dest_enc)
{
if($src_enc == $dest_enc) return $str;
if(function_exists('mb_convert_encoding'))
return mb_convert_encoding($str, $dest_enc, $src_enc);
elseif(function_exists('iconv'))
return iconv($src_enc, $dest_enc, $str);
else
return $str;
}

// Title conveter for EXTRA_SEO
function rewrite_prep($title)
{
global $cfg;
// Strip all special characters from the URL
$title = preg_replace('#[\x00-\x1f\x21-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]#', '', $title);
$title = str_replace(' ', '-', $title);
if($cfg['plugin']['rewrite']['translit'])
{
// Replace iconv() with your function if it doesn't work:
//$title = iconv($cfg['plugin']['rewrite']['output_encoding'], 'ASCII//TRANSLIT', $title);
$title = rewrite_translit_win1251($title);
}
else
$title = rewrite_conv($title, $cfg['plugin']['rewrite']['output_encoding'], 'UTF-8');
return urlencode($title);
}

// Special character encoder/decoder
function rewrite_enc($str)
{
global $cfg, $repl;
$str = str_replace($cfg['plugin']['rewrite']['sep'], '._.', $str);
return $str;
}

function rewrite_dec($str)
{
global $cfg, $repl;
$str = str_replace('._.', $cfg['plugin']['rewrite']['sep'], $str);
return $str;
}

// Main output processor
function rewrite_output($output)
{
// Global import
global $db_forum_topics, $db_forum_sections, $db_forum_posts, $db_pages, $db_users, $site_uri, $abs_url, $cfg;
if(!$cfg['plugin']['rewrite']['engine_on']) return $output;

// Override search pattern
$convert = '#(href|src|action|url|value)=(\'|")?('.$abs_url.')?('.$cfg['plugin']['rewrite']['scripts'].')\.php(((?:\?|\&|\&\;)[\w_]+=.*?)*)(\#[\w\-_]*)?(\'|")#';

// Changing all the host urls
if(preg_match_all($convert, $output, $matches, PREG_SET_ORDER))
{
for($i = 0; $i < count($matches); $i++)
{
$script = $matches[$i][4];
// Parsing the arguments
parse_str(str_replace('&amp;', '&', substr($matches[$i][5], 1, strlen($matches[$i][5]) - 1)), $params);
$cnt = count($params);
// Generating the URL
$replacement = $matches[$i][1].'='.$matches[$i][2].$site_uri;
// Custom shortcuts
$not_append = false;
if($cfg['plugin']['rewrite']['shortcuts'])
{
if($script == 'list' && isset($params['c']))
{
$replacement .= 'c'.$cfg['plugin']['rewrite']['psep'].$params['c'];
unset($params['c']);
}
elseif($script == 'page' && (isset($params['id']) || isset($params['al'])))
{
if($cfg['plugin']['rewrite']['extra_seo'] && isset($params['id']))
{
$page_id = (int) $params['id'];
$page = sed_sql_fetchassoc(sed_sql_query("SELECT page_title FROM $db_pages WHERE page_id=$page_id"));
$replacement .= 'i'.$cfg['plugin']['rewrite']['psep'].$page_id.$cfg['plugin']['rewrite']['psep'].rewrite_prep($page['page_title']);
unset($params['id']);
}
elseif(isset($params['id']))
{
$replacement .= 'i'.$cfg['plugin']['rewrite']['psep'].$params['id'];
unset($params['id']);
}
elseif(isset($params['al']))
{
$replacement .= 'a'.$cfg['plugin']['rewrite']['psep'].$params['al'];
unset($params['al']);
}
else $replacement .= $script;
}
elseif($script == 'plug')
{
if(isset($params['e']))
{
if($params['e'] == 'weblogs' && !isset($params['m']) && isset($params['id']) && $cfg['plugin']['rewrite']['users'])
{
// Weblogs
$id = (int) $params['id'];
// Web-login hack
/*$tmp_urr = sed_sql_fetchassoc(sed_sql_query("SELECT user_name, user_irc FROM $db_users WHERE user_id = $id"));
if(empty($tmp_urr['user_irc']))
{
$tmp_uname = urlencode($tmp_urr['user_name']);
if($tmp_uname == $tmp_urr['user_name'] && count($params) == 2)
$not_append = true;
else
$not_append = false;
}
else
{
$tmp_uname = urlencode($tmp_urr['user_irc']);
$not_append = (count($params) == 2);
}*/
$tmp_urr = sed_sql_fetchassoc(sed_sql_query("SELECT user_name FROM $db_users WHERE user_id = $id"));
$tmp_uname = urlencode($tmp_urr['user_name']);
$replacement .= 'blog'.$cfg['plugin']['rewrite']['sep'].$tmp_uname;
unset($params['id']);
}
else $replacement .= 'p'.$cfg['plugin']['rewrite']['psep'].$params['e'];
unset($params['e']);
}
elseif(isset($params['o']))
{
$replacement .= 'o'.$cfg['plugin']['rewrite']['psep'].$params['o'];
unset($params['o']);
}
else $replacement .= $script;
}
elseif($script == 'forums')
{
if(isset($params['m']) && $params['m'] == 'topics')
{
if($cfg['plugin']['rewrite']['extra_seo'] && isset($params['s']))
{
$s = (int) $params['s'];
$sect = sed_sql_fetchassoc(sed_sql_query("SELECT fs_title FROM $db_forum_sections WHERE fs_id=$s"));
$replacement .= 's'.$cfg['plugin']['rewrite']['psep'].$s.$cfg['plugin']['rewrite']['psep'].rewrite_prep($sect['fs_title']);
unset($params['s']);
unset($params['m']);
}
elseif(isset($params['s']))
{
$replacement .= 's'.$cfg['plugin']['rewrite']['psep'].$params['s'];
unset($params['s']);
unset($params['m']);
}
else $replacement .= $script;
}
elseif(isset($params['m']) && $params['m'] == 'posts')
{
if($cfg['plugin']['rewrite']['extra_seo'] && isset($params['q']))
{
$q = (int) $params['q'];
$topic = sed_sql_fetchassoc(sed_sql_query("SELECT ft_title FROM $db_forum_topics WHERE ft_id=$q"));
$replacement .= 'q'.$cfg['plugin']['rewrite']['psep'].$q.$cfg['plugin']['rewrite']['psep'].rewrite_prep($topic['ft_title']);
unset($params['q']);
unset($params['m']);
}
elseif(isset($params['q']))
{
$replacement .= 'q'.$cfg['plugin']['rewrite']['psep'].$params['q'];
unset($params['q']);
unset($params['m']);
}
elseif($cfg['plugin']['rewrite']['extra_seo'] && isset($params['p']))
{
$p = (int) $params['p'];
$pst = sed_sql_fetchassoc(sed_sql_query("SELECT fp_topicid FROM $db_forum_posts WHERE fp_id=$p"));
$topic = sed_sql_fetchassoc(sed_sql_query('SELECT ft_title FROM '.$db_forum_topics.' WHERE ft_id='.$pst['fp_topicid']));
$replacement .= 't'.$cfg['plugin']['rewrite']['psep'].$p.$cfg['plugin']['rewrite']['psep'].rewrite_prep($topic['ft_title']);
unset($params['p']);
unset($params['m']);
}
elseif(isset($params['p']))
{
$replacement .= 't'.$cfg['plugin']['rewrite']['psep'].$params['p'];
unset($params['p']);
unset($params['m']);
}
else $replacement .= $script;
}
else $replacement .= $script;
}
elseif($script == 'users')
{
if($params['m'] == 'details' && isset($params['id']))
{
if($cfg['plugin']['rewrite']['users'])
{
$id = (int) $params['id'];
// Web-login hack
/*$tmp_urr = sed_sql_fetchassoc(sed_sql_query("SELECT user_name, user_irc FROM $db_users WHERE user_id = $id"));
if(empty($tmp_urr['user_irc']))
{
$tmp_uname = urlencode($tmp_urr['user_name']);
if($tmp_uname == $tmp_urr['user_name'] && count($params) == 2)
$not_append = true;
else
$not_append = false;
}
else
{
$tmp_uname = urlencode($tmp_urr['user_irc']);
$not_append = (count($params) == 2);
}*/
$tmp_urr = sed_sql_fetchassoc(sed_sql_query("SELECT user_name FROM $db_users WHERE user_id = $id"));
$tmp_uname = urlencode($tmp_urr['user_name']);
$replacement .= 'user'.$cfg['plugin']['rewrite']['sep'].$tmp_uname;
}
else $replacement .= 'u'.$cfg['plugin']['rewrite']['psep'].$params['id'];
unset($params['id']);
unset($params['m']);
}
else $replacement .= $script;
}
else $replacement .= $script;
}
else $replacement .= $script;
// Stripping comments/ratings if specified
if($cfg['plugin']['rewrite']['no_comments'] && $params['comments'] == '1')
unset($params['comments']);
if($cfg['plugin']['rewrite']['no_ratings'] && $params['ratings'] == '1')
unset($params['ratings']);
// Appending the rest
foreach($params as $key => $val) $replacement .= $cfg['plugin']['rewrite']['sep'].$key.$cfg['plugin']['rewrite']['psep'].rewrite_enc($val);
// web-login hack
if($not_append) $replacement .= $matches[$i][7].$matches[$i][8];
else $replacement .= $cfg['plugin']['rewrite']['suffix'].$matches[$i][7].$matches[$i][8];
// Replacing
$output = str_replace($matches[$i][0], $replacement, $output);
}
}

// Fixing the rest relative urls by making them server-relative
$convert = '#(href|src|background)=(\'|")((?:'.$cfg['plugin']['rewrite']['ignore'].')/(?:.+?))\2#i';
$output = preg_replace($convert, '$1=$2'.$site_uri.'$3$2', $output);

return $output;
}

// Input parameters import
function rewrite_input()
{
global $cfg;
$rewrite = $_GET['rwr'];
// Get the delimiters back on IIS
/*if(strpos(__FILE__, '\\') !== FALSE)
{
$rewrite = str_replace(urlencode($cfg['plugin']['rewrite']['sep']), $cfg['plugin']['rewrite']['sep'], $rewrite);
$rewrite = str_replace(urlencode($cfg['plugin']['rewrite']['psep']), $cfg['plugin']['rewrite']['psep'], $rewrite);
$rewrite = str_replace(urlencode('#'), '#', $rewrite);
}*/
// Remove the anchor if appended
$anchpos = strpos($rewrite, '#');
if($anchpos > 0)
$rewrite = substr($rewrite, 0, $anchpos);
// Parse the rewrite parameters into the get variables
$pairs = explode($cfg['plugin']['rewrite']['sep'], $rewrite);
foreach($pairs as $pair)
{
$pair = explode($cfg['plugin']['rewrite']['psep'], $pair, 2);
$data = rewrite_dec($pair[1]);
$_GET[$pair[0]] = $data;
$_REQUEST[$pair[0]] = $data;
$HTTP_GET_VARS[$pair[0]] = $data;
}
}

// Exit callback to rewrite location and refresh headers.
// Unfortunately, it's impossible to modify headers correctly in Seditio with register_shutdown_function
// because there are a lot of explicit exit() calls.
/*function rewrite_headers()
{
global $site_uri, $abs_url, $cfg;
if(!function_exists('sed_header') && function_exists('headers_list') && !headers_sent())
{
$hdrs = headers_list();
for($i = 0; $i < count($hdrs); $i++)
{
$loc = false;
$ref = false;
if(stripos($hdrs[$i], 'location') === 0) $loc = true;
elseif(stripos($hdrs[$i], 'refresh') === 0) $ref = true;
// Changing all the relative page urls
$search_reg = '#('.$cfg['plugin']['rewrite']['scripts'].')\.php(((?:\?|\&|\&\;)[\w_]+=.*?)*)(\#[\w\-_]*)?$#';
if($cfg['plugin']['rewrite']['engine_on'] && preg_match($search_reg, $hdrs[$i], $matches))
{
$replacement = $abs_url.$matches[1];
if(!empty($matches[2]))
{
$args = substr($matches[2], 1, strlen($matches[2]) - 1);
$args = str_replace('&amp;', $cfg['plugin']['rewrite']['sep'], $args);
$args = str_replace('&', $cfg['plugin']['rewrite']['sep'], $args);
$args = str_replace('=', $cfg['plugin']['rewrite']['psep'], $args);
$replacement .= $cfg['plugin']['rewrite']['sep'].$args;
}
$replacement .= $cfg['plugin']['rewrite']['suffix'].$matches[4];
$string = str_replace($matches[0], $replacement, $hdrs[$i]);
header($string);
}
else
{
// Just turn into absolute
$string = $loc ? preg_replace('#^Location\:\s+(.+)$#i', 'Location: '.$abs_url.'$2', $hdrs[$i]) :
preg_replace('#^Refresh\:\s+(\d+)\;\s+url=(.+)$#i', 'Refresh: $1; URL='.$abs_url.'$2', $hdrs[$i]);
header($string);
}
break;
}
}
}*/

// Rewrite extension header patch
function sed_header($string, $replace = true, $http_response_code = null)
{
global $site_uri, $abs_url, $cfg;
if(stripos($string, 'location') === 0) $loc = true;
elseif(stripos($hdrs[$i], 'refresh') === 0) $ref = true;
if($loc || $ref)
{
// URL patching needed
// Changing all the relative page urls
$search_reg = '#('.$cfg['plugin']['rewrite']['scripts'].')\.php(((?:\?|\&|\&\;)[\w_]+=.*?)*)(\#[\w\-_]*)?$#';
if($cfg['plugin']['rewrite']['engine_on'] && preg_match($search_reg, $string, $matches))
{
$replacement = $abs_url.$matches[1];
if(!empty($matches[2]))
{
$args = substr($matches[2], 1, strlen($matches[2]) - 1);
$args = str_replace('&amp;', $cfg['plugin']['rewrite']['sep'], $args);
$args = str_replace('&', $cfg['plugin']['rewrite']['sep'], $args);
$args = str_replace('=', $cfg['plugin']['rewrite']['psep'], $args);
$replacement .= $cfg['plugin']['rewrite']['sep'].$args;
}
$replacement .= $cfg['plugin']['rewrite']['suffix'].$matches[4];
$string = str_replace($matches[0], $replacement, $string);
}
elseif(!stristr($string, $abs_url))
{
// Just turn into absolute if relative
$string = $loc ? preg_replace('#^Location\:\s+(.+)$#i', 'Location: '.$abs_url.'$1', $string) :
preg_replace('#^Refresh\:\s+(\d+)\;\s+url=(.+)$#i', 'Refresh: $1; URL='.$abs_url.'$2', $string);
}
}
$http_response_code == null ? header($string, $replace) : header($string, $replace, $http_response_code);
}

// Registering shutdown callback
//register_shutdown_function('rewrite_headers');
?>
CMS Developer

TheRaskol 

171 posts
http://www.raskolserna.com
Location: Argentina Rosario
Occupation: Palyaço
Age: 20
#504   25-05-2008 16:43 GMT      
Teşekkür ederiz gökhan.

ya bir de şu code tagında şunu kullansanıza çok uzun oluyor (:


Kod:
.code { font-size:13px; color:#59739B; height: 200px; overflow: auto; background-color:#E0E0E0; padding:2px; margin-bottom:5px; font-family:monospace; }

G.YILDIZ 

486 posts
http://www.gokhan-yildiz.com
Location: Turkey Ünye
Occupation: Web Tasarımcısı
Age: 30
#505   25-05-2008 16:47 GMT      
şimdi dediğini yaptım diyelim.şuan senin vermiş olduğun kodların olduğu yerin boyutu 200px değil.ama arka plan 200px olacak.Ozaman görüntü bozukluğu olmaz mı?
CMS Developer

TheRaskol 

171 posts
http://www.raskolserna.com
Location: Argentina Rosario
Occupation: Palyaço
Age: 20
#506   25-05-2008 16:49 GMT      
bence şuankinden daha hoş olur dostum xD

Olabiliyorsa satır sorgulaması yaptır (:

G.YILDIZ 

486 posts
http://www.gokhan-yildiz.com
Location: Turkey Ünye
Occupation: Web Tasarımcısı
Age: 30
#507   25-05-2008 16:50 GMT      
hoş olur bunun farkındayım ama ana sayfada eklendiğim kodlar da görüntü bozukluğuna yol açar
CMS Developer

TheRaskol 

171 posts
http://www.raskolserna.com
Location: Argentina Rosario
Occupation: Palyaço
Age: 20
#508   25-05-2008 17:04 GMT      
Satır sorgualaması yapılamaz mı acaba?
5 satırdan az ise falan

G.YILDIZ 

486 posts
http://www.gokhan-yildiz.com
Location: Turkey Ünye
Occupation: Web Tasarımcısı
Age: 30
#509   25-05-2008 17:07 GMT      
o konuda bir bilgim yok
CMS Developer

Kaan 

78 posts
http://www.ntka.org
Location: Turkey İstanbul
Occupation: Web Tasarım
Age: 26
#524   26-05-2008 12:51 GMT      
Satır sorgulaması nasıl biraz daha acarsan konuyu daha iyi bilgi sahibi oluruz ve yardımcı olmaya çalışırız.
Uygun Fiyata Seditio Tasarımı Yapılır..
Seditio Eklentilerini Ntka.Org da bulabilirsiniz..
Sitemap Yenilendi..
Youtube Girmek için Tıkla..

ersin 

12 posts

Location: Turkey
Occupation:
Age:
#1271   14-07-2008 21:08 GMT      
merhaba, bu eklentiyi kurdum. Tek sorunum var. Bir yazı eklerken yanlış url diye hata veriyor. Ama yazıyı onaylama kısmına atıyor. Bu hata nereden kaynaklanıyor olabilir. Tşk.ler

G.YILDIZ 

486 posts
http://www.gokhan-yildiz.com
Location: Turkey Ünye
Occupation: Web Tasarımcısı
Age: 30
#1272   14-07-2008 22:05 GMT      
CMS Developer
Copyright © 2008 Seditione.Com. All Rights Reserved.
Sayfa oluşturma süresi 0.089 saniye

[1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11