function update_addFilemanager() { global $_CONF, $_TABLES; $configAdminId = DB_getItem($_TABLES['groups'], 'grp_id', "grp_name = 'Configuration Admin' "); $storyAdminId = DB_getItem($_TABLES['groups'], 'grp_id', "grp_name = 'Story Admin' "); // Add Filemanager Admin group DB_query("INSERT INTO {$_TABLES['groups']} (grp_id, grp_name, grp_descr, grp_gl_core) VALUES (null, 'Filemanager Admin', 'Has full access to File Manager', 1);"); $groupId = DB_insertId(); // Add features $featureIds = array(); DB_query("INSERT INTO {$_TABLES['features']} (ft_id, ft_name, ft_descr, ft_gl_core) VALUES (null, 'filemanager.admin', 'Ability to use File Manager', 0)"); $featureIds['filemanager.admin'] = DB_insertId(); DB_query("INSERT INTO {$_TABLES['features']} (ft_id, ft_name, ft_descr, ft_gl_core) VALUES (null, 'config.Filemanager.tab_general', 'Access to configure Filemanager General Settings', 0)"); $featureIds['config.Filemanager.tab_general'] = DB_insertId(); DB_query("INSERT INTO {$_TABLES['features']} (ft_id, ft_name, ft_descr, ft_gl_core) VALUES (null, 'config.Filemanager.tab_upload', 'Access to configure Filemanager Upload Settings', 0)"); $featureIds['config.Filemanager.tab_upload'] = DB_insertId(); DB_query("INSERT INTO {$_TABLES['features']} (ft_id, ft_name, ft_descr, ft_gl_core) VALUES (null, 'config.Filemanager.tab_images', 'Access to configure Filemanager Images Settings', 0)"); $featureIds['config.Filemanager.tab_images'] = DB_insertId(); DB_query("INSERT INTO {$_TABLES['features']} (ft_id, ft_name, ft_descr, ft_gl_core) VALUES (null, 'config.Filemanager.tab_videos', 'Access to configure Filemanager Videos Settings', 0)"); $featureIds['config.Filemanager.tab_videos'] = DB_insertId(); DB_query("INSERT INTO {$_TABLES['features']} (ft_id, ft_name, ft_descr, ft_gl_core) VALUES (null, 'config.Filemanager.tab_audios', 'Access to configure Filemanager Audios Settings', 0)"); $featureIds['config.Filemanager.tab_audios'] = DB_insertId(); // Add access rights DB_query("INSERT INTO {$_TABLES['access']} (acc_ft_id, acc_grp_id) VALUES ({$featureIds['filemanager.admin']}, {$groupId}) "); DB_query("INSERT INTO {$_TABLES['access']} (acc_ft_id, acc_grp_id) VALUES ({$featureIds['filemanager.admin']}, {$storyAdminId}) "); DB_query("INSERT INTO {$_TABLES['access']} (acc_ft_id, acc_grp_id) VALUES ({$featureIds['config.Filemanager.tab_general']}, {$configAdminId}) "); DB_query("INSERT INTO {$_TABLES['access']} (acc_ft_id, acc_grp_id) VALUES ({$featureIds['config.Filemanager.tab_upload']}, {$configAdminId}) "); DB_query("INSERT INTO {$_TABLES['access']} (acc_ft_id, acc_grp_id) VALUES ({$featureIds['config.Filemanager.tab_images']}, {$configAdminId}) "); DB_query("INSERT INTO {$_TABLES['access']} (acc_ft_id, acc_grp_id) VALUES ({$featureIds['config.Filemanager.tab_videos']}, {$configAdminId}) "); DB_query("INSERT INTO {$_TABLES['access']} (acc_ft_id, acc_grp_id) VALUES ({$featureIds['config.Filemanager.tab_audios']}, {$configAdminId}) "); // Add group assignment DB_query("INSERT INTO {$_TABLES['group_assignments']} (ug_main_grp_id, ug_uid, ug_grp_id) VALUES ({$groupId}, NULL, 1) "); }
/** * Puts the datastructures for this plugin into the Geeklog database * * @return boolean TRUE if successful FALSE otherwise */ function plugin_install_now() { global $pi_name, $pi_version, $gl_version, $pi_url, $NEWFEATURE; global $_TABLES, $_CONF; DB_query("INSERT INTO {$_TABLES['groups']} (grp_name, grp_descr) " . "VALUES ('{$pi_name} Admin', 'Users in this group can administer the {$pi_name} plugin')", 1); if (DB_error()) { COM_errorLog('failed insert groups table', 1); plugin_uninstall_nmoxtopicown(); return FALSE; } $group_id = DB_insertId(); DB_query("INSERT INTO {$_TABLES['vars']} VALUES ('{$pi_name}_admin', '{$group_id}')", 1); if (DB_error()) { COM_errorLog('failed insert vars table', 1); plugin_uninstall_nmoxtopicown(); return FALSE; } foreach ($NEWFEATURE as $feature => $desc) { DB_query("INSERT INTO {$_TABLES['features']} (ft_name, ft_descr) " . "VALUES ('{$feature}','{$desc}')", 1); if (DB_error()) { COM_errorLog('failed insert feature table', 1); plugin_uninstall_nmoxtopicown(); return FALSE; } $feat_id = DB_insertId(); DB_query("INSERT INTO {$_TABLES['access']} (acc_ft_id, acc_grp_id) VALUES ({$feat_id}, {$group_id})"); if (DB_error()) { COM_errorLog('failed insert access table', 1); plugin_uninstall_nmoxtopicown(); return FALSE; } } DB_query("INSERT INTO {$_TABLES['group_assignments']} VALUES ({$group_id}, NULL, 1)"); if (DB_error()) { COM_errorLog('failed insert group_assignments table', 1); plugin_uninstall_nmoxtopicown(); return FALSE; } DB_delete($_TABLES['plugins'], 'pi_name', 'nmoxtopicown'); DB_query("INSERT INTO {$_TABLES['plugins']} (pi_name, pi_version, pi_gl_version, pi_homepage, pi_enabled) " . "VALUES ('{$pi_name}', '{$pi_version}', '{$gl_version}', '{$pi_url}', 1)"); if (DB_error()) { COM_errorLog('failed insert plugin table', 1); plugin_uninstall_nmoxtopicown(); return FALSE; } return TRUE; }
/** * Add a file to the submission queue * * Most of the code in this function has been lifted from the File Management * plugin's submit.php * */ function submit_file($submitter, $filename, $title, $desc, $version, $homepage, $cid = 0) { global $_CONF, $_USER, $_FM_TABLES, $_FMDOWNLOAD, $filemgmt_FileStore; $myts = new MyTextSanitizer(); // MyTextSanitizer object $name = basename($filename); $url = rawurlencode($name); $name = $myts->makeTboxData4Save($name); $url = $myts->makeTboxData4Save($url); if (DB_count($_FM_TABLES['filemgmt_filedetail'], 'url', $name) > 0) { COM_errorLog("FM submit_file: file '" . $name . "' already exists in DB"); return false; } $title = $myts->makeTboxData4Save($title); $homepage = $myts->makeTboxData4Save($homepage); $version = $myts->makeTboxData4Save($version); $size = sprintf('%u', filesize($filename)); $description = $myts->makeTareaData4Save($desc); //$comments = ($_CONF['comment_code'] == 0) ? 1 : 0; $comments = 0; // prefer no comments on Geeklog tarballs $date = time(); $tmpfilename = randomfilename(); $uploadfilename = basename($filename); $pos = strrpos($uploadfilename, '.') + 1; $fileExtension = strtolower(substr($uploadfilename, $pos)); if (array_key_exists($fileExtension, $_FMDOWNLOAD)) { if ($_FMDOWNLOAD[$fileExtension] == 'reject') { COM_errorLog("FM submit_file: file extension '" . $fileExtension . "' not allowed."); return false; } $fileExtension = $_FMDOWNLOAD[$fileExtension]; $tmpfilename = $tmpfilename . '.' . $fileExtension; $pos = strrpos($url, '.') + 1; $url = strtolower(substr($url, 0, $pos)) . $fileExtension; } else { $tmpfilename = $tmpfilename . '.' . $fileExtension; } // would have preferred rename (i.e. move), but ran into file permission // problems on www.geeklog.net ... copy($filename, $filemgmt_FileStore . 'tmp/' . $tmpfilename); $logourl = ''; DB_query("INSERT INTO {$_FM_TABLES['filemgmt_filedetail']} (cid, title, url, homepage, version, size, platform, logourl, submitter, status, date, hits, rating, votes, comments) VALUES ('{$cid}', '{$title}', '{$url}', '{$homepage}', '{$version}', '{$size}', '{$tmpfilename}', '{$logourl}', '{$submitter}', 0, '{$date}', 0, 0, 0, '{$comments}')"); $newid = DB_insertId(); DB_query("INSERT INTO {$_FM_TABLES['filemgmt_filedesc']} (lid, description) VALUES ({$newid}, '{$description}')"); return true; }
/** * Add Language feature */ function update_addLanguage() { global $_TABLES; // Add `language_items` table $sql = "\nCREATE TABLE {$_TABLES['language_items']} (\n id INT(11) NOT NULL AUTO_INCREMENT,\n var_name VARCHAR(30) NOT NULL,\n language VARCHAR(30) NOT NULL,\n name VARCHAR(30) NOT NULL,\n value VARCHAR(255) NOT NULL DEFAULT '',\n PRIMARY KEY (id)\n) ENGINE=MyISAM\n"; DB_query($sql); // Add `Language Admin` group $sql = "INSERT INTO {$_TABLES['groups']} (grp_name, grp_descr, grp_gl_core) VALUES ('Language Admin', 'Has full access to language', 1);"; DB_query($sql, 1); $grpId = DB_insertId(); // Add `language.edit` feature $sql = "INSERT INTO {$_TABLES['features']} (ft_name, ft_descr, ft_gl_core) VALUES ('language.edit', 'Can manage Language Settings', 1)"; DB_query($sql, 1); $ftId = DB_insertId(); // Give `language.edit` feature to `Language Admin` group $sql = "INSERT INTO {$_TABLES['access']} (acc_ft_id, acc_grp_id) VALUES ({$ftId}, {$grpId}) "; DB_query($sql, 1); // Add Root users to `Language Admin` $sql = "INSERT INTO {$_TABLES['group_assignments']} (ug_main_grp_id, ug_uid, ug_grp_id) VALUES ({$grpId}, NULL, 1) "; DB_query($sql, 1); }
/** * Add is new security rights for the Group "XMLSitemap Admin" * */ function xmlsitemap_update_ConfigSecurity_1_0_0() { global $_TABLES; // Add in security rights for XMLSitemap Admin $group_id = DB_getItem($_TABLES['groups'], 'grp_id', "grp_name = 'XMLSitemap Admin'"); /* * For some time, from Geeklog 1.6.0 through to 1.7.0, we already had * an XMLSitemap Admin group in the database. It was dropped in 1.7.1 * but not removed from the database. This is now coming back to haunt * us ... We also need to remove the unused xmlsitemap.edit permission * while we're at it. */ if (empty($group_id)) { // cover: null, false, 0, etc. - doesn't exist yet // Add new Core Admin Group for Configuration DB_query("INSERT INTO {$_TABLES['groups']} (grp_name, grp_descr, grp_gl_core) VALUES ('XMLSitemap Admin', 'Has full access to XMLSitemap features', 0);"); $group_id = DB_insertId(); // Assign XMLSitemap Admin group to Root group DB_query("INSERT INTO {$_TABLES['group_assignments']} (ug_main_grp_id, ug_uid, ug_grp_id) VALUES ({$group_id}, NULL, 1)"); } else { // if the XMLSitemap Admin group already exists, then there will // probably also be a xmlsitemap.edit permission - remove it SEC_removeFeatureFromDB('xmlsitemap.edit'); } // now that we cleaned this up, add the new stuff if ($group_id > 0) { $ft_names[] = 'config.xmlsitemap.tab_main'; $ft_names[] = 'config.xmlsitemap.tab_pri'; $ft_names[] = 'config.xmlsitemap.tab_freq'; foreach ($ft_names as $name) { $ft_id = DB_getItem($_TABLES['features'], 'ft_id', "ft_name = '{$name}'"); if ($ft_id > 0) { $sql = "INSERT INTO {$_TABLES['access']} (acc_ft_id, acc_grp_id) VALUES ({$ft_id}, {$group_id})"; DB_query($sql); } } } }
/** * Install SpamX plugin (also handled updates from version 1.0) * */ function install_spamx_plugin() { global $_TABLES; $_SPX_TABLE = "CREATE TABLE {$_TABLES['spamx']} (" . " name varchar(20) NOT NULL default ''," . " value varchar(255) NOT NULL default ''," . " INDEX spamx_name (name)" . ") TYPE=MyISAM"; // SpamX plugin information, 'spamx.admin' feature, SpamX Admin group $_SPX_PLUGIN = "INSERT INTO {$_TABLES['plugins']} (pi_name, pi_version, pi_gl_version, pi_enabled, pi_homepage) VALUES ('spamx', '1.0.1','1.3.10',1,'http://www.pigstye.net/gplugs/staticpages/index.php/spamx') "; $_SPX_FEAT = "INSERT INTO {$_TABLES['features']} (ft_name, ft_descr, ft_gl_core) VALUES ('spamx.admin', 'spamx Admin', 0) "; $_SPX_ADMIN = "INSERT INTO {$_TABLES['groups']} (grp_name, grp_descr, grp_gl_core) VALUES ('spamx Admin', 'Users in this group can administer the spamx plugin',0) "; $group_id = DB_getItem($_TABLES['groups'], 'grp_id', "grp_name = 'spamx Admin'"); if ($group_id <= 0) { DB_query($_SPX_ADMIN); // add SpamX Admin group $group_id = DB_insertId(); } $feat_id = DB_getItem($_TABLES['features'], 'ft_id', "ft_name = 'spamx.admin'"); if ($feat_id <= 0) { DB_query($_SPX_FEAT); // add 'spamx.admin' feature $feat_id = DB_insertId(); } if (DB_getItem($_TABLES['access'], 'acc_grp_id', "acc_ft_id = {$feat_id}") != $group_id) { // add feature to spamx admin group DB_query("INSERT INTO {$_TABLES['access']} (acc_ft_id, acc_grp_id) VALUES ({$feat_id}, {$group_id})"); } if (DB_getItem($_TABLES['group_assignments'], 'ug_main_grp_id', "ug_uid = NULL AND ug_grp_id = 1") != $group_id) { // make Root group a member of the SpamX Admin group DB_query("INSERT INTO {$_TABLES['group_assignments']} VALUES ({$group_id}, NULL, 1)"); } $spxversion = get_SPX_Ver(); if ($spxversion == 0 || $spxversion == 1) { // delete plugin entry so that we can update it below DB_delete($_TABLES['plugins'], 'pi_name', 'spamx'); // create 'spamx' table DB_query($_SPX_TABLE); DB_query($_SPX_PLUGIN); // add entry to 'plugins' table } return true; }
/** * Puts the datastructures for this plugin into the Geeklog database * * Note: Corresponding uninstall routine is in functions.inc * * @return boolean True if successful False otherwise */ function plugin_install_dataproxy() { global $pi_name, $pi_version, $gl_version, $pi_url, $NEWTABLE, $DEFVALUES, $NEWFEATURE, $_TABLES, $_CONF; COM_errorLog("Attempting to install the {$pi_name} Plugin", 1); // Create the Plugins Tables foreach ($NEWTABLE as $table => $sql) { COM_errorLog("Creating {$table} table", 1); DB_query($sql, 1); if (DB_error()) { COM_errorLog("Error Creating {$table} table", 1); plugin_uninstall_dataproxy(); return false; } COM_errorLog("Success - Created {$table} table", 1); } // Insert Default Data foreach ($DEFVALUES as $table => $sqls) { COM_errorLog("Inserting default data into {$table} table", 1); foreach ($sqls as $sql) { DB_query($sql, 1); if (DB_error()) { COM_errorLog("Error inserting default data into {$table} table", 1); plugin_uninstall_dataproxy(); return false; } } COM_errorLog("Success - inserting data into {$table} table", 1); } // Create the plugin admin security group COM_errorLog("Attempting to create {$pi_name} admin group", 1); DB_query("INSERT INTO {$_TABLES['groups']} (grp_name, grp_descr) " . "VALUES ('{$pi_name} Admin', 'Users in this group can administer the {$pi_name} plugin')", 1); if (DB_error()) { plugin_uninstall_dataproxy(); return false; } COM_errorLog('...success', 1); $group_id = DB_insertId(); // Save the grp id for later uninstall COM_errorLog('About to save group_id to vars table for use during uninstall', 1); DB_query("INSERT INTO {$_TABLES['vars']} VALUES ('{$pi_name}_gid', '{$group_id}')", 1); if (DB_error()) { plugin_uninstall_dataproxy(); return false; } COM_errorLog('...success', 1); // Add plugin Features foreach ($NEWFEATURE as $feature => $desc) { COM_errorLog("Adding {$feature} feature", 1); DB_query("INSERT INTO {$_TABLES['features']} (ft_name, ft_descr) " . "VALUES ('{$feature}','{$desc}')", 1); if (DB_error()) { COM_errorLog("Failure adding {$feature} feature", 1); plugin_uninstall_dataproxy(); return false; } $feat_id = DB_insertId(); COM_errorLog('Success', 1); COM_errorLog("Adding {$feature} feature to admin group", 1); DB_query("INSERT INTO {$_TABLES['access']} (acc_ft_id, acc_grp_id) VALUES ('{$feat_id}', '{$group_id}')"); if (DB_error()) { COM_errorLog("Failure adding {$feature} feature to admin group", 1); plugin_uninstall_dataproxy(); return false; } COM_errorLog("Success", 1); } /** * OK, now give Root users access to this plugin now! * NOTE: Root group should always be 1 */ COM_errorLog("Attempting to give all users in Root group access to {$pi_name} admin group", 1); DB_query("INSERT INTO {$_TABLES['group_assignments']} VALUES ('{$group_id}', NULL, 1)"); if (DB_error()) { plugin_uninstall_dataproxy(); return false; } // Register the plugin with Geeklog COM_errorLog("Registering {$pi_name} plugin with Geeklog", 1); DB_delete($_TABLES['plugins'], 'pi_name', 'dataproxy'); DB_query("INSERT INTO {$_TABLES['plugins']} (pi_name, pi_version, pi_gl_version, pi_homepage, pi_enabled) " . "VALUES ('{$pi_name}', '{$pi_version}', '{$gl_version}', '{$pi_url}', 1)"); if (DB_error()) { plugin_uninstall_dataproxy(); return false; } COM_errorLog("Succesfully installed the {$pi_name} Plugin!", 1); return true; }
/** * Adds PHP blocks and scans all the items supported by the Tag plugin */ function plugin_postinstall_tag($pi_name) { global $_CONF, $_TABLES, $_USER, $_TAG_CONF, $LANG_TAG; require_once dirname(__FILE__) . '/functions.inc'; if (is_callable('COM_createHTMLDocument')) { // Adds a tag cloud block to the site $sql = "INSERT INTO {$_TABLES['blocks']} " . " (is_enabled, name, type, title, blockorder, onleft, " . " phpblockfn, owner_id, group_id, perm_owner, perm_group, " . " perm_members, perm_anon) " . "VALUES (1, '" . addslashes($_TAG_CONF['default_block_name']) . "', 'phpblock', '" . addslashes($LANG_TAG['default_block_title']) . "', 1, 0, 'phpblock_tag_cloud', '" . addslashes($_USER['uid']) . "', 1, 3, 3, 2, 2)"; DB_query($sql); $bid = DB_insertId(); $sql = "INSERT INTO {$_TABLES['topic_assignments']} " . " (tid, type, id, inherit, tdefault) " . "VALUES ('all', 'block', {$bid}, 1, 0) "; DB_query($sql); // Adds a tag menu block to the site $sql = "INSERT INTO {$_TABLES['blocks']} (is_enabled, name, type, title, " . " blockorder, onleft, phpblockfn, owner_id, group_id, " . " perm_owner, perm_group, perm_members, perm_anon) " . "VALUES (1, '" . addslashes($_TAG_CONF['default_block_name_menu']) . "', 'phpblock', '" . addslashes($LANG_TAG['default_block_title_menu']) . "', 1, 1, 'phpblock_tag_menu', '" . addslashes($_USER['uid']) . "', 1, 3, 3, 2, 2)"; DB_query($sql); $bid = DB_insertId(); $sql = "INSERT INTO {$_TABLES['topic_assignments']} " . " (tid, type, id, inherit, tdefault) " . "VALUES ('all', 'block', {$bid}, 1, 0) "; DB_query($sql); } else { // Adds a tag cloud block to the site $sql = "INSERT INTO {$_TABLES['blocks']} " . " (is_enabled, name, type, title, tid, blockorder, onleft, " . " phpblockfn, owner_id, group_id, perm_owner, perm_group, " . " perm_members, perm_anon) " . "VALUES (1, '" . addslashes($_TAG_CONF['default_block_name']) . "', 'phpblock', '" . addslashes($LANG_TAG['default_block_title']) . "', 'all', '1', '0', 'phpblock_tag_cloud', '" . addslashes($_USER['uid']) . "', '1', '3', '3', '2', '2')"; DB_query($sql); // Adds a tag menu block to the site $sql = "INSERT INTO {$_TABLES['blocks']} (is_enabled, name, type, title, " . " tid, blockorder, onleft, phpblockfn, owner_id, group_id, " . " perm_owner, perm_group, perm_members, perm_anon) " . "VALUES ('1', '" . addslashes($_TAG_CONF['default_block_name_menu']) . "', 'phpblock', '" . addslashes($LANG_TAG['default_block_title_menu']) . "', 'all', '1', '1', 'phpblock_tag_menu', '" . addslashes($_USER['uid']) . "', '1', '3', '3', '2', '2')"; DB_query($sql); } // Scans all contents for tags TAG_scanAll(); return TRUE; }
/** * Save a new category submitted with the event. * Returns the ID of the newly-added category, or of the existing * catgory if $cat_name is a duplicate. * * @param string $cat_name New category name. * @return integer ID of category */ public function SaveCategory($cat_name) { global $_TABLES; $cat_name = DB_escapeString($cat_name); // Make sure it's not a duplicate name. While we're at it, get // the category ID to return. $id = DB_getItem($_TABLES['evlist_categories'], 'id', "name='{$cat_name}'"); if (!$id) { DB_query("INSERT INTO {$_TABLES['evlist_categories']}\n (name, status)\n VALUES\n ('{$cat_name}', 1)"); if (!DB_error()) { $id = DB_insertId(); } } return $id; }
$charset = "abcdefghijklmnopqrstuvwxyz"; for ($i = 0; $i < 12; $i++) { $random_name .= $charset[mt_rand(0, strlen($charset) - 1)]; } $random_name .= '.' . $fileExtension; if (fm_uploadfile($directory, $random_name)) { if (!get_magic_quotes_gpc()) { $uploadfilename = addslashes($uploadfilename); } // Status of file record will default to 0 -- not online $sql = "INSERT INTO {$_TABLES['nxfile_filesubmissions']} "; $sql .= "(cid,fname,tempname,title,ftype,description,version_note,size,mimetype,extension,submitter,date,tags) "; $sql .= "VALUES ({$_CLEAN['cid']},'{$uploadfilename}','{$random_name}','{$_CLEAN['filetitle']}','file',"; $sql .= "'{$_CLEAN['description']}','{$_CLEAN['vernote']}','{$filesize}','{$mimetype}','{$fileExtension}','{$uid}','{$date}','{$_CLEAN['tags']}')"; DB_query($sql); $sid = DB_insertId(); PLG_itemSaved($sid, 'nexfile_filesubmission'); // Determine if any users that have upload.admin permission for this category // or nexfile admin rights should be notified of new file awaiting approval fm_sendAdminApprovalNofications($cid, $sid); fm_updateAuditLog("New upload submission, in Category: {$cid}"); $data['message'] = "File successfully uploaded and you will be notified once it's approved"; $data['error'] = 'File successfully uploaded'; $data['retcode'] = 200; } } else { $data['retcode'] = 400; $data['error'] = 'Error: You do not have upload permission for that folder'; } $retval = json_encode($data); break;
function INSTALLER_install_block($step, &$vars) { global $_TABLES, $_CONF, $_USER; COM_errorLog("AutoInstall: Creating block {$step['name']}..."); $is_enabled = isset($step['is_enabled']) ? intval($step['is_enabled']) : 1; $rdflimit = isset($step['rdflimit']) ? intval($step['rdflimit']) : 0; $onleft = isset($step['onleft']) ? intval($step['onleft']) : 0; $allow_autotags = isset($step['allow_autotags']) ? intval($step['allow_autotags']) : 0; $name = isset($step['name']) ? DB_escapeString($step['name']) : ''; $title = isset($step['title']) ? DB_escapeString($step['title']) : ''; $type = isset($step['block_type']) ? DB_escapeString($step['block_type']) : 'unknown'; $phpblockfn = isset($step['phpblockfn']) ? DB_escapeString($step['phpblockfn']) : ''; $help = isset($step['help']) ? DB_escapeString($step['help']) : ''; $content = isset($step['content']) ? DB_escapeString($step['content']) : ''; $blockorder = isset($step['blockorder']) ? intval($step['blockorder']) : 9999; $owner_id = isset($_USER['uid']) ? $_USER['uid'] : 2; $group_id = isset($vars[$step['group_id']]) ? $vars[$step['group_id']] : 1; list($perm_owner, $perm_group, $perm_members, $perm_anon) = $_CONF['default_permissions_block']; DB_query("INSERT INTO {$_TABLES['blocks']} " . "(is_enabled,name,type,title,tid,blockorder,content,allow_autotags,rdflimit,onleft,phpblockfn,help,owner_id,group_id,perm_owner,perm_group,perm_members,perm_anon)" . " VALUES ({$is_enabled},'{$name}','{$type}','{$title}','all',{$blockorder},'{$content}',{$allow_autotags},{$rdflimit},{$onleft},'{$phpblockfn}','{$help}',{$owner_id},{$group_id},{$perm_owner},{$perm_group},{$perm_members},{$perm_anon})", 1); if (DB_error()) { COM_errorLog("AutoInstall: Block creation failed!"); return 1; } $bid = DB_insertId(); if (isset($step['variable'])) { $vars[$step['variable']] = $bid; } return "DELETE FROM {$_TABLES['blocks']} WHERE bid = {$bid}"; }
/** * Upgrade to version 1.3.0 * Many changes in this version, so a function was created to * hold them all. * * @return boolean True on success, False on failure */ function evlist_upgrade_1_3_0() { global $_CONF, $_EV_CONF, $_TABLES, $_DB_dbms, $c, $CONF_EVLIST_DEFAULT; USES_evlist_class_event(); $c->add('default_view', $CONF_EVLIST_DEFAULT['default_view'], 'select', 0, 1, 14, 90, true, 'evlist'); $c->add('max_upcoming_days', $CONF_EVLIST_DEFAULT['max_upcoming_days'], 'text', 0, 1, 0, 100, true, 'evlist'); // Combine users allowed to add events into one variable $can_add = 0; if ($EV_CONF['allow_anon_add'] > 0) { $can_add += EV_ANON_CAN_ADD; } if ($EV_CONF['allow_user_add'] > 0) { $can_add += EV_USER_CAN_ADD; } $c->add('can_add', $can_add, 'select', 0, 1, 15, 20, true, 'evlist'); $c->del('allow_user_add', 'evlist'); $c->del('allow_anon_add', 'evlist'); // Add new options for plugin integration $c->add('use_locator', $CONF_EVLIST_DEFAULT['use_locator'], 'select', 0, 1, 0, 110, true, 'evlist'); $c->add('use_weather', $CONF_EVLIST_DEFAULT['use_weather'], 'select', 0, 1, 0, 120, true, 'evlist'); // Date & Time formats moved from the DB to simple $_CONF variables $format = DB_getItem($_TABLES['evlist_dateformat'], 'format', "id='{$_EV_CONF['date_format']}'"); if (empty($format)) { $format = '%a %b %d, %Y'; } $c->set_default('date_format', $format, 'evlist'); $c->set('date_format', $format, 'evlist'); $format = DB_getItem($_TABLES['evlist_timeformat'], 'format', "id='{$_EV_CONF['date_format']}'"); if (empty($format)) { $format = '%I:%M %p'; } $c->set_default('time_format', $format, 'evlist'); $c->set('time_format', $format, 'evlist'); DB_query("DROP TABLE {$_TABLES['evlist_dateformat']}"); DB_query("DROP TABLE {$_TABLES['evlist_timeformat']}"); // Change feature name DB_query("UPDATE {$_TABLES['features']}\n SET ft_name='evlist.admin' WHERE ft_name='evlist.edit'"); // Add new "submit" feature & map to Root group DB_query("INSERT INTO {$_TABLES['features']} (ft_name, ft_descr)\n VALUES ('evlist.submit', \n 'Allowed to bypass the evList submission queue')", 1); if (!DB_error()) { $ft_id = (int) DB_insertId(); if ($ft_id > 0) { DB_query("INSERT INTO {$_TABLES['access']} (acc_ft_id, acc_grp_id)\n VALUES('{$ft_id}', '1')"); } } EVLIST_do_upgrade_sql('1.3.0'); // Add the new fields to the event & submission tables /*$new_sql = "ADD det_id int(10) NOT NULL, ADD show_upcoming tinyint(1) unsigned NOT NULL DEFAULT '1', ADD cal_id int(10) unsigned NOT NULL DEFAULT '1', ADD options varchar(255)"; DB_query("ALTER TABLE {$_TABLES['evlist_events']} $new_sql"); DB_query("ALTER TABLE {$_TABLES['evlist_submissions']} $new_sql");*/ // Create the new tables /*DB_query($_SQL['evlist_repeat']); DB_query($_SQL['evlist_calendars']); DB_query($_SQL['evlist_detail']); DB_query($DEFVALUES['evlist_calendars']);*/ // Now split out the detail and create the repeats $result = DB_query("SELECT * FROM {$_TABLES['evlist_events']}"); $error = 0; while ($A = DB_fetchArray($result, false)) { $A = array_map('DB_escapeString', $A); $sql = "INSERT INTO {$_TABLES['evlist_detail']} (\n ev_id, title, summary, full_description, url, location,\n street, city, province, country, postal, contact,\n email, phone\n ) VALUES (\n '{$A['id']}', '{$A['title']}', '{$A['summary']}', \n '{$A['full_description']}', '{$A['url']}',\n '{$A['location']}', '{$A['street']}',\n '{$A['city']}', '{$A['province']}',\n '{$A['country']}', '{$A['postal']}',\n '{$A['contact']}', '{$A['email']}','{$A['phone']}'\n )"; DB_query($sql, 1); if (DB_error()) { $error = 1; break; } else { $DB_det_id = DB_insertID(); } $rec_data = array(); if ($A['recurring'] == 1) { $rec_data['type'] = $A['rec_option']; switch ($A['rec_option']) { case EV_RECUR_DAILY: case EV_RECUR_MONTHLY: case EV_RECUR_YEARLY: list($stop, $skip) = explode(';', $A['rec_data']); if (!empty($skip)) { $rec_data['skip'] = (int) $skip; } break; case EV_RECUR_WEEKLY: list($listdays, $stop) = explode(';', $A['rec_data']); $rec_data['listdays'] = explode(',', $listdays); break; case EV_RECUR_DOM: list($interval, $weekday, $stop) = explode(';', $A['rec_data']); $rec_data['weekday'] = $weekday; $rec_data['interval'] = $interval; break; case EV_RECUR_DATES: $rec_data['custom'] = explode(',', $A['rec_data']); $stop = 'XX'; // unused flag break; } // switch recurring type // Check the stop date for validity and format it properly if ($stop != 'XX') { if (strtotime($stop) > strtotime('2037-01-01') || $stop < '1970-01-01') { $stop = '2037-12-31'; } list($y, $m, $d) = explode('-', $stop); $rec_data['stop'] = sprintf('%d-%02d-%02d', $y, $m, $d); } } else { // not a recurring event $rec_data['type'] = 0; } $DB_rec_data = DB_escapeString(serialize($rec_data)); $sql = "UPDATE {$_TABLES['evlist_events']} SET\n rec_data = '{$DB_rec_data}',\n det_id = '{$DB_det_id}'\n WHERE id='{$A['id']}'"; DB_query($sql, 1); if (DB_error()) { $error = 1; break; } // Now that the updated info is saved to the event record, // use the evEvent class to create the repeats $Ev = new evEvent($A['id']); $Ev->UpdateRepeats(); } // for each event record if ($error == 0) { // Now drop the no-longer-used fields $alter_sql = "DROP title, DROP summary, DROP full_description,\n DROP date_start2, DROP date_end2,\n DROP url, DROP location, DROP street, DROP city,\n DROP province, DROP country, DROP postal, DROP contact,\n DROP email, DROP phone"; DB_query("ALTER TABLE {$_TABLES['evlist_events']} {$alter_sql}"); DB_query("ALTER TABLE {$_TABLES['evlist_submissions']} {$alter_sql}"); DB_query("ALTER TABLE {$_TABLES['evlist_remlookup']}\n DROP id,\n ADD rp_id int(10) unsigned NOT NULL default 0 AFTER eid,\n DROP date_start,\n DROP timestamp"); // Add new options. Set values to emulate current behavior. $options = array('contactlink' => 1); $opt_str = DB_escapeString(serialize($options)); DB_query("UPDATE {$_TABLES['evlist_events']} SET options='{$opt_str}'"); DB_query("UPDATE {$_TABLES['evlist_submissions']} SET options='{$opt_str}'"); } CTL_clearCache(); // Clear cache to activate new configuration items. return $error; }
/** * Save a trackback (or pingback) comment. * * Also filters parameters and handles multiple trackbacks from the same source. * * Note: Spam check should have been done before calling this function. * * @param string $sid entry id * @param string $type type of entry ('article' = story, etc.) * @param string $url URL of the trackback comment * @param string $title title of the comment (set to $url if empty) * @param string $blog name of the blog that sent the comment * @param string $excerpt excerpt from the comment * @return int < 0: error, > 0: ID of the trackback comment * */ function TRB_saveTrackbackComment($sid, $type, $url, $title = '', $blog = '', $excerpt = '') { global $_CONF, $_TABLES; $url = COM_applyFilter($url); $title = TRB_filterTitle($title); $blog = TRB_filterBlogname($blog); $excerpt = TRB_filterExcerpt($excerpt); // MT does that, so follow its example ... if (MBYTE_strlen($excerpt) > 255) { $excerpt = MBYTE_substr($excerpt, 0, 252) . '...'; } $title = str_replace(array('$', '{', '}'), array('$', '{', '~'), $title); $excerpt = str_replace(array('$', '{', '}'), array('$', '{', '~'), $excerpt); $blog = str_replace(array('$', '{', '}'), array('$', '{', '~'), $blog); $url = DB_escapeString($url); $title = DB_escapeString($title); $blog = DB_escapeString($blog); $excerpt = DB_escapeString($excerpt); if ($_CONF['multiple_trackbacks'] == 0) { // multiple trackbacks not allowed - check if we have this one already if (DB_count($_TABLES['trackback'], array('url', 'sid', 'type'), array($url, $sid, $type)) >= 1) { return TRB_SAVE_REJECT; } } else { if ($_CONF['multiple_trackbacks'] == 1) { // delete any earlier trackbacks from the same URL DB_delete($_TABLES['trackback'], array('url', 'sid', 'type'), array($url, $sid, $type)); } } // else: multiple trackbacks allowed DB_save($_TABLES['trackback'], 'sid,url,title,blog,excerpt,date,type,ipaddress', "'{$sid}','{$url}','{$title}','{$blog}','{$excerpt}',NOW(),'{$type}','{$_SERVER['REMOTE_ADDR']}'"); $comment_id = DB_insertId(); if ($type == 'article') { DB_query("UPDATE {$_TABLES['stories']} SET trackbacks = trackbacks + 1 WHERE (sid = '{$sid}')"); } return $comment_id; }
/** * Insert or update a calendar. * * @param array $A Array of data to save, typically from form */ public function Save($A = array()) { global $_TABLES, $_EV_CONF; if (is_array($A) && !empty($A)) { $this->SetVars($A); } if ($this->cat_id > 0) { $this->isNew = false; } else { $this->isNew = true; } $fld_sql = "name = '" . DB_escapeString($this->cat_name) . "',\n status = '{$this->cat_status}'"; if ($this->isNew) { $sql = "INSERT INTO {$_TABLES['evlist_categories']} SET \n {$fld_sql}"; } else { $sql = "UPDATE {$_TABLES['evlist_categories']} SET \n {$fld_sql}\n WHERE id='{$this->cat_id}'"; } //echo $sql;die; DB_query($sql, 1); if (!DB_error()) { if ($this->isNew) { $this->cat_id = DB_insertId(); } return true; } else { return false; } }
/** * Perform database upgrades * * @param string $current_gl_version Current glFusion version * @param boolean $use_innodb Whether or not to use InnoDB support with MySQL * @return boolean True if successful * */ function INST_doDatabaseUpgrades($current_fusion_version, $use_innodb = false) { global $_TABLES, $_CONF, $_SYSTEM, $_SP_CONF, $_DB, $_DB_dbms, $_DB_table_prefix, $LANG_AM, $dbconfig_path, $siteconfig_path, $html_path, $LANG_INSTALL; global $_GLFUSION; $rc = true; $errors = ''; $_DB->setDisplayError(true); // Because the upgrade sql syntax can vary from dbms-to-dbms we are // leaving that up to each glFusion database driver $progress = ''; switch ($current_fusion_version) { case '1.0.0': case '1.0.1': case '1.0.2': $_SQL = array(); if (!@file_exists($_CONF['path'] . 'sql/updates/mysql_1.0.1_to_1.1.0.php')) { echo _displayError(FILE_INCLUDE_ERROR, 'pathsetting'); exit; } require_once $_CONF['path'] . 'sql/updates/mysql_1.0.1_to_1.1.0.php'; list($rc, $errors) = INST_updateDB($_SQL); if ($rc === false) { return array($rc, $errors); } // index cleanup... $_SQLi = array(); $_SQLi[] = "ALTER TABLE {$_TABLES['blocks']} DROP INDEX blocks_bid"; $_SQLi[] = "ALTER TABLE {$_TABLES['events']} DROP INDEX events_eid"; $_SQLi[] = "ALTER TABLE {$_TABLES['group_assignments']} DROP INDEX ug_main_grp_id"; $_SQLi[] = "ALTER TABLE {$_TABLES['sessions']} DROP INDEX sess_id"; $_SQLi[] = "ALTER TABLE {$_TABLES['stories']} DROP INDEX stories_sid"; $_SQLi[] = "ALTER TABLE {$_TABLES['userindex']} DROP INDEX userindex_uid"; if (isset($_TABLES['polltopics'])) { $_SQLi[] = "ALTER TABLE {$_TABLES['polltopics']} DROP INDEX pollquestions_pid"; } foreach ($_SQLi as $sqli) { $rc = DB_query($sqli, 1); } $_SQLi = array(); if (!@file_exists($_CONF['path_system'] . 'classes/config.class.php')) { echo _displayError(FILE_INCLUDE_ERROR, 'pathsetting'); exit; } require_once $_CONF['path_system'] . 'classes/config.class.php'; $c = config::get_instance(); $c->add('comment_code', 0, 'select', 4, 21, 17, 1670, TRUE); $c->add('comment_edit', 0, 'select', 4, 21, 0, 1680, TRUE); $c->add('comment_edittime', 1800, 'text', 4, 21, NULL, 1690, TRUE); $c->add('article_comment_close_days', 30, 'text', 4, 21, NULL, 1700, TRUE); $c->add('comment_close_rec_stories', 0, 'text', 4, 21, NULL, 1710, TRUE); $c->add('image_lib', 'gdlib', 'select', 5, 22, 10, 1450, TRUE); $c->add('jhead_enabled', 0, 'select', 5, 22, 0, 1480, TRUE); $c->add('path_to_jhead', '', 'text', 5, 22, NULL, 1490, TRUE); $c->add('jpegtrans_enabled', 0, 'select', 5, 22, 0, 1500, TRUE); $c->add('path_to_jpegtrans', '', 'text', 5, 22, NULL, 1510, TRUE); $c->add('hide_adminmenu', TRUE, 'select', 3, 12, 1, 1170, TRUE); $c->add('fs_search', NULL, 'fieldset', 0, 6, NULL, 0, TRUE); $c->add('search_style', 'google', 'select', 0, 6, 18, 650, TRUE); $c->add('search_limits', '10,15,25,30', 'text', 0, 6, NULL, 660, TRUE); $c->add('num_search_results', 25, 'text', 0, 6, NULL, 670, TRUE); $c->add('search_show_limit', TRUE, 'select', 0, 6, 1, 680, TRUE); $c->add('search_show_sort', TRUE, 'select', 0, 6, 1, 690, TRUE); $c->add('search_show_num', TRUE, 'select', 0, 6, 1, 700, TRUE); $c->add('search_show_type', TRUE, 'select', 0, 6, 1, 710, TRUE); $c->add('search_show_user', TRUE, 'select', 0, 6, 1, 720, TRUE); $c->add('search_show_hits', TRUE, 'select', 0, 6, 1, 730, TRUE); $c->add('search_no_data', '<i>Not available...</i>', 'text', 0, 6, NULL, 740, TRUE); $c->add('search_separator', ' > ', 'text', 0, 6, NULL, 750, TRUE); $c->add('search_def_keytype', 'phrase', 'select', 0, 6, 19, 760, TRUE); $c->add('default_search_order', 'date', 'select', 0, 6, 22, 770, TRUE); $c->add('search_use_fulltext', FALSE, 'hidden', 0, 6); $c->add('mail_backend', 'mail', 'select', 0, 1, 20, 60, TRUE); $c->add('mail_sendmail_path', '', 'text', 0, 1, NULL, 70, TRUE); $c->add('mail_sendmail_args', '', 'text', 0, 1, NULL, 80, TRUE); $c->add('mail_smtp_host', '', 'text', 0, 1, NULL, 90, TRUE); $c->add('mail_smtp_port', '', 'text', 0, 1, NULL, 100, TRUE); $c->add('mail_smtp_auth', FALSE, 'select', 0, 1, 0, 110, TRUE); $c->add('mail_smtp_username', '', 'text', 0, 1, NULL, 120, TRUE); $c->add('mail_smtp_password', '', 'text', 0, 1, NULL, 130, TRUE); $c->add('mail_smtp_secure', 'none', 'select', 0, 1, 21, 140, TRUE); $c->add('compress_css', TRUE, 'select', 2, 11, 0, 1370, TRUE); $c->add('allow_embed_object', TRUE, 'select', 7, 34, 1, 1720, TRUE); $c->add('digg_enabled', 1, 'select', 1, 7, 0, 1235, TRUE); // now delete the old setting - we don't want it anymore... $c->del('mail_settings', 'Core'); $c->del('use_safe_html', 'Core'); $c->del('user_html', 'Core'); $c->del('admin_html', 'Core'); $c->del('allowed_protocols', 'Core'); DB_query("INSERT INTO {$_TABLES['vars']} SET value='1.1.0',name='glfusion'", 1); DB_query("UPDATE {$_TABLES['vars']} SET value='1.1.0' WHERE name='glfusion'", 1); $current_fusion_version = '1.1.0'; $_SQL = array(); case '1.1.0': case '1.1.1': if (!@file_exists($_CONF['path_system'] . 'classes/config.class.php')) { echo _displayError(FILE_INCLUDE_ERROR, 'pathsetting'); exit; } require_once $_CONF['path_system'] . 'classes/config.class.php'; $c = config::get_instance(); $c->add('story_submit_by_perm_only', 0, 'select', 4, 20, 0, 780, TRUE); $c->add('use_from_site_mail', 0, 'select', 0, 1, 0, 150, TRUE); $c->del('pdf_enabled', 'Core'); DB_query("INSERT INTO {$_TABLES['vars']} SET value='1.1.2',name='glfusion'", 1); DB_query("UPDATE {$_TABLES['vars']} SET value='1.1.2' WHERE name='glfusion'", 1); $current_fusion_version = '1.1.2'; case '1.1.2': $_SQL = array(); if (!@file_exists($_CONF['path'] . 'sql/updates/mysql_1.1.2_to_1.1.3.php')) { echo _displayError(FILE_INCLUDE_ERROR, 'pathsetting'); exit; } require_once $_CONF['path'] . 'sql/updates/mysql_1.1.2_to_1.1.3.php'; list($rc, $errors) = INST_updateDB($_SQL); if ($rc === false) { return array($rc, $errors); } if (!@file_exists($_CONF['path_system'] . 'classes/config.class.php')) { echo _displayError(FILE_INCLUDE_ERROR, 'pathsetting'); exit; } require_once $_CONF['path_system'] . 'classes/config.class.php'; $c = config::get_instance(); $c->add('hidestorydate', 0, 'select', 1, 7, 0, 1205, TRUE); $c->add('fs_caching', NULL, 'fieldset', 2, 12, NULL, 0, TRUE); $c->add('cache_templates', 1, 'select', 2, 12, 0, 1375, TRUE); $c->add('template_comments', FALSE, 'select', 2, 11, 0, 1373, TRUE); DB_query("INSERT INTO {$_TABLES['vars']} SET value='1.1.3',name='glfusion'", 1); DB_query("UPDATE {$_TABLES['vars']} SET value='1.1.3' WHERE name='glfusion'", 1); $current_fusion_version = '1.1.3'; case '1.1.3': $_SQL = array(); if (!@file_exists($_CONF['path'] . 'sql/updates/mysql_1.1.3_to_1.1.4.php')) { echo _displayError(FILE_INCLUDE_ERROR, 'pathsetting'); exit; } require_once $_CONF['path'] . 'sql/updates/mysql_1.1.3_to_1.1.4.php'; list($rc, $errors) = INST_updateDB($_SQL); if ($rc === false) { return array($rc, $errors); } DB_query("INSERT INTO {$_TABLES['vars']} SET value='1.1.4',name='glfusion'", 1); DB_query("UPDATE {$_TABLES['vars']} SET value='1.1.4' WHERE name='glfusion'", 1); DB_query("DELETE FROM {$_TABLES['vars']} WHERE name='database_version'", 1); $current_fusion_version = '1.1.4'; case '1.1.4': DB_query("ALTER TABLE {$_TABLES['stories']} DROP INDEX stories_in_transit", 1); DB_query("ALTER TABLE {$_TABLES['stories']} DROP COLUMN in_transit", 1); DB_query("ALTER TABLE {$_TABLES['userprefs']} ADD search_result_format VARCHAR( 48 ) NOT NULL DEFAULT 'google'", 1); DB_query("UPDATE {$_TABLES['conf_values']} SET type='text' WHERE name='mail_smtp_host'", 1); DB_query("UPDATE {$_TABLES['conf_values']} SET selectionArray='23' WHERE name='censormode'", 1); DB_query("INSERT INTO {$_TABLES['vars']} SET value='1.1.5',name='glfusion'", 1); DB_query("UPDATE {$_TABLES['vars']} SET value='1.1.5' WHERE name='glfusion'", 1); DB_query("DELETE FROM {$_TABLES['vars']} WHERE name='database_version'", 1); if (!@file_exists($_CONF['path_system'] . 'classes/config.class.php')) { echo _displayError(FILE_INCLUDE_ERROR, 'pathsetting'); exit; } require_once $_CONF['path_system'] . 'classes/config.class.php'; $c = config::get_instance(); $c->add('hide_exclude_content', 0, 'select', 4, 16, 0, 295, TRUE); $c->add('maintenance_mode', 0, 'select', 0, 0, 0, 520, TRUE); $c->del('search_show_limit', 'Core'); $c->del('search_show_sort', 'Core'); $_SQL = array(); if (!@file_exists($_CONF['path'] . 'sql/updates/mysql_1.1.4_to_1.1.5.php')) { echo _displayError(FILE_INCLUDE_ERROR, 'pathsetting'); exit; } require_once $_CONF['path'] . 'sql/updates/mysql_1.1.4_to_1.1.5.php'; list($rc, $errors) = INST_updateDB($_SQL); if ($rc === false) { return array($rc, $errors); } $current_fusion_version = '1.1.5'; case '1.1.5': DB_query("INSERT INTO {$_TABLES['vars']} SET value='1.1.6',name='glfusion'", 1); DB_query("UPDATE {$_TABLES['vars']} SET value='1.1.6' WHERE name='glfusion'", 1); DB_query("DELETE FROM {$_TABLES['vars']} WHERE name='database_version'", 1); $current_fusion_version = '1.1.6'; case '1.1.6': $_SQL = array(); if (!@file_exists($_CONF['path'] . 'sql/updates/mysql_1.1.6_to_1.1.7.php')) { echo _displayError(FILE_INCLUDE_ERROR, 'pathsetting'); exit; } require_once $_CONF['path'] . 'sql/updates/mysql_1.1.6_to_1.1.7.php'; list($rc, $errors) = INST_updateDB($_SQL); if ($rc === false) { return array($rc, $errors); } if (!@file_exists($_CONF['path_system'] . 'classes/config.class.php')) { echo _displayError(FILE_INCLUDE_ERROR, 'pathsetting'); exit; } require_once $_CONF['path_system'] . 'classes/config.class.php'; $c = config::get_instance(); $c->add('rating_enabled', 1, 'select', 1, 7, 24, 1237, TRUE); DB_query("INSERT INTO {$_TABLES['vars']} SET value='1.1.7',name='glfusion'", 1); DB_query("UPDATE {$_TABLES['vars']} SET value='1.1.7' WHERE name='glfusion'", 1); DB_query("DELETE FROM {$_TABLES['vars']} WHERE name='database_version'", 1); $current_fusion_version = '1.1.7'; case '1.1.7': require_once $_CONF['path_system'] . 'classes/config.class.php'; $c = config::get_instance(); $c->add('user_reg_fullname', 1, 'select', 4, 19, 25, 980, TRUE); DB_query("INSERT INTO {$_TABLES['vars']} SET value='1.1.8',name='glfusion'", 1); DB_query("UPDATE {$_TABLES['vars']} SET value='1.1.8' WHERE name='glfusion'", 1); DB_query("DELETE FROM {$_TABLES['vars']} WHERE name='database_version'", 1); $current_fusion_version = '1.1.8'; case '1.1.8': require_once $_CONF['path_system'] . 'classes/config.class.php'; $c = config::get_instance(); $c->add('article_comment_close_enabled', 0, 'select', 4, 21, 0, 1695, TRUE); $session_ip_check = 1; if (isset($_SYSTEM['skip_ip_check']) && $_SYSTEM['skip_ip_check'] == 1) { $session_ip_check = 0; } $c->add('session_ip_check', $session_ip_check, 'select', 7, 30, 26, 545, TRUE); $c->del('default_search_order', 'Core'); DB_query("UPDATE {$_TABLES['conf_values']} SET selectionArray = '0' WHERE name='searchloginrequired' AND group_name='Core'"); DB_query("ALTER TABLE {$_TABLES['groups']} ADD grp_default tinyint(1) unsigned NOT NULL default '0' AFTER grp_gl_core"); DB_query("ALTER TABLE {$_TABLES['users']} CHANGE `passwd` `passwd` VARCHAR( 40 ) NOT NULL default ''"); // clean up group names and assign proper admin setting DB_query("UPDATE {$_TABLES['groups']} SET grp_gl_core=2 WHERE grp_name='Bad Behavior2 Admin'", 1); DB_query("UPDATE {$_TABLES['groups']} SET grp_name='calendar Admin' WHERE grp_name='Calendar Admin'", 1); DB_query("UPDATE {$_TABLES['groups']} SET grp_gl_core=2 WHERE grp_name='calendar Admin'", 1); DB_query("UPDATE {$_TABLES['groups']} SET grp_gl_core=2 WHERE grp_name='filemgmt Admin'", 1); DB_query("UPDATE {$_TABLES['groups']} SET grp_gl_core=2 WHERE grp_name='forum Admin'", 1); DB_query("UPDATE {$_TABLES['groups']} SET grp_name='links Admin' WHERE grp_name='Links Admin'", 1); DB_query("UPDATE {$_TABLES['groups']} SET grp_gl_core=2 WHERE grp_name='links Admin'", 1); DB_query("UPDATE {$_TABLES['groups']} SET grp_gl_core=2 WHERE grp_name='mediagallery Admin'", 1); DB_query("UPDATE {$_TABLES['groups']} SET grp_name='polls Admin' WHERE grp_name='Polls Admin'", 1); DB_query("UPDATE {$_TABLES['groups']} SET grp_gl_core=2 WHERE grp_name='polls Admin'", 1); DB_query("UPDATE {$_TABLES['groups']} SET grp_gl_core=2 WHERE grp_name='sitetailor Admin'", 1); DB_query("UPDATE {$_TABLES['groups']} SET grp_name='staticpages Admin' WHERE grp_name='Static Page Admin'", 1); DB_query("UPDATE {$_TABLES['groups']} SET grp_gl_core=2 WHERE grp_name='staticpages Admin'", 1); DB_query("UPDATE {$_TABLES['groups']} SET grp_gl_core=2 WHERE grp_name='spamx Admin'", 1); // move multi-language support to its own fieldset DB_query("INSERT INTO {$_TABLES['conf_values']} (name,value,type,group_name,default_value,subgroup,selectionArray,sort_order,fieldset) VALUES ('fs_mulitlanguage','N;','fieldset','Core','N;',6,-1,0,41)", 1); DB_query("UPDATE {$_TABLES['conf_values']} SET fieldset='41' WHERE name='language_files' AND group_name='Core'", 1); DB_query("UPDATE {$_TABLES['conf_values']} SET fieldset='41' WHERE name='languages' AND group_name='Core'", 1); // topic sort DB_query("ALTER TABLE {$_TABLES['topics']} ADD sort_by TINYINT(1) NOT NULL DEFAULT '0' AFTER archive_flag", 1); DB_query("ALTER TABLE {$_TABLES['topics']} ADD sort_dir CHAR( 4 ) NOT NULL DEFAULT 'DESC' AFTER sort_by", 1); // new stats.view permission DB_query("INSERT INTO {$_TABLES['features']} (ft_name, ft_descr, ft_gl_core) VALUES ('stats.view','Allows access to the Stats page.',0)", 1); $ft_id = DB_insertId(); $all_grp_id = intval(DB_getItem($_TABLES['groups'], 'grp_id', "grp_name = 'All Users'")); $loggedin_grp_id = intval(DB_getItem($_TABLES['groups'], 'grp_id', "grp_name = 'Logged-in Users'")); $root_grp_id = intval(DB_getItem($_TABLES['groups'], 'grp_id', "grp_name = 'Root'")); if ($_CONF['statsloginrequired'] || $_CONF['loginrequired']) { DB_query("INSERT INTO {$_TABLES['access']} (acc_ft_id, acc_grp_id) VALUES ({$ft_id}, {$loggedin_grp_id})", 1); } else { DB_query("INSERT INTO {$_TABLES['access']} (acc_ft_id, acc_grp_id) VALUES ({$ft_id}, {$all_grp_id})", 1); } DB_query("INSERT INTO {$_TABLES['access']} (acc_ft_id, acc_grp_id) VALUES ({$ft_id}, {$root_grp_id})", 1); $c->del('statsloginrequired', 'Core'); $c->add('registration_type', 0, 'select', 4, 19, 27, 785, TRUE, 'Core'); DB_query("ALTER TABLE {$_TABLES['users']} ADD act_token VARCHAR(32) NOT NULL DEFAULT '' AFTER pwrequestid", 1); DB_query("ALTER TABLE {$_TABLES['users']} ADD act_time DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' AFTER act_token", 1); $c->del('cookie_ip', 'Core'); DB_query("ALTER TABLE {$_TABLES['sessions']} DROP PRIMARY KEY", 1); DB_query("ALTER TABLE {$_TABLES['sessions']} ADD PRIMARY KEY (md5_sess_id)", 1); $c->add('comment_postmode', 'plaintext', 'select', 4, 21, 5, 1693, TRUE); $c->add('comment_editor', 0, 'select', 4, 21, 28, 1694, TRUE); DB_query("INSERT INTO {$_TABLES['vars']} SET value='1.2.0',name='glfusion'", 1); DB_query("UPDATE {$_TABLES['vars']} SET value='1.2.0' WHERE name='glfusion'", 1); DB_query("DELETE FROM {$_TABLES['vars']} WHERE name='database_version'", 1); $current_fusion_version = '1.2.0'; case '1.2.0': DB_query("INSERT INTO {$_TABLES['vars']} SET value='1.2.1',name='glfusion'", 1); DB_query("UPDATE {$_TABLES['vars']} SET value='1.2.1' WHERE name='glfusion'", 1); DB_query("DELETE FROM {$_TABLES['vars']} WHERE name='database_version'", 1); $current_fusion_version = '1.2.1'; case '1.2.1': case '1.2.2': case '1.2.3': require_once $_CONF['path'] . 'sql/updates/mysql_1.2.2_to_1.3.0.php'; list($rc, $errors) = INST_updateDB($_SQL); if ($rc === false) { return array($rc, $errors); } require_once $_CONF['path_system'] . 'classes/config.class.php'; $c = config::get_instance(); // logo $c->add('fs_logo', NULL, 'fieldset', 5, 28, NULL, 0, TRUE); $c->add('max_logo_height', 150, 'text', 5, 28, NULL, 1630, TRUE); $c->add('max_logo_width', 500, 'text', 5, 28, NULL, 1640, TRUE); // whats new cache time $c->add('whatsnew_cache_time', 3600, 'text', 3, 15, NULL, 1060, TRUE); // add user photo option to whosonline block $c->add('whosonline_photo', FALSE, 'select', 3, 14, 0, 930, TRUE); // remove old wikitext configuration $c->del('wikitext_editor', 'Core'); // add oauth user_login_method $c->del('user_login_method', 'Core'); // delete microsummary $c->del('microsummary_short', 'Core'); $standard = $_CONF['user_login_method']['standard'] ? true : false; $openid = $_CONF['user_login_method']['openid'] ? true : false; $thirdparty = $_CONF['user_login_method']['3rdparty'] ? true : false; // OAuth configuration settings $oauth = false; $c->add('user_login_method', array('standard' => $standard, 'openid' => $openid, '3rdparty' => $thirdparty, 'oauth' => $oauth), '@select', 4, 16, 1, 320, TRUE); $c->add('facebook_login', 0, 'select', 4, 16, 1, 330, TRUE); $c->add('facebook_consumer_key', 'not configured yet', 'text', 4, 16, NULL, 335, TRUE); $c->add('facebook_consumer_secret', 'not configured yet', 'text', 4, 16, NULL, 340, TRUE); $c->add('linkedin_login', 0, 'select', 4, 16, 1, 345, TRUE); $c->add('linkedin_consumer_key', 'not configured yet', 'text', 4, 16, NULL, 350, TRUE); $c->add('linkedin_consumer_secret', 'not configured yet', 'text', 4, 16, NULL, 355, TRUE); $c->add('twitter_login', 0, 'select', 4, 16, 1, 360, TRUE); $c->add('twitter_consumer_key', 'not configured yet', 'text', 4, 16, NULL, 365, TRUE); $c->add('twitter_consumer_secret', 'not configured yet', 'text', 4, 16, NULL, 370, TRUE); $c->add('google_login', 0, 'select', 4, 16, 1, 375, TRUE); $c->add('google_consumer_key', 'not configured yet', 'text', 4, 16, NULL, 380, TRUE); $c->add('google_consumer_secret', 'not configured yet', 'text', 4, 16, NULL, 385, TRUE); $c->add('microsoft_login', 0, 'select', 4, 16, 1, 390, TRUE); $c->add('microsoft_consumer_key', 'not configured yet', 'text', 4, 16, NULL, 395, TRUE); $c->add('microsoft_consumer_secret', 'not configured yet', 'text', 4, 16, NULL, 400, TRUE); // date / time format changes $c->add('date', 'l, F d Y @ h:i A T', 'text', 6, 29, NULL, 370, TRUE); $c->add('daytime', 'm/d h:iA', 'text', 6, 29, NULL, 380, TRUE); $c->add('shortdate', 'm/d/y', 'text', 6, 29, NULL, 390, TRUE); $c->add('dateonly', 'd-M', 'text', 6, 29, NULL, 400, TRUE); $c->add('timeonly', 'H:iA', 'text', 6, 29, NULL, 410, TRUE); // hide what's new if empty $c->add('hideemptyblock', 0, 'select', 3, 15, 0, 1045, TRUE); // update check $c->add('fs_update', NULL, 'fieldset', 0, 7, NULL, 0, TRUE); $c->add('update_check_interval', '86400', 'select', 0, 7, 29, 765, TRUE); $c->add('send_site_data', TRUE, 'select', 0, 7, 1, 770, TRUE); // rating $c->add('fs_rating', NULL, 'fieldset', 4, 7, NULL, 0, TRUE); $c->add('rating_speedlimit', 15, 'text', 4, 7, NULL, 10, TRUE); // add new logo.admin permission $result = DB_query("SELECT * FROM {$_TABLES['features']} WHERE ft_name='logo.admin'"); if (DB_numRows($result) == 0) { DB_query("INSERT INTO {$_TABLES['features']} (ft_name, ft_descr, ft_gl_core) VALUES ('logo.admin','Ability to modify site logo',1)", 1); $ft_id = DB_insertId(); $grp_id = (int) DB_getItem($_TABLES['groups'], 'grp_id', "grp_name = 'Root'"); DB_query("INSERT INTO {$_TABLES['access']} (acc_ft_id, acc_grp_id) VALUES ({$ft_id}, {$grp_id})", 1); } // add new menu.admin permission $result = DB_query("SELECT * FROM {$_TABLES['features']} WHERE ft_name='menu.admin'"); if (DB_numRows($result) == 0) { DB_query("INSERT INTO {$_TABLES['features']} (ft_name, ft_descr, ft_gl_core) VALUES ('menu.admin','Ability to create/edit site menus',1)", 1); $ft_id = DB_insertId(); $grp_id = (int) DB_getItem($_TABLES['groups'], 'grp_id', "grp_name = 'Root'"); DB_query("INSERT INTO {$_TABLES['access']} (acc_ft_id, acc_grp_id) VALUES ({$ft_id}, {$grp_id})", 1); } // add new autotag features $autotag_admin_ft_id = 0; $autotag_php_ft_id = 0; $autotag_group_id = 0; $tmp_admin_ft_id = DB_getItem($_TABLES['features'], 'ft_id', "ft_name = 'autotag.admin'"); if (empty($tmp_admin_ft_id)) { DB_query("INSERT INTO {$_TABLES['features']} (ft_name, ft_descr, ft_gl_core) VALUES ('autotag.admin','Ability to create / edit autotags',1)", 1); $autotag_admin_ft_id = DB_insertId(); } $tmp_php_ft_id = DB_getItem($_TABLES['features'], 'ft_id', "ft_name = 'autotag.PHP'"); if (empty($tmp_php_ft_id)) { DB_query("INSERT INTO {$_TABLES['features']} (ft_name, ft_descr, ft_gl_core) VALUES ('autotag.PHP','Ability to create / edit autotags utilizing PHP functions',1)", 1); $autotag_php_ft_id = DB_insertId(); } // now check for the group $result = DB_query("SELECT * FROM {$_TABLES['groups']} WHERE grp_name='Autotag Admin'"); if (DB_numRows($result) == 0) { DB_query("INSERT INTO {$_TABLES['groups']} (grp_name, grp_descr, grp_gl_core, grp_default) VALUES ('Autotag Admin','Has full access to create and modify autotags',1,0)"); $autotag_group_id = DB_insertId(); } if ($autotag_admin_ft_id != 0 && $autotag_group_id != 0) { DB_query("INSERT INTO {$_TABLES['access']} (acc_ft_id, acc_grp_id) VALUES (" . $autotag_admin_ft_id . "," . $autotag_group_id . ")"); } if ($autotag_php_ft_id != 0 && $autotag_group_id != 0) { DB_query("INSERT INTO {$_TABLES['access']} (acc_ft_id, acc_grp_id) VALUES (" . $autotag_php_ft_id . "," . $autotag_group_id . ")"); } if ($autotag_group_id != 0) { DB_query("INSERT INTO {$_TABLES['group_assignments']} (ug_main_grp_id,ug_grp_id) VALUES (" . $autotag_group_id . ",1)"); } DB_query("INSERT INTO {$_TABLES['vars']} SET value='1.3.0',name='glfusion'", 1); DB_query("UPDATE {$_TABLES['vars']} SET value='1.3.0' WHERE name='glfusion'", 1); DB_query("DELETE FROM {$_TABLES['vars']} WHERE name='database_version'", 1); $current_fusion_version = '1.3.0'; case '1.3.0': $current_fusion_version = '1.3.1'; case '1.3.1': require_once $_CONF['path_system'] . 'classes/config.class.php'; $c = config::get_instance(); $current_fusion_version = '1.3.2'; case '1.3.2': require_once $_CONF['path_system'] . 'classes/config.class.php'; $c = config::get_instance(); // remove menu_elements - no longer used $c->del('menu_elements', 'Core'); $c->del('mailstory_postmode', 'Core'); $c->del('comment_editor', 'Core'); $c->del('advanced_editor', 'Core'); if (!isset($_CONF['mailuser_postmode'])) { $c->add('mailuser_postmode', 'html', 'select', 4, 5, 5, 43, TRUE); } // set the initial set of html elements if (!isset($_CONF['htmlfilter_comment'])) { $c->add('htmlfilter_default', 'p,b,a,i,strong,em,br', 'text', 7, 5, NULL, 30, true); $c->add('htmlfilter_comment', 'p,b,a,i,strong,em,br,tt,hr,li,ol,ul,code,pre', 'text', 7, 5, NULL, 35, TRUE); $c->add('htmlfilter_story', 'div[class],h1,h2,h3,pre,br,p[style],b[style],s,strong[style],i[style],em[style],u[style],strike,a[style|href|title|target],ol[style|class],ul[style|class],li[style|class],hr[style],blockquote[style],img[style|alt|title|width|height|src|align],table[style|width|bgcolor|align|cellspacing|cellpadding|border],tr[style],td[style],th[style],tbody,thead,caption,col,colgroup,span[style|class],sup,sub', 'text', 7, 5, NULL, 40, TRUE); $c->add('htmlfilter_root', 'div[style|class],span[style|class],table,tr,td,th', 'text', 7, 5, NULL, 50, TRUE); } $sql = "REPLACE INTO {$_TABLES['autotags']} (tag, description, is_enabled, is_function, replacement) VALUES ('youtube', 'Embed Youtube videos into content. Usage:[youtube:ID height:px width:px align:left/right/center pad:px]', 1, 1, NULL)"; DB_query($sql, 1); $current_fusion_version = '1.4.0'; case '1.4.0': require_once $_CONF['path_system'] . 'classes/config.class.php'; $c = config::get_instance(); $c->add('github_login', 0, 'select', 4, 1, 1, 271, TRUE); $c->add('github_consumer_key', 'not configured yet', 'text', 4, 1, NULL, 272, TRUE); $c->add('github_consumer_secret', 'not configured yet', 'text', 4, 1, NULL, 273, TRUE); $current_fusion_version = '1.4.1'; case '1.4.1': require_once $_CONF['path_system'] . 'classes/config.class.php'; $c = config::get_instance(); $current_fusion_version = '1.4.2'; case '1.4.2': require_once $_CONF['path_system'] . 'classes/config.class.php'; $c = config::get_instance(); $c->add('min_username_length', '4', 'text', 4, 4, NULL, 60, TRUE); $current_fusion_version = '1.4.3'; case '1.4.3': $_SQL[] = "ALTER TABLE {$_TABLES['stories']} ADD `alternate_tid` VARCHAR(20) NULL DEFAULT NULL AFTER `tid`, ADD INDEX `alternate_topic` (`alternate_tid`) ;"; $_SQL[] = "ALTER TABLE {$_TABLES['tokens']} CHANGE `urlfor` `urlfor` VARCHAR( 1024 ) NOT NULL"; $_SQL[] = "ALTER TABLE {$_TABLES['comments']} CHANGE `ipaddress` `ipaddress` VARCHAR( 45 ) NOT NULL DEFAULT ''"; $_SQL[] = "ALTER TABLE {$_TABLES['rating_votes']} CHANGE `ip_address` `ip_address` VARCHAR( 45 ) NOT NULL"; $_SQL[] = "ALTER TABLE {$_TABLES['sessions']} CHANGE `remote_ip` `remote_ip` VARCHAR( 45 ) NOT NULL DEFAULT ''"; $_SQL[] = "ALTER TABLE {$_TABLES['trackback']} `ipaddress` `ipaddress` VARCHAR( 45 ) NOT NULL DEFAULT ''"; $_SQL[] = "ALTER TABLE {$_TABLES['users']} CHANGE `remote_ip` `remote_ip` VARCHAR( 45 ) NOT NULL DEFAULT ''"; $_SQL[] = "ALTER TABLE {$_TABLES['topics']} CHANGE `tid` `tid` VARCHAR(128) NOT NULL DEFAULT '';"; $_SQL[] = "ALTER TABLE {$_TABLES['topics']} CHANGE `topic` `topic` VARCHAR(128) NULL DEFAULT NULL;"; $_SQL[] = "ALTER TABLE {$_TABLES['stories']} CHANGE `tid` `tid` VARCHAR(128) NOT NULL DEFAULT 'General';"; $_SQL[] = "ALTER TABLE {$_TABLES['stories']} CHANGE `alternate_tid` `alternate_tid` VARCHAR(128) NULL DEFAULT NULL;"; $_SQL[] = "ALTER TABLE {$_TABLES['blocks']} CHANGE `tid` `tid` VARCHAR(128) NOT NULL DEFAULT 'All';"; $_SQL[] = "ALTER TABLE {$_TABLES['storysubmission']} CHANGE `tid` `tid` VARCHAR(128) NOT NULL DEFAULT 'General';"; foreach ($_SQL as $sql) { DB_query($sql, 1); } $result = DB_query("SELECT * FROM {$_TABLES['autotags']} WHERE tag='uikitlogin'"); if (DB_numRows($result) < 1) { $sql = "INSERT INTO {$_TABLES['autotags']} (`tag`, `description`, `is_enabled`, `is_function`, `replacement`) VALUES ('uikitlogin', 'UIKit Login Widget', '1', '1', NULL);"; DB_query($sql, 1); } require_once $_CONF['path_system'] . 'classes/config.class.php'; $c = config::get_instance(); $current_fusion_version = '1.5.0'; case '1.5.0': $_SQL[] = "ALTER TABLE {$_TABLES['article_images']} CHANGE `ai_sid` `ai_sid` VARCHAR(128);"; $_SQL[] = "ALTER TABLE {$_TABLES['comments']} CHANGE `sid` `sid` VARCHAR(128);"; $_SQL[] = "ALTER TABLE {$_TABLES['stories']} CHANGE `sid` `sid` VARCHAR(128);"; $_SQL[] = "ALTER TABLE {$_TABLES['storysubmission']} CHANGE `sid` `sid` VARCHAR(128);"; $_SQL[] = "ALTER TABLE {$_TABLES['syndication']} CHANGE `topic` `topic` VARCHAR(128);"; $_SQL[] = "ALTER TABLE {$_TABLES['trackback']} CHANGE `sid` `sid` VARCHAR(128);"; foreach ($_SQL as $sql) { DB_query($sql, 1); } $current_fusion_version = '1.5.1'; case '1.5.1': $current_fusion_version = '1.5.2'; default: DB_query("INSERT INTO {$_TABLES['vars']} SET value='" . $current_fusion_version . "',name='glfusion'", 1); DB_query("UPDATE {$_TABLES['vars']} SET value='" . $current_fusion_version . "' WHERE name='glfusion'", 1); DB_query("DELETE FROM {$_TABLES['vars']} WHERE name='database_version'", 1); break; } DB_query("ALTER TABLE {$_TABLES['userprefs']} ADD search_result_format VARCHAR( 48 ) NOT NULL DEFAULT 'google'", 1); // delete the security check flag on every update to force the user // to run admin/sectest.php again DB_delete($_TABLES['vars'], 'name', 'security_check'); INST_resyncConfig(); return array($rc, $errors); }
/** * Puts the datastructures for this plugin into the Geeklog database * Note: Corresponding uninstall routine is in functions.inc * @return boolean True if successful False otherwise * @ignore */ function plugin_install_external() { global $pi_name, $NEWTABLE, $_CONF_EXP, $DEFVALUES, $NEWFEATURE, $_TABLES, $_CONF; COM_errorLog("Attempting to install the {$pi_name} Plugin", 1); // Create the Plugins Tables foreach ($NEWTABLE as $table => $sql) { COM_errorLog("Creating {$table} table", 1); DB_query($sql, 1); if (DB_error()) { COM_errorLog("Error Creating {$table} table", 1); PLG_uninstall($pi_name); return false; exit; } COM_errorLog("Success - Created {$table} table", 1); } // Insert Default Data /*foreach ($DEFVALUES as $table => $sql) { COM_errorLog("Inserting default data into $table table",1); DB_query($sql,1); if (DB_error()) { COM_errorLog("Error inserting default data into $table table",1); PLG_uninstall($pi_name); return false; exit; } COM_errorLog("Success - inserting data into $table table",1); }*/ // Create the plugin admin security group COM_errorLog("Attempting to create {$pi_name} admin group", 1); DB_query("INSERT INTO {$_TABLES['groups']} (\n grp_name, \n grp_descr) \n VALUES (\n '{$pi_name} Admin', \n 'Users in this group can administer the {$pi_name} plugin')", 1); if (DB_error()) { PLG_uninstall($pi_name); return false; exit; } COM_errorLog('...success', 1); $group_id = DB_insertId(); // Save the grp id for later uninstall COM_errorLog('About to save group_id to vars table for use during uninstall', 1); DB_query("INSERT INTO {$_TABLES['vars']} \n VALUES ('{$pi_name}_gid', {$group_id})", 1); if (DB_error()) { PLG_uninstall($pi_name); return false; exit; } COM_errorLog('...success', 1); // Add plugin Features foreach ($NEWFEATURE as $feature => $desc) { COM_errorLog("Adding {$feature} feature", 1); DB_query("INSERT INTO {$_TABLES['features']} \n (ft_name, ft_descr) \n VALUES \n ('{$feature}','{$desc}')", 1); if (DB_error()) { COM_errorLog("Failure adding {$feature} feature", 1); PLG_uninstall($pi_name); return false; exit; } $feat_id = DB_insertId(); COM_errorLog("Success", 1); COM_errorLog("Adding {$feature} feature to admin group", 1); DB_query("INSERT INTO {$_TABLES['access']} \n (acc_ft_id, acc_grp_id) \n VALUES \n ({$feat_id}, {$group_id})"); if (DB_error()) { COM_errorLog("Failure adding {$feature} feature to admin group", 1); PLG_uninstall($pi_name); return false; exit; } COM_errorLog("Success", 1); } // OK, now give Root users access to this plugin now! NOTE: Root group should always be 1 COM_errorLog("Attempting to give all users in Root group access to {$pi_name} admin group", 1); DB_query("INSERT INTO {$_TABLES['group_assignments']} \n VALUES ({$group_id}, NULL, 1)"); if (DB_error()) { PLG_uninstall($pi_name); return false; exit; } // Load the online configuration records if (!plugin_initconfig_external($group_id)) { PLG_uninstall($pi_name); return false; } // Register the plugin with Geeklog COM_errorLog("Registering {$pi_name} plugin with Geeklog", 1); DB_delete($_TABLES['plugins'], 'pi_name', 'external'); DB_query("INSERT INTO {$_TABLES['plugins']} (\n pi_name, \n pi_version, \n pi_gl_version, \n pi_homepage, \n pi_enabled) \n VALUES (\n '{$_CONF_EXP['pi_name']}', \n '{$_CONF_EXP['pi_version']}', \n '{$_CONF_EXP['gl_version']}', \n '{$_CONF_EXP['pi_url']}', \n 1)"); if (DB_error()) { PLG_uninstall($pi_name); return false; exit; } COM_errorLog("Succesfully installed the {$pi_name} Plugin!", 1); return true; }
/** * Puts the datastructures for this plugin into the Geeklog database * */ function plugin_install_now() { global $_CONF, $_TABLES, $_USER, $_DB_dbms, $GROUPS, $FEATURES, $MAPPINGS, $DEFVALUES, $base_path, $pi_name, $pi_display_name, $pi_version, $gl_version, $pi_url; COM_errorLog("Attempting to install the {$pi_display_name} plugin", 1); // create the plugin's groups $admin_group_id = 0; foreach ($GROUPS as $name => $desc) { COM_errorLog("Attempting to create {$name} group", 1); $grp_name = addslashes($name); $grp_desc = addslashes($desc); DB_query("INSERT INTO {$_TABLES['groups']} (grp_name, grp_descr) VALUES ('{$grp_name}', '{$grp_desc}')", 1); if (DB_error()) { PLG_uninstall($pi_name); return false; } // replace the description with the new group id so we can use it later $GROUPS[$name] = DB_insertId(); // assume that the first group is the plugin's Admin group if ($admin_group_id == 0) { $admin_group_id = $GROUPS[$name]; } } // Create the plugin's table(s) $_SQL = array(); if (file_exists($base_path . 'sql/' . $_DB_dbms . '_install.php')) { require_once $base_path . 'sql/' . $_DB_dbms . '_install.php'; } if (count($_SQL) > 0) { $use_innodb = false; if ($_DB_dbms == 'mysql' && DB_getItem($_TABLES['vars'], 'value', "name = 'database_engine'") == 'InnoDB') { $use_innodb = true; } foreach ($_SQL as $sql) { $sql = str_replace('#group#', $admin_group_id, $sql); if ($use_innodb) { $sql = str_replace('MyISAM', 'InnoDB', $sql); } DB_query($sql); if (DB_error()) { COM_errorLog('Error creating table', 1); PLG_uninstall($pi_name); return false; } } } // Add the plugin's features COM_errorLog("Attempting to add {$pi_display_name} feature(s)", 1); foreach ($FEATURES as $feature => $desc) { $ft_name = addslashes($feature); $ft_desc = addslashes($desc); DB_query("INSERT INTO {$_TABLES['features']} (ft_name, ft_descr) " . "VALUES ('{$ft_name}', '{$ft_desc}')", 1); if (DB_error()) { PLG_uninstall($pi_name); return false; } $feat_id = DB_insertId(); if (isset($MAPPINGS[$feature])) { foreach ($MAPPINGS[$feature] as $group) { COM_errorLog("Adding {$feature} feature to the {$group} group", 1); DB_query("INSERT INTO {$_TABLES['access']} (acc_ft_id, acc_grp_id) VALUES ({$feat_id}, {$GROUPS[$group]})"); if (DB_error()) { PLG_uninstall($pi_name); return false; } } } } // Add plugin's Admin group to the Root user group // (assumes that the Root group's ID is always 1) COM_errorLog("Attempting to give all users in the Root group access to the {$pi_display_name}'s Admin group", 1); DB_query("INSERT INTO {$_TABLES['group_assignments']} VALUES " . "({$admin_group_id}, NULL, 1)"); if (DB_error()) { PLG_uninstall($pi_name); return false; } // Pre-populate tables or run any other SQL queries COM_errorLog('Inserting default data', 1); foreach ($DEFVALUES as $sql) { $sql = str_replace('#group#', $admin_group_id, $sql); DB_query($sql, 1); if (DB_error()) { PLG_uninstall($pi_name); return false; } } // Load the online configuration records if (function_exists('plugin_load_configuration')) { if (!plugin_load_configuration()) { PLG_uninstall($pi_name); return false; } } // Finally, register the plugin with Geeklog COM_errorLog("Registering {$pi_display_name} plugin with Geeklog", 1); // silently delete an existing entry DB_delete($_TABLES['plugins'], 'pi_name', $pi_name); DB_query("INSERT INTO {$_TABLES['plugins']} (pi_name, pi_version, pi_gl_version, pi_homepage, pi_enabled) VALUES " . "('{$pi_name}', '{$pi_version}', '{$gl_version}', '{$pi_url}', 1)"); if (DB_error()) { PLG_uninstall($pi_name); return false; } // give the plugin a chance to perform any post-install operations if (function_exists('plugin_postinstall')) { if (!plugin_postinstall()) { PLG_uninstall($pi_name); return false; } } COM_errorLog("Successfully installed the {$pi_display_name} plugin!", 1); return true; }
/** * Save feed. * * @param array $A * @return string HTML redirect on success or feed editor + error message * */ function FEED_save($A) { global $_CONF, $_TABLES, $LANG33; foreach ($A as $name => $value) { $A[$name] = $value; } if ($A['is_enabled'] == 'on') { $A['is_enabled'] = 1; } else { $A['is_enabled'] = 0; } if (empty($A['title']) || empty($A['description']) || empty($A['filename'])) { $retval = COM_siteHeader('menu', $LANG33[38]) . COM_showMessageText($LANG33[39], $LANG33[38], true) . FEED_edit($A['fid'], $A['type']) . COM_siteFooter(); return $retval; } $result = DB_query("SELECT COUNT(*) AS count FROM {$_TABLES['syndication']} WHERE filename = '{$A['filename']}' AND (fid <> '{$A['fid']}')"); $C = DB_fetchArray($result); if ($C['count'] > 0) { $retval = COM_siteHeader('menu', $LANG33[52]) . COM_showMessageText($LANG33[51], $LANG33[52], true) . FEED_edit($A['fid'], $A['type']) . COM_siteFooter(); return $retval; } if ($A['limits'] <= 0) { $retval = COM_siteHeader('menu', $LANG33[38]) . COM_showMessageText($LANG33[40], $LANG33[38], true) . FEED_edit($A['fid'], $A['type']) . COM_siteFooter(); return $retval; } if ($A['limits_in'] == 1) { $A['limits'] .= 'h'; } // we can compensate if these are missing ... if (empty($A['charset'])) { $A['charset'] = $_CONF['default_charset']; if (empty($A['charset'])) { $A['charset'] = 'UTF-8'; } } if (empty($A['language'])) { $A['language'] = $_CONF['rdf_language']; if (empty($A['language'])) { $A['language'] = $_CONF['locale']; } } if (empty($A['content_length']) || $A['content_length'] < 0) { $A['content_length'] = 0; } foreach ($A as $name => $value) { $A[$name] = DB_escapeString($value); } DB_save($_TABLES['syndication'], 'fid,type,topic,header_tid,format,limits,content_length,title,description,feedlogo,filename,charset,language,is_enabled,updated,update_info', "{$A['fid']},'{$A['type']}','{$A['topic']}','{$A['header_tid']}','{$A['format']}','{$A['limits']}',{$A['content_length']},'{$A['title']}','{$A['description']}','{$A['feedlogo']}','{$A['filename']}','{$A['charset']}','{$A['language']}',{$A['is_enabled']},'1000-01-01 00:00:00',NULL"); if ($A['fid'] == 0) { $A['fid'] = DB_insertId(); } SYND_updateFeed($A['fid']); CACHE_remove_instance('story'); COM_setMessage(58); return COM_refresh($_CONF['site_admin_url'] . '/syndication.php'); }
function nexdocsrv_approveFileSubmission($id) { global $_TABLES, $_CONF, $_FMCONF; $query = DB_query("SELECT fid,cid,fname,tempname,title,description,tags,ftype,size,version,version_note,submitter,date,version_ctl,notify FROM {$_TABLES['nxfile_filesubmissions']} WHERE id={$id}"); list($fid, $cid, $fname, $tmpname, $title, $description, $tags, $ftype, $fsize, $version, $verNote, $submitter, $date, $versionmgmt, $notify) = DB_fetchARRAY($query); $data = array(); // Check if there have been multiple submission requests for the same file and thus have same new version # if ($version == 1) { if ($ftype == 'file') { $curfile = "{$_FMCONF['storage_path']}{$cid}/submissions/{$tmpname}"; $newfile = "{$_FMCONF['storage_path']}{$cid}/{$fname}"; $rename = @rename($curfile, $newfile); } DB_query("INSERT INTO {$_TABLES['nxfile_files']} (cid,fname,title,version,ftype,size,submitter,status,date,version_ctl)\r\n VALUES ('{$cid}','{$fname}','{$title}','1','{$ftype}','{$fsize}','{$submitter}',1,'{$date}','{$versionmgmt}')"); $newfid = DB_insertId(); DB_query("INSERT INTO {$_TABLES['nxfile_filedetail']} (fid,description,hits,rating,votes,comments)\r\n VALUES ('{$newfid}','{$description}',0,0,0,0)"); DB_query("INSERT INTO {$_TABLES['nxfile_fileversions']} (fid,fname,ftype,version,notes,size,date,uid,status)\r\n VALUES ('{$newfid}','{$uploadfilename}','{$ftype}','1','{$verNote}','{$fsize}','{$date}','{$submitter}',1)"); } else { // Need to rename the current versioned file if ($ftype == 'file') { $curfile = $_CONF['path_html'] . 'nexfile/data/' . $cid . '/submissions/' . $tmpname; $newfile = $_CONF['path_html'] . 'nexfile/data/' . $cid . '/' . $fname; $rename = @rename($curfile, $newfile); } DB_query("INSERT INTO {$_TABLES['nxfile_fileversions']} (fid,fname,ftype,version,notes,size,date,uid,status)\r\n VALUES ('{$fid}','{$fname}','{$ftype}','{$version}','{$verNote}','{$fsize}','{$date}','{$submitter}','1')"); DB_query("UPDATE {$_TABLES['nxfile_files']} SET fname='{$fname}',version='{$version}', date='{$date}' WHERE fid={$fid}"); $newfid = $fid; } if ($newfid > 0) { $tagcloud = new nexfileTagCloud(); // Update tags table and return tags formated as required $tagcloud->update_tags($newfid, $tags); // Send out notifications of approval fm_sendNotification($newfid, "2"); DB_query("DELETE FROM {$_TABLES['nxfile_filesubmissions']} WHERE id={$id}"); // Optionally add notification records and send out notifications to all users with view access to this new file if (DB_getItem($_TABLES['nxfile_categories'], 'auto_create_notifications', "cid='{$cid}'") == 1) { fm_autoCreateNotifications($fid, $cid); } // Send out notifications of update to all subscribed users fm_sendNotification($newfid, "1"); return true; } else { return false; } }
$retval .= "<status>200</status>\n"; $retval .= "<op>{$op}</op>\n"; switch ($op) { case 'save_new_task': $steptype = COM_applyFilter($_POST['steptype']); $offsetLeft = intval($_POST['offsetleft']); $offsetTop = intval($_POST['offsettop']); $templateid = intval($_POST['templateid']); $stepid = DB_getItem($_TABLES['nf_steptype'], 'id', "stepType LIKE '{$steptype}'"); $logicalid = intval(DB_getItem($_TABLES['nf_templatedata'], 'logicalID', "nf_templateID={$templateid} ORDER BY logicalID DESC LIMIT 1")); $logicalid++; $sql = "INSERT INTO {$_TABLES['nf_templatedata']} "; $sql .= "(nf_templateID, taskname, offsetLeft, offsetTop, logicalID, nf_stepType) "; $sql .= "VALUES ({$templateid}, 'New Task', {$offsetLeft}, {$offsetTop}, {$logicalid}, {$stepid})"; $res = DB_Query($sql); $taskid = intval(DB_insertId()); $retval .= "<taskid>{$taskid}</taskid>\n"; break; case 'save_task_lines': $type = intval($_POST['type']); $from = intval($_POST['startid']); if ($type == 1) { $toTrue = intval($_POST['endid']); $toFalse = 0; } else { $toTrue = 0; $toFalse = intval($_POST['endid']); } //get current next steps for this task $sql = "INSERT INTO {$_TABLES['nf_templatedatanextstep']} "; $sql .= "(nf_templateDataFrom, nf_templateDataTo, nf_templateDataToFalse) ";
function doImport() { global $_TABLES, $_CONF; $_ARR = array(); $importsql = $_CONF['path_html'] . 'admin/plugins/nexflow/export/nexflow_export.sql'; require_once $importsql; //we now have the entire dump of data into a usable array for us to import. $sql = $_ARR['template']; $res = DB_query($sql); if (DB_error()) { COM_errorLog("executing " . current($_SQL)); COM_errorLog("Error executing SQL", 1); exit; } $newTemplateID = DB_insertId(); //now do the variables $len = count($_ARR['variables']); for ($cntr = 0; $cntr < $len; $cntr++) { $sql = $_ARR['variables'][$cntr]['SQL']; $sql = str_replace('{templateID}', $newTemplateID, $sql); $res = DB_query($sql); if (DB_error()) { COM_errorLog("executing " . current($_SQL)); COM_errorLog("Error executing SQL", 1); exit; } $insertid = DB_insertId(); $_ARR['variables'][$cntr]['newid'] = $insertid; } //now do the template data $len = count($_ARR['templatedata']); for ($cntr = 0; $cntr < $len; $cntr++) { $sql = $_ARR['templatedata'][$cntr]['SQL']; $sql = str_replace('{templateID}', $newTemplateID, $sql); $pattern = '/{argumentvariable:[^}]*./'; $sql = performVariableMatch($sql, $pattern, "{argumentvariable:'", '', $_ARR); $pattern = '/{dynamicformvariable:[^}]*./'; $sql = performVariableMatch($sql, $pattern, "{dynamicformvariable:'", '', $_ARR); $pattern = '/{dynamictasknamevariable:[^}]*./'; $sql = performVariableMatch($sql, $pattern, "{dynamictasknamevariable:'", '', $_ARR); $res = DB_query($sql); if (DB_error()) { COM_errorLog("executing " . current($_SQL)); COM_errorLog("Error executing SQL", 1); exit; } $insertid = DB_insertId(); $_ARR['templatedata'][$cntr]['newid'] = "{$insertid}"; } //now do the nextStep values $len = count($_ARR['nextstep']); for ($cntr = 0; $cntr < $len; $cntr++) { $sql = $_ARR['nextstep'][$cntr]['SQL']; $pattern = '/{from:[^}]*./'; $sql = performVariableMatch($sql, $pattern, "{from:'", 'templatedataid', $_ARR); $pattern = '/{to:[^}]*./'; $sql = performVariableMatch($sql, $pattern, "{to:'", 'templatedataid', $_ARR); $pattern = '/{false:[^}]*./'; $sql = performVariableMatch($sql, $pattern, "{false:'", 'templatedataid', $_ARR); $res = DB_query($sql); if (DB_error()) { COM_errorLog("executing " . current($_SQL)); COM_errorLog("Error executing SQL", 1); exit; } $insertid = DB_insertId(); $_ARR['nextstep'][$cntr]['newid'] = "{$insertid}"; } //now do the assignment values $len = count($_ARR['assignments']); for ($cntr = 0; $cntr < $len; $cntr++) { $sql = $_ARR['assignments'][$cntr]['SQL']; $pattern = '/{templatedataid:[^}]*./'; $sql = performVariableMatch($sql, $pattern, "{templatedataid:'", 'templatedataid', $_ARR); $pattern = '/{processvariable:[^}]*./'; $sql = performVariableMatch($sql, $pattern, "{processvariable:'", '', $_ARR); $pattern = '/{prenotifyvariable:[^}]*./'; $sql = performVariableMatch($sql, $pattern, "{prenotifyvariable:'", '', $_ARR); $pattern = '/{postnotifyvariable:[^}]*./'; $sql = performVariableMatch($sql, $pattern, "{postnotifyvariable:'", '', $_ARR); $pattern = '/{remindernotifyvariable:[^}]*./'; $sql = performVariableMatch($sql, $pattern, "{remindernotifyvariable:'", '', $_ARR); $res = DB_query($sql); if (DB_error()) { COM_errorLog("executing " . current($_SQL)); COM_errorLog("Error executing SQL", 1); exit; } $insertid = DB_insertId(); $_ARR['assignments'][$cntr]['newid'] = "{$insertid}"; } }
function MB_saveNewMenu() { global $_CONF, $_TABLES, $_GROUPS, $LANG_MB; $errors = 0; $errMsg = ''; // sanity check if (!isset($_POST['menuname']) || $_POST['menuname'] == '') { $errors++; $errMsg .= $LANG_MB['menu_name_error']; } else { $menuname = COM_applyFilter($_POST['menuname']); if (strstr($menuname, ' ') !== FALSE) { $errors++; $errMsg .= $LANG_MB['menu_name_space'] . '<br/>'; } $existing_id = DB_getItem($_TABLES['menu'], 'id', 'menu_name="' . DB_escapeString($menuname) . '"'); if ($existing_id > 0) { $errors++; $errMsg .= $LANG_MB['menu_name_exits']; } } if ($errors > 0) { return $errMsg; } $menuname = DB_escapeString(COM_applyFilter($_POST['menuname'])); $menutype = COM_applyFilter($_POST['menutype'], true); $menuactive = isset($_POST['menuactive']) ? COM_applyFilter($_POST['menuactive'], true) : 0; $menugroup = COM_applyFilter($_POST['group'], true); $sqlFieldList = 'menu_name,menu_type,menu_active,group_id'; $sqlDataValues = "'{$menuname}',{$menutype},{$menuactive},{$menugroup}"; DB_save($_TABLES['menu'], $sqlFieldList, $sqlDataValues); $menu_id = DB_insertId(); CACHE_remove_instance('menu'); CACHE_remove_instance('css'); $randID = rand(); DB_save($_TABLES['vars'], 'name,value', "'cacheid',{$randID}"); return ''; }
/** * Perform database upgrades * * @param string $current_gl_version Current glFusion version * @param boolean $use_innodb Whether or not to use InnoDB support with MySQL * @return boolean True if successful * */ function INST_doDatabaseUpgrades($current_fusion_version, $use_innodb = false) { global $_TABLES, $_CONF, $_SYSTEM, $_SP_CONF, $_DB, $_DB_dbms, $_DB_table_prefix, $LANG_AM, $dbconfig_path, $siteconfig_path, $html_path, $LANG_INSTALL; global $_GLFUSION; $rc = true; $errors = ''; $_DB->setDisplayError(true); // Because the upgrade sql syntax can vary from dbms-to-dbms we are // leaving that up to each glFusion database driver $progress = ''; switch ($current_fusion_version) { case '1.0.0': case '1.0.1': case '1.0.2': $_SQL = array(); if (!@file_exists($_CONF['path'] . 'sql/updates/mysql_1.0.1_to_1.1.0.php')) { echo _displayError(FILE_INCLUDE_ERROR, 'pathsetting'); exit; } require_once $_CONF['path'] . 'sql/updates/mysql_1.0.1_to_1.1.0.php'; list($rc, $errors) = INST_updateDB($_SQL); if ($rc === false) { return array($rc, $errors); } // index cleanup... $_SQLi = array(); $_SQLi[] = "ALTER TABLE {$_TABLES['blocks']} DROP INDEX blocks_bid"; $_SQLi[] = "ALTER TABLE {$_TABLES['events']} DROP INDEX events_eid"; $_SQLi[] = "ALTER TABLE {$_TABLES['group_assignments']} DROP INDEX ug_main_grp_id"; $_SQLi[] = "ALTER TABLE {$_TABLES['sessions']} DROP INDEX sess_id"; $_SQLi[] = "ALTER TABLE {$_TABLES['stories']} DROP INDEX stories_sid"; $_SQLi[] = "ALTER TABLE {$_TABLES['userindex']} DROP INDEX userindex_uid"; if (isset($_TABLES['polltopics'])) { $_SQLi[] = "ALTER TABLE {$_TABLES['polltopics']} DROP INDEX pollquestions_pid"; } foreach ($_SQLi as $sqli) { $rc = DB_query($sqli, 1); } $_SQLi = array(); if (!@file_exists($_CONF['path_system'] . 'classes/config.class.php')) { echo _displayError(FILE_INCLUDE_ERROR, 'pathsetting'); exit; } require_once $_CONF['path_system'] . 'classes/config.class.php'; $c = config::get_instance(); $c->add('comment_code', 0, 'select', 4, 21, 17, 1670, TRUE); $c->add('comment_edit', 0, 'select', 4, 21, 0, 1680, TRUE); $c->add('comment_edittime', 1800, 'text', 4, 21, NULL, 1690, TRUE); $c->add('article_comment_close_days', 30, 'text', 4, 21, NULL, 1700, TRUE); $c->add('comment_close_rec_stories', 0, 'text', 4, 21, NULL, 1710, TRUE); $c->add('image_lib', 'gdlib', 'select', 5, 22, 10, 1450, TRUE); $c->add('jhead_enabled', 0, 'select', 5, 22, 0, 1480, TRUE); $c->add('path_to_jhead', '', 'text', 5, 22, NULL, 1490, TRUE); $c->add('jpegtrans_enabled', 0, 'select', 5, 22, 0, 1500, TRUE); $c->add('path_to_jpegtrans', '', 'text', 5, 22, NULL, 1510, TRUE); $c->add('hide_adminmenu', TRUE, 'select', 3, 12, 1, 1170, TRUE); $c->add('fs_search', NULL, 'fieldset', 0, 6, NULL, 0, TRUE); $c->add('search_style', 'google', 'select', 0, 6, 18, 650, TRUE); $c->add('search_limits', '10,15,25,30', 'text', 0, 6, NULL, 660, TRUE); $c->add('num_search_results', 25, 'text', 0, 6, NULL, 670, TRUE); $c->add('search_show_limit', TRUE, 'select', 0, 6, 1, 680, TRUE); $c->add('search_show_sort', TRUE, 'select', 0, 6, 1, 690, TRUE); $c->add('search_show_num', TRUE, 'select', 0, 6, 1, 700, TRUE); $c->add('search_show_type', TRUE, 'select', 0, 6, 1, 710, TRUE); $c->add('search_show_user', TRUE, 'select', 0, 6, 1, 720, TRUE); $c->add('search_show_hits', TRUE, 'select', 0, 6, 1, 730, TRUE); $c->add('search_no_data', '<i>Not available...</i>', 'text', 0, 6, NULL, 740, TRUE); $c->add('search_separator', ' > ', 'text', 0, 6, NULL, 750, TRUE); $c->add('search_def_keytype', 'phrase', 'select', 0, 6, 19, 760, TRUE); $c->add('default_search_order', 'date', 'select', 0, 6, 22, 770, TRUE); $c->add('search_use_fulltext', FALSE, 'hidden', 0, 6); $c->add('mail_backend', 'mail', 'select', 0, 1, 20, 60, TRUE); $c->add('mail_sendmail_path', '', 'text', 0, 1, NULL, 70, TRUE); $c->add('mail_sendmail_args', '', 'text', 0, 1, NULL, 80, TRUE); $c->add('mail_smtp_host', '', 'text', 0, 1, NULL, 90, TRUE); $c->add('mail_smtp_port', '', 'text', 0, 1, NULL, 100, TRUE); $c->add('mail_smtp_auth', FALSE, 'select', 0, 1, 0, 110, TRUE); $c->add('mail_smtp_username', '', 'text', 0, 1, NULL, 120, TRUE); $c->add('mail_smtp_password', '', 'text', 0, 1, NULL, 130, TRUE); $c->add('mail_smtp_secure', 'none', 'select', 0, 1, 21, 140, TRUE); $c->add('compress_css', TRUE, 'select', 2, 11, 0, 1370, TRUE); $c->add('allow_embed_object', TRUE, 'select', 7, 34, 1, 1720, TRUE); $c->add('digg_enabled', 1, 'select', 1, 7, 0, 1235, TRUE); // now delete the old setting - we don't want it anymore... $c->del('mail_settings', 'Core'); $c->del('use_safe_html', 'Core'); $c->del('user_html', 'Core'); $c->del('admin_html', 'Core'); $c->del('allowed_protocols', 'Core'); DB_query("INSERT INTO {$_TABLES['vars']} SET value='1.1.0',name='glfusion'", 1); DB_query("UPDATE {$_TABLES['vars']} SET value='1.1.0' WHERE name='glfusion'", 1); $current_fusion_version = '1.1.0'; $_SQL = array(); case '1.1.0': case '1.1.1': if (!@file_exists($_CONF['path_system'] . 'classes/config.class.php')) { echo _displayError(FILE_INCLUDE_ERROR, 'pathsetting'); exit; } require_once $_CONF['path_system'] . 'classes/config.class.php'; $c = config::get_instance(); $c->add('story_submit_by_perm_only', 0, 'select', 4, 20, 0, 780, TRUE); $c->add('use_from_site_mail', 0, 'select', 0, 1, 0, 150, TRUE); $c->del('pdf_enabled', 'Core'); DB_query("INSERT INTO {$_TABLES['vars']} SET value='1.1.2',name='glfusion'", 1); DB_query("UPDATE {$_TABLES['vars']} SET value='1.1.2' WHERE name='glfusion'", 1); $current_fusion_version = '1.1.2'; case '1.1.2': $_SQL = array(); if (!@file_exists($_CONF['path'] . 'sql/updates/mysql_1.1.2_to_1.1.3.php')) { echo _displayError(FILE_INCLUDE_ERROR, 'pathsetting'); exit; } require_once $_CONF['path'] . 'sql/updates/mysql_1.1.2_to_1.1.3.php'; list($rc, $errors) = INST_updateDB($_SQL); if ($rc === false) { return array($rc, $errors); } if (!@file_exists($_CONF['path_system'] . 'classes/config.class.php')) { echo _displayError(FILE_INCLUDE_ERROR, 'pathsetting'); exit; } require_once $_CONF['path_system'] . 'classes/config.class.php'; $c = config::get_instance(); $c->add('hidestorydate', 0, 'select', 1, 7, 0, 1205, TRUE); $c->add('fs_caching', NULL, 'fieldset', 2, 12, NULL, 0, TRUE); $c->add('cache_templates', 1, 'select', 2, 12, 0, 1375, TRUE); $c->add('template_comments', FALSE, 'select', 2, 11, 0, 1373, TRUE); DB_query("INSERT INTO {$_TABLES['vars']} SET value='1.1.3',name='glfusion'", 1); DB_query("UPDATE {$_TABLES['vars']} SET value='1.1.3' WHERE name='glfusion'", 1); $current_fusion_version = '1.1.3'; case '1.1.3': $_SQL = array(); if (!@file_exists($_CONF['path'] . 'sql/updates/mysql_1.1.3_to_1.1.4.php')) { echo _displayError(FILE_INCLUDE_ERROR, 'pathsetting'); exit; } require_once $_CONF['path'] . 'sql/updates/mysql_1.1.3_to_1.1.4.php'; list($rc, $errors) = INST_updateDB($_SQL); if ($rc === false) { return array($rc, $errors); } DB_query("INSERT INTO {$_TABLES['vars']} SET value='1.1.4',name='glfusion'", 1); DB_query("UPDATE {$_TABLES['vars']} SET value='1.1.4' WHERE name='glfusion'", 1); DB_query("DELETE FROM {$_TABLES['vars']} WHERE name='database_version'", 1); $current_fusion_version = '1.1.4'; case '1.1.4': DB_query("ALTER TABLE {$_TABLES['stories']} DROP INDEX stories_in_transit", 1); DB_query("ALTER TABLE {$_TABLES['stories']} DROP COLUMN in_transit", 1); DB_query("ALTER TABLE {$_TABLES['userprefs']} ADD search_result_format VARCHAR( 48 ) NOT NULL DEFAULT 'google'", 1); DB_query("UPDATE {$_TABLES['conf_values']} SET type='text' WHERE name='mail_smtp_host'", 1); DB_query("UPDATE {$_TABLES['conf_values']} SET selectionArray='23' WHERE name='censormode'", 1); DB_query("INSERT INTO {$_TABLES['vars']} SET value='1.1.5',name='glfusion'", 1); DB_query("UPDATE {$_TABLES['vars']} SET value='1.1.5' WHERE name='glfusion'", 1); DB_query("DELETE FROM {$_TABLES['vars']} WHERE name='database_version'", 1); if (!@file_exists($_CONF['path_system'] . 'classes/config.class.php')) { echo _displayError(FILE_INCLUDE_ERROR, 'pathsetting'); exit; } require_once $_CONF['path_system'] . 'classes/config.class.php'; $c = config::get_instance(); $c->add('hide_exclude_content', 0, 'select', 4, 16, 0, 295, TRUE); $c->add('maintenance_mode', 0, 'select', 0, 0, 0, 520, TRUE); $c->del('search_show_limit', 'Core'); $c->del('search_show_sort', 'Core'); $_SQL = array(); if (!@file_exists($_CONF['path'] . 'sql/updates/mysql_1.1.4_to_1.1.5.php')) { echo _displayError(FILE_INCLUDE_ERROR, 'pathsetting'); exit; } require_once $_CONF['path'] . 'sql/updates/mysql_1.1.4_to_1.1.5.php'; list($rc, $errors) = INST_updateDB($_SQL); if ($rc === false) { return array($rc, $errors); } $current_fusion_version = '1.1.5'; case '1.1.5': DB_query("INSERT INTO {$_TABLES['vars']} SET value='1.1.6',name='glfusion'", 1); DB_query("UPDATE {$_TABLES['vars']} SET value='1.1.6' WHERE name='glfusion'", 1); DB_query("DELETE FROM {$_TABLES['vars']} WHERE name='database_version'", 1); $current_fusion_version = '1.1.6'; case '1.1.6': $_SQL = array(); if (!@file_exists($_CONF['path'] . 'sql/updates/mysql_1.1.6_to_1.1.7.php')) { echo _displayError(FILE_INCLUDE_ERROR, 'pathsetting'); exit; } require_once $_CONF['path'] . 'sql/updates/mysql_1.1.6_to_1.1.7.php'; list($rc, $errors) = INST_updateDB($_SQL); if ($rc === false) { return array($rc, $errors); } if (!@file_exists($_CONF['path_system'] . 'classes/config.class.php')) { echo _displayError(FILE_INCLUDE_ERROR, 'pathsetting'); exit; } require_once $_CONF['path_system'] . 'classes/config.class.php'; $c = config::get_instance(); $c->add('rating_enabled', 1, 'select', 1, 7, 24, 1237, TRUE); DB_query("INSERT INTO {$_TABLES['vars']} SET value='1.1.7',name='glfusion'", 1); DB_query("UPDATE {$_TABLES['vars']} SET value='1.1.7' WHERE name='glfusion'", 1); DB_query("DELETE FROM {$_TABLES['vars']} WHERE name='database_version'", 1); $current_fusion_version = '1.1.7'; case '1.1.7': require_once $_CONF['path_system'] . 'classes/config.class.php'; $c = config::get_instance(); $c->add('user_reg_fullname', 1, 'select', 4, 19, 25, 980, TRUE); DB_query("INSERT INTO {$_TABLES['vars']} SET value='1.1.8',name='glfusion'", 1); DB_query("UPDATE {$_TABLES['vars']} SET value='1.1.8' WHERE name='glfusion'", 1); DB_query("DELETE FROM {$_TABLES['vars']} WHERE name='database_version'", 1); $current_fusion_version = '1.1.8'; case '1.1.8': require_once $_CONF['path_system'] . 'classes/config.class.php'; $c = config::get_instance(); $c->add('article_comment_close_enabled', 0, 'select', 4, 21, 0, 1695, TRUE); $session_ip_check = 1; if (isset($_SYSTEM['skip_ip_check']) && $_SYSTEM['skip_ip_check'] == 1) { $session_ip_check = 0; } $c->add('session_ip_check', $session_ip_check, 'select', 7, 30, 26, 545, TRUE); $c->del('default_search_order', 'Core'); DB_query("UPDATE {$_TABLES['conf_values']} SET selectionArray = '0' WHERE name='searchloginrequired' AND group_name='Core'"); DB_query("ALTER TABLE {$_TABLES['groups']} ADD grp_default tinyint(1) unsigned NOT NULL default '0' AFTER grp_gl_core"); DB_query("ALTER TABLE {$_TABLES['users']} CHANGE `passwd` `passwd` VARCHAR( 40 ) NOT NULL default ''"); // clean up group names and assign proper admin setting DB_query("UPDATE {$_TABLES['groups']} SET grp_gl_core=2 WHERE grp_name='Bad Behavior2 Admin'", 1); DB_query("UPDATE {$_TABLES['groups']} SET grp_name='calendar Admin' WHERE grp_name='Calendar Admin'", 1); DB_query("UPDATE {$_TABLES['groups']} SET grp_gl_core=2 WHERE grp_name='calendar Admin'", 1); DB_query("UPDATE {$_TABLES['groups']} SET grp_gl_core=2 WHERE grp_name='filemgmt Admin'", 1); DB_query("UPDATE {$_TABLES['groups']} SET grp_gl_core=2 WHERE grp_name='forum Admin'", 1); DB_query("UPDATE {$_TABLES['groups']} SET grp_name='links Admin' WHERE grp_name='Links Admin'", 1); DB_query("UPDATE {$_TABLES['groups']} SET grp_gl_core=2 WHERE grp_name='links Admin'", 1); DB_query("UPDATE {$_TABLES['groups']} SET grp_gl_core=2 WHERE grp_name='mediagallery Admin'", 1); DB_query("UPDATE {$_TABLES['groups']} SET grp_name='polls Admin' WHERE grp_name='Polls Admin'", 1); DB_query("UPDATE {$_TABLES['groups']} SET grp_gl_core=2 WHERE grp_name='polls Admin'", 1); DB_query("UPDATE {$_TABLES['groups']} SET grp_gl_core=2 WHERE grp_name='sitetailor Admin'", 1); DB_query("UPDATE {$_TABLES['groups']} SET grp_name='staticpages Admin' WHERE grp_name='Static Page Admin'", 1); DB_query("UPDATE {$_TABLES['groups']} SET grp_gl_core=2 WHERE grp_name='staticpages Admin'", 1); DB_query("UPDATE {$_TABLES['groups']} SET grp_gl_core=2 WHERE grp_name='spamx Admin'", 1); // move multi-language support to its own fieldset DB_query("INSERT INTO {$_TABLES['conf_values']} (name,value,type,group_name,default_value,subgroup,selectionArray,sort_order,fieldset) VALUES ('fs_mulitlanguage','N;','fieldset','Core','N;',6,-1,0,41)", 1); DB_query("UPDATE {$_TABLES['conf_values']} SET fieldset='41' WHERE name='language_files' AND group_name='Core'", 1); DB_query("UPDATE {$_TABLES['conf_values']} SET fieldset='41' WHERE name='languages' AND group_name='Core'", 1); // topic sort DB_query("ALTER TABLE {$_TABLES['topics']} ADD sort_by TINYINT(1) NOT NULL DEFAULT '0' AFTER archive_flag", 1); DB_query("ALTER TABLE {$_TABLES['topics']} ADD sort_dir CHAR( 4 ) NOT NULL DEFAULT 'DESC' AFTER sort_by", 1); // new stats.view permission DB_query("INSERT INTO {$_TABLES['features']} (ft_name, ft_descr, ft_gl_core) VALUES ('stats.view','Allows access to the Stats page.',0)", 1); $ft_id = DB_insertId(); $all_grp_id = intval(DB_getItem($_TABLES['groups'], 'grp_id', "grp_name = 'All Users'")); $loggedin_grp_id = intval(DB_getItem($_TABLES['groups'], 'grp_id', "grp_name = 'Logged-in Users'")); $root_grp_id = intval(DB_getItem($_TABLES['groups'], 'grp_id', "grp_name = 'Root'")); if ($_CONF['statsloginrequired'] || $_CONF['loginrequired']) { DB_query("INSERT INTO {$_TABLES['access']} (acc_ft_id, acc_grp_id) VALUES ({$ft_id}, {$loggedin_grp_id})", 1); } else { DB_query("INSERT INTO {$_TABLES['access']} (acc_ft_id, acc_grp_id) VALUES ({$ft_id}, {$all_grp_id})", 1); } DB_query("INSERT INTO {$_TABLES['access']} (acc_ft_id, acc_grp_id) VALUES ({$ft_id}, {$root_grp_id})", 1); $c->del('statsloginrequired', 'Core'); $c->add('registration_type', 0, 'select', 4, 19, 27, 785, TRUE, 'Core'); DB_query("ALTER TABLE {$_TABLES['users']} ADD act_token VARCHAR(32) NOT NULL DEFAULT '' AFTER pwrequestid", 1); DB_query("ALTER TABLE {$_TABLES['users']} ADD act_time DATETIME NOT NULL DEFAULT '1000-01-01 00:00:00.000000' AFTER act_token", 1); $c->del('cookie_ip', 'Core'); DB_query("ALTER TABLE {$_TABLES['sessions']} DROP PRIMARY KEY", 1); DB_query("ALTER TABLE {$_TABLES['sessions']} ADD PRIMARY KEY (md5_sess_id)", 1); $c->add('comment_postmode', 'plaintext', 'select', 4, 21, 5, 1693, TRUE); $c->add('comment_editor', 0, 'select', 4, 21, 28, 1694, TRUE); DB_query("INSERT INTO {$_TABLES['vars']} SET value='1.2.0',name='glfusion'", 1); DB_query("UPDATE {$_TABLES['vars']} SET value='1.2.0' WHERE name='glfusion'", 1); DB_query("DELETE FROM {$_TABLES['vars']} WHERE name='database_version'", 1); $current_fusion_version = '1.2.0'; case '1.2.0': DB_query("INSERT INTO {$_TABLES['vars']} SET value='1.2.1',name='glfusion'", 1); DB_query("UPDATE {$_TABLES['vars']} SET value='1.2.1' WHERE name='glfusion'", 1); DB_query("DELETE FROM {$_TABLES['vars']} WHERE name='database_version'", 1); $current_fusion_version = '1.2.1'; case '1.2.1': case '1.2.2': case '1.2.3': require_once $_CONF['path'] . 'sql/updates/mysql_1.2.2_to_1.3.0.php'; list($rc, $errors) = INST_updateDB($_SQL); if ($rc === false) { return array($rc, $errors); } require_once $_CONF['path_system'] . 'classes/config.class.php'; $c = config::get_instance(); // logo $c->add('fs_logo', NULL, 'fieldset', 5, 28, NULL, 0, TRUE); $c->add('max_logo_height', 150, 'text', 5, 28, NULL, 1630, TRUE); $c->add('max_logo_width', 500, 'text', 5, 28, NULL, 1640, TRUE); // whats new cache time $c->add('whatsnew_cache_time', 3600, 'text', 3, 15, NULL, 1060, TRUE); // add user photo option to whosonline block $c->add('whosonline_photo', FALSE, 'select', 3, 14, 0, 930, TRUE); // remove old wikitext configuration $c->del('wikitext_editor', 'Core'); // add oauth user_login_method $c->del('user_login_method', 'Core'); // delete microsummary $c->del('microsummary_short', 'Core'); $standard = $_CONF['user_login_method']['standard'] ? true : false; $thirdparty = $_CONF['user_login_method']['3rdparty'] ? true : false; // OAuth configuration settings $oauth = false; $c->add('user_login_method', array('standard' => $standard, '3rdparty' => $thirdparty, 'oauth' => $oauth), '@select', 4, 16, 1, 320, TRUE); $c->add('facebook_login', 0, 'select', 4, 16, 1, 330, TRUE); $c->add('facebook_consumer_key', 'not configured yet', 'text', 4, 16, NULL, 335, TRUE); $c->add('facebook_consumer_secret', 'not configured yet', 'text', 4, 16, NULL, 340, TRUE); $c->add('linkedin_login', 0, 'select', 4, 16, 1, 345, TRUE); $c->add('linkedin_consumer_key', 'not configured yet', 'text', 4, 16, NULL, 350, TRUE); $c->add('linkedin_consumer_secret', 'not configured yet', 'text', 4, 16, NULL, 355, TRUE); $c->add('twitter_login', 0, 'select', 4, 16, 1, 360, TRUE); $c->add('twitter_consumer_key', 'not configured yet', 'text', 4, 16, NULL, 365, TRUE); $c->add('twitter_consumer_secret', 'not configured yet', 'text', 4, 16, NULL, 370, TRUE); $c->add('google_login', 0, 'select', 4, 16, 1, 375, TRUE); $c->add('google_consumer_key', 'not configured yet', 'text', 4, 16, NULL, 380, TRUE); $c->add('google_consumer_secret', 'not configured yet', 'text', 4, 16, NULL, 385, TRUE); $c->add('microsoft_login', 0, 'select', 4, 16, 1, 390, TRUE); $c->add('microsoft_consumer_key', 'not configured yet', 'text', 4, 16, NULL, 395, TRUE); $c->add('microsoft_consumer_secret', 'not configured yet', 'text', 4, 16, NULL, 400, TRUE); // date / time format changes $c->add('date', 'l, F d Y @ h:i A T', 'text', 6, 29, NULL, 370, TRUE); $c->add('daytime', 'm/d h:iA', 'text', 6, 29, NULL, 380, TRUE); $c->add('shortdate', 'm/d/y', 'text', 6, 29, NULL, 390, TRUE); $c->add('dateonly', 'd-M', 'text', 6, 29, NULL, 400, TRUE); $c->add('timeonly', 'H:iA', 'text', 6, 29, NULL, 410, TRUE); // hide what's new if empty $c->add('hideemptyblock', 0, 'select', 3, 15, 0, 1045, TRUE); // update check $c->add('fs_update', NULL, 'fieldset', 0, 7, NULL, 0, TRUE); $c->add('update_check_interval', '86400', 'select', 0, 7, 29, 765, TRUE); $c->add('send_site_data', TRUE, 'select', 0, 7, 1, 770, TRUE); // rating $c->add('fs_rating', NULL, 'fieldset', 4, 7, NULL, 0, TRUE); $c->add('rating_speedlimit', 15, 'text', 4, 7, NULL, 10, TRUE); // add new logo.admin permission $result = DB_query("SELECT * FROM {$_TABLES['features']} WHERE ft_name='logo.admin'"); if (DB_numRows($result) == 0) { DB_query("INSERT INTO {$_TABLES['features']} (ft_name, ft_descr, ft_gl_core) VALUES ('logo.admin','Ability to modify site logo',1)", 1); $ft_id = DB_insertId(); $grp_id = (int) DB_getItem($_TABLES['groups'], 'grp_id', "grp_name = 'Root'"); DB_query("INSERT INTO {$_TABLES['access']} (acc_ft_id, acc_grp_id) VALUES ({$ft_id}, {$grp_id})", 1); } // add new menu.admin permission $result = DB_query("SELECT * FROM {$_TABLES['features']} WHERE ft_name='menu.admin'"); if (DB_numRows($result) == 0) { DB_query("INSERT INTO {$_TABLES['features']} (ft_name, ft_descr, ft_gl_core) VALUES ('menu.admin','Ability to create/edit site menus',1)", 1); $ft_id = DB_insertId(); $grp_id = (int) DB_getItem($_TABLES['groups'], 'grp_id', "grp_name = 'Root'"); DB_query("INSERT INTO {$_TABLES['access']} (acc_ft_id, acc_grp_id) VALUES ({$ft_id}, {$grp_id})", 1); } // add new autotag features $autotag_admin_ft_id = 0; $autotag_php_ft_id = 0; $autotag_group_id = 0; $tmp_admin_ft_id = DB_getItem($_TABLES['features'], 'ft_id', "ft_name = 'autotag.admin'"); if (empty($tmp_admin_ft_id)) { DB_query("INSERT INTO {$_TABLES['features']} (ft_name, ft_descr, ft_gl_core) VALUES ('autotag.admin','Ability to create / edit autotags',1)", 1); $autotag_admin_ft_id = DB_insertId(); } $tmp_php_ft_id = DB_getItem($_TABLES['features'], 'ft_id', "ft_name = 'autotag.PHP'"); if (empty($tmp_php_ft_id)) { DB_query("INSERT INTO {$_TABLES['features']} (ft_name, ft_descr, ft_gl_core) VALUES ('autotag.PHP','Ability to create / edit autotags utilizing PHP functions',1)", 1); $autotag_php_ft_id = DB_insertId(); } // now check for the group $result = DB_query("SELECT * FROM {$_TABLES['groups']} WHERE grp_name='Autotag Admin'"); if (DB_numRows($result) == 0) { DB_query("INSERT INTO {$_TABLES['groups']} (grp_name, grp_descr, grp_gl_core, grp_default) VALUES ('Autotag Admin','Has full access to create and modify autotags',1,0)"); $autotag_group_id = DB_insertId(); } if ($autotag_admin_ft_id != 0 && $autotag_group_id != 0) { DB_query("INSERT INTO {$_TABLES['access']} (acc_ft_id, acc_grp_id) VALUES (" . $autotag_admin_ft_id . "," . $autotag_group_id . ")"); } if ($autotag_php_ft_id != 0 && $autotag_group_id != 0) { DB_query("INSERT INTO {$_TABLES['access']} (acc_ft_id, acc_grp_id) VALUES (" . $autotag_php_ft_id . "," . $autotag_group_id . ")"); } if ($autotag_group_id != 0) { DB_query("INSERT INTO {$_TABLES['group_assignments']} (ug_main_grp_id,ug_grp_id) VALUES (" . $autotag_group_id . ",1)"); } DB_query("INSERT INTO {$_TABLES['vars']} SET value='1.3.0',name='glfusion'", 1); DB_query("UPDATE {$_TABLES['vars']} SET value='1.3.0' WHERE name='glfusion'", 1); DB_query("DELETE FROM {$_TABLES['vars']} WHERE name='database_version'", 1); $current_fusion_version = '1.3.0'; case '1.3.0': $current_fusion_version = '1.3.1'; case '1.3.1': require_once $_CONF['path_system'] . 'classes/config.class.php'; $c = config::get_instance(); $current_fusion_version = '1.3.2'; case '1.3.2': require_once $_CONF['path_system'] . 'classes/config.class.php'; $c = config::get_instance(); // remove menu_elements - no longer used $c->del('menu_elements', 'Core'); $c->del('mailstory_postmode', 'Core'); $c->del('comment_editor', 'Core'); $c->del('advanced_editor', 'Core'); if (!isset($_CONF['mailuser_postmode'])) { $c->add('mailuser_postmode', 'html', 'select', 4, 5, 5, 43, TRUE); } // set the initial set of html elements if (!isset($_CONF['htmlfilter_comment'])) { $c->add('htmlfilter_default', 'p,b,a,i,strong,em,br', 'text', 7, 5, NULL, 30, true); $c->add('htmlfilter_comment', 'p,b,a,i,strong,em,br,tt,hr,li,ol,ul,code,pre', 'text', 7, 5, NULL, 35, TRUE); $c->add('htmlfilter_story', 'div[class],h1,h2,h3,pre,br,p[style],b[style],s,strong[style],i[style],em[style],u[style],strike,a[style|href|title|target],ol[style|class],ul[style|class],li[style|class],hr[style],blockquote[style],img[style|alt|title|width|height|src|align],table[style|width|bgcolor|align|cellspacing|cellpadding|border],tr[style],td[style],th[style],tbody,thead,caption,col,colgroup,span[style|class],sup,sub', 'text', 7, 5, NULL, 40, TRUE); $c->add('htmlfilter_root', 'div[style|class],span[style|class],table,tr,td,th', 'text', 7, 5, NULL, 50, TRUE); } $sql = "REPLACE INTO {$_TABLES['autotags']} (tag, description, is_enabled, is_function, replacement) VALUES ('youtube', 'Embed Youtube videos into content. Usage:[youtube:ID height:px width:px align:left/right/center pad:px]', 1, 1, NULL)"; DB_query($sql, 1); $current_fusion_version = '1.4.0'; case '1.4.0': require_once $_CONF['path_system'] . 'classes/config.class.php'; $c = config::get_instance(); $c->add('github_login', 0, 'select', 4, 1, 1, 271, TRUE); $c->add('github_consumer_key', 'not configured yet', 'text', 4, 1, NULL, 272, TRUE); $c->add('github_consumer_secret', 'not configured yet', 'text', 4, 1, NULL, 273, TRUE); $current_fusion_version = '1.4.1'; case '1.4.1': require_once $_CONF['path_system'] . 'classes/config.class.php'; $c = config::get_instance(); $current_fusion_version = '1.4.2'; case '1.4.2': require_once $_CONF['path_system'] . 'classes/config.class.php'; $c = config::get_instance(); $c->add('min_username_length', '4', 'text', 4, 4, NULL, 60, TRUE); $current_fusion_version = '1.4.3'; case '1.4.3': $_SQL[] = "ALTER TABLE {$_TABLES['stories']} ADD `alternate_tid` VARCHAR(20) NULL DEFAULT NULL AFTER `tid`, ADD INDEX `alternate_topic` (`alternate_tid`) ;"; $_SQL[] = "ALTER TABLE {$_TABLES['tokens']} CHANGE `urlfor` `urlfor` VARCHAR( 1024 ) NOT NULL"; $_SQL[] = "ALTER TABLE {$_TABLES['comments']} CHANGE `ipaddress` `ipaddress` VARCHAR( 45 ) NOT NULL DEFAULT ''"; $_SQL[] = "ALTER TABLE {$_TABLES['rating_votes']} CHANGE `ip_address` `ip_address` VARCHAR( 45 ) NOT NULL"; $_SQL[] = "ALTER TABLE {$_TABLES['sessions']} CHANGE `remote_ip` `remote_ip` VARCHAR( 45 ) NOT NULL DEFAULT ''"; $_SQL[] = "ALTER TABLE {$_TABLES['trackback']} `ipaddress` `ipaddress` VARCHAR( 45 ) NOT NULL DEFAULT ''"; $_SQL[] = "ALTER TABLE {$_TABLES['users']} CHANGE `remote_ip` `remote_ip` VARCHAR( 45 ) NOT NULL DEFAULT ''"; $_SQL[] = "ALTER TABLE {$_TABLES['topics']} CHANGE `tid` `tid` VARCHAR(128) NOT NULL DEFAULT '';"; $_SQL[] = "ALTER TABLE {$_TABLES['topics']} CHANGE `topic` `topic` VARCHAR(128) NULL DEFAULT NULL;"; $_SQL[] = "ALTER TABLE {$_TABLES['stories']} CHANGE `tid` `tid` VARCHAR(128) NOT NULL DEFAULT 'General';"; $_SQL[] = "ALTER TABLE {$_TABLES['stories']} CHANGE `alternate_tid` `alternate_tid` VARCHAR(128) NULL DEFAULT NULL;"; $_SQL[] = "ALTER TABLE {$_TABLES['blocks']} CHANGE `tid` `tid` VARCHAR(128) NOT NULL DEFAULT 'All';"; $_SQL[] = "ALTER TABLE {$_TABLES['storysubmission']} CHANGE `tid` `tid` VARCHAR(128) NOT NULL DEFAULT 'General';"; foreach ($_SQL as $sql) { DB_query($sql, 1); } $result = DB_query("SELECT * FROM {$_TABLES['autotags']} WHERE tag='uikitlogin'"); if (DB_numRows($result) < 1) { $sql = "INSERT INTO {$_TABLES['autotags']} (`tag`, `description`, `is_enabled`, `is_function`, `replacement`) VALUES ('uikitlogin', 'UIKit Login Widget', '1', '1', NULL);"; DB_query($sql, 1); } require_once $_CONF['path_system'] . 'classes/config.class.php'; $c = config::get_instance(); $current_fusion_version = '1.5.0'; case '1.5.0': $_SQL[] = "ALTER TABLE {$_TABLES['article_images']} CHANGE `ai_sid` `ai_sid` VARCHAR(128);"; $_SQL[] = "ALTER TABLE {$_TABLES['comments']} CHANGE `sid` `sid` VARCHAR(128);"; $_SQL[] = "ALTER TABLE {$_TABLES['stories']} CHANGE `sid` `sid` VARCHAR(128);"; $_SQL[] = "ALTER TABLE {$_TABLES['storysubmission']} CHANGE `sid` `sid` VARCHAR(128);"; $_SQL[] = "ALTER TABLE {$_TABLES['syndication']} CHANGE `topic` `topic` VARCHAR(128);"; $_SQL[] = "ALTER TABLE {$_TABLES['trackback']} CHANGE `sid` `sid` VARCHAR(128);"; foreach ($_SQL as $sql) { DB_query($sql, 1); } $current_fusion_version = '1.5.1'; case '1.5.1': case '1.5.2': require_once $_CONF['path_system'] . 'classes/config.class.php'; $c = config::get_instance(); $c->add('infinite_scroll', 1, 'select', 1, 1, 0, 25, TRUE); $c->add('comment_engine', 'internal', 'select', 4, 6, 30, 1, TRUE); $c->add('comment_disqus_shortname', 'not defined', 'text', 4, 6, NULL, 2, TRUE); $c->add('comment_fb_appid', 'not defined', 'text', 4, 6, NULL, 3, TRUE); $c->add('social_site_extra', '', 'text', 0, 0, NULL, 1, TRUE, 'social_internal'); $c->add('fb_appid', '', 'text', 0, 0, NULL, 90, TRUE); // remove openid $sql = "SELECT * FROM {$_TABLES['conf_values']} WHERE name='user_login_method' AND group_name='Core'"; $result = DB_query($sql, 1); if (DB_numRows($result) > 0) { $row = DB_fetchArray($result); $methods = @unserialize($row['value']); $standard = $methods['standard'] ? true : false; $thirdparty = $methods['3rdparty'] ? true : false; $oauth = $methods['oauth'] ? true : false; if ($standard === false && $thirdparty === false && $oauth === false) { $standard = true; } $c->del('user_login_method', 'Core'); $c->add('user_login_method', array('standard' => $standard, '3rdparty' => $thirdparty, 'oauth' => $oauth), '@select', 4, 1, 1, 120, TRUE); } DB_query("ALTER TABLE {$_TABLES['subscriptions']} DROP INDEX `type`", 1); DB_query("DROP INDEX `trackback_url` ON {$_TABLES['trackback']};", 1); $_SQL = array(); $_SQL[] = "ALTER TABLE {$_TABLES['sessions']} CHANGE `md5_sess_id` `md5_sess_id` VARCHAR(128) NOT NULL DEFAULT '';"; $_SQL[] = "ALTER TABLE {$_TABLES['stories']} ADD `subtitle` VARCHAR(128) DEFAULT NULL AFTER `title`;"; $_SQL[] = "ALTER TABLE {$_TABLES['stories']} ADD `story_image` VARCHAR(128) DEFAULT NULL AFTER `alternate_tid`;"; $_SQL[] = "UPDATE {$_TABLES['plugins']} SET pi_enabled='0' WHERE pi_name='ban'"; $_SQL[] = "ALTER TABLE {$_TABLES['autotags']} CHANGE `description` `description` VARCHAR(250) NULL DEFAULT '';"; $_SQL[] = "REPLACE INTO {$_TABLES['autotags']} (tag, description, is_enabled, is_function, replacement) VALUES ('vimeo', 'Embed Vimeo videos into content. Usage:[vimeo:ID height:PX width:PX align:LEFT/RIGHT pad:PX responsive:0/1]', 1, 1, NULL)"; $_SQL[] = "REPLACE INTO {$_TABLES['autotags']} (tag, description, is_enabled, is_function, replacement) VALUES ('newimage', 'HTML: embeds new images in flexible grid. usage: [newimage:<i>#</i> - How many images to display <i>truncate:0/1</i> - 1 = truncate number of images to keep square grid <i>caption:0/1</i> 1 = include title]', 1, 1, '');"; $_SQL[] = "ALTER TABLE {$_TABLES['rating']} CHANGE `item_id` `item_id` VARCHAR(128) NOT NULL DEFAULT '';"; $_SQL[] = "ALTER TABLE {$_TABLES['rating_votes']} CHANGE `item_id` `item_id` VARCHAR(128) NOT NULL DEFAULT '';"; $_SQL[] = "ALTER TABLE {$_TABLES['subscriptions']} CHANGE `id` `id` VARCHAR(128) NOT NULL DEFAULT '';"; $_SQL[] = "CREATE TABLE `{$_TABLES['social_share']}` (\n `id` varchar(128) NOT NULL DEFAULT '',\n `name` varchar(128) NOT NULL DEFAULT '',\n `display_name` varchar(128) NOT NULL DEFAULT '',\n `icon` varchar(128) NOT NULL DEFAULT '',\n `url` varchar(128) NOT NULL DEFAULT '',\n `enabled` tinyint(1) UNSIGNED NOT NULL DEFAULT '1',\n PRIMARY KEY (id)\n ) ENGINE=MyISAM;\n "; $_SQL[] = "CREATE TABLE {$_TABLES['social_follow_services']} (\n `ssid` int(10) UNSIGNED NOT NULL auto_increment,\n `url` varchar(128) NOT NULL DEFAULT '',\n `enabled` tinyint(1) NOT NULL DEFAULT '1',\n `icon` varchar(128) NOT NULL,\n `service_name` varchar(128) NOT NULL,\n `display_name` varchar(128) NOT NULL,\n UNIQUE KEY `ssid` (`ssid`),\n UNIQUE KEY `service_name` (`service_name`)\n ) ENGINE=MyISAM;"; $_SQL[] = "CREATE TABLE {$_TABLES['social_follow_user']} (\n `suid` int(10) NOT NULL AUTO_INCREMENT,\n `ssid` int(11) NOT NULL DEFAULT '0',\n `uid` int(11) NOT NULL,\n `ss_username` varchar(128) NOT NULL DEFAULT '',\n UNIQUE KEY `suid` (`suid`),\n UNIQUE KEY `ssid` (`ssid`,`uid`)\n ) ENGINE=MyISAM;"; $_SQL[] = "ALTER TABLE {$_TABLES['rating']} CHANGE `type` `type` varchar(30) NOT NULL DEFAULT '';"; $_SQL[] = "ALTER TABLE {$_TABLES['rating_votes']} CHANGE `type` `type` varchar(30) NOT NULL DEFAULT '';"; $_SQL[] = "ALTER TABLE {$_TABLES['subscriptions']} CHANGE `type` `type` varchar(30) NOT NULL DEFAULT '';"; $_SQL[] = "ALTER TABLE {$_TABLES['logo']} CHANGE `config_name` `config_name` varchar(128) DEFAULT NULL;"; list($rc, $errors) = INST_updateDB($_SQL); $_DATA = array(); $_DATA[] = "INSERT INTO `{$_TABLES['social_share']}` (`id`, `name`, `display_name`, `icon`, `url`, `enabled`) VALUES('fb', 'facebook', 'Facebook', 'facebook', 'http://www.facebook.com/sharer.php?s=100', 1);"; $_DATA[] = "INSERT INTO `{$_TABLES['social_share']}` (`id`, `name`, `display_name`, `icon`, `url`, `enabled`) VALUES('gg', 'google-plus', 'Google+', 'google-plus', 'https://plus.google.com/share?url', 1);"; $_DATA[] = "INSERT INTO `{$_TABLES['social_share']}` (`id`, `name`, `display_name`, `icon`, `url`, `enabled`) VALUES('li', 'linkedin', 'LinkedIn', 'linkedin', 'http://www.linkedin.com', 1);"; $_DATA[] = "INSERT INTO `{$_TABLES['social_share']}` (`id`, `name`, `display_name`, `icon`, `url`, `enabled`) VALUES('lj', 'livejournal', 'Live Journal', 'pencil', 'http://www.livejournal.com', 1);"; $_DATA[] = "INSERT INTO `{$_TABLES['social_share']}` (`id`, `name`, `display_name`, `icon`, `url`, `enabled`) VALUES('mr', 'mail-ru', 'Mail.ru', 'at', 'http://mail-ru.com', 1);"; $_DATA[] = "INSERT INTO `{$_TABLES['social_share']}` (`id`, `name`, `display_name`, `icon`, `url`, `enabled`) VALUES('ok', 'odnoklassniki', 'Odnoklassniki', 'odnoklassniki', 'http://www.odnoklassniki.ru/dk?st.cmd=addShare&st.s=1', 1);"; $_DATA[] = "INSERT INTO `{$_TABLES['social_share']}` (`id`, `name`, `display_name`, `icon`, `url`, `enabled`) VALUES('pt', 'pinterest', 'Pinterest', 'pinterest-p', 'http://www.pinterest.com', 1);"; $_DATA[] = "INSERT INTO `{$_TABLES['social_share']}` (`id`, `name`, `display_name`, `icon`, `url`, `enabled`) VALUES('rd', 'reddit', 'reddit', 'reddit-alien', 'http://reddit.com/submit?url=%%u&title=%%t', 1);"; $_DATA[] = "INSERT INTO `{$_TABLES['social_share']}` (`id`, `name`, `display_name`, `icon`, `url`, `enabled`) VALUES('tw', 'twitter', 'Twitter', 'twitter', 'http://www.twitter.com', 1);"; $_DATA[] = "INSERT INTO `{$_TABLES['social_share']}` (`id`, `name`, `display_name`, `icon`, `url`, `enabled`) VALUES('vk', 'vk', 'vk', 'vk', 'http://www.vk.org', 1);"; $_DATA[] = "INSERT INTO {$_TABLES['social_follow_services']} (`ssid`, `url`, `enabled`, `icon`, `service_name`, `display_name`) VALUES(1, 'https://twitter.com/%%u', 1, 'twitter', 'twitter', 'Twitter');"; $_DATA[] = "INSERT INTO {$_TABLES['social_follow_services']} (`ssid`, `url`, `enabled`, `icon`, `service_name`, `display_name`) VALUES(2, 'http://facebook.com/%%u', 1, 'facebook', 'facebook', 'Facebook');"; $_DATA[] = "INSERT INTO {$_TABLES['social_follow_services']} (`ssid`, `url`, `enabled`, `icon`, `service_name`, `display_name`) VALUES(3, 'http://pinterest.com/%%u', 1, 'pinterest-p', 'pinterest', 'Pinterest');"; $_DATA[] = "INSERT INTO {$_TABLES['social_follow_services']} (`ssid`, `url`, `enabled`, `icon`, `service_name`, `display_name`) VALUES(4, 'http://youtube.com/%%u', 1, 'youtube', 'youtube', 'Youtube');"; $_DATA[] = "INSERT INTO {$_TABLES['social_follow_services']} (`ssid`, `url`, `enabled`, `icon`, `service_name`, `display_name`) VALUES(5, 'http://plus.google.com/+%%u', 1, 'google-plus', 'google-plus', 'Google+');"; $_DATA[] = "INSERT INTO {$_TABLES['social_follow_services']} (`ssid`, `url`, `enabled`, `icon`, `service_name`, `display_name`) VALUES(6, 'http://linkedin.com/in/%%u', 1, 'linkedin', 'linkedin', 'LinkedIn');"; $_DATA[] = "INSERT INTO {$_TABLES['social_follow_services']} (`ssid`, `url`, `enabled`, `icon`, `service_name`, `display_name`) VALUES(7, 'http://linkedin.com/company/%%u', 1, 'linkedin-square', 'linkedin-co', 'LinkedIn (Company)');"; $_DATA[] = "INSERT INTO {$_TABLES['social_follow_services']} (`ssid`, `url`, `enabled`, `icon`, `service_name`, `display_name`) VALUES(8, 'http://github.com/%%u', 1, 'github', 'github', 'GitHub');"; $_DATA[] = "INSERT INTO {$_TABLES['social_follow_services']} (`ssid`, `url`, `enabled`, `icon`, `service_name`, `display_name`) VALUES(9, 'http://instagram.com/%%u', 1, 'instagram', 'instagram', 'Instagram');"; $_DATA[] = "INSERT INTO {$_TABLES['social_follow_services']} (`ssid`, `url`, `enabled`, `icon`, `service_name`, `display_name`) VALUES(10, 'http://vimeo.com/%%u', 1, 'vimeo', 'vimeo', 'Vimeo');"; $_DATA[] = "INSERT INTO {$_TABLES['social_follow_services']} (`ssid`, `url`, `enabled`, `icon`, `service_name`, `display_name`) VALUES(11, 'http://flickr.com/photos/%%u', 1, 'flickr', 'flickr', 'Flickr');"; $_DATA[] = "INSERT INTO {$_TABLES['social_follow_services']} (`ssid`, `url`, `enabled`, `icon`, `service_name`, `display_name`) VALUES(12, 'http://foursquare.com/%%u', 1, 'foursquare', 'foursquare', 'Foursquare');"; $_DATA[] = "INSERT INTO {$_TABLES['social_follow_services']} (`ssid`, `url`, `enabled`, `icon`, `service_name`, `display_name`) VALUES(13, 'http://yelp.com/biz/%%u', 1, 'yelp', 'yelp', 'Yelp');"; $_DATA[] = "INSERT INTO {$_TABLES['social_follow_services']} (`ssid`, `url`, `enabled`, `icon`, `service_name`, `display_name`) VALUES(14, 'http://dribbble.com/%%u', 1, 'dribbble', 'dribbble', 'Dribbble');"; $_DATA[] = "REPLACE INTO " . $_TABLES['autotags'] . " (tag, description, is_enabled, is_function, replacement) VALUES ('headlines', 'HTML: embeds article headslines. usage: [headlines:<i>topic_name or all</i> display:## meta:0/1 titlelink:0/1 featured:0/1 frontpage:0/1 cols:# template:template_name]', 1, 1, '');"; $_DATA[] = "REPLACE INTO " . $_TABLES['autotags'] . " (tag, description, is_enabled, is_function, replacement) VALUES ('mgslider', 'HTML: displays Media Gallery album. usage: [mgslider:<i>#album_id#</i> - Album ID for images <i>kenburns:0/1</i> - 1 = Enable Ken Burns effect <i>autoplay:0/1</i> 1 = Autoplay the slides <i>template:_name_</i> - Custom template name if wanted]', 1, 1, '');"; $_DATA[] = "REPLACE INTO {$_TABLES['blocks']} (`bid`, `is_enabled`, `name`, `type`, `title`, `tid`, `blockorder`, `content`, `allow_autotags`, `rdfurl`, `rdfupdated`, `rdf_last_modified`, `rdf_etag`, `rdflimit`, `onleft`, `phpblockfn`, `help`, `owner_id`, `group_id`, `perm_owner`, `perm_group`, `perm_members`, `perm_anon`) VALUES(56, 1, 'followusblock', 'phpblock', 'Follow Us', 'all', 0, '', 0, '', '1000-01-01 00:00:00.000000', NULL, NULL, 0, 0, 'phpblock_social', '', 4, 4, 3, 2, 2, 2);"; foreach ($_DATA as $sql) { DB_query($sql, 1); } // add new social features $sis_admin_ft_id = 0; $sis_group_id = 0; $tmp_admin_ft_id = DB_getItem($_TABLES['features'], 'ft_id', "ft_name = 'social.admin'"); if (empty($tmp_admin_ft_id)) { DB_query("INSERT INTO {$_TABLES['features']} (ft_name, ft_descr, ft_gl_core) VALUES ('social.admin','Ability to manage social features.',1)", 1); $sis_admin_ft_id = DB_insertId(); } // now check for the group $result = DB_query("SELECT * FROM {$_TABLES['groups']} WHERE grp_name='Social Admin'"); if (DB_numRows($result) == 0) { DB_query("INSERT INTO {$_TABLES['groups']} (grp_name, grp_descr, grp_gl_core, grp_default) VALUES ('Social Admin','Has full access to manage social integrations.',1,0)"); $sis_group_id = DB_insertId(); } if ($sis_admin_ft_id != 0 && $sis_group_id != 0) { DB_query("INSERT INTO {$_TABLES['access']} (acc_ft_id, acc_grp_id) VALUES (" . $sis_admin_ft_id . "," . $sis_group_id . ")"); } if ($sis_group_id != 0) { DB_query("INSERT INTO {$_TABLES['group_assignments']} (ug_main_grp_id,ug_grp_id) VALUES (" . $sis_group_id . ",1)"); } $current_fusion_version = '1.6.0'; case '1.6.0': require_once $_CONF['path_system'] . 'classes/config.class.php'; $c = config::get_instance(); $c->del('fs_mysql', 'Core'); $c->del('allow_mysqldump', 'Core'); $c->del('mysqldump_path', 'Core'); $c->del('mysqldump_options', 'Core'); $_SQL = array(); $_SQL[] = "ALTER TABLE {$_TABLES['blocks']} CHANGE `title` `title` VARCHAR(255) NULL DEFAULT NULL;"; $_SQL[] = "ALTER TABLE {$_TABLES['stories']} ADD `attribution_url` VARCHAR(255) NOT NULL default '' AFTER `expire`;"; $_SQL[] = "ALTER TABLE {$_TABLES['stories']} ADD `attribution_name` VARCHAR(255) NOT NULL DEFAULT '' AFTER `attribution_url`;"; $_SQL[] = "ALTER TABLE {$_TABLES['stories']} ADD `attribution_author` VARCHAR(255) NOT NULL DEFAULT '' AFTER `attribution_name`;"; list($rc, $errors) = INST_updateDB($_SQL); $current_fusion_version = '1.6.1'; default: DB_query("INSERT INTO {$_TABLES['vars']} SET value='" . $current_fusion_version . "',name='glfusion'", 1); DB_query("UPDATE {$_TABLES['vars']} SET value='" . $current_fusion_version . "' WHERE name='glfusion'", 1); DB_query("DELETE FROM {$_TABLES['vars']} WHERE name='database_version'", 1); break; } DB_query("ALTER TABLE {$_TABLES['userprefs']} ADD search_result_format VARCHAR( 48 ) NOT NULL DEFAULT 'google'", 1); // delete the security check flag on every update to force the user // to run admin/sectest.php again DB_delete($_TABLES['vars'], 'name', 'security_check'); INST_resyncConfig(); return array($rc, $errors); }
if ($_USER['uid'] < 2) { $display .= CLASSIFIEDS_loginRequiredForm(); break; } $sql = "catid = '{$_REQUEST['catid']}', " . "status = '{$status}', " . "type = '{$_REQUEST['type']}', " . "tel = '{$clean_tel}', " . "hide_tel = '{$hide_tel}', " . "title = '{$title}', " . "text = '{$text}', " . "price = '{$price}', " . "postcode = '{$_REQUEST['postcode']}', " . "city = '{$city}', " . "siren = '{$_REQUEST['siren']}', " . "created = '{$created}', " . "modified = '{$modified}', " . "owner_id = '{$_USER['uid']}'\n\t\t\t "; $sql = "INSERT INTO {$_TABLES['cl']} SET {$sql} "; DB_query($sql); $last_pid = DB_insertId(); if ($last_pid == 0) { $last_pid = 1; } if (DB_error()) { $msg = $LANG_CLASSIFIEDS_2['save_fail']; } else { $msg = $LANG_CLASSIFIEDS_2['save_success']; $adnumber = DB_insertId(); if (function_exists('CLASSIFIEDS_emailNewAd')) { CLASSIFIEDS_emailNewAd($title, $text, $adnumber, $_USER['uid'], $price); } //add user to classifieds users group require_once $_CONF['path_system'] . 'lib-user.php'; $ad_users = DB_getItem($_TABLES['groups'], 'grp_id', "grp_name='Classifieds Users'"); USER_addGroup($ad_users, $_USER['uid']); // Populate user data if (DB_count($_TABLES['cl_users'], 'user_id', $_USER['uid']) > 0) { DB_query("UPDATE {$_TABLES['cl_users']} SET tel = '{$clean_tel}', postcode = '{$_REQUEST['postcode']}',\n\t\t\t\t\t\t\tcity = '{$city}', status = '{$status}', siren = '{$_REQUEST['siren']}' WHERE user_id = '{$_USER['uid']}'"); } else { DB_query("INSERT INTO {$_TABLES['cl_users']} SET user_id = '{$_USER['uid']}', \n\t\t\t\t\t\t\ttel = '{$clean_tel}', postcode = '{$_REQUEST['postcode']}',\n\t\t\t\t\t\t\tcity = '{$city}', status = '{$status}',\n\t\t\t\t\t\t\tsiren = '{$_REQUEST['siren']}'\n\t\t\t\t\t\t\t"); } } }
/** * Plugin postinstall * * We're inserting our default data here since it depends on other stuff that * has to happen first ... * * @return boolean true = proceed with install, false = an error occured * */ function plugin_postinstall_nexproject($pi_name) { global $_DB_dbms, $_CONF, $_DB_table_prefix, $_TABLES; require_once $_CONF['path'] . 'plugins/nexproject/nexproject.php'; // fix nexproject block group ownership $blockAdminGroup = DB_getItem($_TABLES['groups'], 'grp_id', "grp_name = 'Block Admin'"); if ($blockAdminGroup > 0) { // set the block's permissions $A = array(); SEC_setDefaultPermissions($A, $_CONF['default_permissions_block']); // ... and make it the last block on the right side $result = DB_query("SELECT MAX(blockorder) FROM {$_TABLES['blocks']} WHERE onleft = 0"); list($order) = DB_fetchArray($result); $order += 10; DB_query("UPDATE {$_TABLES['blocks']} SET group_id = {$blockAdminGroup}, blockorder = {$order}, perm_owner = {$A['perm_owner']}, perm_group = {$A['perm_group']}, perm_members = {$A['perm_members']}, perm_anon = {$A['perm_anon']} WHERE (type = 'phpblock') AND (phpblockfn = 'phpblock_nexproject')"); } $nexfile = true; if (!function_exists("fm_createCategory")) { //COM_errorLog ('The nexFile plugin is not installed. Please install it before continuing', 1); //echo COM_refresh ($_CONF['site_admin_url'] . '/plugins.php?msg=2&plugin='.$pi_name); //exit(0); $nexfile = false; } $forum = true; if (!function_exists("forum_addForum")) { //COM_errorLog ('The forum plugin is not installed. Please install it before continuing', 1); //echo COM_refresh ($_CONF['site_admin_url'] . '/plugins.php?msg=4&plugin='.$pi_name); //exit(0); $forum = false; } //And now, install the lookup lists and add nxprj config values to house the nexlist items $sql = "insert into {$_TABLES['nexlist']} (plugin, category, name, description, listfields, edit_perms, view_perms, active)\r\n values ( 'all','nexPro', 'Locations', 'List of locations', 1, 1, 2, 1);"; $res = DB_query($sql); $locID = DB_insertId(); $sql = "insert into {$_TABLES['nexlist']} (plugin, category, name, description, listfields, edit_perms, view_perms, active)\r\n values ('all','nexPro','Departments','List of Departments', 1, 1, 2, 1);"; $res = DB_query($sql); $deptID = DB_insertId(); $sql = "insert into {$_TABLES['nexlist']} (plugin, category, name, description, listfields, edit_perms, view_perms, active)\r\n values ('all','nexPro', 'Categories','List of Categories', 1, 1, 2, 1);"; $res = DB_query($sql); $catID = DB_insertId(); $sql = "INSERT INTO {$_TABLES['nexlist']} (plugin, category, name, description, listfields, edit_perms, view_perms, active)\r\n VALUES ('all', 'nexPro', 'Objectives', 'List of Project Objectives', 1, 1, 2, 1);"; $res = DB_query($sql); $objID = DB_insertId(); /* create lookuplist Fields for list definitions */ $_PRJSQL[] = "insert into {$_TABLES['nexlistfields']} (lid, fieldname) values('{$locID}','Location' )"; $_PRJSQL[] = "insert into {$_TABLES['nexlistfields']} (lid, fieldname) values('{$deptID}','Department' )"; $_PRJSQL[] = "insert into {$_TABLES['nexlistfields']} (lid, fieldname) values('{$catID}','Department' )"; $_PRJSQL[] = "insert into {$_TABLES['nexlistfields']} (lid, fieldname) values('{$objID}','Objective' )"; /* create lookuplist list records for each definition */ $_PRJSQL[] = "insert into {$_TABLES['nexlistitems']} (lid, itemorder, value, active) values ('{$locID}', 10, 'Toronto',1)"; $_PRJSQL[] = "insert into {$_TABLES['nexlistitems']} (lid, itemorder, value, active) values ('{$locID}', 20, 'Hong Kong',1)"; $_PRJSQL[] = "insert into {$_TABLES['nexlistitems']} (lid, itemorder, value, active) values ('{$locID}', 30, 'Brisbane',1)"; $_PRJSQL[] = "insert into {$_TABLES['nexlistitems']} (lid, itemorder, value, active) values ('{$locID}', 40, 'Tokyo',1)"; $_PRJSQL[] = "insert into {$_TABLES['nexlistitems']} (lid, itemorder, value, active) values ('{$locID}', 50, 'New York',1)"; $_PRJSQL[] = "insert into {$_TABLES['nexlistitems']} (lid, itemorder, value, active) values ('{$locID}', 60, 'San Fransisco',1)"; $_PRJSQL[] = "insert into {$_TABLES['nexlistitems']} (lid, itemorder, value, active) values ('{$locID}', 70, 'London',1)"; $_PRJSQL[] = "insert into {$_TABLES['nexlistitems']} (lid, itemorder, value, active) values ('{$deptID}', 10, 'Sales',1)"; $_PRJSQL[] = "insert into {$_TABLES['nexlistitems']} (lid, itemorder, value, active) values ('{$deptID}', 20, 'Information Technology',1)"; $_PRJSQL[] = "insert into {$_TABLES['nexlistitems']} (lid, itemorder, value, active) values ('{$deptID}', 30, 'Marketing',1)"; $_PRJSQL[] = "insert into {$_TABLES['nexlistitems']} (lid, itemorder, value, active) values ('{$deptID}', 40, 'Finance',1)"; $_PRJSQL[] = "insert into {$_TABLES['nexlistitems']} (lid, itemorder, value, active) values ('{$deptID}', 50, 'Operations',1)"; $_PRJSQL[] = "insert into {$_TABLES['nexlistitems']} (lid, itemorder, value, active) values ('{$deptID}', 60, 'Legal',1)"; $_PRJSQL[] = "insert into {$_TABLES['nexlistitems']} (lid, itemorder, value, active) values ('{$deptID}', 70, 'Revenue',1)"; $_PRJSQL[] = "insert into {$_TABLES['nexlistitems']} (lid, itemorder, value, active) values ('{$catID}', 10, 'Revenue',1)"; $_PRJSQL[] = "insert into {$_TABLES['nexlistitems']} (lid, itemorder, value, active) values ('{$catID}', 20, 'Safety',1)"; $_PRJSQL[] = "insert into {$_TABLES['nexlistitems']} (lid, itemorder, value, active) values ('{$catID}', 30, 'Environment',1)"; $_PRJSQL[] = "insert into {$_TABLES['nexlistitems']} (lid, itemorder, value, active) values ('{$catID}', 40, 'Training',1)"; $_PRJSQL[] = "insert into {$_TABLES['nexlistitems']} (lid, itemorder, value, active) values ('{$catID}', 50, 'Product Development',1)"; $_PRJSQL[] = "insert into {$_TABLES['nexlistitems']} (lid, itemorder, value, active) values ('{$catID}', 60, 'Branding',1)"; $_PRJSQL[] = "insert into {$_TABLES['nexlistitems']} (lid, itemorder, value, active) values ('{$catID}', 70, 'Investment',1)"; $_PRJSQL[] = "insert into {$_TABLES['nexlistitems']} (lid, itemorder, value, active) values ('{$catID}', 80, 'Capital Expenditure',1)"; $_PRJSQL[] = "insert into {$_TABLES['nexlistitems']} (lid, itemorder, value, active) VALUES ('{$objID}', 90, 'Business Growth', 1);"; $_PRJSQL[] = "insert into {$_TABLES['nexlistitems']} (lid, itemorder, value, active) VALUES ('{$objID}', 100, 'Product Development', 1);"; $_PRJSQL[] = "insert into {$_TABLES['nexlistitems']} (lid, itemorder, value, active) VALUES ('{$objID}', 110, 'Objective 3', 1);"; foreach ($_PRJSQL as $sql) { DB_query($sql); if (DB_error()) { $err = 1; } } $c = config::get_instance(); $c->add('prj_list', NULL, 'fieldset', 0, 1, NULL, 0, true, 'nexproject'); $c->add('nexlist_locations', $locID, 'text', 0, 1, 0, 150, true, 'nexproject'); $c->add('nexlist_departments', $deptID, 'text', 0, 1, 0, 160, true, 'nexproject'); $c->add('nexlist_category', $catID, 'text', 0, 1, 0, 170, true, 'nexproject'); $c->add('nexlist_objective', $objID, 'text', 0, 1, 0, 180, true, 'nexproject'); //we are assuming that nexfile and the forum are installed here. We cannot get this far if they werent! //the first thing we do is create a new nexFile category which will be used as the base category ID to dump files into for projects if ($nexfile) { $arr = fm_createCategory(0, 'nexProject Category', 'This base category is used by the nexProject plugin to create document repositories for each project.', true); //config parms for this $c->add('prj_file', NULL, 'fieldset', 0, 2, NULL, 0, true, 'nexproject'); $c->add('nexfile_parent', $arr[0], 'text', 0, 2, 0, 190, true, 'nexproject'); } else { //config parms for this $c->add('prj_file', NULL, 'fieldset', 0, 2, NULL, 0, true, 'nexproject'); $c->add('nexfile_parent', 0, 'text', 0, 2, 0, 190, true, 'nexproject'); } //and now, we create a new forum category and dump that into the config database if ($forum) { $sql = "INSERT INTO {$_TABLES['gf_categories']} (cat_order,cat_name,cat_dscp) values (0,'nexProject Category','This base category is used by the nexProject plugin to create forum repositories for each project.') "; DB_query($sql); $catid = DB_insertId(); $c->add('prj_forum', NULL, 'fieldset', 0, 3, NULL, 0, true, 'nexproject'); $c->add('forum_parent', $catid, 'text', 0, 3, 0, 200, true, 'nexproject'); } else { $c->add('prj_forum', NULL, 'fieldset', 0, 3, NULL, 0, true, 'nexproject'); $c->add('forum_parent', 0, 'text', 0, 3, 0, 200, true, 'nexproject'); } return true; }
/** * Saves a block * * @param string $bid Block ID * @param string $title Block title * @param string $type Type of block * @param int $blockorder Order block appears relative to the others * @param string $content Content of block * @param string $tid Ids of topics block is assigned to * @param string $rdfurl URL to headline feed for portal blocks * @param string $rdfupdated Date RSS/RDF feed was last updated * @param string $rdflimit max. number of entries to import from feed * @param string $phpblockfn Name of php function to call to get content * @param int $onleft Flag indicates if block shows up on left or right * @param int $owner_id ID of owner * @param int $group_id ID of group block belongs to * @param array $perm_owner Permissions the owner has on the object * @param array $perm_group Permissions the group has on the object * @param array $perm_members Permissions the logged in members have * @param array $perm_anon Permissinos anonymous users have * @param int $is_enabled Flag, indicates if block is enabled or not * @return string HTML redirect or error message * */ function saveblock($bid, $name, $title, $help, $type, $blockorder, $content, $rdfurl, $rdfupdated, $rdflimit, $phpblockfn, $onleft, $owner_id, $group_id, $perm_owner, $perm_group, $perm_members, $perm_anon, $is_enabled, $allow_autotags, $cache_time) { global $_CONF, $_TABLES, $LANG01, $LANG21, $MESSAGE, $_USER; $retval = ''; $title = DB_escapeString(COM_stripslashes(strip_tags($title))); $phpblockfn = DB_escapeString(COM_stripslashes(trim($phpblockfn))); if (empty($title) || !TOPIC_checkTopicSelectionControl()) { $retval .= COM_showMessageText($LANG21[64], $LANG21[63]) . editblock($bid); $retval = COM_createHTMLDocument($retval, array('pagetitle' => $LANG21[63])); return $retval; } // Convert array values to numeric permission values list($perm_owner, $perm_group, $perm_members, $perm_anon) = SEC_getPermissionValues($perm_owner, $perm_group, $perm_members, $perm_anon); $access = 0; if ($bid > 0 && DB_count($_TABLES['blocks'], 'bid', $bid) > 0) { $result = DB_query("SELECT owner_id,group_id,perm_owner,perm_group,perm_members,perm_anon FROM {$_TABLES['blocks']} WHERE bid = '{$bid}'"); $A = DB_fetchArray($result); $access = SEC_hasAccess($A['owner_id'], $A['group_id'], $A['perm_owner'], $A['perm_group'], $A['perm_members'], $A['perm_anon']); } else { $access = SEC_hasAccess($owner_id, $group_id, $perm_owner, $perm_group, $perm_members, $perm_anon); } if ($access < 3 || !TOPIC_hasMultiTopicAccess('topic') || !SEC_inGroup($group_id)) { $retval .= COM_showMessageText($MESSAGE[29], $MESSAGE[30]); $retval = COM_createHTMLDocument($retval, array('pagetitle' => $MESSAGE[30])); COM_accessLog("User {$_USER['username']} tried to illegally create or edit block {$bid}."); return $retval; } elseif (!empty($name) and ($type == 'normal' && !empty($title) && !empty($content) or $type == 'portal' && !empty($title) && !empty($rdfurl) or $type == 'phpblock' && !empty($phpblockfn) && !empty($title) or $type == 'gldefault' && strlen($blockorder) > 0)) { if ($is_enabled == 'on') { $is_enabled = 1; } else { $is_enabled = 0; } if ($allow_autotags == 'on') { $allow_autotags = 1; } else { $allow_autotags = 0; } if ($cache_time < -1 or $cache_time == "") { $cache_time = $_CONF['default_cache_time_block']; } if ($type == 'portal') { $content = ''; $rdfupdated = ''; $phpblockfn = ''; // get rid of possible extra prefixes (e.g. "feed://http://...") if (substr($rdfurl, 0, 4) == 'rss:') { $rdfurl = substr($rdfurl, 4); } elseif (substr($rdfurl, 0, 5) == 'feed:') { $rdfurl = substr($rdfurl, 5); } if (substr($rdfurl, 0, 2) == '//') { $rdfurl = substr($rdfurl, 2); } $rdfurl = COM_sanitizeUrl($rdfurl, array('http', 'https')); } if ($type == 'gldefault') { $content = ''; $rdfurl = ''; $rdfupdated = ''; $rdflimit = 0; $phpblockfn = ''; } if ($type == 'phpblock') { // NOTE: PHP Blocks must be within a function and the function // must start with phpblock_ as the prefix. This will prevent // the arbitrary execution of code if (!stristr($phpblockfn, 'phpblock_')) { $retval .= COM_showMessageText($LANG21[38], $LANG21[37]) . editblock($bid); $retval = COM_createHTMLDocument($retval, array('pagetitle' => $LANG21[37])); return $retval; } $content = ''; $rdfurl = ''; $rdfupdated = ''; $rdflimit = 0; } if ($type == 'normal') { $rdfurl = ''; $rdfupdated = ''; $rdflimit = 0; $phpblockfn = ''; if ($allow_autotags == 1) { // Remove any autotags the user doesn't have permission to use $content = PLG_replaceTags($content, '', true); } $content = DB_escapeString($content); } if ($rdflimit < 0) { $rdflimit = 0; } if (!empty($rdfurl)) { $rdfurl = DB_escapeString($rdfurl); } if (empty($rdfupdated)) { $rdfupdated = '0000-00-00 00:00:00'; } if ($bid > 0) { DB_save($_TABLES['blocks'], 'bid,name,title,help,type,blockorder,content,rdfurl,rdfupdated,rdflimit,phpblockfn,onleft,owner_id,group_id,perm_owner,perm_group,perm_members,perm_anon,is_enabled,allow_autotags,cache_time,rdf_last_modified,rdf_etag', "{$bid},'{$name}','{$title}','{$help}','{$type}','{$blockorder}','{$content}','{$rdfurl}','{$rdfupdated}','{$rdflimit}','{$phpblockfn}',{$onleft},{$owner_id},{$group_id},{$perm_owner},{$perm_group},{$perm_members},{$perm_anon},{$is_enabled},{$allow_autotags},{$cache_time},NULL,NULL"); } else { $sql = array(); $sql['mysql'] = $sql['mssql'] = "INSERT INTO {$_TABLES['blocks']} " . '(name,title,help,type,blockorder,content,rdfurl,rdfupdated,rdflimit,phpblockfn,onleft,owner_id,group_id,perm_owner,perm_group,perm_members,perm_anon,is_enabled,allow_autotags,cache_time) ' . "VALUES ('{$name}','{$title}','{$help}','{$type}','{$blockorder}','{$content}','{$rdfurl}','{$rdfupdated}','{$rdflimit}','{$phpblockfn}',{$onleft},{$owner_id},{$group_id},{$perm_owner},{$perm_group},{$perm_members},{$perm_anon},{$is_enabled},{$allow_autotags},{$cache_time})"; $sql['pgsql'] = "INSERT INTO {$_TABLES['blocks']} " . '(bid,name,title,help,type,blockorder,content,rdfurl,rdfupdated,rdflimit,phpblockfn,onleft,owner_id,group_id,perm_owner,perm_group,perm_members,perm_anon,is_enabled,allow_autotags,cache_time) ' . "VALUES ((SELECT NEXTVAL('{$_TABLES['blocks']}_bid_seq')),'{$name}','{$title}','{$help}','{$type}','{$blockorder}','{$content}','{$rdfurl}','1970-01-01','{$rdflimit}','{$phpblockfn}',{$onleft},{$owner_id},{$group_id},{$perm_owner},{$perm_group},{$perm_members},{$perm_anon},{$is_enabled},{$allow_autotags},{$cache_time})"; DB_query($sql); $bid = DB_insertId(); } TOPIC_saveTopicSelectionControl('block', $bid); $cacheInstance = 'block__' . $bid . '__'; // remove any of this blocks instances if exists CACHE_remove_instance($cacheInstance); return COM_refresh($_CONF['site_admin_url'] . '/block.php?msg=11'); } else { if (empty($name)) { // empty block name $msgtxt = $LANG21[50]; } elseif ($type == 'portal') { // Portal block is missing fields $msgtxt = $LANG21[33]; } elseif ($type == 'phpblock') { // PHP Block is missing field $msgtxt = $LANG21[34]; } elseif ($type == 'normal') { // Normal block is missing field $msgtxt = $LANG21[35]; } elseif ($type == 'gldefault') { // Default geeklog field missing $msgtxt = $LANG21[42]; } else { // Layout block missing content $msgtxt = $LANG21[36]; } $retval .= COM_showMessageText($msgtxt, $LANG21[32]) . editblock($bid); $retval = COM_createHTMLDocument($retval, array('pagetitle' => $LANG21[32])); } return $retval; }
/** * Do the actual plugin auto install * * @param string $plugin Plugin name * @param array $inst_parms Installation parameters for the plugin * @param boolean $verbose true: enable verbose logging * @return boolean true on success, false otherwise * */ function plugin_do_autoinstall($plugin, $inst_parms, $verbose = true) { global $_CONF, $_TABLES, $_USER, $_DB_dbms, $_DB_table_prefix; $base_path = $_CONF['path'] . 'plugins/' . $plugin . '/'; if ($verbose) { COM_errorLog("Attempting to install the '{$plugin}' plugin", 1); } // sanity checks in $inst_parms if (isset($inst_parms['info'])) { $pi_name = $inst_parms['info']['pi_name']; $pi_version = $inst_parms['info']['pi_version']; $pi_gl_version = $inst_parms['info']['pi_gl_version']; $pi_homepage = $inst_parms['info']['pi_homepage']; } if (empty($pi_name) || $pi_name != $plugin || empty($pi_version) || empty($pi_gl_version) || empty($pi_homepage)) { COM_errorLog('Incomplete plugin info', 1); return false; } // add plugin tables, if any if (!empty($inst_parms['tables'])) { $tables = $inst_parms['tables']; foreach ($tables as $table) { $_TABLES[$table] = $_DB_table_prefix . $table; } } // Create the plugin's group(s), if any $groups = array(); $admin_group_id = 0; if (!empty($inst_parms['groups'])) { $groups = $inst_parms['groups']; foreach ($groups as $name => $desc) { if ($verbose) { COM_errorLog("Attempting to create '{$name}' group", 1); } $grp_name = addslashes($name); $grp_desc = addslashes($desc); $sql = array(); $sql['pgsql'] = "INSERT INTO {$_TABLES['groups']} (grp_id,grp_name, grp_descr) VALUES ((SELECT NEXTVAL('{$_TABLES['groups']}_grp_id_seq')),'{$grp_name}', '{$grp_desc}')"; $sql['mysql'] = "INSERT INTO {$_TABLES['groups']} (grp_name, grp_descr) VALUES ('{$grp_name}', '{$grp_desc}')"; $sql['mssql'] = "INSERT INTO {$_TABLES['groups']} (grp_name, grp_descr) VALUES ('{$grp_name}', '{$grp_desc}')"; DB_query($sql, 1); if (DB_error()) { COM_errorLog('Error creating plugin group', 1); PLG_uninstall($plugin); return false; } // keep the new group's ID for use in the mappings section (below) $groups[$name] = DB_insertId(); // assume that the first group is the plugin's Admin group if ($admin_group_id == 0) { $admin_group_id = $groups[$name]; } } } // Create the plugin's table(s) $_SQL = array(); $DEFVALUES = array(); if (file_exists($base_path . 'sql/' . $_DB_dbms . '_install.php')) { require_once $base_path . 'sql/' . $_DB_dbms . '_install.php'; } if (count($_SQL) > 0) { $use_innodb = false; if ($_DB_dbms == 'mysql' && DB_getItem($_TABLES['vars'], 'value', "name = 'database_engine'") == 'InnoDB') { $use_innodb = true; } foreach ($_SQL as $sql) { $sql = str_replace('#group#', $admin_group_id, $sql); if ($use_innodb) { $sql = str_replace('MyISAM', 'InnoDB', $sql); } DB_query($sql); if (DB_error()) { COM_errorLog('Error creating plugin table', 1); PLG_uninstall($plugin); return false; } } } // Add the plugin's features if ($verbose) { COM_errorLog("Attempting to add '{$plugin}' features", 1); } $features = array(); $mappings = array(); if (!empty($inst_parms['features'])) { $features = $inst_parms['features']; if (!empty($inst_parms['mappings'])) { $mappings = $inst_parms['mappings']; } foreach ($features as $feature => $desc) { $ft_name = addslashes($feature); $ft_desc = addslashes($desc); $sql = array(); $sql['pgsql'] = "INSERT INTO {$_TABLES['features']} (ft_id,ft_name, ft_descr)\n VALUES ((SELECT nextval('{$_TABLES['features']}_ft_id_seq')),'{$ft_name}', '{$ft_desc}')"; $sql['mysql'] = "INSERT INTO {$_TABLES['features']} (ft_name, ft_descr)\n VALUES ('{$ft_name}', '{$ft_desc}')"; $sql['mysql'] = "INSERT INTO {$_TABLES['features']} (ft_name, ft_descr)\n VALUES ('{$ft_name}', '{$ft_desc}')"; DB_query($sql, 1); if (DB_error()) { COM_errorLog('Error adding plugin feature', 1); PLG_uninstall($plugin); return false; } $feat_id = DB_insertId(); if (isset($mappings[$feature])) { foreach ($mappings[$feature] as $group) { if ($verbose) { COM_errorLog("Adding '{$feature}' feature to the '{$group}' group", 1); } DB_query("INSERT INTO {$_TABLES['access']} (acc_ft_id, acc_grp_id) VALUES ({$feat_id}, {$groups[$group]})"); if (DB_error()) { COM_errorLog('Error mapping plugin feature', 1); PLG_uninstall($plugin); return false; } } } } } // Add plugin's Admin group to the Root user group // (assumes that the Root group's ID is always 1) if (count($groups) > 0) { if ($verbose) { COM_errorLog("Attempting to give all users in the Root group access to the '{$plugin}' Admin group", 1); } foreach ($groups as $key => $value) { DB_query("INSERT INTO {$_TABLES['group_assignments']} VALUES " . "({$value}, NULL, 1)"); if (DB_error()) { COM_errorLog('Error adding plugin admin group to Root group', 1); PLG_uninstall($plugin); return false; } } } // Pre-populate tables or run any other SQL queries if (count($DEFVALUES) > 0) { if ($verbose) { COM_errorLog('Inserting default data', 1); } foreach ($DEFVALUES as $sql) { $sql = str_replace('#group#', $admin_group_id, $sql); DB_query($sql, 1); if (DB_error()) { COM_errorLog('Error adding plugin default data', 1); PLG_uninstall($plugin); return false; } } } // Load the online configuration records $load_config = 'plugin_load_configuration_' . $plugin; if (function_exists($load_config)) { if (!$load_config($plugin)) { COM_errorLog('Error loading plugin configuration', 1); PLG_uninstall($plugin); return false; } require_once $_CONF['path'] . 'system/classes/config.class.php'; $config =& config::get_instance(); $config->initConfig(); // force re-reading, including new plugin conf } // Finally, register the plugin with Geeklog if ($verbose) { COM_errorLog("Registering '{$plugin}' plugin", 1); } // silently delete an existing entry DB_delete($_TABLES['plugins'], 'pi_name', $plugin); DB_query("INSERT INTO {$_TABLES['plugins']} (pi_name, pi_version, pi_gl_version, pi_homepage, pi_enabled) VALUES " . "('{$plugin}', '{$pi_version}', '{$pi_gl_version}', '{$pi_homepage}', 1)"); if (DB_error()) { COM_errorLog('Failed to register plugin', 1); PLG_uninstall($plugin); return false; } // give the plugin a chance to perform any post-install operations $post_install = 'plugin_postinstall_' . $plugin; if (function_exists($post_install)) { if (!$post_install($plugin)) { COM_errorLog('Plugin postinstall failed', 1); PLG_uninstall($plugin); return false; } } if ($verbose) { COM_errorLog("Successfully installed the '{$plugin}' plugin!", 1); } // load plugin here already, for any plugins wanting to act on // PLG_pluginStateChange($plugin, 'installed') when we return from here require_once $_CONF['path'] . 'plugins/' . $plugin . '/functions.inc'; return true; }
/** * Moves comment from submission table to comments table * * @param int cid comment id * @copyright Jared Wenerd 2008 * @author Jared Wenerd, wenerd87 AT gmail DOT com * @param string $cid comment id * @return string of story id */ function CMT_approveModeration($cid) { global $_CONF, $_TABLES; $result = DB_query("SELECT type, sid, date, title, comment, uid, name, pid, ipaddress FROM {$_TABLES['commentsubmissions']} WHERE cid = '{$cid}'"); $A = DB_fetchArray($result); if ($A['pid'] > 0) { // get indent+1 of parent $indent = DB_getItem($_TABLES['comments'], 'indent+1', "cid = '{$A['pid']}'"); if (empty($indent)) { $indent = 0; } } else { $indent = 0; } $A['title'] = DB_escapeString($A['title']); $A['comment'] = DB_escapeString($A['comment']); if (isset($A['name'])) { // insert data $A['name'] = DB_escapeString($A['name']); DB_save($_TABLES['comments'], 'type,sid,date,title,comment,uid,name,pid,ipaddress,indent', "'{$A['type']}','{$A['sid']}','{$A['date']}','{$A['title']}','{$A['comment']}','{$A['uid']}'," . "'{$A['name']}','{$A['pid']}','{$A['ipaddress']}',{$indent}"); } else { // insert data, null automatically goes into name column DB_save($_TABLES['comments'], 'type,sid,date,title,comment,uid,pid,ipaddress,indent', "'{$A['type']}','{$A['sid']}','{$A['date']}','{$A['title']}','{$A['comment']}','{$A['uid']}'," . "'{$A['pid']}','{$A['ipaddress']}',{$indent}"); } $newcid = DB_insertId('', 'comments_cid_seq'); DB_delete($_TABLES['commentsubmissions'], 'cid', $cid); DB_change($_TABLES['commentnotifications'], 'cid', $newcid, 'mid', $cid); // notify of new published comment if ($_CONF['allow_reply_notifications'] == 1 && $A['pid'] > 0) { // $sql = "SELECT cid, uid, deletehash FROM {$_TABLES['commentnotifications']} WHERE cid = $pid"; // Used in Geeklog 2.0.0 and before. Notification sent only if someone directly replies to the comment (not a reply of a reply) $sql = "SELECT cn.cid, cn.uid, cn.deletehash " . "FROM {$_TABLES['comments']} AS c, {$_TABLES['comments']} AS c2, " . "{$_TABLES['commentnotifications']} AS cn " . "WHERE c2.cid = cn.cid AND (c.lft >= c2.lft AND c.lft <= c2.rht) " . "AND c.cid = {$A['pid']} GROUP BY cn.uid"; $result = DB_query($sql); $B = DB_fetchArray($result); if ($B !== false) { CMT_sendReplyNotification($B); } } // Update Comment Feeds COM_rdfUpToDateCheck('comment'); // Delete What's New block cache so it can get updated again if ($_CONF['whatsnew_cache_time'] > 0 and !$_CONF['hidenewcomments']) { $cacheInstance = 'whatsnew__'; // remove all whatsnew instances CACHE_remove_instance($cacheInstance); } return $A['sid']; }
/** * Perform database upgrades * * @param string $currentGlVersion Current Geeklog version * @return bool True if successful */ private function doDatabaseUpgrades($currentGlVersion) { global $_TABLES, $_CONF, $_SP_CONF, $_DB, $_DB_dbms, $_DB_table_prefix; $_DB->setDisplayError(true); // Because the upgrade sql syntax can vary from dbms-to-dbms we are // leaving that up to each Geeklog database driver $done = false; $progress = ''; $_SQL = array(); while (!$done) { switch ($currentGlVersion) { case '1.2.5-1': // Get DMBS-specific update sql require_once $_CONF['path'] . 'sql/updates/' . $_DB_dbms . '_1.2.5-1_to_1.3.php'; $this->updateDB($_SQL, $progress); // OK, now we need to add all users except anonymous to the All Users group and Logged in users group // I can hard-code these group numbers because the group table was JUST created with these numbers $result = DB_query("SELECT uid FROM {$_TABLES['users']} WHERE uid <> 1"); $numRows = DB_numRows($result); for ($i = 1; $i <= $numRows; $i++) { $U = DB_fetchArray($result); DB_query("INSERT INTO {$_TABLES['group_assignments']} VALUES (2, {$U['uid']}, NULL)"); DB_query("INSERT INTO {$_TABLES['group_assignments']} VALUES (13, {$U['uid']}, NULL)"); } // Now take care of any orphans off the user table...and let me curse MySQL lack for supporting foreign // keys at this time ;-) $result = DB_query("SELECT MAX(uid) FROM {$_TABLES['users']}"); $ITEM = DB_fetchArray($result); $max_uid = $ITEM[0]; if (!empty($max_uid) && $max_uid != 0) { DB_query("DELETE FROM {$_TABLES['userindex']} WHERE uid > {$max_uid}"); DB_query("DELETE FROM {$_TABLES['userinfo']} WHERE uid > {$max_uid}"); DB_query("DELETE FROM {$_TABLES['userprefs']} WHERE uid > {$max_uid}"); DB_query("DELETE FROM {$_TABLES['usercomment']} WHERE uid > {$max_uid}"); } $currentGlVersion = '1.3'; $_SQL = array(); break; case '1.3': require_once $_CONF['path'] . 'sql/updates/' . $_DB_dbms . '_1.3_to_1.3.1.php'; $this->updateDB($_SQL, $progress); $currentGlVersion = '1.3.1'; $_SQL = array(); break; case '1.3.1': require_once $_CONF['path'] . 'sql/updates/' . $_DB_dbms . '_1.3.1_to_1.3.2.php'; $this->updateDB($_SQL, $progress); $currentGlVersion = '1.3.2-1'; $_SQL = array(); break; case '1.3.2': case '1.3.2-1': require_once $_CONF['path'] . 'sql/updates/' . $_DB_dbms . '_1.3.2-1_to_1.3.3.php'; $this->updateDB($_SQL, $progress); // Now we need to switch how user blocks are stored. Right now we only store the blocks the // user wants. This will switch it to store the ones they don't want which allows us to add // new blocks and ensure they are shown to the user. $result = DB_query("SELECT {$_TABLES['users']}.uid,boxes FROM {$_TABLES['users']},{$_TABLES['userindex']} WHERE boxes IS NOT NULL AND boxes <> '' AND {$_TABLES['users']}.uid = {$_TABLES['userindex']}.uid"); $numRows = DB_numRows($result); for ($i = 1; $i <= $numRows; $i++) { $row = DB_fetchArray($result); $uBlocks = str_replace(' ', ',', $row['boxes']); $result2 = DB_query("SELECT bid,name FROM {$_TABLES['blocks']} WHERE bid NOT IN ({$uBlocks})"); $newBlocks = ''; for ($x = 1; $x <= DB_numRows($result2); $x++) { $currentBlock = DB_fetchArray($result2); if ($currentBlock['name'] !== 'user_block' && $currentBlock['name'] !== 'admin_block' && $currentBlock['name'] !== 'section_block') { $newBlocks .= $currentBlock['bid']; if ($x != DB_numRows($result2)) { $newBlocks .= ' '; } } } DB_query("UPDATE {$_TABLES['userindex']} SET boxes = '{$newBlocks}' WHERE uid = {$row['uid']}"); } $currentGlVersion = '1.3.3'; $_SQL = array(); break; case '1.3.3': require_once $_CONF['path'] . 'sql/updates/' . $_DB_dbms . '_1.3.3_to_1.3.4.php'; $this->updateDB($_SQL, $progress); $currentGlVersion = '1.3.4'; $_SQL = array(); break; case '1.3.4': require_once $_CONF['path'] . 'sql/updates/' . $_DB_dbms . '_1.3.4_to_1.3.5.php'; $this->updateDB($_SQL, $progress); $result = DB_query("SELECT ft_id FROM {$_TABLES['features']} WHERE ft_name = 'user.mail'"); $row = DB_fetchArray($result); $mail_ft = $row['ft_id']; $result = DB_query("SELECT grp_id FROM {$_TABLES['groups']} WHERE grp_name = 'Mail Admin'"); $row = DB_fetchArray($result); $group_id = $row['grp_id']; DB_query("INSERT INTO {$_TABLES['access']} (acc_grp_id, acc_ft_id) VALUES ({$group_id}, {$mail_ft})"); $currentGlVersion = '1.3.5'; $_SQL = array(); break; case '1.3.5': require_once $_CONF['path'] . 'sql/updates/' . $_DB_dbms . '_1.3.5_to_1.3.6.php'; $this->updateDB($_SQL, $progress); if (!empty($_DB_table_prefix)) { DB_query("RENAME TABLE staticpage TO {$_TABLES['staticpage']}"); } $currentGlVersion = '1.3.6'; $_SQL = array(); break; case '1.3.6': // fix wrong permissions value DB_query("UPDATE {$_TABLES['topics']} SET perm_anon = 2 WHERE perm_anon = 3"); // check for existence of 'date' field in gl_links table DB_query("SELECT date FROM {$_TABLES['links']}", 1); if (strpos(DB_error(), 'date') > 0) { DB_query("ALTER TABLE {$_TABLES['links']} ADD date datetime default NULL"); } // Fix primary key so that more than one user can add an event // to his/her personal calendar. DB_query("ALTER TABLE {$_TABLES['personal_events']} DROP PRIMARY KEY, ADD PRIMARY KEY (eid,uid)"); $currentGlVersion = '1.3.7'; $_SQL = array(); break; case '1.3.7': require_once $_CONF['path'] . 'sql/updates/' . $_DB_dbms . '_1.3.7_to_1.3.8.php'; $this->updateDB($_SQL, $progress); // upgrade Static Pages plugin $spVersion = $this->getStaticPagesVersion(); if ($spVersion == 1) { // original version DB_query("ALTER TABLE {$_TABLES['staticpage']} " . "ADD COLUMN group_id mediumint(8) unsigned DEFAULT '1'," . "ADD COLUMN owner_id mediumint(8) unsigned DEFAULT '1'," . "ADD COLUMN perm_owner tinyint(1) unsigned DEFAULT '3'," . "ADD COLUMN perm_group tinyint(1) unsigned DEFAULT '2'," . "ADD COLUMN perm_members tinyint(1) unsigned DEFAULT '2'," . "ADD COLUMN perm_anon tinyint(1) unsigned DEFAULT '2'," . "ADD COLUMN sp_php tinyint(1) unsigned DEFAULT '0'," . "ADD COLUMN sp_nf tinyint(1) unsigned DEFAULT '0'," . "ADD COLUMN sp_centerblock tinyint(1) unsigned NOT NULL default '0'," . "ADD COLUMN sp_tid varchar(20) NOT NULL default 'none'," . "ADD COLUMN sp_where tinyint(1) unsigned NOT NULL default '1'"); DB_query("INSERT INTO {$_TABLES['features']} (ft_name, ft_descr) VALUES ('staticpages.PHP','Ability to use PHP in static pages')"); $php_id = DB_insertId(); $group_id = DB_getItem($_TABLES['groups'], 'grp_id', "grp_name = 'Static Page Admin'"); DB_query("INSERT INTO {$_TABLES['access']} (acc_ft_id, acc_grp_id) VALUES ({$php_id}, {$group_id})"); } elseif ($spVersion == 2) { // extended version by Phill or Tom DB_query("ALTER TABLE {$_TABLES['staticpage']} " . "DROP COLUMN sp_pos," . "DROP COLUMN sp_search_keywords," . "ADD COLUMN sp_nf tinyint(1) unsigned DEFAULT '0'," . "ADD COLUMN sp_centerblock tinyint(1) unsigned NOT NULL default '0'," . "ADD COLUMN sp_tid varchar(20) NOT NULL default 'none'," . "ADD COLUMN sp_where tinyint(1) unsigned NOT NULL default '1'"); } if ($spVersion > 0) { // update plugin version number DB_query("UPDATE {$_TABLES['plugins']} SET pi_version = '1.3', pi_gl_version = '1.3.8' WHERE pi_name = 'staticpages'"); // remove Static Pages 'lock' flag DB_query("DELETE FROM {$_TABLES['vars']} WHERE name = 'staticpages'"); // remove Static Pages Admin group id DB_query("DELETE FROM {$_TABLES['vars']} WHERE name = 'sp_group_id'"); if ($spVersion == 1) { $result = DB_query("SELECT DISTINCT sp_uid FROM {$_TABLES['staticpage']}"); $authors = DB_numRows($result); for ($i = 0; $i < $authors; $i++) { $A = DB_fetchArray($result); DB_query("UPDATE {$_TABLES['staticpage']} SET owner_id = '{$A['sp_uid']}' WHERE sp_uid = '{$A['sp_uid']}'"); } } $result = DB_query("SELECT sp_label FROM {$_TABLES['staticpage']} WHERE sp_title = 'Frontpage'"); if (DB_numRows($result) > 0) { $A = DB_fetchArray($result); if ($A['sp_label'] == 'nonews') { DB_query("UPDATE {$_TABLES['staticpage']} SET sp_centerblock = 1, sp_where = 0 WHERE sp_title = 'Frontpage'"); } elseif (!empty($A['sp_label'])) { DB_query("UPDATE {$_TABLES['staticpage']} SET sp_centerblock = 1, sp_title = '{$A['sp_label']}' WHERE sp_title = 'Frontpage'"); } else { DB_query("UPDATE {$_TABLES['staticpage']} SET sp_centerblock = 1 WHERE sp_title = 'Frontpage'"); } } } $currentGlVersion = '1.3.8'; $_SQL = array(); break; case '1.3.8': require_once $_CONF['path'] . 'sql/updates/' . $_DB_dbms . '_1.3.8_to_1.3.9.php'; $this->updateDB($_SQL, $progress); $pos = strrpos($_CONF['rdf_file'], '/'); $filename = substr($_CONF['rdf_file'], $pos + 1); $siteName = DB_escapeString($_CONF['site_name']); $siteSlogan = DB_escapeString($_CONF['site_slogan']); DB_query("INSERT INTO {$_TABLES['syndication']} (title, description, limits, content_length, filename, charset, language, is_enabled, updated, update_info) VALUES ('{$siteName}', '{$siteSlogan}', '{$_CONF['rdf_limit']}', {$_CONF['rdf_storytext']}, '{$filename}', '{$_CONF['default_charset']}', '{$_CONF['rdf_language']}', {$_CONF['backend']}, CURRENT_TIMESTAMP, NULL)"); // upgrade static pages plugin $spVersion = $this->getStaticPagesVersion(); if ($spVersion > 0) { if ($spVersion < 4) { if (!isset($_SP_CONF['in_block'])) { $_SP_CONF['in_block'] = 1; } elseif ($_SP_CONF['in_block'] > 1) { $_SP_CONF['in_block'] = 1; } elseif ($_SP_CONF['in_block'] < 0) { $_SP_CONF['in_block'] = 0; } DB_query("ALTER TABLE {$_TABLES['staticpage']} ADD COLUMN sp_inblock tinyint(1) unsigned DEFAULT '{$_SP_CONF['in_block']}'"); } DB_query("UPDATE {$_TABLES['plugins']} SET pi_version = '1.4', pi_gl_version = '1.3.9' WHERE pi_name = 'staticpages'"); } // recreate 'date' field for old links $result = DB_query("SELECT lid FROM {$_TABLES['links']} WHERE date IS NULL"); $num = DB_numRows($result); if ($num > 0) { for ($i = 0; $i < $num; $i++) { $A = DB_fetchArray($result); $myYear = substr($A['lid'], 0, 4); $myMonth = substr($A['lid'], 4, 2); $myDay = substr($A['lid'], 6, 2); $myHour = substr($A['lid'], 8, 2); $myMin = substr($A['lid'], 10, 2); $mySec = substr($A['lid'], 12, 2); $mTime = mktime($myHour, $myMin, $mySec, $myMonth, $myDay, $myYear); $date = date('Y-m-d H:i:s', $mTime); DB_query("UPDATE {$_TABLES['links']} SET date = '{$date}' WHERE lid = '{$A['lid']}'"); } } // remove unused entries left over from deleted groups $result = DB_query("SELECT grp_id FROM {$_TABLES['groups']}"); $num = DB_numRows($result); $groups = array(); for ($i = 0; $i < $num; $i++) { $A = DB_fetchArray($result); $groups[] = $A['grp_id']; } $groupList = '(' . implode(',', $groups) . ')'; DB_query("DELETE FROM {$_TABLES['group_assignments']} WHERE (ug_main_grp_id NOT IN {$groupList}) OR (ug_grp_id NOT IN {$groupList})"); $currentGlVersion = '1.3.9'; $_SQL = array(); break; case '1.3.9': require_once $_CONF['path'] . 'sql/updates/' . $_DB_dbms . '_1.3.9_to_1.3.10.php'; $this->updateDB($_SQL, $progress); commentsToPreorderTree(); $result = DB_query("SELECT sid,introtext,bodytext FROM {$_TABLES['stories']}"); $numStories = DB_numRows($result); for ($i = 0; $i < $numStories; $i++) { $A = DB_fetchArray($result); $related = DB_escapeString(implode("\n", UPDATE_extractLinks($A['introtext'] . ' ' . $A['bodytext']))); if (empty($related)) { DB_query("UPDATE {$_TABLES['stories']} SET related = NULL WHERE sid = '{$A['sid']}'"); } else { DB_query("UPDATE {$_TABLES['stories']} SET related = '{$related}' WHERE sid = '{$A['sid']}'"); } } $spVersion = $this->getStaticPagesVersion(); if ($spVersion > 0) { // no database changes this time, but set new version number DB_query("UPDATE {$_TABLES['plugins']} SET pi_version = '1.4.1', pi_gl_version = '1.3.10' WHERE pi_name = 'staticpages'"); } // install SpamX plugin // (also handles updates from version 1.0) install_spamx_plugin(); $currentGlVersion = '1.3.10'; $_SQL = array(); break; case '1.3.10': require_once $_CONF['path'] . 'sql/updates/' . $_DB_dbms . '_1.3.10_to_1.3.11.php'; $this->updateDB($_SQL, $progress); $currentGlVersion = '1.3.11'; $_SQL = array(); break; case '1.3.11': require_once $_CONF['path'] . 'sql/updates/' . $_DB_dbms . '_1.3.11_to_1.4.0.php'; $this->updateDB($_SQL, $progress); upgrade_addFeature(); upgrade_uniqueGroupNames(); $currentGlVersion = '1.4.0'; $_SQL = array(); break; case '1.4.0': require_once $_CONF['path'] . 'sql/updates/' . $_DB_dbms . '_1.4.0_to_1.4.1.php'; $this->updateDB($_SQL, $progress); upgrade_addSyndicationFeature(); upgrade_ensureLastScheduledRunFlag(); upgrade_plugins_141(); $currentGlVersion = '1.4.1'; $_SQL = array(); break; case '1.4.1': require_once $_CONF['path'] . 'sql/updates/' . $_DB_dbms . '_1.4.1_to_1.5.0.php'; $this->updateDB($_SQL, $progress); upgrade_addWebservicesFeature(); create_ConfValues(); require_once $_CONF['path_system'] . 'classes/config.class.php'; $config = config::get_instance(); if (file_exists($_CONF['path'] . 'config.php')) { // Read the values from config.php and use them to populate conf_values $tempPath = $_CONF['path']; // We'll need this to remember what the correct path is. // Including config.php will overwrite all our $_CONF values. require $tempPath . 'config.php'; // Load some important values from config.php into conf_values foreach ($_CONF as $key => $val) { $config->set($key, $val); } if (!$this->setDefaultCharset($this->env['siteconfig_path'], $_CONF['default_charset'])) { exit($this->LANG['INSTALL'][26] . ' ' . $this->env['siteconfig_path'] . $this->LANG['INSTALL'][58]); } require $this->env['siteconfig_path']; require $this->env['dbconfig_path']; } // Update the GL configuration with the correct paths. $config->set('path_html', $this->env['html_path']); $config->set('path_log', $_CONF['path'] . 'logs/'); $config->set('path_language', $_CONF['path'] . 'language/'); $config->set('backup_path', $_CONF['path'] . 'backups/'); $config->set('path_data', $_CONF['path'] . 'data/'); $config->set('path_images', $this->env['html_path'] . 'images/'); $config->set('path_themes', $this->env['html_path'] . 'layout/'); $config->set('path_editors', $this->env['html_path'] . 'editors/'); $config->set('rdf_file', $this->env['html_path'] . 'backend/geeklog.rss'); $config->set('path_pear', $_CONF['path_system'] . 'pear/'); // core plugin updates are done in the plugins themselves $currentGlVersion = '1.5.0'; $_SQL = array(); break; case '1.5.0': require_once $_CONF['path'] . 'sql/updates/' . $_DB_dbms . '_1.5.0_to_1.5.1.php'; $this->updateDB($_SQL, $progress); $currentGlVersion = '1.5.1'; $_SQL = array(); break; case '1.5.1': // there were no core database changes in 1.5.2 $currentGlVersion = '1.5.2'; $_SQL = array(); break; case '1.5.2': require_once $_CONF['path'] . 'sql/updates/' . $_DB_dbms . '_1.5.2_to_1.6.0.php'; $this->updateDB($_SQL, $progress); update_ConfValues(); upgrade_addNewPermissions(); upgrade_addIsoFormat(); $this->fixOptionalConfig(); $currentGlVersion = '1.6.0'; $_SQL = array(); break; case '1.6.0': require_once $_CONF['path'] . 'sql/updates/' . $_DB_dbms . '_1.6.0_to_1.6.1.php'; $this->updateDB($_SQL, $progress); update_ConfValuesFor161(); $currentGlVersion = '1.6.1'; $_SQL = array(); break; case '1.6.1': require_once $_CONF['path'] . 'sql/updates/' . $_DB_dbms . '_1.6.1_to_1.7.0.php'; $this->updateDB($_SQL, $progress); update_ConfValuesFor170(); $currentGlVersion = '1.7.0'; $_SQL = array(); break; case '1.7.0': $currentGlVersion = '1.7.2'; // skip ahead $_SQL = array(); break; case '1.7.1': // there were no database changes in 1.7.1 // there were no database changes in 1.7.1 case '1.7.2': require_once $_CONF['path'] . 'sql/updates/' . $_DB_dbms . '_1.7.2_to_1.8.0.php'; $this->updateDB($_SQL, $progress); update_ConfValuesFor180(); update_ConfigSecurityFor180(); update_UsersFor180(); $currentGlVersion = '1.8.0'; $_SQL = array(); break; case '1.8.0': case '1.8.1': case '1.8.2': // there were no database changes in 1.8.x require_once $_CONF['path'] . 'sql/updates/' . $_DB_dbms . '_1.8.2_to_2.0.0.php'; $this->updateDB($_SQL, $progress); update_ConfValuesFor200(); update_BlockTopicAssignmentsFor200(); update_StoryTopicAssignmentsFor200(); $currentGlVersion = '2.0.0'; $_SQL = array(); break; case '2.0.0': require_once $_CONF['path'] . 'sql/updates/' . $_DB_dbms . '_2.0.0_to_2.1.0.php'; $this->updateDB($_SQL, $progress); update_addFilemanager(); update_ConfValuesFor210(); $currentGlVersion = '2.1.0'; $_SQL = array(); break; case '2.1.1': require_once $_CONF['path'] . 'sql/updates/' . $_DB_dbms . '_2.1.1_to_2.1.2.php'; $this->updateDB($_SQL, $progress); update_ConfValuesFor212(); $currentGlVersion = '2.1.2'; $_SQL = array(); break; default: $done = true; } } $this->setVersion($this->env['siteconfig_path']); // delete the security check flag on every update to force the user // to run admin/sectest.php again DB_delete($_TABLES['vars'], 'name', 'security_check'); return true; }
/** * Moves comment from submission table to comments table * * @copyright Jared Wenerd 2008 * @author Jared Wenerd, wenerd87 AT gmail DOT com * @param string $cid comment id * @return string of story id */ function CMT_approveModeration($cid) { global $_CONF, $_TABLES; $result = DB_query("SELECT type, sid, date, title, comment, uid, name, pid, ipaddress FROM {$_TABLES['commentsubmissions']} WHERE cid = '{$cid}'"); $A = DB_fetchArray($result); if ($A['pid'] > 0) { // get indent+1 of parent $indent = DB_getItem($_TABLES['comments'], 'indent+1', "cid = '{$A['pid']}'"); } else { $indent = 0; } $A['title'] = addslashes($A['title']); $A['comment'] = addslashes($A['comment']); if (isset($A['name'])) { // insert data $A['name'] = addslashes($A['name']); DB_save($_TABLES['comments'], 'type,sid,date,title,comment,uid,name,pid,ipaddress,indent', "'{$A['type']}','{$A['sid']}','{$A['date']}','{$A['title']}','{$A['comment']}','{$A['uid']}'," . "'{$A['name']}','{$A['pid']}','{$A['ipaddress']}',{$indent}"); } else { // insert data, null automatically goes into name column DB_save($_TABLES['comments'], 'type,sid,date,title,comment,uid,pid,ipaddress,indent', "'{$A['type']}','{$A['sid']}','{$A['date']}','{$A['title']}','{$A['comment']}','{$A['uid']}'," . "'{$A['pid']}','{$A['ipaddress']}',{$indent}"); } $newcid = DB_insertId(); DB_delete($_TABLES['commentsubmissions'], 'cid', $cid); DB_change($_TABLES['commentnotifications'], 'cid', $newcid, 'mid', $cid); // notify of new published comment if ($_CONF['allow_reply_notifications'] == 1 && $A['pid'] > 0) { $result = DB_query("SELECT cid, uid, deletehash FROM {$_TABLES['commentnotifications']} WHERE cid = {$A['pid']}"); $B = DB_fetchArray($result); if ($B !== false) { CMT_sendReplyNotification($B); } } return $A['sid']; }