function plugin_install_captcha() { global $pi_name, $pi_version, $gl_version, $pi_url, $NEWTABLE, $DEFVALUES, $NEWFEATURE; global $_TABLES, $_CONF, $LANG_CP00, $_DB_dbms; COM_errorLog("Attempting to install the {$pi_name} Plugin", 1); $_SQL['cp_config'] = "CREATE TABLE {$_TABLES['cp_config']} ( " . " `config_name` varchar(255) NOT NULL default '', " . " `config_value` varchar(255) NOT NULL default '', " . " PRIMARY KEY (`config_name`) " . " );"; $_SQL['cp_sessions'] = "CREATE TABLE {$_TABLES['cp_sessions']} ( " . " `session_id` varchar(40) NOT NULL default '', " . " `cptime` INT(11) NOT NULL default 0, " . " `validation` varchar(40) NOT NULL default '', " . " `counter` TINYINT(4) NOT NULL default 0, " . " PRIMARY KEY (`session_id`) " . " );"; foreach ($_SQL 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_captcha(); return false; exit; } COM_errorLog("Success - Created {$table} table", 1); } $SQL_DEFAULTS = "INSERT INTO `{$_TABLES['cp_config']}` (`config_name`, `config_value`) VALUES " . " ('anonymous_only', '1'), " . " ('remoteusers','0'), " . " ('debug', '0'), " . " ('enable_comment', '0'), " . " ('enable_contact', '0'), " . " ('enable_emailstory', '0'), " . " ('enable_forum', '0'), " . " ('enable_registration', '0'), " . " ('enable_story', '0'), " . " ('gfxDriver', '2'), " . " ('gfxFormat', 'jpg'), " . " ('gfxPath', '');"; DB_query($SQL_DEFAULTS, 1); // Register the plugin with Geeklog COM_errorLog("Registering {$pi_name} plugin with Geeklog", 1); DB_delete($_TABLES['plugins'], 'pi_name', 'captcha'); 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("Failure registering plugin with Geeklog"); plugin_uninstall_captcha(); return false; exit; } // Create initial log entry CAPTCHA_errorLog("CAPTCHA Plugin Successfully Installed"); COM_errorLog("Successfully installed the {$pi_name} Plugin!", 1); return true; }
/** * Execute the SQL statement to perform a version upgrade. * An empty SQL parameter will return success. * * @param string $version Version being upgraded to * @param array $sql SQL statement to execute * @return integer Zero on success, One on failure. */ function EXP_upgrade_sql($version = 'Undefined', $sql = '') { global $_TABLES, $_CONF_EXP; // We control this, so it shouldn't happen, but just to be safe... if ($version == 'Undefined') { COM_errorLog("Error updating {$_CONF_EXP['pi_name']} - Undefined Version"); return 1; } // If no sql statements passed in, return success if (!is_array($sql)) { return 0; } // Execute SQL now to perform the upgrade COM_errorLOG("--Updating External Pages to version {$version}"); for ($i = 1; $i <= count($sql); $i++) { COM_errorLOG("External Pages Plugin {$version} update: Executing SQL => " . current($sql)); DB_query(current($sql), '1'); if (DB_error()) { COM_errorLog("SQL Error during External Pages plugin update", 1); return 1; break; } next($sql); } return 0; }
function nexform_importForm($_SQL, $cntr) { global $CONF_FE, $_TABLES; DB_query($_SQL[0], '1'); if (DB_error()) { COM_errorLog("nexform SQL error importing form: {$_SQL[0]}"); } $newformid = DB_insertID(); /* Delete any previous imported form field definition records New field definition records will have a formid of '99999' assigned Insert the new records and then update to match the new form definition */ DB_query("DELETE FROM {$_TABLES['nxform_fields']} WHERE formid='{$cntr}'"); next($_SQL); // Increment to the field definition records for ($i = 1; $i < count($_SQL); $i++) { DB_query(current($_SQL), '1'); if (DB_error()) { COM_errorLog("executing " . current($_SQL)); COM_errorLog("Error executing SQL", 1); exit; } next($_SQL); } DB_query("UPDATE {$_TABLES['nxform_fields']} set formid='{$newformid}' WHERE formid='{$cntr}'"); // Need to cycle thru the fields now and update any fieldnames if auto fieldname used $query = DB_query("SELECT id,type FROM {$_TABLES['nxform_fields']} WHERE formid='{$newformid}' AND field_name LIKE '%_frm%'"); while (list($fieldid, $fieldtype) = DB_fetchArray($query)) { $fieldname = "{$CONF_FE['fieldtypes'][$fieldtype][0]}{$newformid}_{$fieldid}"; DB_query("UPDATE {$_TABLES['nxform_fields']} set field_name='{$fieldname}' WHERE id='{$fieldid}'"); } }
function update_150_to_151() { global $_TABLES, $_CONF, $_SP_CONF; $P_SQL = array(); $P_SQL[] = "ALTER TABLE {$_TABLES['staticpage']} ADD sp_search tinyint(4) NOT NULL default '1' AFTER postmode"; // allow searching on all existing static pages $P_SQL[] = "UPDATE {$_TABLES['staticpage']} SET sp_search = 1"; $P_SQL[] = "UPDATE {$_TABLES['plugins']} SET pi_version = '1.5.1', pi_gl_version = '1.1.0', pi_homepage='http://www.glfusion.org' WHERE pi_name = 'staticpages'"; foreach ($P_SQL as $sql) { $rst = DB_query($sql, 1); if (DB_error()) { COM_errorLog("StaticPage Update Error: Could not execute the following SQL: " . $sql); return false; } } $res = DB_query("SELECT * FROM {$_TABLES['vars']} WHERE name='sp_fix_01'"); if (DB_numRows($res) < 1) { $sql = "SELECT * FROM {$_TABLES['staticpage']}"; $result = DB_query($sql); while ($A = DB_fetchArray($result)) { $newcontent = stripslashes($A['sp_content']); $newcontent = mysql_real_escape_string($newcontent); DB_query("UPDATE {$_TABLES['staticpage']} SET sp_content='" . $newcontent . "' WHERE sp_id='" . $A['sp_id'] . "'"); } DB_query("INSERT INTO {$_TABLES['vars']} VALUES ('sp_fix_01', 1)", 1); } return true; }
function update_tables() { global $_TABLES; global $_CONF; //マスタのデータ $_SQL = array(); //=====SQL 定義 ココから // 更新が必要なところの条件を変更して使用してください if (1 === 0) { //カテゴリ定義に親カテゴリIDとグループID追加 $_SQL[] = "\n\t\tCREATE TABLE {$_TABLES['DATABOX_def_fieldset']} (\n\t\t`fieldset_id` int(11) NOT NULL,\n\t\t`name` varchar(64) NOT NULL,\n\t\t`description` mediumtext,\n\t\t`udatetime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,\n\t\t`uuid` mediumint(8) NOT NULL,\n\t\tPRIMARY KEY (`fieldset_id`)\n\t\t) ENGINE=MyISAM\n\t\t"; //属性セット関連 $_SQL[] = "\n\t\tCREATE TABLE {$_TABLES['DATABOX_def_fieldset_assignments']} (\n\t\t`seq` int(11) NOT NULL AUTO_INCREMENT,\n\t\t`fieldset_id` int(11) NOT NULL,\n\t\t`field_id` int(11) NOT NULL,\n\t\tPRIMARY KEY (`seq`),\n\t\tKEY `fieldset_id` (`fieldset_id`)\n\t\t) ENGINE=MyISAM\n\t\t"; $_SQL[] = "\n ALTER TABLE {$_TABLES['DATABOX_base']}\n\t\tADD `fieldset_id` int(11) NOT NULL default 0 AFTER `orderno`,\n "; } //=====SQL 定義 ココまで //------------------------------------------------------------------ for ($i = 1; $i <= count($_SQL); $i++) { $w = current($_SQL); DB_query(current($_SQL)); next($_SQL); } if (DB_error()) { COM_errorLog("error DataBox table update ", 1); return false; } COM_errorLog("Success - DataBox table update", 1); return "end"; }
/** * Resize an image to the specified dimensions, placing the resulting * image in the specified location. At least one of $newWidth or * $newHeight must be specified. * * @param string $type Either 'thumb' or 'disp' * @param integer $newWidth New width, in pixels * @param integer $newHeight New height, in pixels * @return string Blank if successful, error message otherwise. */ public static function ReSize($src, $dst, $newWidth = 0, $newHeight = 0) { global $_LGLIB_CONF; // Calculate the new dimensions $A = self::reDim($src, $newWidth, $newHeight); if ($A === false) { COM_errorLog("Invalid image {$src}"); return 'invalid image conversion'; } list($sWidth, $sHeight, $dWidth, $dHeight) = $A; // Get the mime type for the glFusion resizing functions $mime_type = image_type_to_mime_type(exif_imagetype($src)); // Returns an array, with [0] either true/false and [1] // containing a message. $result = array(); if (function_exists(_img_resizeImage)) { $result = _img_resizeImage($src, $dst, $sHeight, $sWidth, $dHeight, $dWidth, $mime_type); } else { $result[0] = false; } if ($result[0] == true) { return ''; } else { COM_errorLog("Failed to convert {$src} ({$sHeight} x {$sWidth}) to {$dst} ({$dHeight} x {$dWidth})"); return 'invalid image conversion'; } }
function nf_check4files($projectid, $taskid, $fieldname) { global $_FILES, $_CONF, $_TABLES, $_USER, $CONF_NF, $LANG_GF00; $errmsg = ''; $uploadfile = $_FILES[$fieldname]; // Check if there is a request to delete any attachments if (isset($_POST['chk_removeattachment'])) { foreach ($_POST['chk_removeattachment'] as $id) { $filename = DB_getItem($_TABLES['nf_projectattachments'], 'filename', "id={$id}"); $parts = explode(':', $filename); COM_errorLog("{$CONF_NF['uploadpath']}/{$parts[0]}"); DB_query("DELETE FROM {$_TABLES['nf_projectattachments']} WHERE id={$id}"); @unlink("{$CONF_NF['uploadpath']}/{$parts[0]}"); } } if ($uploadfile['name'] != '') { $uploadfilename = ppRandomFilename(); $pos = strrpos($uploadfile['name'], '.') + 1; $ext = strtolower(substr($uploadfile['name'], $pos)); $filename = "{$uploadfilename}.{$ext}"; COM_errorlog("Workflow file upload: Original file: {$uploadfile['name']} and new filename: {$filename}"); $filestore_path = $CONF_NF['uploadpath']; if (nf_uploadfile($filename, $uploadfile, $CONF_NF['allowablefiletypes'], $filestore_path)) { // Store both the created filename and the real file source filename $filename = "{$filename}:{$uploadfile['name']}"; DB_query("INSERT INTO {$_TABLES['nf_projectattachments']} (project_id,task_id,fieldname,filename)\r\n VALUES ({$projectid},{$taskid},'{$fieldname}','{$filename}')"); } else { COM_errorlog("upload error:" . $GLOBALS['nf_errmsg']); $errmsg = $GLOBALS['nf_errmsg']; } } return $errmsg; }
/** * Set the system's timezone * * @param string $tz timezone to set; use $_CONF['timezone'] if empty * @return void * @static * */ public static function setSystemTimeZone($tz = '') { global $_CONF; static $system_timezone = ''; if (empty($tz) && !empty($_CONF['timezone'])) { $tz = $_CONF['timezone']; } if (!empty($tz)) { if ($tz != $system_timezone) { if (function_exists('date_default_timezone_set')) { if (!@date_default_timezone_set($tz)) { date_default_timezone_set('UTC'); COM_errorLog("Timezone '{$tz}' not valid - using 'UTC' instead", 1); $system_timezone = 'UTC'; } else { $system_timezone = $tz; } } elseif (!ini_get('safe_mode') && function_exists('putenv')) { // aka "Timezone Hack" putenv('TZ=' . $tz); $system_timezone = $tz; } } } elseif (function_exists('date_default_timezone_get')) { // this is not ideal but will stop PHP 5.3.0ff from complaining ... $system_timezone = @date_default_timezone_get(); date_default_timezone_set($system_timezone); } }
/** * Loads the configuration records for the Online Config Manager * @return boolean true = proceed with install, false = an error occured */ function plugin_load_configuration_external() { global $_CONF, $_CONF_EXP, $_TABLES; COM_errorLog("Loading the configuration for the External plugin", 1); require_once $_CONF['path'] . 'plugins/' . $_CONF_EXP['pi_name'] . '/install_defaults.php'; // Get the admin group ID that was saved previously. $group_id = (int) DB_getItem($_TABLES['groups'], 'grp_id', "grp_name='{$_CONF_EXP['pi_name']} Admin'"); return plugin_initconfig_external($group_id); }
/** * Puts the datastructures for this plugin into the glFusion database * Note: Corresponding uninstall routine is in functions.inc * * @return boolean True if successful False otherwise */ function plugin_install_lglib() { global $INSTALL_plugin, $_LGLIB_CONF; COM_errorLog("Attempting to install the {$_LGLIB_CONF['pi_name']} plugin", 1); $ret = INSTALLER_install($INSTALL_plugin[$_LGLIB_CONF['pi_name']]); if ($ret > 0) { return false; } else { return true; } }
/** * Puts the datastructures for this plugin into the glFusion database * * Note: Corresponding uninstall routine is in functions.inc * * @return boolean True if successful False otherwise * */ function plugin_install_mediagallery() { global $INSTALL_plugin, $_MG_CONF; $pi_name = $_MG_CONF['pi_name']; $pi_display_name = $_MG_CONF['pi_display_name']; $pi_version = $_MG_CONF['pi_version']; COM_errorLog("Attempting to install the {$pi_display_name} plugin", 1); $ret = INSTALLER_install($INSTALL_plugin[$pi_name]); if ($ret > 0) { return false; } return true; }
/** * Puts the datastructures for this plugin into the glFusion database * * Note: Corresponding uninstall routine is in functions.inc * * @return boolean True if successful False otherwise * */ function plugin_install_filemgmt() { global $INSTALL_plugin, $CONF_FM; $pi_name = $CONF_FM['pi_name']; $pi_display_name = $CONF_FM['pi_display_name']; $pi_version = $CONF_FM['pi_version']; COM_errorLog("Attempting to install the {$pi_display_name} plugin", 1); $ret = INSTALLER_install($INSTALL_plugin[$pi_name]); if ($ret > 0) { return false; } return true; }
/** * Puts the datastructures for this plugin into the glFusion database. * Note: Corresponding uninstall routine is in functions.inc. * * @return boolean True if successful, False otherwise */ function plugin_install_classifieds() { global $INSTALL_plugin, $_CONF_ADVT; $pi_name = $_CONF_ADVT['pi_name']; $pi_display_name = $_CONF_ADVT['pi_display_name']; $pi_version = $_CONF_ADVT['pi_version']; COM_errorLog("Attempting to install the {$pi_display_name} plugin", 1); $ret = INSTALLER_install($INSTALL_plugin[$pi_name]); if ($ret > 0) { return false; } return true; }
function MG_approveSubmission($media_id) { global $_CONF, $_TABLES, $LANG_MG01; $mid = addslashes($media_id); $owner_uid = DB_getItem($_TABLES['mg_mediaqueue'], 'media_user_id', "media_id='" . $mid . "'"); DB_delete($_TABLES['mg_mediaqueue'], 'media_id', $mid); $album_id = DB_getItem($_TABLES['mg_media_album_queue'], 'album_id', "media_id='" . $mid . "'"); DB_save($_TABLES['mg_media_albums'], 'album_id, media_id, media_order', "{$album_id}, '{$mid}', 0"); require_once $_CONF['path'] . 'plugins/mediagallery/include/sort.php'; MG_SortMedia($album_id); DB_delete($_TABLES['mg_media_album_queue'], 'media_id', $mid); $sql = "SELECT media_filename, media_type " . "FROM {$_TABLES['mg_media']} WHERE media_id='" . $mid . "'"; $result = DB_query($sql); list($media_filename, $media_type) = DB_fetchArray($result); $media_count = DB_getItem($_TABLES['mg_albums'], 'media_count', 'album_id=' . $album_id); $media_count++; DB_change($_TABLES['mg_albums'], 'media_count', $media_count, 'album_id', $album_id); MG_updateAlbumLastUpdate($album_id); $album_cover = DB_getItem($_TABLES['mg_albums'], 'album_cover', 'album_id=' . $album_id); if ($album_cover == -1 && $media_type == 0) { DB_change($_TABLES['mg_albums'], 'album_cover_filename', $media_filename, 'album_id', $album_id); } // email the owner / uploader that the item has been approved. COM_clearSpeedlimit(600, 'mgapprove'); $last = COM_checkSpeedlimit('mgapprove'); if ($last == 0) { $result2 = DB_query("SELECT username, fullname, email FROM {$_TABLES['users']} WHERE uid='" . $owner_uid . "'"); list($username, $fullname, $email) = DB_fetchArray($result2); if ($email != '') { $subject = $LANG_MG01['upload_approved']; $body = $LANG_MG01['upload_approved']; $body .= '<br' . XHTML . '><br' . XHTML . '>'; $body .= $LANG_MG01['thanks_submit']; $body .= '<br' . XHTML . '><br' . XHTML . '>'; $body .= $_CONF['site_name'] . '<br' . XHTML . '>'; $body .= $_CONF['site_url'] . '<br' . XHTML . '>'; $to = array(); $from = array(); $to = COM_formatEmailAddress($username, $email); $from = COM_formatEmailAddress($_CONF['site_name'], $_CONF['site_mail']); if (!COM_mail($to, $subject, $body, $from, true)) { COM_errorLog("Media Gallery Error - Unable to send queue notification email"); } COM_updateSpeedlimit('mgapprove'); } } // PLG_itemSaved($media_id, 'mediagallery'); // COM_rdfUpToDateCheck(); // COM_olderStuff(); return; }
/** * Return an instance of a report formatter class * * @param string $type Name of the formatter * @return mixed Instance of the formatter object. */ function &factory($type) { $classfile = "format/{$type}.class.php"; if (include_once $classfile) { $class = "{$type}_format"; if (class_exists($class)) { $object =& new $class($options); return $object; } else { COM_errorLog("report.class - Unable to instantiate class {$class} from {$classfile}"); } } else { COM_errorLog("report.class - Unable to include file: {$classfile}"); } }
private function _sendDM($name, $msg) { try { $this->consumer = new HTTP_OAuth_Consumer($this->consumer_key, $this->consumer_secret, $this->token, $this->token_secret); $this->consumer->accept($this->request); $response = $this->consumer->sendRequest('http://api.twitter.com/1/direct_messages/new.xml', array('screen_name' => $name, 'text' => $msg), 'POST'); if ($response->getStatus() !== 200) { $this->errormsg = $response->getStatus() . ' : ' . $response->getBody(); COM_errorLog("TwitterAuth DM Error(" . $response->getStatus() . "/" . $response->getBody() . ") TwitterId={$name}, DM={$msg}"); } } catch (HTTP_OAuth_Consumer_Exception_Invalid_Response $e) { $this->errormsg = get_class($e) . ': ' . $e->getBody(); } catch (Exception $e) { $this->errormsg = get_class($e) . ': ' . $e->getMessage(); } }
/** * Sample PHP Block function * * this is a sample function used by a PHP block. This will show the rights that * a user has in the "What you have access to" block. * */ function phpblock_showrights() { global $_RIGHTS, $_CST_VERBOSE; $retval = ''; if ($_CST_VERBOSE) { COM_errorLog('**** Inside phpblock_showrights in lib-custom.php ****', 1); } $retval .= ' '; for ($i = 0; $i < count($_RIGHTS); $i++) { $retval .= '<li>' . $_RIGHTS[$i] . '</li>' . LB; } if ($_CST_VERBOSE) { COM_errorLog('**** Leaving phpblock_showrights in lib-custom.php ****', 1); } return $retval; }
/** * FTP Import * * @param int album_id album_id upload media * @return string HTML * */ function MG_ftpUpload($album_id) { global $_USER, $_CONF, $_MG_CONF, $LANG_MG00, $LANG_MG01, $LANG_MG03; $retval = ''; $album = new mgAlbum($album_id); if ($album->access == 3 || $album->member_uploads == 1 && $_USER['uid'] >= 2) { $T = COM_newTemplate(MG_getTemplatePath($album_id)); $T->set_file('mupload', 'ftpupload.thtml'); $T->set_var(array('album_id' => $album_id, 'start_block' => COM_startBlock($LANG_MG03['upload_media']), 'end_block' => COM_endBlock(), 'navbar' => MG_navbar($LANG_MG01['ftp_media'], $album_id), 's_form_action' => $_MG_CONF['site_url'] . '/admin.php', 'lang_upload_help' => $LANG_MG03['upload_help'], 'lang_media_ftp' => $LANG_MG01['upload_media'], 'lang_directory' => $LANG_MG01['directory'], 'lang_recurse' => $LANG_MG01['recurse'], 'lang_delete_files' => $LANG_MG01['delete_files'], 'lang_caption' => $LANG_MG01['caption'], 'lang_file' => $LANG_MG01['file'], 'lang_description' => $LANG_MG01['description'], 'lang_save' => $LANG_MG01['save'], 'lang_cancel' => $LANG_MG01['cancel'], 'lang_reset' => $LANG_MG01['reset'], 'lang_yes' => $LANG_MG01['yes'], 'lang_no' => $LANG_MG01['no'], 'lang_ftp_help' => $LANG_MG03['ftp_help'], 'album_id' => $album_id, 'ftp_path' => $_MG_CONF['ftp_path'], 'action' => 'ftp')); $retval .= $T->finish($T->parse('output', 'mupload')); return $retval; } else { COM_errorLog("MediaGallery: user attempted to upload to a restricted album."); return COM_showMessageText($LANG_MG00['access_denied_msg']); } }
/** * 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; }
function update_tables() { global $_TABLES; global $_CONF; //マスタのデータ $_SQL = array(); // 更新が必要なところの条件を変更して使用してください //20110208 if (1 === 0) { $_SQL[] = "\n ALTER TABLE {$_TABLES['USERBOX_base']}\n CHANGE `orderno` `orderno` INT( 2 ) NOT NULL DEFAULT '0'\n "; $_SQL[] = "\n ALTER TABLE {$_TABLES['USERBOX_base']}\n CHANGE `expired` `expired` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00'\n "; } //20110622 // userbox.edit (gl_feature) add if (1 === 0) { $_SQL[] = "\n INSERT INTO {$_TABLES['features']} (\n `ft_name` ,\n `ft_descr` ,\n `ft_gl_core`\n )\n VALUES (\n\t\t'userbox.edit', 'can edit profile to userbox plugin', '0'\n )\n\t\t"; $_SQL[] = "\n INSERT INTO {$_TABLES['features']} (\n `ft_name` ,\n `ft_descr` ,\n `ft_gl_core`\n )\n VALUES (\n\t\t'userbox.joingroup', 'can edit join group to userbox plugin', '0'\n )\n\t\t"; } //20110803 // group_id=0 add if (1 === 0) { $_SQL[] = "\n\t\tINSERT INTO {$_TABLES['USERBOX_def_group']} (\n\t\t`group_id` \n\t\t)\n\t\tVALUES (\n\t\t'0'\n\t\t);\n\t\t"; } //20110826 // group_id=0 add if (1 === 0) { $_SQL[] = "\n\t\tALTER TABLE {$_TABLES['USERBOX_base']}\n\t\tADD `eyechatchingimage` MEDIUMTEXT NULL AFTER `defaulttemplatesdirectory` \n\t\t"; } //20110915 // group_id=0 add if (1 === 1) { $_SQL[] = "\n INSERT INTO {$_TABLES['features']} (\n `ft_name` ,\n `ft_descr` ,\n `ft_gl_core`\n )\n VALUES (\n\t\t'userbox.user', 'Can register to UserBox', '0'\n )\n\t\t"; } //------------------------------------------------------------------ for ($i = 1; $i <= count($_SQL); $i++) { $w = current($_SQL); DB_query(current($_SQL)); next($_SQL); } if (DB_error()) { COM_errorLog("error UserBox table update ", 1); return false; } COM_errorLog("Success - UserBox table update", 1); return "end"; }
/** * Check for spam links * * @param string $post post to check for spam * @return boolean true = spam found, false = no spam * * Note: Also returns 'false' in case of problems communicating with SLV. * Error messages are logged in Geeklog's error.log * */ function CheckForSpam($post) { global $_SPX_CONF; require_once 'XML/RPC.php'; $retval = false; if (empty($post)) { return $retval; } $links = $this->prepareLinks($post); if (empty($links)) { return $retval; } if (!isset($_SPX_CONF['timeout'])) { $_SPX_CONF['timeout'] = 5; // seconds } if ($this->_verbose) { SPAMX_log("Sending to SLV: {$links}"); } $params = array(new XML_RPC_Value($links, 'string')); $msg = new XML_RPC_Message('slv', $params); $cli = new XML_RPC_Client('/slv.php', 'http://www.linksleeve.org'); if ($this->_debug) { $client->setDebug(1); } $resp = $cli->send($msg, $_SPX_CONF['timeout']); if (!$resp) { COM_errorLog('Error communicating with SLV: ' . $cli->errstr . '; Message was ' . $msg->serialize()); } else { if ($resp->faultCode()) { COM_errorLog('Error communicating with SLV. Fault code: ' . $resp->faultCode() . ', Fault reason: ' . $resp->faultString() . '; Message was ' . $msg->serialize()); } else { $val = $resp->value(); // note that SLV returns '1' for acceptable posts and '0' for spam if ($val->scalarval() != '1') { $retval = true; SPAMX_log("SLV: spam detected"); } else { if ($this->_verbose) { SPAMX_log("SLV: no spam detected"); } } } } return $retval; }
public function authenticate($username, $password) { global $_SIMPLE_LDAP_CONF; require_once __DIR__ . '/simple_ldap/config.php'; if (!is_callable('ldap_connect')) { COM_errorLog('Simple_LDAP Error: LDAP extension is disabled'); return false; } $ldap_connection = ldap_connect($_SIMPLE_LDAP_CONF['ldap_host']); if ($ldap_connection === false) { COM_errorLog("Simple_LDAP Error: Cannot connect to LDAP server " . $_SIMPLE_LDAP_CONF['ldap_host']); return false; } if (!ldap_set_option($ldap_connection, LDAP_OPT_PROTOCOL_VERSION, 3)) { COM_errorLog("Simple_LDAP Error: Cannot set LDAP protocol version to 3"); return false; } $ldap_result = ldap_search($ldap_connection, $_SIMPLE_LDAP_CONF['base_dn'], "uid={$username}"); if ($ldap_result === false) { COM_errorLog('Simple_LDAP Error: Search for user ' . $username . ' failed'); return false; } $A = ldap_get_entries($ldap_connection, $ldap_result); if ($A === false || $A['count'] == 0) { COM_errorLog('Simple_LDAP Error: User ' . $username . ' does not exist.'); return false; } // Trying to bind against LDAP given username and password $ldap_found_user_dn = $A[0]['dn']; $ldap_bind = @ldap_bind($ldap_connection, $ldap_found_user_dn, $password); if ($ldap_bind === false) { COM_errorLog('Simple_LDAP Error: Cannot bind to LDAP directory: ' . ldap_error($ldap_connection)); return false; } // Bind successful, get some more infos from LDAP $this->fullname = $A[0]['cn'][0]; $this->email = $A[0]['mail'][0]; $this->homepage = $A[0]['labeleduri'][0]; if (ldap_unbind($ldap_connection)) { return true; } else { COM_errorLog('Simple_LDAP Error: Could not unbind from LDAP directory'); return false; } }
/** * FTP Import * * @param int album_id album_id upload media * @return string HTML * */ function MG_ftpUpload($album_id) { global $MG_albums, $_USER, $_CONF, $_MG_CONF, $LANG_MG00, $LANG_MG01, $LANG_MG03; $retval = ''; $T = new Template(MG_getTemplatePath($album_id)); $T->set_file('mupload', 'ftpupload.thtml'); $T->set_var('site_url', $_CONF['site_url']); $T->set_var('album_id', $album_id); if ($MG_albums[$album_id]->access == 3 || SEC_hasRights('mediagallery.admin') || $MG_albums[$album_id]->member_uploads == 1 && !COM_isAnonUser()) { $T->set_var(array('s_form_action' => $_MG_CONF['site_url'] . '/admin.php', 'lang_upload_help' => $LANG_MG03['upload_help'], 'lang_media_ftp' => $LANG_MG01['upload_media'], 'lang_directory' => $LANG_MG01['directory'], 'lang_recurse' => $LANG_MG01['recurse'], 'lang_delete_files' => $LANG_MG01['delete_files'], 'lang_caption' => $LANG_MG01['caption'], 'lang_file' => $LANG_MG01['file'], 'lang_description' => $LANG_MG01['description'], 'lang_save' => $LANG_MG01['save'], 'lang_cancel' => $LANG_MG01['cancel'], 'lang_reset' => $LANG_MG01['reset'], 'lang_yes' => $LANG_MG01['yes'], 'lang_no' => $LANG_MG01['no'], 'lang_ftp_help' => $LANG_MG03['ftp_help'], 'album_id' => $album_id, 'ftp_path' => $_MG_CONF['ftp_path'], 'action' => 'ftp')); $T->parse('output', 'mupload'); $retval .= $T->finish($T->get_var('output')); return $retval; } else { COM_errorLog("MediaGallery: user attempted to upload to a restricted album."); return MG_genericError($LANG_MG00['access_denied_msg']); } }
/** * Delete an ad and associated photos * * @param integer $ad_id Ad ID number * @param boolean $admin True if this is an administrator */ function adDelete($ad_id = '', $admin = false, $table = 'ad_ads') { global $_USER, $_TABLES, $_CONF_ADVT; $ad_id = COM_sanitizeID($ad_id); if ($ad_id == '') { return 1; } if ($table != 'ad_ads' && $table != 'ad_submission') { return 2; } // Check the user's access level. If this is an admin call, // force access to read-write. $myaccess = $admin ? 3 : CLASSIFIEDS_checkAccess($ad_id); if ($myaccess < 3) { return 3; } /* $selection = "ad_id = '$ad_id'"; if (!$admin) { $selection.= " AND uid={$_USER['uid']}"; } $ad = DB_getItem($_TABLES[$table], 'ad_id', $selection); if ($ad == '') return 5;*/ // If we've gotten this far, then the current user has access // to delete this ad. if ($table == 'ad_submission') { // Do the normal plugin rejection stuff plugin_moderationdelete_classifieds($ad_id); } else { // Do the extra cleanup manually if (deletePhotos($ad_id) != 0) { return 5; } } // After the cleanup stuff, delete the ad record itself. DB_delete($_TABLES[$table], 'ad_id', $ad_id); CLASSIFIEDS_auditLog("Ad {$ad_id} deleted."); if (DB_error()) { COM_errorLog(DB_error()); return 4; } else { return 0; } }
/** * Fix site_url in content * * If the site's URL changed due to the migration, this function will replace * the old URL with the new one in text content of the given tables. * * @param string $old_url the site's previous URL * @param string $new_url the site's new URL after the migration * @param array $tablespec (optional) list of tables to patch * * The $tablespec is an array of tablename => fieldlist pairs, where the field * list contains the text fields to be searched and the table's index field * as the first(!) entry. * * NOTE: This function may be used by plugins during PLG_migrate. Changes should * ensure backward compatibility. * */ function INST_updateSiteUrl($old_url, $new_url, $tablespec = '') { global $_TABLES; // standard tables to update if no $tablespec given $tables = array('stories' => 'sid, introtext, bodytext, related', 'storysubmission' => 'sid, introtext, bodytext', 'comments' => 'cid, comment', 'trackback' => 'cid, excerpt, url', 'blocks' => 'bid, content'); if (empty($tablespec) || !is_array($tablespec)) { $tablespec = $tables; } if (empty($old_url) || empty($new_url)) { return; } if ($old_url == $new_url) { return; } foreach ($tablespec as $table => $fieldlist) { $fields = explode(',', str_replace(' ', '', $fieldlist)); $index = array_shift($fields); if (empty($_TABLES[$table]) || !DB_checkTableExists($table)) { COM_errorLog("Table {$table} does not exist - skipping migration"); continue; } $result = DB_query("SELECT {$fieldlist} FROM {$_TABLES[$table]}"); $numRows = DB_numRows($result); for ($i = 0; $i < $numRows; $i++) { $A = DB_fetchArray($result); $changed = false; foreach ($fields as $field) { $newtxt = str_replace($old_url, $new_url, $A[$field]); if ($newtxt != $A[$field]) { $A[$field] = $newtxt; $changed = true; } } if ($changed) { $sql = "UPDATE {$_TABLES[$table]} SET "; foreach ($fields as $field) { $sql .= "{$field} = '" . DB_escapeString($A[$field]) . "', "; } $sql = substr($sql, 0, -2); DB_query($sql . " WHERE {$index} = '" . DB_escapeString($A[$index]) . "'"); } } } }
function MG_batchDeleteSession() { global $_MG_CONF, $_CONF, $_TABLES; if (!empty($_POST['sel'])) { $numItems = count($_POST['sel']); for ($i = 0; $i < $numItems; $i++) { DB_delete($_TABLES['mg_session_items'], 'session_id', $_POST['sel'][$i]); if (DB_error()) { COM_errorLog("Media Gallery Error: Error removing session items"); } DB_delete($_TABLES['mg_sessions'], 'session_id', $_POST['sel'][$i]); if (DB_error()) { COM_errorLog("Media Gallery Error: Error removing session"); } } } echo COM_refresh($_MG_CONF['admin_url'] . 'sessions.php'); exit; }
function MG_batchDeleteSession() { global $_MG_CONF, $_CONF, $_TABLES, $_POST; $numItems = count($_POST['sel']); for ($i = 0; $i < $numItems; $i++) { $sql = "DELETE FROM {$_TABLES['mg_session_items']} WHERE session_id='" . $_POST['sel'][$i] . "'"; $result = DB_query($sql); if (DB_error()) { COM_errorLog("Media Gallery Error: Error removing session items"); } $sql = "DELETE FROM {$_TABLES['mg_sessions']} WHERE session_id='" . $_POST['sel'][$i] . "'"; $result = DB_query($sql); if (DB_error()) { COM_errorLog("Media Gallery Error: Error removing session"); } } echo COM_refresh($_MG_CONF['admin_url'] . 'sessions.php'); exit; }
function MG_MassdeleteAlbum($album_id) { global $MG_albums, $_USER, $_CONF, $_TABLES, $_MG_CONF, $LANG_MG00, $LANG_MG01; // need to check perms here... if ($MG_albums[$album_id]->access != 3) { COM_errorLog("MediaGallery: Someone has tried to illegally delete an album in Media Gallery. User id: {$_USER['uid']}, Username: {$_USER['username']}, IP: " . $_SERVER['REMOTE_ADDR'], 1); return MG_genericError($LANG_MG00['access_denied_msg']); } MG_MassdeleteChildAlbums($album_id); if ($_MG_CONF['member_albums'] == 1 && $MG_albums[$album_id]->parent == $_MG_CONF['member_album_root']) { $result = DB_query("SELECT * FROM {$_TABLES['mg_albums']} WHERE owner_id=" . $MG_albums[$album_id]->owner_id . " AND album_parent=" . $MG_albums[$album_id]->parent); $numRows = DB_numRows($result); if ($numRows == 0) { DB_query("UPDATE {$_TABLES['mg_userprefs']} SET member_gallery=0 WHERE uid=" . $MG_albums[$album_id]->owner_id, 1); } } MG_initAlbums(); require_once $_CONF['path'] . 'plugins/mediagallery/include/rssfeed.php'; MG_buildFullRSS(); }
/** * Returns the content of a given staticpage * * @author mystral-kk - geeklog AT mystral-kk DOT net * @license GPL v2 * @param $sp_id string an id of a staticpage * @return string the content of the staticpage */ function CUSTOM_getStaticpage($sp_id) { global $_TABLES, $_PLUGINS, $_SP_CONF, $LANG_STATIC; $retval = ''; if (!in_array('staticpages', $_PLUGINS)) { return $retval; } $sql = "SELECT sp_php, sp_content FROM {$_TABLES['staticpage']} " . "WHERE (sp_id = '" . addslashes($sp_id) . "') " . "AND " . SP_getPerms(); $result = DB_query($sql); if (DB_error() or DB_numRows($result) == 0) { return $retval; } else { $A = DB_fetchArray($result); $sp_php = $A['sp_php']; $sp_content = stripslashes($A['sp_content']); } if ($_SP_CONF['allow_php'] == 1) { // Check for type (i.e. html or php) if ($sp_php == 1) { $retval .= eval($sp_content); } else { if ($sp_php == 2) { ob_start(); eval($sp_content); $retval .= ob_get_contents(); ob_end_clean(); } else { $retval .= PLG_replacetags($sp_content); } } } else { if ($sp_php != 0) { COM_errorLog("PHP in static pages is disabled. Cannot display page '{$sp_id}'.", 1); $retval .= $LANG_STATIC['deny_msg']; } else { $retval .= $sp_content; } } return $retval; }
function MG_rotateMedia($album_id, $media_id, $direction, $actionURL = '') { global $_TABLES, $_MG_CONF; $sql = "SELECT * FROM " . $_TABLES['mg_media'] . " WHERE media_id='" . DB_escapeString($media_id) . "'"; $result = DB_query($sql); $numRows = DB_numRows($result); if ($numRows == 0) { $sql = "SELECT * FROM " . $_TABLES['mg_mediaqueue'] . " WHERE media_id='" . DB_escapeString($media_id) . "'"; $result = DB_query($sql); $numRows = DB_numRows($result); } if ($numRows == 0) { COM_errorLog("MG_rotateMedia: Unable to retrieve media object data"); if ($actionURL == '') { return false; } echo COM_refresh($actionURL); exit; } $row = DB_fetchArray($result); $filename = $row['media_filename']; $media_size = false; foreach ($_MG_CONF['validExtensions'] as $ext) { if (file_exists($_MG_CONF['path_mediaobjects'] . 'tn/' . $filename[0] . '/' . $filename . $ext)) { $tn = $_MG_CONF['path_mediaobjects'] . 'tn/' . $filename[0] . '/' . $filename . $ext; $disp = $_MG_CONF['path_mediaobjects'] . 'disp/' . $filename[0] . '/' . $filename . $ext; break; } } $orig = $_MG_CONF['path_mediaobjects'] . 'orig/' . $filename[0] . '/' . $filename . '.' . $row['media_mime_ext']; list($rc, $msg) = IMG_rotateImage($tn, $direction); list($rc, $msg) = IMG_rotateImage($disp, $direction); list($rc, $msg) = IMG_rotateImage($orig, $direction); if ($actionURL == -1 || $actionURL == '') { return true; } echo COM_refresh($actionURL . '&t=' . time()); exit; }