{"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_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_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}},"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":[{"id":25,"url":"https:\/\/thepizzy.net\/blog\/2006\/04\/update-tsnx-sub-forums-80-complete\/","url_meta":{"origin":56,"position":0},"title":"Update: tsnX &#8211; Sub-forums, 80% complete","author":"[[Neo]]","date":"April 5, 2006","format":false,"excerpt":"This is the longest mod to do by hand, because it's sooooo long. It was one I was hoping to do with the EasyMod script. But it's about 80% done. After that comes the Profile Control Panel mod, and hopefully I can still use the EasyMod script on it, but\u2026","rel":"","context":"In &quot;Technology&quot;","block_context":{"text":"Technology","link":"https:\/\/thepizzy.net\/blog\/category\/tech\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":55,"url":"https:\/\/thepizzy.net\/blog\/2006\/05\/update-tsnx3-registrationlogin-fixed\/","url_meta":{"origin":56,"position":1},"title":"Update: tsnX.3 &#8211; Registration\/Login Fixed","author":"[[Neo]]","date":"May 15, 2006","format":false,"excerpt":"The issues that we had with the cache and logging in after you registered have been fixed. There is nothing more frustrating than going through a mod that has worked in the past, but doesn't work this time, because everything else that it had interacted with before has changed. The\u2026","rel":"","context":"In &quot;Technology&quot;","block_context":{"text":"Technology","link":"https:\/\/thepizzy.net\/blog\/category\/tech\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":52,"url":"https:\/\/thepizzy.net\/blog\/2006\/05\/update-tsnx-good-newsbad-news\/","url_meta":{"origin":56,"position":2},"title":"Update: tsnX &#8211; Good News\/Bad News","author":"[[Neo]]","date":"May 14, 2006","format":false,"excerpt":"Good News: I'm going to be making progress starting tomorrow with the site coding and design. Bad News: I'm going to be making progress by starting over with the whole thing. The reason: I cannot figure out where the code errors are, and the updates that I did to the\u2026","rel":"","context":"In &quot;Technology&quot;","block_context":{"text":"Technology","link":"https:\/\/thepizzy.net\/blog\/category\/tech\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":46,"url":"https:\/\/thepizzy.net\/blog\/2006\/04\/update-tsnx-lesser-mods-bookmarks-multi-domains-100\/","url_meta":{"origin":56,"position":3},"title":"Update: tsnX &#8211; Lesser Mods &#8211; Bookmarks, Multi-Domains @ 100%","author":"[[Neo]]","date":"April 22, 2006","format":false,"excerpt":"I have begun working on the lesser mods to the site. I have completed the Bookmarks mod, to bookmark forums, like in the previous site. I've also put in a mod to let people access the forums from different domain names. This will be beneficial for the sub-sites that have\u2026","rel":"","context":"In &quot;Technology&quot;","block_context":{"text":"Technology","link":"https:\/\/thepizzy.net\/blog\/category\/tech\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":24,"url":"https:\/\/thepizzy.net\/blog\/2006\/04\/update-tsnx-installed-the-forum\/","url_meta":{"origin":56,"position":4},"title":"Update: tsnX &#8211; Installed the forum","author":"[[Neo]]","date":"April 5, 2006","format":false,"excerpt":"I've got the forum installed, again, but since something isn't going right with the Sub-Forum mod, I am going to have to code it by hand. And I can't put in the Profile Control Panel mod until that one is installed, because it creates files that the PCP references and\u2026","rel":"","context":"In &quot;Technology&quot;","block_context":{"text":"Technology","link":"https:\/\/thepizzy.net\/blog\/category\/tech\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":51,"url":"https:\/\/thepizzy.net\/blog\/2006\/05\/update-tsnx-still-debugging\/","url_meta":{"origin":56,"position":5},"title":"Update: tsnX &#8211; Still Debugging","author":"[[Neo]]","date":"May 12, 2006","format":false,"excerpt":"I'm still debugging the code updates that I have been working on the past 48 hours straight...breaking only to sleep and eat. But right now, I'm coded out, and need a break. I'll get back into it either later tonight, or tomorrow morning. I updated the category hierarchy to version\u2026","rel":"","context":"In &quot;Technology&quot;","block_context":{"text":"Technology","link":"https:\/\/thepizzy.net\/blog\/category\/tech\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"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}]}}