{"id":56,"date":"2006-05-16T18:17:30","date_gmt":"2006-05-17T00:17:30","guid":{"rendered":"http:\/\/thepizzy.net\/blog\/?p=56"},"modified":"2008-09-16T15:12:47","modified_gmt":"2008-09-16T21:12:47","slug":"were-number-1","status":"publish","type":"post","link":"https:\/\/thepizzy.net\/blog\/2006\/05\/were-number-1\/","title":{"rendered":"&#8220;We&#8217;re number 1!!&#8221;"},"content":{"rendered":"<p>Ok, so while coding the tsnX forums for the-spot.net, there were several instances in which the mods didn&#8217;t work because everyone&#8217;s mods assume (usually) that they are going to be the only mod installed in the forums. And while this is the ideology that saves time when writing a modification, it is not a &#8220;best practice&#8221; in programming. So to help with some of that frustration as to why your mod won&#8217;t work, I&#8217;m going to do my best to post some of the code changes that will need to be made in order to make some of these things interact with each other. <!--more--><\/p>\n<p>So far, on tsnX.3 I&#8217;ve installed phpBB 2.0.20, Category Hierarchy 2.1.4c, and Profile Control Panel 200-1, and Registration IP 1.0.0. At least, those are the ones that I had to write my own code to get the mods to work.<\/p>\n<p>So after you install phpbb 2.0.20, then you install CH 2.1.4c. Once you&#8217;ve done that, install Profile CP, and in the root\/profilecp\/profilecp_register.php you&#8217;ll need to make these modifications:<\/p>\n<p>First, we<br \/>\nFind:<\/p>\n<blockquote>\n<pre>\t\tif ( !$row = $db->sql_fetchrow($result) )\r\n\t\t{\r\n\t\t\tmessage_die(GENERAL_ERROR, 'Could not obtain next user_id information', '', __LINE__, __FILE__, $sql);\r\n\t\t}\r\n\t\t$userrow['user_id'] = $row['total'] + 1;<\/pre>\n<\/blockquote>\n<p>Add After:<\/p>\n<blockquote>\n<pre>\/\/-- mod : categories hierarchy ------------------------------------------------\r\n\/\/-- add\r\n\t\t\t\/\/ update last user\r\n\t\t\t$config->set('stat_last_user', $user_id);\r\n\t\t\t$config->set('stat_last_username', stripslashes($username));\r\n\t\t\t$sql = 'SELECT COUNT(user_id) AS total_users\r\n\t\t\t\t\t\tFROM ' . USERS_TABLE . '\r\n\t\t\t\t\t\tWHERE user_id <> ' . ANONYMOUS;\r\n\t\t\t$result = $db->sql_query($sql, false, __LINE__, __FILE__);\r\n\t\t\t$row = $db->sql_fetchrow($result);\r\n\t\t\t$config->set('stat_total_users', intval($row['total_users']) + 1);\r\n\/\/-- fin mod : categories hierarchy --------------------------------------------<\/pre>\n<\/blockquote>\n<p>Find:<\/p>\n<blockquote>\n<pre>\t\t$sql = \"INSERT INTO \" . USER_GROUP_TABLE . \" (user_id, group_id, user_pending)\r\n\t\t\t\tVALUES ($user_id, $group_id, 0)\";\r\n\t\tif( !($result = $db->sql_query($sql, END_TRANSACTION)) )\r\n\t\t{\r\n\t\t\tmessage_die(GENERAL_ERROR, 'Could not insert data into user_group table', '', __LINE__, __FILE__, $sql);\r\n\t\t}<\/pre>\n<\/blockquote>\n<p>Add After:<\/p>\n<blockquote>\n<pre>\/\/-- mod : categories hierarchy ------------------------------------------------\r\n\/\/-- add\r\n\t\t\t\/\/ cache groups list and set the user_id on the single group_id\r\n\t\t\t$view_user = new user();\r\n\t\t\t$view_user->read($user_id);\r\n\t\t\t$view_user->get_groups_list(true);\r\n\/\/-- fin mod : categories hierarchy --------------------------------------------<\/pre>\n<\/blockquote>\n<p>Find:<br \/>\n<blockquote\n\n<pre>\t\t\tif ( $username_changed )\r\n\t\t\t{\r\n\t\t\t\t$sql = &#8220;UPDATE &#8221; . GROUPS_TABLE . &#8221; \r\n\t\t\t\t\t\tSET group_name = &#8216;&#8221; . str_replace(&#8220;\\'&#8221;, &#8220;&#8221;&#8221;, $username) . &#8220;&#8216;\r\n\t\t\t\t\t\tWHERE group_name = &#8216;&#8221; . str_replace(&#8220;\\'&#8221;, &#8220;&#8221;&#8221;, $view_userdata[&#8216;username&#8217;] ) . &#8220;&#8216;&#8221;;\r\n\t\t\t\tif ( !$result = $db->sql_query($sql) )\r\n\t\t\t\t{\r\n\t\t\t\t\tmessage_die(GENERAL_ERROR, &#8216;Could not rename users group&#8217;, &#8221;, __LINE__, __FILE__, $sql);\r\n\t\t\t\t}\r\n\t\t\t}<\/pre>\n<\/blockquote>\n<p>After Add:<\/p>\n<blockquote>\n<pre>\/\/-- mod : categories hierarchy ------------------------------------------------\r\n\/\/-- add\r\n\t\t\t\/\/ if name changed, update some data\r\n\t\t\tif ( !empty($username_sql) )\r\n\t\t\t{\r\n\t\t\t\t$fields = array(\r\n\t\t\t\t\t'forum_last_username' => stripslashes($username),\r\n\t\t\t\t);\r\n\t\t\t\t$db->sql_statement($fields);\r\n\r\n\t\t\t\t\/\/ update forums last poster\r\n\t\t\t\t$sql = 'UPDATE ' . FORUMS_TABLE . '\r\n\t\t\t\t\t\t\tSET ' . $db->sql_update . '\r\n\t\t\t\t\t\t\tWHERE forum_last_poster = ' . intval($user_id);\r\n\t\t\t\t$db->sql_query($sql, false, __LINE__, __FILE__);\r\n\r\n\t\t\t\t\/\/ update last user\r\n\t\t\t\tif ( ($user_id == $config->data['stat_last_user']) || empty($config->data['stat_last_username']) )\r\n\t\t\t\t{\r\n\t\t\t\t\t$config->set('stat_last_user', $user_id);\r\n\t\t\t\t\t$config->set('stat_last_username', stripslashes($username));\r\n\t\t\t\t}\r\n\r\n\t\t\t\t\/\/ recache moderators\r\n\t\t\t\tinclude_once($config->url('includes\/class_forums'));\r\n\t\t\t\t$moderators = new moderators();\r\n\t\t\t\t$moderators->set_users_status();\r\n\t\t\t\t$moderators->read(true);\r\n\t\t\t}\r\n\/\/-- fin mod : categories hierarchy --------------------------------------------<\/pre>\n<\/blockquote>\n<p>Those changes take care of the caching that the Category Hierarchy does when creating a new user, and\/or updating the username\/group information if\/when the user changes their name.<\/p>\n<p>Then I installed the Registration IP mod, that grabs the session IP while registering and puts it into the user&#8217;s profile. What you should do is install the mod like normal, and then go back to this page (root\/profilecp\/profilecp_register.php) and do this:<\/p>\n<p>Find:<\/p>\n<blockquote>\n<pre>\tif ( $active_changed )\t $values['user_actkey'] = $user_actkey;<\/pre<\/blockquote>\r\nAfter Add:\r\n<blockquote><pre>\tif ( $create_user )\t\t $values['user_regip'] = $userdata['session_ip'];<\/pre>\n<\/blockquote>\n<p>That will put the ip into the database in the next couple lines where the SQL statement grabs the $values for insterting into the user_table.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Ok, so while coding the tsnX forums for the-spot.net, there were several instances in which the mods didn&#8217;t work because everyone&#8217;s mods assume (usually) that they are going to be the only mod installed in the forums. And while this is the ideology that saves time when writing a modification, it is not a &#8220;best [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[25,3,9],"tags":[351,352,357,350,152,47,354,954,349,356,353,348,355],"class_list":["post-56","post","type-post","status-publish","format-standard","hentry","category-programming","category-tech","category-the-spot-net","tag-categories-hierarchy","tag-category-hierarchy","tag-forum","tag-forums","tag-php","tag-phpbb","tag-profilecp","tag-programming","tag-query-sql","tag-registration","tag-registration-ip","tag-stripslashes","tag-tsnx"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_likes_enabled":false,"jetpack_shortlink":"https:\/\/wp.me\/prOO4-U","jetpack-related-posts":[],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/thepizzy.net\/blog\/wp-json\/wp\/v2\/posts\/56","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/thepizzy.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/thepizzy.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/thepizzy.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/thepizzy.net\/blog\/wp-json\/wp\/v2\/comments?post=56"}],"version-history":[{"count":1,"href":"https:\/\/thepizzy.net\/blog\/wp-json\/wp\/v2\/posts\/56\/revisions"}],"predecessor-version":[{"id":132,"href":"https:\/\/thepizzy.net\/blog\/wp-json\/wp\/v2\/posts\/56\/revisions\/132"}],"wp:attachment":[{"href":"https:\/\/thepizzy.net\/blog\/wp-json\/wp\/v2\/media?parent=56"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/thepizzy.net\/blog\/wp-json\/wp\/v2\/categories?post=56"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/thepizzy.net\/blog\/wp-json\/wp\/v2\/tags?post=56"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}