From 3082c27bc88657f1eabbaa5dc7ade9816976fa98 Mon Sep 17 00:00:00 2001 From: Stefan Brannfjell Date: Sat, 31 Aug 2013 13:31:07 +0200 Subject: [PATCH] Forum search script, multi keyword search supported search: titles, posts, authors latest posts authors latest threads view latest threads view latest posts ------- working on new ipn for paygol (under dev) --- config.php | 47 ++++++----- forum_search.php | 207 +++++++++++++++++++++++++++++++++++++++++++++++ highscores.php | 2 +- paygol_ipn.php | 37 +++++++++ 4 files changed, 270 insertions(+), 23 deletions(-) create mode 100644 forum_search.php diff --git a/config.php b/config.php index 4365a86..0c4026f 100644 --- a/config.php +++ b/config.php @@ -4,7 +4,7 @@ // TFS 0.3 = TFS_03 (If ur using 0.3.6, set $config['salt'] to false)! // TFS 0.4 = TFS_03 // TFS 1.0 = TFS_10 (Under developement) - $config['TFSVersion'] = 'TFS_10'; + $config['TFSVersion'] = 'TFS_03'; $config['site_title'] = 'Znote AAC'; $config['site_title_context'] = 'Because open communities are good communities. :3'; @@ -14,13 +14,13 @@ // ------------------------ \\ // phpmyadmin username for OT server: (DONT USE "root" if ur hosting to public.). - $config['sqlUser'] = 'new'; + $config['sqlUser'] = 'username'; // phpmyadmin password for OT server: - $config['sqlPassword'] = 'new'; + $config['sqlPassword'] = 'password'; // The database name to connect to. (This is usually same as username). - $config['sqlDatabase'] = 'new'; + $config['sqlDatabase'] = 'database'; // Hostname is usually localhost or 127.0.0.1. $config['sqlHost'] = 'localhost'; @@ -62,16 +62,7 @@ // Town ids and names: (In RME map editor, open map, click CTRL + T to view towns, their names and their IDs. // townID => 'townName' etc: ['3'=>'Thais'] $config['towns'] = array( - 0 => 'Town 0', - 1 => 'Town 1', - 2 => 'Town 2', - 3 => 'Town 3', - 4 => 'Town 4', - 5 => 'Town 5', - 6 => 'Town 6', - 7 => 'Town 7', - 8 => 'Town 8', - 9 => 'Town 9', + 2 => 'Thyrfing', ); // Leave on black square in map and player should get teleported to their selected town. @@ -108,13 +99,13 @@ $config['available_vocations'] = array(1, 2, 3, 4); // Available towns (specify town ids, etc: (0, 1, 2); to display 3 town options (town id 0, 1 and 2). - $config['available_towns'] = array(1); + $config['available_towns'] = array(2); $config['level'] = 8; $config['health'] = 185; - $config['mana'] = 35; + $config['mana'] = 40; $config['cap'] = 435; - $config['soul'] = 0; + $config['soul'] = 100; $config['maleOutfitId'] = 128; $config['femaleOutfitId'] = 138; @@ -122,9 +113,9 @@ // No vocation info (if user select vocation id 0, we force thees configurations on him $config['nvlevel'] = 1; $config['nvHealth'] = 150; - $config['nvMana'] = 0; + $config['nvMana'] = 5; $config['nvCap'] = 400; - $config['nvSoul'] = 0; + $config['nvSoul'] = 100; $config['nvForceTown'] = 0; // Force a town to no vocation even though he selected something else? 0 = no, 1 = yes. $config['nvTown'] = 0; // Town id to force no vocations to get to, if nvForceTown is 1. @@ -154,7 +145,7 @@ ); $config['validate_IP'] = true; // Only allow legal IP addresses to register and create character. - $config['salt'] = false; // Some noob 0.3.6 servers don't support salt. + $config['salt'] = true; // Some noob 0.3.6 servers don't support salt. // Restricted names $config['invalidNameTags'] = array("god", "gm", "cm", "gamemaster", "hoster", "admin", "admim", "adm", "owner", "staff"); @@ -186,13 +177,13 @@ $config['port'] = 7171; // Port number to connect to your OT. // How often do you want highscores to update? - $config['cache_lifespan'] = 60 * 15; // 15 minutes. + $config['cache_lifespan'] = 1;//60 * 15; // 15 minutes. // WARNING! Account names written here will have admin access to web page! $config['page_admin_access'] = array( 'otland0', 'otland1', - 'znote' + //'znote' ); // Built-in FORUM @@ -413,6 +404,18 @@ 'imageType' => 'gif', ); + ////////// + /// Let players sell characters. + ///////// + $config['shop_auction'] = array( + 'characterAuction' => true, // Enable/disable this system + 'requiredLevel' => 50, // Minimum level of sold character + 'leastValue' => 10, // Lowest donation points a char can be sold for. + 'leastTime' => 24, // In hours. False to disable. + // leastTime = Lowest duration of time an auctioned player has to be + // sellable before auctioneer can claim character back. + ); + // If useDB is false, this array list will be used for shop offers. $config['shop_offers'] = array( // offer 1 diff --git a/forum_search.php b/forum_search.php new file mode 100644 index 0000000..bc36582 --- /dev/null +++ b/forum_search.php @@ -0,0 +1,207 @@ + +

Search forum

+
+ + + +
+ 4 && $type <= 6) { + $forums = mysql_select_multi("SELECT `id` FROM `znote_forum` WHERE `access`='1' AND `guild_id`='0';"); + $allowedForums = array(); + foreach($forums as $forum) $allowedForums[] = $forum['id']; + + //data_dump($allowedForums, false, "Allowed forums to search"); + // in_array(6, $allowedForums) + + $results = false; + switch ($type) { + case 1: // Search titles + $results = mysql_select_multi("SELECT `id` AS `thread_id`, `forum_id`, `title`, `text`, `player_name` FROM `znote_forum_threads` WHERE $textTitleSql ORDER BY `id` DESC LIMIT $searchResults;"); + // Filter out search results in custom access boards. + for ($i = 0; $i < count($results); $i++) + if (!in_array($results[$i]['forum_id'], $allowedForums)) + $results[$i]['forum_id'] = false; + else { + $results[$i]['title'] = stripBBCode($results[$i]['title']); + $results[$i]['text'] = stripBBCode($results[$i]['text']); + } + + //if ($results !== false) data_dump($results, false, "Search results"); + //else echo "
No results."; + break; + + case 2: // Search posts + $results = mysql_select_multi("SELECT `thread_id`, `player_name`, `text` FROM `znote_forum_posts` WHERE $textPostSql ORDER BY `id` DESC LIMIT $searchResults;"); + // Missing ['forum_id'], ['title'], lets get them + for ($i = 0; $i < count($results); $i++) { + // $results[$i]['asd'] + $thread = mysql_select_single("SELECT `forum_id`, `title` FROM `znote_forum_threads` WHERE `id`='".$results[$i]['thread_id']."' LIMIT 1;"); + if ($thread !== false) { + $results[$i]['forum_id'] = $thread['forum_id']; + $results[$i]['title'] = $thread['title']; + if (!in_array($results[$i]['forum_id'], $allowedForums)) $results[$i]['forum_id'] = false; + else { + $results[$i]['title'] = stripBBCode($results[$i]['title']); + $results[$i]['text'] = stripBBCode($results[$i]['text']); + } + } else $results[$i]['forum_id'] = false; + + } // DONE. :) + //data_dump(false, $results, "DATA"); + break; + + case 3: // Search authors last threads + $results = mysql_select_multi("SELECT `id` AS `thread_id`, `forum_id`, `title`, `text`, `player_name` FROM `znote_forum_threads` WHERE $textAuthorSql ORDER BY `id` DESC LIMIT $searchResults;"); + // Filter out search results in custom access boards. + for ($i = 0; $i < count($results); $i++) + if (!in_array($results[$i]['forum_id'], $allowedForums)) + $results[$i]['forum_id'] = false; + else { + $results[$i]['title'] = stripBBCode($results[$i]['title']); + $results[$i]['text'] = stripBBCode($results[$i]['text']); + } + + //if ($results !== false) data_dump($results, false, "Search results"); + //else echo "
No results."; + break; + + case 4: // Search authors last posts + $results = mysql_select_multi("SELECT `thread_id`, `player_name`, `text` FROM `znote_forum_posts` WHERE $textAuthorSql ORDER BY `id` DESC LIMIT $searchResults;"); + // Missing ['forum_id'], ['title'], lets get them + for ($i = 0; $i < count($results); $i++) { + // $results[$i]['asd'] + $thread = mysql_select_single("SELECT `forum_id`, `title` FROM `znote_forum_threads` WHERE `id`='".$results[$i]['thread_id']."' LIMIT 1;"); + if ($thread !== false) { + $results[$i]['forum_id'] = $thread['forum_id']; + $results[$i]['title'] = $thread['title']; + if (!in_array($results[$i]['forum_id'], $allowedForums)) $results[$i]['forum_id'] = false; + else { + $results[$i]['title'] = stripBBCode($results[$i]['title']); + $results[$i]['text'] = stripBBCode($results[$i]['text']); + } + } else $results[$i]['forum_id'] = false; + + } // DONE. :) + break; + + case 5: // Search latest titles + $results = mysql_select_multi("SELECT `id` AS `thread_id`, `forum_id`, `title`, `text`, `player_name` FROM `znote_forum_threads` ORDER BY `id` DESC LIMIT $searchResults;"); + // Filter out search results in custom access boards. + for ($i = 0; $i < count($results); $i++) + if (!in_array($results[$i]['forum_id'], $allowedForums)) + $results[$i]['forum_id'] = false; + else { + $results[$i]['title'] = stripBBCode($results[$i]['title']); + $results[$i]['text'] = stripBBCode($results[$i]['text']); + } + + //if ($results !== false) data_dump($results, false, "Search results"); + //else echo "
No results."; + break; + + case 6: // Search posts + $results = mysql_select_multi("SELECT `thread_id`, `player_name`, `text` FROM `znote_forum_posts` ORDER BY `id` DESC LIMIT $searchResults;"); + // Missing ['forum_id'], ['title'], lets get them + for ($i = 0; $i < count($results); $i++) { + // $results[$i]['asd'] + $thread = mysql_select_single("SELECT `forum_id`, `title` FROM `znote_forum_threads` WHERE `id`='".$results[$i]['thread_id']."' LIMIT 1;"); + if ($thread !== false) { + $results[$i]['forum_id'] = $thread['forum_id']; + $results[$i]['title'] = $thread['title']; + if (!in_array($results[$i]['forum_id'], $allowedForums)) $results[$i]['forum_id'] = false; + else { + $results[$i]['title'] = stripBBCode($results[$i]['title']); + $results[$i]['text'] = stripBBCode($results[$i]['text']); + } + } else $results[$i]['forum_id'] = false; + + } // DONE. :) + //data_dump(false, $results, "DATA"); + break; + default: + # code... + break; + } + + // Create table and show stuff! + if ($results !== false) { + $count = 0; + foreach ($results as $r) if ($r['forum_id'] !== false) $count++; + if ($count > 0) { + ?> + + + + + + + + + + + + + +
CharThreadPost
+ + + + 140) ? substr($result['text'],0,137).'...' : $result['text']; ?>
+ You must fill in all fields!"; + +include 'layout/overall/footer.php'; ?> \ No newline at end of file diff --git a/highscores.php b/highscores.php index 268ad78..6faea9c 100644 --- a/highscores.php +++ b/highscores.php @@ -69,7 +69,7 @@ if (empty($_POST) === false) { '; echo ''. $value['name'] .''; if ($skillid == 7) echo ''. $value['level'] .''; diff --git a/paygol_ipn.php b/paygol_ipn.php index 686e79d..06c85f2 100644 --- a/paygol_ipn.php +++ b/paygol_ipn.php @@ -82,4 +82,41 @@ } else echo ' character data false'; } else echo 'service id wrong'; +?> + + + + \ No newline at end of file