function create_metatags story global config db keyword_count 20 newar

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
function create_metatags($story) {
global $config, $db;
$keyword_count = 20;
$newarr = array ();
$headers = array ();
$quotes = array ("\x27", "\x22", "\x60", "\t", '\n', '\r', "\n", "\r", '\\', "'", ",", ".", "/", "¬", "#", ";", ":", "@", "~", "[", "]", "{", "}", "=", "-", "+", ")", "(", "*", "&", "^", "%", "$", "<", ">", "?", "!", '"' );
$fastquotes = array ("\x27", "\x22", "\x60", "\t", "\n", "\r", '"', "'", '\r', '\n', "/", "\\", "{", "}", "[", "]" );
$story = preg_replace( "'\[hide\](.*?)\[/hide\]'si", "", $story );
$story = preg_replace( "'\[attachment=(.*?)\]'si", "", $story );
$story = preg_replace( "'\[page=(.*?)\](.*?)\[/page\]'si", "", $story );
$story = str_replace( "{PAGEBREAK}", "", $story );
$story = str_replace( '<br />', ' ', $story );
$story = trim( strip_tags( $story ) );
if( trim( $_REQUEST['descr'] ) != "" ) {
$headers['description'] = $db->safesql( substr( strip_tags( stripslashes( $_REQUEST['descr'] ) ), 0, 190 ) );
} else {
$story = str_replace( $fastquotes, '', $story );
$headers['description'] = $db->safesql( substr( $story, 0, 190 ) );
}
if( trim( $_REQUEST['keywords'] ) != "" ) {
$headers['keywords'] = $db->safesql( str_replace( $fastquotes, " ", strip_tags( stripslashes( $_REQUEST['keywords'] ) ) ) );
} else {
$story = str_replace( $quotes, '', $story );
$arr = explode( " ", $story );
foreach ( $arr as $word ) {
if( strlen( $word ) > 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 ) );
}
return $headers;
}