function module_db_add_field($field_table, $field_name, $field_type, $field_length, $field_attributes, $field_null, $field_default) { //field_table = the table the field will go into, without the prefix, users, comments, votes etc //field_name = the name of the field //field_type = varchar, text, int etc... //field_length = length of the field //field_attributes = unsigned etc... //field_null = 0=not null, 1=null //field_default = default value global $db; if ($field_table == 'users') { $field_table = table_users; } $fieldexists = checkforfield($field_name, $field_table); if (!$fieldexists) { $sql = 'ALTER TABLE `' . $field_table . '` ADD `' . $field_name . '` ' . $field_type; if ($field_length != '') { $sql .= '(' . $field_length . ')'; } if ($field_attributes != '') { $sql .= ' ' . $field_attributes; } if ($field_null == 0) { $sql .= ' not null'; } else { $sql .= ' null'; } if ($field_default != '') { $sql .= " default '" . $field_default . "'"; } //echo $sql . '<br>'; $db->query($sql); } }
$fieldexists = checkforfield('category_author_level', table_categories); if (!$fieldexists) { $sql = "ALTER TABLE `" . table_categories . "` ADD `category_author_level` enum('normal','moderator','admin') NOT NULL default 'normal';"; $db->query($sql); } $fieldexists = checkforfield('category_author_group', table_categories); if (!$fieldexists) { $sql = "ALTER TABLE `" . table_categories . "` ADD `category_author_group` VARCHAR(255) NOT NULL default '';"; $db->query($sql); } $fieldexists = checkforfield('category_votes', table_categories); if (!$fieldexists) { $sql = "ALTER TABLE `" . table_categories . "` ADD `category_votes` VARCHAR(4) NOT NULL default '';"; $db->query($sql); } $fieldexists = checkforfield('category_karma', table_categories); if (!$fieldexists) { $sql = "ALTER TABLE `" . table_categories . "` ADD `category_karma` VARCHAR(4) NOT NULL default '';"; $db->query($sql); } $sql = "DELETE FROM " . table_config . " WHERE var_name='enable_show_last_visit'"; $db->query($sql); $sql = "DELETE FROM `" . table_config . "` WHERE `var_name` = 'StorySummary_ContentTruncate';"; $db->query($sql); // Change the default template value to Bootstrap $sql = "UPDATE `" . table_config . "` SET `var_defaultvalue` = 'bootstrap' WHERE `var_name` = '{$thetemp}';"; $db->query($sql); // Delete Pageviews and Captcha $sql = "DELETE FROM `" . table_config . "` WHERE `var_name` = 'PageViews';"; $db->query($sql); $sql = "DELETE FROM `" . table_config . "` WHERE `var_page` = 'Captcha';";
break; case 'voted': $sql = "SELECT DISTINCT * FROM " . table_links . ", " . table_votes . " WHERE vote_user_id={$userid} AND vote_link_id=link_id AND vote_value > 0 AND (link_status='published' OR link_status='new') ORDER BY link_date DESC LIMIT {$start_up}, {$page_size}"; $load_page = 1; break; case 'upvoted': $sql = "SELECT DISTINCT * FROM " . table_links . ", " . table_votes . " WHERE vote_user_id={$userid} AND vote_link_id=link_id AND vote_value > 0 AND (link_status='published' OR link_status='new') ORDER BY link_votes DESC LIMIT {$start_up}, {$page_size}"; $load_page = 1; break; case 'downvoted': $sql = "SELECT DISTINCT * FROM " . table_links . ", " . table_votes . " WHERE vote_user_id={$userid} AND vote_link_id=link_id AND vote_value < 0 AND (link_status='published' OR link_status='new') ORDER BY link_votes ASC LIMIT {$start_up}, {$page_size}"; $load_page = 1; break; case 'saved': $load_page = 1; $fieldexists = checkforfield('saved_privacy', table_saved_links); if ($fieldexists) { if ($curuserid == $userid) { $sql = "SELECT " . table_links . ".* FROM " . table_saved_links . " \r\n\t\t\t\t\t\t\t\t\tLEFT JOIN " . table_links . " ON saved_link_id=link_id\r\n\t\t\t\t\t\t\t\t\tWHERE saved_user_id={$userid} ORDER BY saved_link_id DESC LIMIT {$start_up},{$page_size}"; } else { $sql = "SELECT " . table_links . ".* FROM " . table_saved_links . " \r\n\t\t\t\t\t\t\t\t\tLEFT JOIN " . table_links . " ON saved_link_id=link_id\r\n\t\t\t\t\t\t\t\t\tWHERE saved_user_id={$userid} and saved_privacy = 'public' ORDER BY saved_link_id DESC LIMIT {$start_up},{$page_size}"; } } else { $sql = "SELECT " . table_links . ".* FROM " . table_saved_links . " \r\n\t\t\t\t\t\t\t\tLEFT JOIN " . table_links . " ON saved_link_id=link_id\r\n\t\t\t\t\t\t\t\tWHERE saved_user_id={$userid} ORDER BY saved_link_id DESC LIMIT {$start_up},{$page_size}"; } break; } $linksum_sql = $sql; } else { if ($page_name == "index" || $page_name == "new" || $page_name == "published") { $linksum_sql = $search->sql;
function do_stories() { global $db, $main_smarty, $rows, $user, $offset, $page_size, $current_user, $cached_links; //if ($current_user->user_id == $user->id) //{ $output = ''; $link = new Link(); $rows = $db->get_var("SELECT count(*) FROM " . table_saved_links . " WHERE saved_user_id={$user->id}"); $fieldexists = checkforfield('saved_privacy', table_saved_links); if ($fieldexists) { if ($current_user->user_id == $user->id) { $links = $db->get_results("SELECT * FROM " . table_saved_links . " \r\n\t\t\t\t\t\t\t\tLEFT JOIN " . table_links . " ON saved_link_id=link_id\r\n\t\t\t\t\t\t\t\tWHERE saved_user_id={$user->id} ORDER BY saved_link_id DESC LIMIT {$offset},{$page_size}"); } else { $links = $db->get_results("SELECT * FROM " . table_saved_links . " \r\n\t\t\t\t\t\t\t\tLEFT JOIN " . table_links . " ON saved_link_id=link_id\r\n\t\t\t\t\t\t\t\tWHERE saved_user_id={$user->id} and saved_privacy = 'public' ORDER BY saved_link_id DESC LIMIT {$offset},{$page_size}"); } } else { $links = $db->get_results("SELECT * FROM " . table_saved_links . " \r\n\t\t\t\t\t\t\tLEFT JOIN " . table_links . " ON saved_link_id=link_id\r\n\t\t\t\t\t\t\tWHERE saved_user_id={$user->id} ORDER BY saved_link_id DESC LIMIT {$offset},{$page_size}"); } if ($links) { foreach ($links as $dblink) { $link->id = $dblink->link_id; $cached_links[$dblink->link_id] = $dblink; $link->read(); //$output.= $current_user->user_id."<br/>"; //$output.= $user->id."<br/>"; $output .= $link->print_summary('summary', true); } } $main_smarty->assign('user_page', $output); //} }
$fieldexists = checkforfield('lft', table_categories); if (!$fieldexists) { $sql = "ALTER TABLE `" . table_categories . "` ADD `lft` int(11) NOT NULL"; $db->query($sql); } $fieldexists = checkforfield('category_enabled', table_categories); if (!$fieldexists) { $sql = "ALTER TABLE `" . table_categories . "` ADD `category_enabled` int(11) NOT NULL default '1'"; $db->query($sql); } $fieldexists = checkforfield('category_order', table_categories); if (!$fieldexists) { $sql = "ALTER TABLE `" . table_categories . "` ADD `category_order` int(11) NOT NULL default '0'"; $db->query($sql); } $fieldexists = checkforfield('category_color', table_categories); if (!$fieldexists) { $sql = "ALTER TABLE `" . table_categories . "` ADD `category_color` varchar(6) default '000000'"; $db->query($sql); $sql = "ALTER TABLE `" . table_categories . "` DROP INDEX `category_lang`"; $db->query($sql); $sql = "ALTER TABLE `" . table_categories . "` ADD UNIQUE `key` (`category_name`)"; $db->query($sql); $sql = "INSERT INTO `" . table_categories . "` VALUES (0, '" . $dblang . "', 0, 0, 'all', 'all', 0, 0, 2, 0, '000000');"; $db->query($sql); $sql = "UPDATE `" . table_categories . "` SET `category__auto_id` = '0' WHERE `category_name` = 'all' LIMIT 1;"; $db->query($sql); } include_once mnminclude . 'dbtree.php'; rebuild_the_tree(); ordernew();