<commit_before><?php
/*-------------------------------------------------------+
| PHP-Fusion Content Management System
| Copyright (C) PHP-Fusion Inc
| https://www.php-fusion.co.uk/
+--------------------------------------------------------+
| Filename: upgrade.php
| Author: <NAME> (Digitanium)
+--------------------------------------------------------+
| This program is released as free software under the
| Affero GPL license. You can redistribute it and/or
| modify it under the terms of this license which you
| can read by viewing the included agpl.txt or online
| at www.gnu.org/licenses/agpl.html. Removal of this
| copyright header is strictly prohibited without
| written permission from the original author(s).
+--------------------------------------------------------*/
require_once "../maincore.php";
if (!checkrights("U") || !defined("iAUTH") || !isset($_GET['aid']) || $_GET['aid'] != iAUTH) {
	redirect("../index.php");
}
require_once THEMES."templates/admin_header.php";
if (file_exists(LOCALE.LOCALESET."admin/upgrade.php")) {
	include LOCALE.LOCALESET."admin/upgrade.php";
} else {
	include LOCALE."English/admin/upgrade.php";
}

opentable($locale['400']);
echo "<div style='text-align:center'><br />\n";
echo "<form name='upgradeform' method='post' action='".FUSION_SELF.$aidlink."'>\n";
if (str_replace(".", "", $settings['version']) < "90000") {
	if (!isset($_POST['stage'])) {
		echo sprintf($locale['500'], $locale['504'])."<br />\n".$locale['501']."<br /><br />\n";
		echo "<input type='hidden' name='stage' value='2'>\n";
		echo "<input type='submit' name='upgrade' value='".$locale['400']."' class='button'><br /><br />\n";
	} elseif (isset($_POST['upgrade']) && isset($_POST['stage']) && $_POST['stage'] == 2) {
		//Get locales for required language injections
		if (file_exists(LOCALE.LOCALESET."setup.php")) {
			include LOCALE.LOCALESET."setup.php";
		} else {
		include LOCALE."English/setup.php";
		}
		//Check files from earlier installations
		echo "<div style='width:550px; margin:15px auto;' class='tbl'>\n";
		echo "File check, please save and remove according to list.<br />\n";
		echo "<div class='tbl-border' style='margin-top:10px; padding: 5px; text-align:left;'>\n";
		if (file_exists(ADMIN."settings_links.php")) {
			echo "<span style='color:red;'>administration/settings_links.php </span> need to be deleted<br />";
		}
		if (file_exists(ADMIN."shoutbox.php")) {
			echo "<span style='color:red;'>administration/shoutbox.php </span> need to be deleted<br />";
		}
		if (file_exists(ADMIN."updateuser.php")) {
			echo "<span style='color:red;'>administration/updateuser.php </span> need to be deleted<br />";
		}
		if (file_exists(THEMES."templates/header_mce.php")) {
			echo "<span style='color:red;'>themes/templates/header_mce.php </span> need to be deleted<br />";
		}
		if (file_exists(THEMES."templates/admin_header_mce.php")) {
			echo "<span style='color:red;'>themes/templates/admin_header_mce.php </span> need to be deleted<br />";
		}
		if (file_exists(IMAGES."edit.gif")) {
			echo "<span style='color:red;'>images/edit.gif </span> need to be deleted<br />";
		}
		if (file_exists(IMAGES."star.gif")) {
			echo "<span style='color:red;'>images/star.gif </span> need to be deleted<br />";
		}
		if (file_exists(IMAGES."tick.gif")) {
			echo "<span style='color:red;'>images/tick.gif </span> need to be deleted<br />";
		}
		if (file_exists(INCLUDES."jscripts/tiny_mce/langs/hu.js")) {
			echo "<span style='color:red;'>includes/jscripts/tiny_mce/langs/hu.js </span> need to be deleted<br />";
		}
		if (file_exists(INCLUDES."jscripts/tiny_mce/plugins/compat2x/editor_plugin.js")) {
			echo "<span style='color:red;'>includes/jscripts/tiny_mce/plugins/compat2x/editor_plugin.js </span> need to be deleted<br />";
		}
		if (file_exists(INCLUDES."jscripts/tiny_mce/plugins/compat2x/editor_plugin_src.js")) {
			echo "<span style='color:red;'>includes/jscripts/tiny_mce/plugins/compat2x/editor_plugin_src.js </span> need to be deleted<br />";
		}
		if (file_exists(INCLUDES."jscripts/tiny_mce/plugins/paste/css/blank.css")) {
			echo "<span style='color:red;'>includes/jscripts/tiny_mce/plugins/paste/css/blank.css </span> need to be deleted<br />";
		}
		if (file_exists(INCLUDES."jscripts/tiny_mce/plugins/paste/css/pasteword.css")) {
			echo "<span style='color:red;'>includes/jscripts/tiny_mce/plugins/paste/css/pasteword.css </span> need to be deleted<br />";
		}
		if (file_exists(INCLUDES."jscripts/tiny_mce/plugins/paste/blank.htm")) {
			echo "<span style='color:red;'>includes/jscripts/tiny_mce/plugins/paste/blank.htm </span> need to be deleted<br />";
		}
		if (file_exists(INCLUDES."jscripts/tiny_mce/plugins/safari/blank.htm")) {
			echo "<span style='color:red;'>includes/jscripts/tiny_mce/plugins/safari/blank.htm </span> need to be deleted<br />";
		}
		if (file_exists(INCLUDES."jscripts/tiny_mce/plugins/safari/editor_plugin.js")) {
			echo "<span style='color:red;'>includes/jscripts/tiny_mce/plugins/safari/editor_plugin.js </span> need to be deleted<br />";
		}
		if (file_exists(INCLUDES."jscripts/tiny_mce/plugins/safari/editor_plugin_src.js")) {
			echo "<span style='color:red;'>includes/jscripts/tiny_mce/plugins/safari/editor_plugin_src.js </span> need to be deleted<br />";
		}
		if (file_exists(INCLUDES."jscripts/tiny_mce/plugins/xhtmlxtras/css/xhtmlxtras.css")) {
			echo "<span style='color:red;'>includes/jscripts/tiny_mce/plugins/xhtmlxtras/css/xhtmlxtras.css </span> need to be deleted<br />";
		}
		if (file_exists(INCLUDES."jscripts/tiny_mce/utils/mclayer.js")) {
			echo "<span style='color:red;'>includes/jscripts/tiny_mce/utils/mclayer.js </span> need to be deleted<br />";
		}
		if (file_exists(INCLUDES."securimage/index.php")) {
			echo "<span style='color:red;'>The folder includes/securimage and it´s content </span> need to be deleted<br />";
		}
		if (file_exists(INCLUDES."captcha_include.php")) {
			echo "<span style='color:red;'>includes/captcha_include.php </span> need to be deleted<br />";
		}
		if (file_exists(INCLUDES."jquery.js")) {
			echo "<span style='color:red;'>includes/jquery.js </span> need to be deleted<br />";
		}
		if (file_exists(INCLUDES."phpmailer_include.php")) {
			echo "<span style='color:red;'>includes/phpmailer_include.php </span> need to be deleted<br />";
		}
		if (file_exists(INCLUDES."smtp_include.php")) {
			echo "<span style='color:red;'>includes/smtp_include.php </span> need to be deleted<br />";
		}
		if (file_exists(INCLUDES."update_profile_include.php")) {
			echo "<span style='color:red;'>includes/update_profile_include.php </span> need to be deleted<br />";
		}
		if (file_exists(CLASSES."SubCats.class.php")) {
			echo "<span style='color:red;'>includes/classes/SubCats.class.php </span> need to be deleted<br />";
		}
		if (file_exists(INFUSIONS."navigation_panel/index.php")) {
			echo "<span style='color:red;'>The folder infusions/navigation_panel </span> need to be deleted <br /> (<STRONG>Check so you use the new one before!</STRONG>)<br />";
		}
		if (file_exists(LOCALE."English/admin/shoutbox.php")) {
			echo "<span style='color:red;'>locale/English/admin/shoutbox.php </span> need to be deleted<br />";
		}
		if (file_exists(LOCALE."English/edit_profile.php")) {
			echo "<span style='color:red;'>locale/English/edit_profile.php </span> need to be deleted<br />";
		}
		if (file_exists(LOCALE."English/register.php")) {
			echo "<span style='color:red;'>locale/English/register.php </span> need to be deleted<br />";
		}
		if (file_exists(LOCALE."English/view_profile.php")) {
			echo "<span style='color:red;'>locale/English/view_profile.php </span> need to be deleted<br />";
		}
		if (file_exists(BASEDIR."readarticle.php")) {
			echo "<span style='color:red;'>readarticle.php </span> need to be deleted<br />";
		}
		echo "</div></div><br />\n";
		//Function to generate random token keys
		function createRandomToken($length = 32) {
			$chars = array("abcdefghijklmnpqrstuvwxyzABCDEFGHIJKLMNPQRSTUVWXYZ", "123456789");
			$count = array((strlen($chars[0])-1), (strlen($chars[1])-1));
			$key = "";
			for ($i = 0; $i < $length; $i++) {
				$type = mt_rand(0, 1);
				$key .= substr($chars[$type], mt_rand(0, $count[$type]), 1);
			}
			return $key;
		}

		$secret_key = "".createRandomToken()."";
		$secret_key_salt = "".createRandomToken()."";
		echo "<div style='width:550px; margin:15px auto;' class='tbl'>\n";
		echo "Update your config.php right after COOKIE_PREFIX, with the following : <br />\n";
		echo "<div class='tbl-border' style='margin-top:10px; padding: 5px; text-align:left;'>\n";
		echo "\$pdo_enabled = \"0\"; <br />\n";
		echo "define(\"SECRET_KEY\", \"".$secret_key."\"); <br />\n";
		echo "define(\"SECRET_KEY_SALT\", \"".$secret_key_salt."\"); <br />\n";
		echo "</div><br />";
		echo "Please note that you need to change the \$pdo_enabled = \"0\" to \$pdo_enabled = \"1\" manually in order to enable PDO</div><br />\n";

		// Modify All Users Level > 0
		$result = dbquery("SELECT user_id, user_level FROM ".DB_USERS."");
		if (dbrows($result)>0) {
			while ($data = dbarray($result)) {
				if ($data['user_level']) { // will omit 0
					dbquery("UPDATE ".DB_USERS." SET user_level ='-".$data['user_level']."' WHERE user_id='".$data['user_id']."' ");
				}
			}
		}
		// change link_visibility
		$result = dbquery("ALTER TABLE ".DB_SITE_LINKS." CHANGE link_visibility link_visibility CHAR(4) NOT NULL DEFAULT ''");

		//Add language tables to infusions and main content
		$result = dbquery("ALTER TABLE ".DB_ARTICLE_CATS." ADD article_cat_language VARCHAR(50) NOT NULL DEFAULT '".$settings['locale']."' AFTER article_cat_access");
		$result = dbquery("ALTER TABLE ".DB_CUSTOM_PAGES." ADD page_language VARCHAR(50) NOT NULL DEFAULT '".$settings['locale']."' AFTER page_allow_ratings");
		$result = dbquery("ALTER TABLE ".DB_DOWNLOAD_CATS." ADD download_cat_language VARCHAR(50) NOT NULL DEFAULT '".$settings['locale']."' AFTER download_cat_access");
		$result = dbquery("ALTER TABLE ".DB_FAQ_CATS." ADD faq_cat_language VARCHAR(50) NOT NULL DEFAULT '".$settings['locale']."' AFTER faq_cat_description");
		$result = dbquery("ALTER TABLE ".DB_FORUM_RANKS." ADD rank_language VARCHAR(50) NOT NULL DEFAULT '".$settings['locale']."' AFTER rank_apply");
		$result = dbquery("ALTER TABLE ".DB_FORUMS." ADD forum_language VARCHAR(50) NOT NULL DEFAULT '".$settings['locale']."' AFTER forum_merge");
		$result = dbquery("ALTER TABLE ".DB_NEWS." ADD news_language VARCHAR(50) NOT NULL DEFAULT '".$settings['locale']."' AFTER news_allow_ratings");
		$result = dbquery("ALTER TABLE ".DB_NEWS_CATS." ADD news_cat_language VARCHAR(50) NOT NULL DEFAULT '".$settings['locale']."' AFTER news_cat_image");
		$result = dbquery("ALTER TABLE ".DB_PANELS." ADD panel_languages VARCHAR(200) NOT NULL DEFAULT '.".$settings['locale']."' AFTER panel_restriction");
		$result = dbquery("ALTER TABLE ".DB_PHOTO_ALBUMS." ADD album_language varchar(50) NOT NULL default '".$settings['locale']."' AFTER album_datestamp");
		$result = dbquery("ALTER TABLE ".DB_POLLS." ADD poll_language VARCHAR(50) NOT NULL DEFAULT '".$settings['locale']."' AFTER poll_ended");
		$result = dbquery("ALTER TABLE ".DB_SITE_LINKS." ADD link_language VARCHAR(50) NOT NULL DEFAULT '".$settings['locale']."' AFTER link_order");
		$result = dbquery("ALTER TABLE ".DB_USERS." ADD user_language VARCHAR(50) NOT NULL DEFAULT '".$settings['locale']."'");
		$result = dbquery("ALTER TABLE ".DB_WEBLINK_CATS." ADD weblink_cat_language VARCHAR(50) NOT NULL DEFAULT '".$settings['locale']."' AFTER weblink_cat_access");
		//Option to align news images
		$result = dbquery("ALTER TABLE ".DB_NEWS." ADD news_ialign VARCHAR(15) NOT NULL DEFAULT '' AFTER news_image_t2");
		//Option to use keywords in news
		$result = dbquery("ALTER TABLE ".DB_NEWS." ADD news_keywords VARCHAR(250) NOT NULL DEFAULT '' AFTER news_extended");
		//Option to use keywords in downloads
		$result = dbquery("ALTER TABLE ".DB_DOWNLOADS." ADD download_keywords VARCHAR(250) NOT NULL DEFAULT '' AFTER download_description");
		//Option to use keywords in photos
		$result = dbquery("ALTER TABLE ".DB_PHOTOS." ADD photo_keywords VARCHAR(250) NOT NULL DEFAULT '' AFTER photo_description");
		//Option to use keywords in custom_pages
		$result = dbquery("ALTER TABLE ".DB_CUSTOM_PAGES." ADD page_keywords VARCHAR(250) NOT NULL DEFAULT '' AFTER page_content");
		$result = dbquery("ALTER TABLE ".DB_CUSTOM_PAGES." ADD page_link_cat MEDIUMINT(9) UNSIGNED NOT NULL DEFAULT '0' AFTER page_id");
		//Option to use keywords in articles
		$result = dbquery("ALTER TABLE ".DB_ARTICLES." ADD article_keywords VARCHAR(250) NOT NULL DEFAULT '' AFTER article_article");<commit_msg>Change Link Visibility<commit_after><?php
/*-------------------------------------------------------+
| PHP-Fusion Content Management System
| Copyright (C) PHP-Fusion Inc
| https://www.php-fusion.co.uk/
+--------------------------------------------------------+
| Filename: upgrade.php
| Author: <NAME> (Digitanium)
+--------------------------------------------------------+
| This program is released as free software under the
| Affero GPL license. You can redistribute it and/or
| modify it under the terms of this license which you
| can read by viewing the included agpl.txt or online
| at www.gnu.org/licenses/agpl.html. Removal of this
| copyright header is strictly prohibited without
| written permission from the original author(s).
+--------------------------------------------------------*/
require_once "../maincore.php";
if (!checkrights("U") || !defined("iAUTH") || !isset($_GET['aid']) || $_GET['aid'] != iAUTH) {
	redirect("../index.php");
}
require_once THEMES."templates/admin_header.php";
if (file_exists(LOCALE.LOCALESET."admin/upgrade.php")) {
	include LOCALE.LOCALESET."admin/upgrade.php";
} else {
	include LOCALE."English/admin/upgrade.php";
}

opentable($locale['400']);
echo "<div style='text-align:center'><br />\n";
echo "<form name='upgradeform' method='post' action='".FUSION_SELF.$aidlink."'>\n";
if (str_replace(".", "", $settings['version']) < "90000") {
	if (!isset($_POST['stage'])) {
		echo sprintf($locale['500'], $locale['504'])."<br />\n".$locale['501']."<br /><br />\n";
		echo "<input type='hidden' name='stage' value='2'>\n";
		echo "<input type='submit' name='upgrade' value='".$locale['400']."' class='button'><br /><br />\n";
	} elseif (isset($_POST['upgrade']) && isset($_POST['stage']) && $_POST['stage'] == 2) {
		//Get locales for required language injections
		if (file_exists(LOCALE.LOCALESET."setup.php")) {
			include LOCALE.LOCALESET."setup.php";
		} else {
		include LOCALE."English/setup.php";
		}
		//Check files from earlier installations
		echo "<div style='width:550px; margin:15px auto;' class='tbl'>\n";
		echo "File check, please save and remove according to list.<br />\n";
		echo "<div class='tbl-border' style='margin-top:10px; padding: 5px; text-align:left;'>\n";
		if (file_exists(ADMIN."settings_links.php")) {
			echo "<span style='color:red;'>administration/settings_links.php </span> need to be deleted<br />";
		}
		if (file_exists(ADMIN."shoutbox.php")) {
			echo "<span style='color:red;'>administration/shoutbox.php </span> need to be deleted<br />";
		}
		if (file_exists(ADMIN."updateuser.php")) {
			echo "<span style='color:red;'>administration/updateuser.php </span> need to be deleted<br />";
		}
		if (file_exists(THEMES."templates/header_mce.php")) {
			echo "<span style='color:red;'>themes/templates/header_mce.php </span> need to be deleted<br />";
		}
		if (file_exists(THEMES."templates/admin_header_mce.php")) {
			echo "<span style='color:red;'>themes/templates/admin_header_mce.php </span> need to be deleted<br />";
		}
		if (file_exists(IMAGES."edit.gif")) {
			echo "<span style='color:red;'>images/edit.gif </span> need to be deleted<br />";
		}
		if (file_exists(IMAGES."star.gif")) {
			echo "<span style='color:red;'>images/star.gif </span> need to be deleted<br />";
		}
		if (file_exists(IMAGES."tick.gif")) {
			echo "<span style='color:red;'>images/tick.gif </span> need to be deleted<br />";
		}
		if (file_exists(INCLUDES."jscripts/tiny_mce/langs/hu.js")) {
			echo "<span style='color:red;'>includes/jscripts/tiny_mce/langs/hu.js </span> need to be deleted<br />";
		}
		if (file_exists(INCLUDES."jscripts/tiny_mce/plugins/compat2x/editor_plugin.js")) {
			echo "<span style='color:red;'>includes/jscripts/tiny_mce/plugins/compat2x/editor_plugin.js </span> need to be deleted<br />";
		}
		if (file_exists(INCLUDES."jscripts/tiny_mce/plugins/compat2x/editor_plugin_src.js")) {
			echo "<span style='color:red;'>includes/jscripts/tiny_mce/plugins/compat2x/editor_plugin_src.js </span> need to be deleted<br />";
		}
		if (file_exists(INCLUDES."jscripts/tiny_mce/plugins/paste/css/blank.css")) {
			echo "<span style='color:red;'>includes/jscripts/tiny_mce/plugins/paste/css/blank.css </span> need to be deleted<br />";
		}
		if (file_exists(INCLUDES."jscripts/tiny_mce/plugins/paste/css/pasteword.css")) {
			echo "<span style='color:red;'>includes/jscripts/tiny_mce/plugins/paste/css/pasteword.css </span> need to be deleted<br />";
		}
		if (file_exists(INCLUDES."jscripts/tiny_mce/plugins/paste/blank.htm")) {
			echo "<span style='color:red;'>includes/jscripts/tiny_mce/plugins/paste/blank.htm </span> need to be deleted<br />";
		}
		if (file_exists(INCLUDES."jscripts/tiny_mce/plugins/safari/blank.htm")) {
			echo "<span style='color:red;'>includes/jscripts/tiny_mce/plugins/safari/blank.htm </span> need to be deleted<br />";
		}
		if (file_exists(INCLUDES."jscripts/tiny_mce/plugins/safari/editor_plugin.js")) {
			echo "<span style='color:red;'>includes/jscripts/tiny_mce/plugins/safari/editor_plugin.js </span> need to be deleted<br />";
		}
		if (file_exists(INCLUDES."jscripts/tiny_mce/plugins/safari/editor_plugin_src.js")) {
			echo "<span style='color:red;'>includes/jscripts/tiny_mce/plugins/safari/editor_plugin_src.js </span> need to be deleted<br />";
		}
		if (file_exists(INCLUDES."jscripts/tiny_mce/plugins/xhtmlxtras/css/xhtmlxtras.css")) {
			echo "<span style='color:red;'>includes/jscripts/tiny_mce/plugins/xhtmlxtras/css/xhtmlxtras.css </span> need to be deleted<br />";
		}
		if (file_exists(INCLUDES."jscripts/tiny_mce/utils/mclayer.js")) {
			echo "<span style='color:red;'>includes/jscripts/tiny_mce/utils/mclayer.js </span> need to be deleted<br />";
		}
		if (file_exists(INCLUDES."securimage/index.php")) {
			echo "<span style='color:red;'>The folder includes/securimage and it´s content </span> need to be deleted<br />";
		}
		if (file_exists(INCLUDES."captcha_include.php")) {
			echo "<span style='color:red;'>includes/captcha_include.php </span> need to be deleted<br />";
		}
		if (file_exists(INCLUDES."jquery.js")) {
			echo "<span style='color:red;'>includes/jquery.js </span> need to be deleted<br />";
		}
		if (file_exists(INCLUDES."phpmailer_include.php")) {
			echo "<span style='color:red;'>includes/phpmailer_include.php </span> need to be deleted<br />";
		}
		if (file_exists(INCLUDES."smtp_include.php")) {
			echo "<span style='color:red;'>includes/smtp_include.php </span> need to be deleted<br />";
		}
		if (file_exists(INCLUDES."update_profile_include.php")) {
			echo "<span style='color:red;'>includes/update_profile_include.php </span> need to be deleted<br />";
		}
		if (file_exists(CLASSES."SubCats.class.php")) {
			echo "<span style='color:red;'>includes/classes/SubCats.class.php </span> need to be deleted<br />";
		}
		if (file_exists(INFUSIONS."navigation_panel/index.php")) {
			echo "<span style='color:red;'>The folder infusions/navigation_panel </span> need to be deleted <br /> (<STRONG>Check so you use the new one before!</STRONG>)<br />";
		}
		if (file_exists(LOCALE."English/admin/shoutbox.php")) {
			echo "<span style='color:red;'>locale/English/admin/shoutbox.php </span> need to be deleted<br />";
		}
		if (file_exists(LOCALE."English/edit_profile.php")) {
			echo "<span style='color:red;'>locale/English/edit_profile.php </span> need to be deleted<br />";
		}
		if (file_exists(LOCALE."English/register.php")) {
			echo "<span style='color:red;'>locale/English/register.php </span> need to be deleted<br />";
		}
		if (file_exists(LOCALE."English/view_profile.php")) {
			echo "<span style='color:red;'>locale/English/view_profile.php </span> need to be deleted<br />";
		}
		if (file_exists(BASEDIR."readarticle.php")) {
			echo "<span style='color:red;'>readarticle.php </span> need to be deleted<br />";
		}
		echo "</div></div><br />\n";
		//Function to generate random token keys
		function createRandomToken($length = 32) {
			$chars = array("abcdefghijklmnpqrstuvwxyzABCDEFGHIJKLMNPQRSTUVWXYZ", "123456789");
			$count = array((strlen($chars[0])-1), (strlen($chars[1])-1));
			$key = "";
			for ($i = 0; $i < $length; $i++) {
				$type = mt_rand(0, 1);
				$key .= substr($chars[$type], mt_rand(0, $count[$type]), 1);
			}
			return $key;
		}

		$secret_key = "".createRandomToken()."";
		$secret_key_salt = "".createRandomToken()."";
		echo "<div style='width:550px; margin:15px auto;' class='tbl'>\n";
		echo "Update your config.php right after COOKIE_PREFIX, with the following : <br />\n";
		echo "<div class='tbl-border' style='margin-top:10px; padding: 5px; text-align:left;'>\n";
		echo "\$pdo_enabled = \"0\"; <br />\n";
		echo "define(\"SECRET_KEY\", \"".$secret_key."\"); <br />\n";
		echo "define(\"SECRET_KEY_SALT\", \"".$secret_key_salt."\"); <br />\n";
		echo "</div><br />";
		echo "Please note that you need to change the \$pdo_enabled = \"0\" to \$pdo_enabled = \"1\" manually in order to enable PDO</div><br />\n";

		// Modify All Users Level > 0
		$result = dbquery("SELECT user_id, user_level FROM ".DB_USERS."");
		if (dbrows($result)>0) {
			while ($data = dbarray($result)) {
				if ($data['user_level']) { // will omit 0
					dbquery("UPDATE ".DB_USERS." SET user_level ='-".$data['user_level']."' WHERE user_id='".$data['user_id']."' ");
				}
			}
		}
		// change link_visibility
		$result = dbquery("ALTER TABLE ".DB_SITE_LINKS." CHANGE link_visibility link_visibility CHAR(4) NOT NULL DEFAULT ''");
		$link_result = dbquery("SELECT link_id, link_visibility FROM ".DB_SITE_LINKS."");
		if (dbrows($result)>0) {
			while ($data = dbarray($result)) {
				if ($data['link_visibility']) { // will omit 0
					dbquery("UPDATE ".DB_SITE_LINKS." SET user_visibility ='-".$data['link_visibility']."' WHERE link_id='".$data['link_id']."' ");
				}
			}
		}



		//Add language tables to infusions and main content
		$result = dbquery("ALTER TABLE ".DB_ARTICLE_CATS." ADD article_cat_language VARCHAR(50) NOT NULL DEFAULT '".$settings['locale']."' AFTER article_cat_access");
		$result = dbquery("ALTER TABLE ".DB_CUSTOM_PAGES." ADD page_language VARCHAR(50) NOT NULL DEFAULT '".$settings['locale']."' AFTER page_allow_ratings");
		$result = dbquery("ALTER TABLE ".DB_DOWNLOAD_CATS." ADD download_cat_language VARCHAR(50) NOT NULL DEFAULT '".$settings['locale']."' AFTER download_cat_access");
		$result = dbquery("ALTER TABLE ".DB_FAQ_CATS." ADD faq_cat_language VARCHAR(50) NOT NULL DEFAULT '".$settings['locale']."' AFTER faq_cat_description");
		$result = dbquery("ALTER TABLE ".DB_FORUM_RANKS." ADD rank_language VARCHAR(50) NOT NULL DEFAULT '".$settings['locale']."' AFTER rank_apply");
		$result = dbquery("ALTER TABLE ".DB_FORUMS." ADD forum_language VARCHAR(50) NOT NULL DEFAULT '".$settings['locale']."' AFTER forum_merge");
		$result = dbquery("ALTER TABLE ".DB_NEWS." ADD news_language VARCHAR(50) NOT NULL DEFAULT '".$settings['locale']."' AFTER news_allow_ratings");
		$result = dbquery("ALTER TABLE ".DB_NEWS_CATS." ADD news_cat_language VARCHAR(50) NOT NULL DEFAULT '".$settings['locale']."' AFTER news_cat_image");
		$result = dbquery("ALTER TABLE ".DB_PANELS." ADD panel_languages VARCHAR(200) NOT NULL DEFAULT '.".$settings['locale']."' AFTER panel_restriction");
		$result = dbquery("ALTER TABLE ".DB_PHOTO_ALBUMS." ADD album_language varchar(50) NOT NULL default '".$settings['locale']."' AFTER album_datestamp");
		$result = dbquery("ALTER TABLE ".DB_POLLS." ADD poll_language VARCHAR(50) NOT NULL DEFAULT '".$settings['locale']."' AFTER poll_ended");
		$result = dbquery("ALTER TABLE ".DB_SITE_LINKS." ADD link_language VARCHAR(50) NOT NULL DEFAULT '".$settings['locale']."' AFTER link_order");
		$result = dbquery("ALTER TABLE ".DB_USERS." ADD user_language VARCHAR(50) NOT NULL DEFAULT '".$settings['locale']."'");
		$result = dbquery("ALTER TABLE ".DB_WEBLINK_CATS." ADD weblink_cat_language VARCHAR(50) NOT NULL DEFAULT '".$settings['locale']."' AFTER weblink_cat_access");
		//Option to align news images
		$result = dbquery("ALTER TABLE ".DB_NEWS." ADD news_ialign VARCHAR(15) NOT NULL DEFAULT '' AFTER news_image_t2");
		//Option to use keywords in news
		$result = dbquery("ALTER TABLE ".DB_NEWS." ADD news_keywords VARCHAR(250) NOT NULL DEFAULT '' AFTER news_extended");
		//Option to use keywords in downloads
		$result = dbquery("ALTER TABLE ".DB_DOWNLOADS." ADD download_keywords VARCHAR(250) NOT NULL DEFAULT '' AFTER download_description");
		//Option to use keywords in photos
		$result = dbquery("ALTER TABLE ".DB_PHOTOS." ADD photo_keywords VARCHAR(250) NOT NULL DEFAULT '' AFTER photo_description");
		//Option to use keywords in custom_pages
		$result = dbquery("ALTER TABLE ".DB_CUSTOM_PAGES." ADD page_keywords VARCHAR(250) NOT NULL DEFAULT '' AFTER page_content");
		$result = dbquery("ALTER TABLE ".DB_CUSTOM_PAGES." ADD page_link_cat MEDIUMINT(9) UNSIGNED NOT NULL DEFAULT '0' AFTER page_id");
		//Option to use keywords in articles
		$result = dbquery("ALTER TABLE ".DB_ARTICLES." ADD article_keywords VARCHAR(250) NOT NULL DEFAULT '' AFTER article_article");
{'fraction_non_alphanumeric': 0.19412337030550691, 'fraction_numerical': 0.00926250243237984, 'mean_word_length': 4.4509970301230375, 'pattern_counts': {'":': 0, '<': 261, '<?xml version=': 0, '>': 260, 'https://': 2, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4119895', 'n_tokens_mistral': 9471, 'n_tokens_neox': 8603, 'n_words': 1936}