test tag
0, 'dups' => 0); $tag_array = explode(',', $tags); for($i = 0; $i < sizeof($tag_array); $i++) { if(insert_tag(str_replace('"', '', trim($tag_array[$i])), $topic_id)){ $outcome['added']++; }else{ $outcome['dups']++; } } return $outcome; } function insert_tag($tag, $topic_id){ global $db; $sql_array = array('tag' => $tag, 'topic_id' => $topic_id); if(trim($tag) == '') { //exit right away return false; } $sql = 'SELECT * FROM ' . TAGS_TABLE . " WHERE " . $db->sql_build_array('SELECT', $sql_array); $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); if($row != null) { return false; } else { $sql = "INSERT INTO " . TAGS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_array); $db->sql_query($sql); return true; } } function get_board_tags($limit){ global $db, $config, $auth; $sql = "SELECT t.*, topics.forum_id FROM " . TAGS_TABLE . " t JOIN " . TOPICS_TABLE . " topics ON t.topic_id = topics.topic_id "; $sql = get_cloud_sort($sql); if($limit > 0){ $result = $db->sql_query_limit($sql, $limit, 0); }else{ $result = $db->sql_query($sql); } /* for($i = 0; $i < sizeof($result_set); $i++){ $tag_array[$result_set[$i]['tag']] = $result_set[$i]['tag_count']; } * */ $tag_list = array(); while ($row = $db->sql_fetchrow($result)){ // Do not include those topics the user has no permission to access if ($auth->acl_get('f_read', $row['forum_id'])){ if(isset($tag_list[$row['tag']])){ $tag_list[$row['tag']] += 1; }else{ $tag_list[$row['tag']] = 1; } } } return $tag_list; } function get_topic_tags($topic_id, $limit){ global $db, $config, $auth; $sql = "SELECT t.*, topics.forum_id FROM " . TAGS_TABLE . " t JOIN " . TOPICS_TABLE . " topics ON t.topic_id = topics.topic_id - "; + WHERE t.topic_id = " . (int)$topic_id; $sql = get_cloud_sort($sql); if($limit > 0){ $result = $db->sql_query_limit($sql, $limit, 0); }else{ $result = $db->sql_query($sql); } $tag_list = array(); while ($row = $db->sql_fetchrow($result)){ // Do not include those topics the user has no permission to access if ($auth->acl_get('f_read', $row['forum_id'])){ if(isset($tag_list[$row['tag']])){ $tag_list[$row['tag']] += 1; }else{ $tag_list[$row['tag']] = 1; } } } return $tag_list; } function get_cloud_sort($sql){ global $config; switch($config['ptt_tag_sort']){ case 'random': $sql .= " ORDER BY RAND()"; break; case 'popular': $sql .= ' ORDER BY tag_count DESC'; break; case 'alphabetical': default: $sql .= " ORDER BY t.tag"; break; } return $sql; } function get_tag_cloud($min_size, $max_size, $col1, $col2, $limit){ global $phpEx, $user, $config, $phpbb_root_path; $tags = get_board_tags($limit); if(sizeof($tags) > 0){ $min_count = min(array_values($tags)); $max_count = max(array_values($tags)); $spread = $max_count - $min_count; if($spread == 0){ $spread = 1; } $tag_cloud = ''; $cTools = new ColourTools(); $gradient = $cTools->gradient($col1, $col2, $max_count); foreach ($tags as $tag => $count) { $size = $min_size + ($count - $min_count) * ($max_size - $min_size) / $spread; $tag_param = $tag; if(strpos($tag, ' ') !== false){ $tag_param = '"' . urlencode($tag) . '"'; } $tag_cloud .= ' ' . $tag . ' '; } }else{ $tag_cloud = false; } return $tag_cloud; } function get_tag_list($topic_id, $limit, $type = 'topic', $admin = false){ global $phpbb_root_path, $phpEx, $user; $tag_list = ""; $tags = get_topic_tags($topic_id, $limit); if(sizeof($tags) > 0) { foreach ($tags as $tag => $count) { $tag_param = $tag; if(strpos($tag, ' ') !== false) { $tag_param = '"' . urlencode($tag) . '"'; } if($admin){ //$tag_list .= '     '; } $tag_list .= '' . $tag . ', '; } $tag_list = substr($tag_list, 0, -2); } else { $tag_list = false; } return $tag_list; } /* USED FOR DIFFERENT TAGS DEPENDING ON WETHER IT SHOULD BE BOARD, TOPIC, FROUM. NEEDS RE WORKING function get_topic_tags($type = 'board', $id = 0, $limit = 60){ //TODO: santize input global $db; switch($type){ case 'forum': //forum sql $sql = "SELECT t.tag, COUNT(*) tag_count FROM " . TAGS_TABLE . " t, " . TOPICS_TABLE . " topics WHERE topics.forum_id = $id AND t.topic_id = topics.topic_id GROUP BY t.tag"; break; case 'topic': //topic sql $sql = "SELECT t.tag, COUNT(*) tag_count FROM " . TAGS_TABLE . " t WHERE t.topic_id = $id GROUP BY t.tag"; break; case 'board': default: //board sql $sql = "SELECT t.tag, COUNT(*) tag_count FROM " . TAGS_TABLE . " t GROUP BY t.tag"; } if($limit > 0){ $result = $db->sql_query_limit($sql, $limit, 0); }else{ $result = $db->sql_query($sql); } $result_set = $db->sql_fetchrowset($result); $tag_array = array(); for($i = 0; $i < sizeof($result_set); $i++) { $tag_array[$result_set[$i]['tag']] = $result_set[$i]['tag_count']; } return $tag_array; } function get_tag_list($topic_id, $limit, $type = 'topic', $admin = false){ global $phpbb_root_path, $phpEx, $user; $tag_list = ""; $tags = get_topic_tags($type, $topic_id, $limit); if(sizeof($tags) > 0) { foreach ($tags as $tag => $count) { $tag_param = $tag; if(strpos($tag, ' ') !== false) { $tag_param = '"' . $tag . '"'; } if($admin){ $tag_list .= '     '; } $tag_list .= '' . $tag . ', '; } $tag_list = substr($tag_list, 0, -2); } else { $tag_list = false; } return $tag_list; } function get_tag_cloud($type = 'board', $id = -1, $min_size = 8, $max_size = 26, $limit = 60){ global $phpEx, $user, $config; $tags = get_topic_tags($type, $id, $limit); if(sizeof($tags) > 0) { $min_count = min(array_values($tags)); $max_count = max(array_values($tags)); $spread = $max_count - $min_count; if($spread == 0) { $spread = 1; } $cTools = new ColourTools(); $gradient = $cTools->gradient($config['ptt_colour1'], $config['ptt_colour2'], $max_count); foreach ($tags as $tag => $count) { $size = $min_size + ($count - $min_count) * ($max_size - $min_size) / $spread; $tag_param = $tag; if(strpos($tag, ' ') !== false) { $tag_param = '"' . $tag . '"'; } $tag_cloud .= ' ' . $tag . ' '; } } else { $tag_cloud = false; } return $tag_cloud; } */ function get_num_rows($tags){ global $db, $config, $auth; $end = $config['topics_per_page']; $tag_array = filter_tags($tags); $sql = "SELECT topi.topic_id, topi.forum_id, topi.topic_type, topi.topic_replies_real, topi.topic_replies, topi.topic_status, topi.topic_moved_id, topi.topic_last_post_time, topi.topic_approved, topi.topic_poster, topi.topic_first_poster_name, topi.topic_time, topi.topic_last_post_subject, topi.topic_last_post_time, topi.topic_last_poster_id, topi.topic_views, topi.topic_title, topi.icon_id, topi.poll_start, topi.topic_attachment, topi.topic_first_poster_name, COUNT(topi.topic_id) count FROM ". TAGS_TABLE ." t, ". TOPICS_TABLE ." topi"; if(!empty($tag_array['include'])){ $sql .= " WHERE (t.tag IN ("; $sql .= prepare_search_string($tag_array['include']); $sql .= "))"; } if(!empty($tag_array['include']) && !empty($tag_array['exclude'])){ $sql .= " AND "; }else if(empty($tag_array['include']) && !empty($tag_array['exclude'])){ $sql .= " WHERE "; } if(!empty($tag_array['exclude'])){ $sql .= " (topi.topic_id NOT IN ( SELECT top2.topic_id FROM ". TAGS_TABLE ." t2, ". TOPICS_TABLE ." top2 WHERE t2.topic_id = top2.topic_id"; $sql .= prep_exclusion_string($tag_array['exclude']); $sql .= "))"; } $sql .= "AND topi.topic_id = t.topic_id GROUP BY topi.topic_id, topi.forum_id, topi.topic_type, topi.topic_replies_real, topi.topic_replies, topi.topic_status, topi.topic_moved_id, topi.topic_last_post_time, topi.topic_approved, topi.topic_poster, topi.topic_first_poster_name, topi.topic_time, topi.topic_last_post_subject, topi.topic_last_post_time, topi.topic_last_poster_id, topi.topic_views, topi.topic_title, topi.icon_id, topi.poll_start, topi.topic_attachment, topi.topic_first_poster_name ORDER BY count DESC"; if(!($result = $db->sql_query($sql))) { message_die(GENERAL_ERROR, 'Error retrieving search results', '', __LINE__, __FILE__, $sql); } $topic_list = array(); while ($row = $db->sql_fetchrow($result)){ // Do not include those topics the user has no permission to access if ($auth->acl_get('f_read', $row['forum_id'])){ $topic_list[] = $row; } } return sizeof($topic_list); } function search_tags($tags, $start = 0, $end = false){ global $db, $config, $auth; $topics_count = (int) $db->sql_fetchfield('num_topics'); if($end === false){ $end = $config['topics_per_page']; } $tag_array = filter_tags($tags); $sql = "SELECT topi.topic_id, topi.forum_id, topi.topic_type, topi.topic_replies_real, topi.topic_replies, topi.topic_status, topi.topic_moved_id, topi.topic_last_post_time, topi.topic_approved, topi.topic_poster, topi.topic_first_poster_name, topi.topic_time, topi.topic_last_post_subject, topi.topic_last_post_time, topi.topic_last_poster_id, topi.topic_views, topi.topic_title, topi.icon_id, topi.topic_attachment, topi.topic_first_poster_name, topi.topic_last_post_id, topi.topic_last_poster_id, topi.topic_last_poster_name, topi.topic_last_poster_colour, topi.topic_last_post_subject, topi.topic_last_post_time, topi.topic_last_view_time, topi.poll_start, COUNT(topi.topic_id) count FROM ". TAGS_TABLE ." t, ". TOPICS_TABLE ." topi"; if(!empty($tag_array['include'])){ $sql .= " WHERE (t.tag IN ("; $sql .= prepare_search_string($tag_array['include']); $sql .= "))"; } if(!empty($tag_array['include']) && !empty($tag_array['exclude'])){ $sql .= " AND "; }else if(empty($tag_array['include']) && !empty($tag_array['exclude'])){ $sql .= " WHERE "; } if(!empty($tag_array['exclude'])){ $sql .= "(topi.topic_id NOT IN ( SELECT top2.topic_id FROM ". TAGS_TABLE ." t2, ". TOPICS_TABLE ." top2 WHERE t2.topic_id = top2.topic_id"; $sql .= prep_exclusion_string($tag_array['exclude']); $sql .= "))"; } $sql .= "AND topi.topic_id = t.topic_id GROUP BY topi.topic_id, topi.forum_id, topi.topic_type, topi.topic_replies_real, topi.topic_replies, topi.topic_status, topi.topic_moved_id, topi.topic_last_post_time, topi.topic_approved, topi.topic_poster, topi.topic_first_poster_name, topi.topic_time, topi.topic_last_post_subject, topi.topic_last_post_time, topi.topic_last_poster_id, topi.topic_views, topi.topic_title, topi.icon_id, topi.topic_attachment, topi.topic_first_poster_name, topi.topic_last_post_id, topi.topic_last_poster_id, topi.topic_last_poster_name, topi.topic_last_poster_colour, topi.topic_last_post_subject, topi.topic_last_post_time, topi.topic_last_view_time ORDER BY topic_time DESC"; if(!($result = $db->sql_query_limit($sql, $end, $start))) { message_die(GENERAL_ERROR, 'Error retrieving search results', '', __LINE__, __FILE__, $sql); } $topic_list = array(); while ($row = $db->sql_fetchrow($result)){ // Do not include those topics the user has no permission to access if ($auth->acl_get('f_read', $row['forum_id'])){ $topic_list[] = $row; } } return $topic_list; } function prep_exclusion_string($exclude_array){ $string = ''; for($i = 0; $i < sizeof($exclude_array); $i++){ $string .= ' AND t2.tag = \'' . $exclude_array[$i] . '\''; } return $string; } function filter_tags($tags){ $tag_array = tags_to_array($tags); $incl = array(); $excl = array(); $filtered_array = array('include' => $incl, 'exclude' => $excl); for($i = 0; $i < sizeof($tag_array); $i++){ if($tag_array[$i][0] == '-'){ array_push($filtered_array['exclude'], substr($tag_array[$i], 1)); }else{ array_push($filtered_array['include'], $tag_array[$i]); } } return $filtered_array; } function tags_to_array($string){ $str_array = array(); $qoute = false; $str_buffer = ""; $tags = html_entity_decode($string); //$tags = $string; for($i = 0; $i < strlen($tags); $i++ ) { if(($tags[$i] == '"') && $qoute === true) { $qoute = false; } else if(($tags[$i] == '"') && $qoute === false) { $qoute = true; } if($tags[$i] == ' ' && !$qoute) { //str_replace( $str_buffer = str_replace('"', '', $str_buffer); array_push($str_array, $str_buffer); $str_buffer = ""; } else { $str_buffer .= $tags[$i]; } } $str_buffer = htmlspecialchars(str_replace('"', '', $str_buffer)); array_push($str_array, $str_buffer); return $str_array; } function prepare_search_string($str_array){ global $db; $prep_str = ""; for($j = 0; $j < sizeof($str_array); $j++) { $prep_str .= "'" . $db->sql_escape($str_array[$j]) . "',"; } return substr($prep_str, 0, strlen($prep_str)-1); } ?>
Search
 
 

Display results as :
 


Rechercher Advanced Search

Keywords

Latest topics
» Test Blog number one
Sun Aug 31, 2014 8:50 am by Kelsea

» Akashi Tanikaze
Sat Aug 30, 2014 11:41 pm by Tatyina

» This is a basic user generated topic.
Sat Aug 23, 2014 5:14 pm by anegge

» Your first subject
Wed Aug 13, 2014 8:41 pm by Kelsea

May 2018
MonTueWedThuFriSatSun
 123456
78910111213
14151617181920
21222324252627
28293031   

Calendar Calendar

Affiliates

free forum

Forumotion on Facebook Forumotion on Twitter Forumotion on YouTube Forumotion on Google+


Current date/time is Wed May 23, 2018 8:13 pm

Forum Terms of service

Using the forum. By registering on this forum, you agree to use it properly, and to refrain from posting any content that is aggressive, offensive, defamatory, hateful, or in violation of applicable laws and regulations. You agree not to post messages inciting or evoking illegal practices, or violating the terms of use of the service.

The moderators and administrators of this forum will do their best to delete or edit any reprehensible messages that may be posted on the forum. You acknowledge that all messages posted on this forum express the opinion of their respective authors, and do not necessarily reflect the position of the moderators and administrators.

In order to ensure the moderation of this forum, any message violating the preceding provisions may be edited or deleted without notice by the moderators and administrators of the forum. Any abuse may also be sanctioned by banning or deleting the user account. We reserve the right to inform your access provider and/or the judicial authorities of any malicious behaviour.

Your personal data. By registering on this forum, you agree that it may collect some of your personal data. This data collection is done either through the information you provide us, or through the use of the services itself, for technical data used for the forum proper functioning. You can access, modify or delete your data at any time. Users under 16 years old certify that they have obtained the consent of their legal guardian in order to proceed with this registration. For more information, please read our privacy policy.

This forum uses cookies to store information on your computer. These cookies only serve to improve the user experience. You can read the purpose of cookies on our forum help center. You can choose in your browser settings not to enable cookies, as this may disrupt the forum proper functioning.

This forum may send you electronic messages (e-mail), such as activity notifications, or newsletters, sent by Forumotion or by an administrator of this forum. You can choose in your profile preferences to receive or not each of these messages.


Click on the button 'I Agree to these terms' below :
- You acknowledge that you have read these rules in their entirety ;
- You agree to comply fully with this rules ;
- You grant moderators of this forum the right to delete, move or edit any topic at any time.