Created
January 24, 2015 11:27
-
-
Save dlenettr/da010a10dca10f4d4dfe to your computer and use it in GitHub Desktop.
Makale eklerken otomatik keywords ve açıklama oluşturma (684)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function create_metatags($story) { | |
global $config, $db; | |
$keyword_count = 20; | |
$newarr = array (); | |
$headers = array (); | |
$quotes = array ("\x22", "\x60", "\t", '\n', '\r', "\n", "\r", "\\", ",", ".", "/", "¬", "#", ";", ":", "@", "~", "[", "]", "{", "}", "=", "-", "+", ")", "(", "*", "^", "%", "$", "<", ">", "?", "!", '"'); | |
$fastquotes = array ("\x22", "\x60", "\t", "\n", "\r", '"', '\r', '\n', "$", "{", "}", "[", "]", "<", ">", "\\"); | |
$story = preg_replace( "#\[hide\](.+?)\[/hide\]#is", "", $story ); | |
$story = preg_replace( "'\[attachment=(.*?)\]'si", "", $story ); | |
$story = preg_replace( "'\[page=(.*?)\](.*?)\[/page\]'si", "", $story ); | |
$story = str_replace( "{PAGEBREAK}", "", $story ); | |
$story = str_replace( " ", " ", $story ); | |
$story = str_replace( '<br />', ' ', $story ); | |
$story = strip_tags( $story ); | |
$story = preg_replace( "#&(.+?);#", "", $story ); | |
$story = trim(str_replace( " ,", "", $story )); | |
if( trim( $_REQUEST['descr'] ) != "" ) { | |
$headers['description'] = dle_substr( strip_tags( stripslashes( $_REQUEST['descr'] ) ), 0, 200, $config['charset'] ); | |
if( ($temp_dmax = dle_strrpos( $headers['description'], ' ', $config['charset'] )) ) $headers['description'] = dle_substr( $headers['description'], 0, $temp_dmax, $config['charset'] ); | |
$headers['description'] = $db->safesql( str_replace( $fastquotes, '', $headers['description'] )); | |
} elseif($config['create_metatags']) { | |
$story = str_replace( $fastquotes, '', $story ); | |
$headers['description'] = dle_substr( stripslashes($story), 0, 200, $config['charset'] ); | |
if( ($temp_dmax = dle_strrpos( $headers['description'], ' ', $config['charset'] )) ) $headers['description'] = dle_substr( $headers['description'], 0, $temp_dmax, $config['charset'] ); | |
$headers['description'] = $db->safesql( $headers['description'] ); | |
} else { | |
$headers['description'] = ''; | |
} | |
if( trim( $_REQUEST['keywords'] ) != "" ) { | |
$headers['keywords'] = $db->safesql( str_replace( $fastquotes, " ", strip_tags( stripslashes( $_REQUEST['keywords'] ) ) ) ); | |
} elseif( $config['create_metatags'] ) { | |
$story = str_replace( $quotes, ' ', $story ); | |
$arr = explode( " ", $story ); | |
foreach ( $arr as $word ) { | |
if( dle_strlen( $word, $config['charset'] ) > 4 ) $newarr[] = $word; | |
} | |
$arr = array_count_values( $newarr ); | |
arsort( $arr ); | |
$arr = array_keys( $arr ); | |
$total = count( $arr ); | |
$offset = 0; | |
$arr = array_slice( $arr, $offset, $keyword_count ); | |
$headers['keywords'] = $db->safesql( implode( ", ", $arr ) ); | |
} else { | |
$headers['keywords'] = ''; | |
} | |
return $headers; | |
} | |
$metatags = create_metatags( $short_story." ".$full_story ); | |
$db->query( "INSERT INTO " . PREFIX . "_post (date, autor, short_story, full_story, xfields, title, descr, keywords, category, alt_name, allow_comm, approve, allow_main, fixed, allow_br, symbol, tags) values ('$thistime', '{$member_id['name']}', '$short_story', '$full_story', '$filecontents', '$title', '{$metatags['description']}', '{$metatags['keywords']}', '$category_list', '$alt_name', '$allow_comm', '$approve', '$allow_main', '$news_fixed', '$allow_br', '$catalog_url', '" . $_POST['tags'] . "')" ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment