From 5f02930e3782b00a6e38c6480bbf9b76e4a1914d Mon Sep 17 00:00:00 2001 From: Aleksei Miheev Date: Sat, 23 Nov 2024 15:09:46 +0700 Subject: [PATCH] import legacy codebase --- Settings.php | 15 ++++--- Sources/Display.php | 3 +- Sources/Load.php | 5 ++- Sources/Register.php | 20 ++++----- Sources/Security.php | 10 +++++ Sources/Subs.php | 12 ++++-- Themes/default/MessageIndex.template.php | 52 ++++++++++++------------ Themes/default/Register.template.php | 17 ++------ Themes/default/images | 2 +- index.php | 7 ++-- mobiquo/mobiquo.php | 1 - recaptcha | 1 + yarss.php | 3 ++ 13 files changed, 81 insertions(+), 67 deletions(-) create mode 160000 recaptcha diff --git a/Settings.php b/Settings.php index d64e651..00d562d 100644 --- a/Settings.php +++ b/Settings.php @@ -27,21 +27,24 @@ $mmessage = 'Мы тут шаманим немного. Скоро всё буд ########## Forum Info ########## $mbname = 'www.rock.ru'; # The name of your forum. $language = 'russian'; # The default language file set for the forum. -$boardurl = 'http://rock.ru/forum'; # URL to your forum's folder. (without the trailing /!) +$boardurl = 'http://192.168.201.100/forum'; # URL to your forum's folder. (without the trailing /!) $boarddir = '/var/www/rock/forum'; $sourcedir = '/var/www/rock/forum/Sources'; $webmaster_email = 'noreply@rock.ru'; # Email address to send emails from. (like noreply@yourdomain.com.) $cookiename = 'SMFCookie10'; # Name of the cookie to set for authentication. -$mongo_server = "mongodb://rock.home:27017"; -$memcached_host = "127.0.0.1"; +//$mongo_server = "mongodb://10.152.69.6:27017/?replicaSet=rock0"; +$memcached_host = 'memcached'; $memcached_port = 11211; + +$recaptcha_secret = '6LfbSRUUAAAAAM4goUyXz9gB21cfIHL0ZhiQ6doM'; +$recaptcha_site_key = '6LfbSRUUAAAAAN1TtRVmVsHw8NKWe5w50fzjyK3U'; ########## Database Info ########## #$db_server = '127.0.0.1:3306'; -$db_server = 'localhost'; +$db_server = 'mysql'; $db_name = 'rock'; -$db_user = 'rock'; -$db_passwd = 'nla3YjQ0pL'; +$db_user = 'root'; +$db_passwd = ''; $db_prefix = 'smf_'; $db_persist = 0; $db_error_send = 1; diff --git a/Sources/Display.php b/Sources/Display.php index c3ba0a9..b56f08f 100644 --- a/Sources/Display.php +++ b/Sources/Display.php @@ -76,7 +76,8 @@ function Display() else loadTemplate('Display'); - $ignores = $mongodb->rock->ignorelists->findOne(array('user' => (int) $ID_MEMBER), array ("ignores" => 1)); + /*$ignores = $mongodb->rock->ignorelists->findOne(array('user' => (int) $ID_MEMBER), array ("ignores" => 1));*/ + $ignores = NULL; $ignores == NULL ? $context['ignore_list'] = array() : $context['ignore_list'] = $ignores['ignores']; // Find the previous or next topic. Make a fuss if there are no more. diff --git a/Sources/Load.php b/Sources/Load.php index c184364..43b0ceb 100644 --- a/Sources/Load.php +++ b/Sources/Load.php @@ -148,13 +148,14 @@ function loadUserSettings() explode(',', $user_settings['additionalGroups']) ) ); - + if(0) { // skip mongo $__uid = str_replace("uid=","",$_SERVER['USERID']); $mongodb->rock->memberUids->update( array('member' => $ID_MEMBER), array('$addToSet' => array('uids' => $__uid)), array('upsert' => true) - ); + ); + } // end skip mongo } // If the user is a guest, initialize all the critial user settings. diff --git a/Sources/Register.php b/Sources/Register.php index 61e3e5b..935cbe2 100644 --- a/Sources/Register.php +++ b/Sources/Register.php @@ -31,7 +31,7 @@ if (!defined('SMF')) // Begin the registration process. function Register() { - global $txt, $boarddir, $context, $modSettings, $user_info, $db_prefix; + global $txt, $boarddir, $context, $modSettings, $user_info, $db_prefix, $recaptcha_site_key; // Check if the administrator has it disabled. if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == 3) @@ -51,6 +51,7 @@ function Register() $context['sub_template'] = 'before'; $context['allow_hide_email'] = !empty($modSettings['allow_hideEmail']); $context['require_agreement'] = !empty($modSettings['requireAgreement']); + $context['recaptcha_site_key'] = $recaptcha_site_key; $context['page_title'] = $txt[97]; //Begin CAPTCHA Mod 0.1 @@ -66,7 +67,7 @@ function Register() // Actually register the member. function Register2() { - global $scripturl, $txt, $modSettings, $db_prefix, $context, $sourcedir, $user_info, $options, $settings; + global $scripturl, $txt, $modSettings, $db_prefix, $context, $sourcedir, $user_info, $options, $settings, $recaptcha_secret; # print_r($_SESSION); # Engine supports posting extra fields upon registration, but it will never happen in real life @@ -88,16 +89,13 @@ function Register2() //Begin CAPTCHA Mod 0.1 //Check if the CAPTCHA was entered properly... global $boarddir; - require("$boarddir/captcha/captcha.php"); + require("$boarddir/recaptcha/src/autoload.php"); + $recaptcha = new \ReCaptcha\ReCaptcha($recaptcha_secret); + $resp = $recaptcha->verify($_POST['g-recaptcha-response'], $_SERVER['REMOTE_ADDR']); + #var_dump(array($_POST['g-recaptcha-response'], $resp)); - switch($context['captchaObj']->validate_submit()) { - //Entered incorrectly! - case 2: - fatal_error($txt['captchaWrong']); - case 3: - fatal_error($txt['captchaMaxTries']); - - } + if (!$resp->isSuccess()) + fatal_error($txt['captchaWrong']); //End CAPTCHA Mod diff --git a/Sources/Security.php b/Sources/Security.php index 879482c..4d0efd0 100644 --- a/Sources/Security.php +++ b/Sources/Security.php @@ -315,6 +315,15 @@ function is_not_banned() } } + # check Tor: disallow registration + $res = db_query( + "select * from tor_nodes where ip='${user_info['ip']}'", + __FILE__, __LINE__ + ); + if (mysql_num_rows($res) > 0) { + $_SESSION['ban']['cannot_register']['is_banned'] = true; + } + // If you're fully banned, it's end of the story for you. if ($_SESSION['ban']['full_ban']['is_banned']) { @@ -613,6 +622,7 @@ function allowedTo($permission, $boards = null) return true; // no more than 3 polls in 24 hours. moderators excluded + if (! isset($user_info['is_mod'])) $user_info['is_mod'] = false; if (! $user_info['is_mod'] && in_array($permission, array ('poll_post', 'poll_add_own'))) { $request = db_query(" SELECT COUNT(*) as recent_polls diff --git a/Sources/Subs.php b/Sources/Subs.php index 7b3f5b9..f2d508c 100644 --- a/Sources/Subs.php +++ b/Sources/Subs.php @@ -213,6 +213,7 @@ if (!defined('SMF')) */ // Find the earliest unread message in the topic. (the use of topics here is just for both tables.) function getFirstUnreadPostTimestamp($topic, $board, $user) { + global $db_prefix; $request = db_query(" SELECT IFNULL(lt.logTime, IFNULL(lmr.logTime, 0)) AS logTime FROM {$db_prefix}topics AS t @@ -1347,13 +1348,16 @@ function parseVideoDailymotion($url) { } function cache_get($param) { - global $memcached; - return $memcached->get($param); + /*global $memcached;*/ + /*return $memcached->get($param);*/ + return null; } function cache_set($param, $value, $ttl = 0) { - global $memcached; - return $memcached->set($param, $value, $ttl); + /*global $memcached;*/ + /*return $memcached->set($param, $value, $ttl);*/ + + return null; } function parseVideoYoutube($url) { diff --git a/Themes/default/MessageIndex.template.php b/Themes/default/MessageIndex.template.php index dbecda3..6869cff 100644 --- a/Themes/default/MessageIndex.template.php +++ b/Themes/default/MessageIndex.template.php @@ -158,31 +158,33 @@ function template_main() foreach ($context['topics'] as $topic) { - if ($first_topic['is_sticky'] && !$topic['is_sticky']) { - $first_topic['is_sticky'] = 0; - // Display separator - if($context['user']['is_guest']) - echo ' -
- - -
'; - else echo ' '/*, $txt['non_sticky_topics']*/, ''; - } +# if ($first_topic['is_sticky'] && !$topic['is_sticky']) { +# $first_topic['is_sticky'] = 0; +# // Display separator +# if($context['user']['is_guest']) { +# echo ' +#
+# +# +#
'; +# } else { +# echo ' '/*, $txt['non_sticky_topics']*/, ''; +# } +# } if ($first_topic['is_sticky'] && !$topic['is_sticky']) { $first_topic['is_sticky'] = 0; diff --git a/Themes/default/Register.template.php b/Themes/default/Register.template.php index 66f6592..4d2cca5 100644 --- a/Themes/default/Register.template.php +++ b/Themes/default/Register.template.php @@ -9,6 +9,7 @@ function template_before() // Make sure they've agreed to the terms and conditions. echo ' + -
+ @@ -75,17 +77,6 @@ function template_before() - - - - - -
', $txt[97], ' - ', $txt[517], '
- ', $txt['captchaEnter'], ': - - ', $context['captcha_image'], ' - -
@@ -110,7 +101,7 @@ function template_before() echo '
- +
'; diff --git a/Themes/default/images b/Themes/default/images index 2a29803..0a3f332 120000 --- a/Themes/default/images +++ b/Themes/default/images @@ -1 +1 @@ -/var/www/img.rock.ru/forum/Themes/default/images \ No newline at end of file +../../../../img.rock.ru/forum/Themes/default/images \ No newline at end of file diff --git a/index.php b/index.php index d795d37..4ebbf9c 100644 --- a/index.php +++ b/index.php @@ -73,13 +73,14 @@ else if (!$db_connection || !@mysql_select_db($db_name, $db_connection)) db_fatal_error(); -$mongodb = new MongoClient(); +/*$mongodb = new MongoClient($mongo_server);*/ -$memcached = new Memcached(); -$memcached->addServer($memcached_host, $memcached_port); +/*$memcached = new Memcached();*/ +/*$memcached->addServer($memcached_host, $memcached_port);*/ // mysql_query("SET NAMES 'utf8'"); +mysql_query("set SESSION sql_mode='STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'"); setlocale(LC_ALL,"ru_RU.UTF-8"); mb_internal_encoding("UTF-8"); mb_regex_encoding("UTF-8"); diff --git a/mobiquo/mobiquo.php b/mobiquo/mobiquo.php index c25a8ba..f8aa4cc 100644 --- a/mobiquo/mobiquo.php +++ b/mobiquo/mobiquo.php @@ -59,7 +59,6 @@ if (isset($mobiquo_config['hide_forum_id']) && count($mobiquo_config['hide_forum { $user_info['query_see_board'] .= ' AND b.ID_BOARD NOT IN ('. implode(',', $mobiquo_config['hide_forum_id']) .') '; } -file_put_contents('/tmp/request', var_export($context['mod_request'], true)); // Allright, method passed...call it call_user_func('method_' . $context['mob_request']['method']); diff --git a/recaptcha b/recaptcha new file mode 160000 index 0000000..d3274db --- /dev/null +++ b/recaptcha @@ -0,0 +1 @@ +Subproject commit d3274db7c061770472b8eff8a7dbae0871f6cf03 diff --git a/yarss.php b/yarss.php index d830a43..74cbe01 100644 --- a/yarss.php +++ b/yarss.php @@ -104,6 +104,9 @@ require_once($sourcedir . '/Security.php'); if (@version_compare(PHP_VERSION, '4.2.3') != 1) require_once($sourcedir . '/Subs-Compat.php'); +$memcached = new Memcached(); +$memcached->addServer($memcached_host, $memcached_port); + // Connect to the MySQL database. if (empty($db_persist)) $db_connection = @mysql_connect($db_server, $db_user, $db_passwd);