function do_update() { $Q[] = "ALTER TABLE `exp_search` CHANGE `query` `query` MEDIUMTEXT NULL DEFAULT NULL"; $Q[] = "ALTER TABLE `exp_search` CHANGE `custom_fields` `custom_fields` MEDIUMTEXT NULL DEFAULT NULL"; $Q[] = "ALTER TABLE `exp_templates` ADD `last_author_id` INT(10) UNSIGNED NOT NULL AFTER `edit_date`"; $Q[] = "ALTER TABLE `exp_revision_tracker` ADD `item_author_id` INT(10) UNSIGNED NOT NULL AFTER `item_date`"; $query = ee()->db->query('SHOW FIELDS FROM exp_weblog_data'); foreach ($query->result_array() as $row) { if (strncmp($row['Field'], 'field_ft', 8) == 0) { $Q[] = "ALTER TABLE `exp_weblog_data` CHANGE `{$row['Field']}` `{$row['Field']}` TINYTEXT NULL"; } } // run our queries foreach ($Q as $sql) { ee()->db->query($sql); } ee()->load->helper('string'); // We need to add a new template preference, so we'll fetch the existing site template prefs $query = ee()->db->query("SELECT site_id, site_template_preferences FROM exp_sites"); foreach ($query->result_array() as $row) { $prefs = strip_slashes(unserialize($row['site_template_preferences'])); // Add our new pref to the array $prefs['strict_urls'] = $prefs['site_404'] == FALSE ? 'n' : 'y'; // Update the DB ee()->db->query(ee()->db->update_string('exp_sites', array('site_template_preferences' => serialize($prefs)), "site_id = '" . $row['site_id'] . "'")); } return TRUE; }
/** * Strip Slashes * * Removes slashes contained in a string or in an array * * @param mixed string or array * @return mixed string or array */ function strip_slashes($str) { if (!is_array($str)) { return stripslashes($str); } foreach ($str as $key => $val) { $str[$key] = strip_slashes($val); } return $str; }
/** * Strip Slashes * * Removes slashes contained in a string or in an array * * @access public * @param mixed string or array * @return mixed string or array */ public static function strip_slashes($str) { if (is_array($str)) { foreach ($str as $key => $val) { $str[$key] = strip_slashes($val); } } else { $str = stripslashes($str); } return $str; }
function set_var(&$result, $var, $type, $multibyte = false) { settype($var, $type); $result = $var; if ($type == 'string') { $result = strip_slashes(trim(htmlspecialchars(str_replace(array("\r\n", "\r", '\\xFF'), array("\n", "\n", ' '), $result)))); if ($multibyte) { $result = preg_replace('#&(\\#[0-9]+;)#', '&\\1', $result); } } return $result; }
function get_settings($all_sites = FALSE) { $get_settings = $this->EE->db->query("SELECT settings \n\t\t\tFROM exp_extensions \n\t\t\tWHERE class = '" . $this->extension . "' \n\t\t\tLIMIT 1"); $this->EE->load->helper('string'); if ($get_settings->num_rows() > 0 && $get_settings->row('settings') != '') { $settings = strip_slashes(unserialize($get_settings->row('settings'))); $settings = $all_sites == FALSE && isset($settings[$this->EE->config->item('site_id')]) ? $settings[$this->EE->config->item('site_id')] : $settings; } else { $settings = array(); } return $settings; }
function _unserialize($data) { $data = @unserialize(strip_slashes($data)); if (is_array($data)) { foreach ($data as $key => $val) { if (is_string($val)) { $data[$key] = str_replace('{{slash}}', '\\', $val); } } return $data; } return is_string($data) ? str_replace('{{slash}}', '\\', $data) : $data; }
function escape_html($val) { if ($val == "") { return ""; } if (is_array($val)) { return array_map('escape_html', $val); } $val = str_replace(" ", " ", strip_slashes($val)); /* if ( isset($this->vars['strip_space_chr']) AND $this->vars['strip_space_chr'] ) { $val = str_replace( chr(0xCA), "", $val ); //Remove sneaky spaces } */ $val = str_replace("&", "&", $val); $val = str_replace("<!--", "<!--", $val); $val = str_replace("-->", "-->", $val); $val = preg_replace("/<script/i", "<script", $val); $val = str_replace(">", ">", $val); $val = str_replace("<", "<", $val); $val = str_replace('"', """, $val); $val = str_replace("\n", "<br />", $val); // Convert literal newlines $val = str_replace("\$", "$", $val); $val = str_replace("\r", "", $val); // Remove literal carriage returns $val = str_replace("!", "!", $val); $val = str_replace("'", "'", $val); // IMPORTANT: It helps to increase sql query safety. // Ensure unicode chars are OK $val = preg_replace("/&#([0-9]+);/s", "&#\\1;", $val); //----------------------------------------- // Try and fix up HTML entities with missing ; //----------------------------------------- $val = preg_replace("/&#(\\d+?)([^\\d;])/i", "&#\\1;\\2", $val); /* if ( $this->allow_unicode ) { $val = preg_replace("/&#([0-9]+);/s", "&#\\1;", $val ); //----------------------------------------- // Try and fix up HTML entities with missing ; //----------------------------------------- $val = preg_replace( "/&#(\d+?)([^\d;])/i", "&#\\1;\\2", $val ); } */ return $val; }
/** * Class constructor * * @access public * @author Erik Reagan <*****@*****.**> * @return void */ public function __construct() { $this->_EE =& get_instance(); $this->_debug = ($this->_EE->session->userdata['group_id'] == '1' OR $this->_EE->config->item('dh:dev_mode')) ? TRUE : FALSE ; // load our model for access in all methods $this->_EE->load->model('deployment_hooks_model','Deployment_hooks_model'); // Get our add-on's settings $settings = $this->_EE->Deployment_hooks_model->get_settings(); if ($settings->num_rows() > 0 && $settings->row('settings') != '') { // Load the string helper to strip slashes on array items $this->_EE->load->helper('string'); $this->_settings = strip_slashes(unserialize($settings->row('settings'))); } // There's a chance this class will be loaded upon a deployment ACT request // So we don't want to process any of this juicy goodness if that's the case if ( ! $this->_EE->input->get('ACT')) { // Load our config settings $this->_EE->load->config('deployment_hooks'); // Setup our module's URL base for quicker link building between module pages // Defined in our config file located in deployment_hooks/config/deployment_hooks.php $this->_url_base = $this->_EE->config->item('dh:mod_url_base'); // Setup our module's navigation elements // Menu is defined in our config file $this->_EE->cp->set_right_nav($this->_EE->config->item('dh:mod_menu')); // Move this out to a view? Some other approach? // ordered and unordered lists look kinda crappy in tables // but we want them to look nice for our Log page/view $this->_EE->cp->add_to_head(' <style type="text/css" media="screen"> table ol { list-style: numeric; margin: 5px 5px 5px 30px; } table ol li { padding: 3px 0; } </style> '); } // End if ( ! $this->_EE->input->get('ACT')) }
/** * The Universal Caller (Added in EE 1.6) * * Originally, using call(), objects could not be called by reference in PHP 4 * and thus could not be directly modified. I found a clever way around that restriction * by always having the second argument gotten by reference. The problem (and the reason * there is a call() hook above) is that not all extension hooks have a second argument * and the PHP developers in their infinite wisdom decided that only variables could be passed * by reference. So, call() does a little magic to make sure there is always a second * argument and universal_call() handles all of the object and reference handling * when needed. -Paul * * @access public * @param string Name of the extension hook * @param mixed * @return mixed */ function universal_call($which, &$parameter_one) { // Reset Our Variables $this->end_script = FALSE; $this->last_call = FALSE; // HACK: Hooks called by non-CI enabled Bridge modules, need to have the last_call reset // This might be temporary once I switch everything over to Bridge with CI's functionality. if (isset($GLOBALS['EXT']) && is_object($GLOBALS['EXT'])) { $GLOBALS['EXT']->last_call = FALSE; } // Anything to Do Here? if (!isset($this->extensions[$which])) { return; } if ($this->EE->config->item('allow_extensions') != 'y') { return; } if ($this->in_progress == $which) { return; } $this->in_progress = $which; // Retrieve arguments for function if (is_object($parameter_one) && is_php('5.0.0') == TRUE) { $php4_object = FALSE; $args = array_slice(func_get_args(), 1); } else { $php4_object = TRUE; $args = array_slice(func_get_args(), 1); } if (is_php('5.3')) { foreach ($args as $k => $v) { $args[$k] =& $args[$k]; } } // Go through all the calls for this hook foreach ($this->extensions[$which] as $priority => $calls) { foreach ($calls as $class => $metadata) { // Determine Path of Extension $class_name = ucfirst($class); $name = $this->EE->security->sanitize_filename(strtolower($class)); $path = PATH_EXT . 'ext.' . $name . EXT; $third_party = FALSE; if (!file_exists($path)) { if (substr($class, -4) == '_ext') { $name = $this->EE->security->sanitize_filename(strtolower(substr($class, 0, -4))); // remove '_ext' suffix } elseif (substr($class, -10) == '_extension') { $name = $this->EE->security->sanitize_filename(strtolower(substr($class, 0, -10))); // remove '_extension' suffix } // Third Party? $path = PATH_THIRD . $name . '/ext.' . $name . EXT; if (!file_exists($path)) { $error = 'Unable to load the following extension file:<br /><br />' . 'ext.' . $name . EXT; return $this->EE->output->fatal_error($error); } $third_party = TRUE; // HACK: Not for EE 1.x, please. // $this->EE->load->add_package_path(PATH_THIRD.$name.'/'); } // Include File if (!class_exists($class_name)) { require $path; } // A Bit of Meta $method = $metadata['0']; // Unserializing and serializing is relatively slow, so we // cache the settings just in case multiple hooks are calling the // same extension multiple times during a single page load. // Thus, speeding it all up a bit. if (isset($this->s_cache[$class_name])) { $settings = $this->s_cache[$class_name]; } else { // Load the string helper $this->EE->load->helper('string'); $settings = $metadata['1'] == '' ? '' : strip_slashes(unserialize($metadata['1'])); $this->s_cache[$class_name] = $settings; } $version = $metadata['2']; // Call the class(s) // Each method could easily have its own settings, // so we have to send the settings each time $this->OBJ[$class_name] = new $class_name($settings); // Update Extension First? if (version_compare($this->OBJ[$class_name]->version, $this->version_numbers[$class_name], '>') && method_exists($this->OBJ[$class_name], 'update_extension') === TRUE) { $update = call_user_func_array(array(&$this->OBJ[$class_name], 'update_extension'), array($this->version_numbers[$class_name])); $this->version_numbers[$class_name] = $this->OBJ[$class_name]->version; // reset master } // Call Method and Store Returned Data // We put this in a class variable so that any extensions // called after this one can retrieve the returned data from // previous methods and view/maniuplate that returned data // opposed to any original arguments the hook sent. In theory... if (isset($this->EE->TMPL) && is_object($this->EE->TMPL) && method_exists($this->EE->TMPL, 'log_item')) { $this->EE->TMPL->log_item('Calling Extension Class/Method: ' . $class_name . '/' . $method); } if ($php4_object === TRUE) { $this->last_call = call_user_func_array(array(&$this->OBJ[$class_name], $method), array(&$parameter_one) + $args); } else { $this->last_call = call_user_func_array(array(&$this->OBJ[$class_name], $method), $args); } // HACK: Hooks called by non-CI enabled Bridge modules, need to know the last_call. // This might be temporary once I switch everything over to Bridge with CI's functionality. if (isset($GLOBALS['EXT']) && is_object($GLOBALS['EXT'])) { $GLOBALS['EXT']->last_call = $this->last_call; } $this->in_progress = ''; if ($third_party === TRUE) { // HACK: Not for EE 1.x, please. //$this->EE->load->remove_package_path(PATH_THIRD.$name.'/'); } // A $this->EE->extensions->end_script value of TRUE means that the called // method wishes us to stop the calling of the main script. // In this case, even if there are methods after this one for // the hook we still stop the script now because extensions with // a higher priority call the shots and thus override any // extensions with a lower priority. if ($this->end_script === TRUE) { return $this->last_call; } } } return $this->last_call; }
private function getExtensionSettings($name) { if (ee()->config->item('allow_extensions') != 'y') { show_error(lang('unauthorized_access')); } $addon = ee()->security->sanitize_filename(strtolower($name)); $extension = $this->getExtension($addon); if (empty($extension) || $extension['installed'] === FALSE) { show_error(lang('requested_module_not_installed') . NBS . $addon); } ee()->lang->loadfile(strtolower($addon)); $extension_model = ee('Model')->get('Extension')->filter('enabled', 'y')->filter('class', $extension['class'])->first(); $current = strip_slashes($extension_model->settings); $class_name = $extension['class']; $OBJ = new $class_name(); if (method_exists($OBJ, 'settings_form') === TRUE) { return $OBJ->settings_form($current); } $vars = array('base_url' => ee('CP/URL')->make('addons/settings/' . $name . '/save'), 'cp_page_title' => $extension['name'] . ' ' . lang('configuration'), 'save_btn_text' => 'btn_save_settings', 'save_btn_text_working' => 'btn_saving', 'sections' => array(array())); $settings = array(); foreach ($OBJ->settings() as $key => $options) { $element = array('title' => $key, 'desc' => '', 'fields' => array()); if (isset($current[$key])) { $value = $current[$key]; } elseif (is_array($options)) { $value = $options[2]; } elseif (is_string($options)) { $value = $options; } else { $value = ''; } $sub = ''; $choices = array(); $selected = ''; if (isset($subtext[$key])) { foreach ($subtext[$key] as $txt) { $sub .= lang($txt); } } $element['desc'] = $sub; if (!is_array($options)) { $element['fields'][$key] = array('type' => 'text', 'value' => str_replace("\\'", "'", $value)); $vars['sections'][0][] = $element; continue; } switch ($options[0]) { case 's': // Select fields foreach ($options[1] as $k => $v) { $choices[$k] = lang($v); } $element['fields'][$key] = array('type' => 'select', 'value' => $value, 'choices' => $choices); break; case 'r': // Radio buttons foreach ($options[1] as $k => $v) { $choices[$k] = lang($v); } $element['fields'][$key] = array('type' => 'radio', 'value' => $value, 'choices' => $choices); break; case 'ms': case 'c': // Multi-select & Checkboxes foreach ($options[1] as $k => $v) { $choices[$k] = lang($v); } $element['fields'][$key] = array('type' => 'checkbox', 'value' => $value, 'choices' => $choices); break; case 't': // Textareas $element['fields'][$key] = array('type' => 'textarea', 'value' => str_replace("\\'", "'", $value), 'kill_pipes' => $options['1']['kill_pipes']); break; case 'i': // Input fields $element['fields'][$key] = array('type' => 'text', 'value' => str_replace("\\'", "'", $value)); break; } $vars['sections'][0][] = $element; } return ee('View')->make('_shared/form')->render($vars); }
private function getRankingResults($results, &$res_data_array, $data_count = '') { foreach ($results as $item) { $item->tit = strip_slashes($item->title); //remove slashes from term title like "That\'s My Ticket" $res_data_array[$item->title]['total_results' . $data_count] = $item->total_results; if (!isset($res_data_array[$item->title]['brand_results' . $data_count]) || isset($res_data_array[$item->title]['brand_results' . $data_count]) && $item->brand_results > $res_data_array[$item->title]['brand_results' . $data_count]) { $res_data_array[$item->title]['brand_results' . $data_count] = $item->brand_results; } if (!isset($res_data_array[$item->title]['number_in_results' . $data_count])) { $res_data_array[$item->title]['number_in_results' . $data_count] = array(); } if (!isset($res_data_array[$item->title]['on_first_page' . $data_count]) || !empty($res_data_array[$item->title]['on_first_page' . $data_count]) && $item->on_first_page > $res_data_array[$item->title]['on_first_page' . $data_count]) { $res_data_array[$item->title]['on_first_page' . $data_count] = $item->on_first_page; } $res_data_array[$item->title]['number_in_results' . $data_count][$item->number_in_results] = array('num' => $item->number_in_results, 'url' => $item->url); } foreach ($res_data_array as &$dt) { if (empty($dt['on_first_page' . $data_count])) { $dt['on_first_page' . $data_count] = '0/16'; } if (!empty($dt['number_in_results' . $data_count])) { $dt['number_in_results' . $data_count] = $this->ranking_model->sortRankingNumbers($dt['number_in_results' . $data_count]); } else { $dt['tmp_number_in_results' . $data_count] = array(); } } }
/** * Install/Update Our Extension for Module * * Tells ExpressionEngine what extension hooks * we wish to use for this module. If an extension * is part of a module, then it is the module's class * name with the '_extension' (1.x) or '_ext' 2.x * suffix added on to it. * * @access public * @return null */ public function update_extension_hooks() { if (!is_array($this->hooks) or count($this->hooks) == 0) { return TRUE; } //fix EE 1.x extension names ee()->db->update('exp_extensions', array('class' => $this->extension_name, 'enabled' => 'y'), array('class' => $this->class_name . '_extension')); // -------------------------------------------- // Determine Existing Methods // -------------------------------------------- $exists = array(); if ($this->settings == '') { ee()->db->select('settings'); } $query = ee()->db->select('method')->where('class', $this->extension_name)->get('extensions'); foreach ($query->result_array() as $row) { $exists[] = $row['method']; if ($this->settings == '' and !empty($row['settings'])) { ee()->load->helper('string'); $this->settings = strip_slashes(unserialize($row['settings'])); } } // -------------------------------------------- // Extension Table Defaults // -------------------------------------------- $this->extension_defaults = array('class' => $this->extension_name, 'settings' => '', 'priority' => 10, 'version' => $this->version, 'enabled' => 'y'); // -------------------------------------------- // Find Missing and Insert // -------------------------------------------- $current_methods = array(); foreach ($this->hooks as $data) { // Default exp_extension fields, overwrite with any from array $data = array_merge($this->extension_defaults, $data); $current_methods[] = $data['method']; if (!in_array($data['method'], $exists)) { // Every so often, EE can accidentally send empty // $settings argument to the constructor, so // our new hooks will not have any settings, // so we have to fix that here. if ($data['settings'] == '' or $data['settings'] == 's:0:"";') { $data['settings'] = serialize($this->settings); } ee()->db->insert('extensions', $data); } else { unset($data['settings']); ee()->db->update('extensions', $data, array('class' => $data['class'], 'method' => $data['method'])); } } // -------------------------------------------- // Remove Old Hooks // -------------------------------------------- $old_hooks = array_diff($exists, $current_methods); if (!empty($old_hooks)) { ee()->db->where_in('method', $old_hooks)->where('class', $this->extension_name)->delete('extensions'); } }
/** * The Universal Caller (Added in EE 1.6) * * Originally, using call(), objects could not be called by reference in PHP 4 * and thus could not be directly modified. I found a clever way around that restriction * by always having the second argument gotten by reference. The problem (and the reason * there is a call() hook above) is that not all extension hooks have a second argument * and the PHP developers in their infinite wisdom decided that only variables could be passed * by reference. So, call() does a little magic to make sure there is always a second * argument and universal_call() handles all of the object and reference handling * when needed. -Paul * * @access public * @param string Name of the extension hook * @param mixed * @return mixed */ function universal_call($which, &$parameter_one) { // Reset Our Variables $this->end_script = FALSE; $this->last_call = FALSE; $php5_args = array(); // Anything to Do Here? if (!isset($this->extensions[$which])) { return; } if (ee()->config->item('allow_extensions') != 'y') { return; } if ($this->in_progress == $which) { return; } $this->in_progress = $which; ee()->load->library('addons'); ee()->addons->is_package(''); // Retrieve arguments for function if (is_object($parameter_one) && is_php('5.0.0') == TRUE) { $php4_object = FALSE; $args = array_slice(func_get_args(), 1); } else { $php4_object = TRUE; $args = array_slice(func_get_args(), 1); } if (is_php('5')) { foreach ($args as $k => $v) { $php5_args[$k] =& $args[$k]; } } // Give arguments by reference foreach ($args as $k => $v) { $args[$k] =& $args[$k]; } // Go through all the calls for this hook foreach ($this->extensions[$which] as $priority => $calls) { foreach ($calls as $class => $metadata) { // Determine Path of Extension $class_name = ucfirst($class); $name = ee()->security->sanitize_filename(strtolower(substr($class, 0, -4))); // remove '_ext' suffix $path = ee()->addons->_packages[$name]['extension']['path']; $extension_path = reduce_double_slashes($path . '/ext.' . $name . '.php'); if (file_exists($extension_path)) { ee()->load->add_package_path($path, FALSE); } else { $error = 'Unable to load the following extension file:<br /><br />' . 'ext.' . $name . '.php'; return ee()->output->fatal_error($error); } // Include File if (!class_exists($class_name)) { require $extension_path; } // A Bit of Meta $method = $metadata['0']; // Unserializing and serializing is relatively slow, so we // cache the settings just in case multiple hooks are calling the // same extension multiple times during a single page load. // Thus, speeding it all up a bit. if (isset($this->s_cache[$class_name])) { $settings = $this->s_cache[$class_name]; } else { $settings = $metadata['1'] == '' ? '' : strip_slashes(unserialize($metadata['1'])); $this->s_cache[$class_name] = $settings; } $version = $metadata['2']; // Call the class(s) // Each method could easily have its own settings, // so we have to send the settings each time $this->OBJ[$class_name] = new $class_name($settings); // Update Extension First? if (version_compare($this->OBJ[$class_name]->version, $this->version_numbers[$class_name], '>') && method_exists($this->OBJ[$class_name], 'update_extension') === TRUE) { $update = call_user_func_array(array(&$this->OBJ[$class_name], 'update_extension'), array($this->version_numbers[$class_name])); $this->version_numbers[$class_name] = $this->OBJ[$class_name]->version; // reset master } // Call Method and Store Returned Data // We put this in a class variable so that any extensions // called after this one can retrieve the returned data from // previous methods and view/maniuplate that returned data // opposed to any original arguments the hook sent. In theory... if (isset(ee()->TMPL) && is_object(ee()->TMPL) && method_exists(ee()->TMPL, 'log_item')) { ee()->TMPL->log_item('Calling Extension Class/Method: ' . $class_name . '/' . $method); } if ($php4_object === TRUE) { $this->last_call = call_user_func_array(array(&$this->OBJ[$class_name], $method), array(&$parameter_one) + $args); } elseif (!empty($php5_args)) { $this->last_call = call_user_func_array(array(&$this->OBJ[$class_name], $method), $php5_args); } else { $this->last_call = call_user_func_array(array(&$this->OBJ[$class_name], $method), $args); } $this->in_progress = ''; ee()->load->remove_package_path($path); // A ee()->extensions->end_script value of TRUE means that the called // method wishes us to stop the calling of the main script. // In this case, even if there are methods after this one for // the hook we still stop the script now because extensions with // a higher priority call the shots and thus override any // extensions with a lower priority. if ($this->end_script === TRUE) { return $this->last_call; } } } return $this->last_call; }
function save() { $this->EE->load->helper('string'); // get serialized site preferences and member preferences and template preferences /* orig $query = $DB->query("SELECT site_system_preferences, site_member_preferences, site_template_preferences FROM exp_sites WHERE site_id = '" . $this->EE->config->item('site_id') . "'"); */ $this->EE->db->select('site_system_preferences, site_member_preferences, site_template_preferences'); $this->EE->db->from('exp_sites'); $this->EE->db->where('site_id', $this->EE->config->item('site_id')); $query = $this->EE->db->get(); if ($query->num_rows() > 0) { $system_prefs = strip_slashes(unserialize(base64_decode($query->row('site_system_preferences')))); $member_prefs = strip_slashes(unserialize(base64_decode($query->row('site_member_preferences')))); $template_prefs = strip_slashes(unserialize(base64_decode($query->row('site_template_preferences')))); } $updates = array(); $changed = FALSE; foreach ($_POST as $meganame => $value) { // handle submissions from non-serialized tables if (strpos($meganame, "::") !== FALSE) { list($table, $id, $name) = explode("::", $meganame); $table = $this->EE->security->xss_clean($table); $id = $this->EE->security->xss_clean($id); $name = $this->EE->security->xss_clean($name); $value = $this->EE->security->xss_clean($value); if ($table == "exp_channels") { $updates[] = "UPDATE `{$table}` SET `{$name}` = " . $this->EE->db->escape($value) . " WHERE channel_id = " . $this->EE->db->escape($id) . " AND site_id = " . $this->EE->config->item('site_id'); } if ($table == "exp_upload_prefs") { $updates[] = "UPDATE `{$table}` SET `{$name}` = " . $this->EE->db->escape($value) . " WHERE id = " . $this->EE->db->escape($id) . " AND site_id = " . $this->EE->config->item('site_id'); } if ($table == "exp_forum_boards") { $updates[] = "UPDATE `{$table}` SET `{$name}` = " . $this->EE->db->escape($value) . " WHERE board_id = " . $this->EE->db->escape($id) . " AND board_site_id = " . $this->EE->config->item('site_id'); } } elseif (in_array($meganame, $this->from_system_prefs)) { $system_prefs[$meganame] = $value; $changed = TRUE; } elseif (in_array($meganame, $this->from_member_prefs)) { $member_prefs[$meganame] = $value; $changed = TRUE; } elseif (in_array($meganame, $this->from_template_prefs)) { $template_prefs[$meganame] = $value; $changed = TRUE; } } if ($changed) { $system_prefs = base64_encode(serialize($this->EE->security->xss_clean($system_prefs))); $member_prefs = base64_encode(serialize($this->EE->security->xss_clean($member_prefs))); $template_prefs = base64_encode(serialize($this->EE->security->xss_clean($template_prefs))); // just in case we want to echo some debug output -- easier to read than base64 //$system_prefs = serialize($this->EE->security->xss_clean($system_prefs)); //$member_prefs = serialize($this->EE->security->xss_clean($member_prefs)); //$template_prefs = serialize($this->EE->security->xss_clean($template_prefs)); $updates[] = "UPDATE exp_sites set \n\t\t\t\tsite_system_preferences = '{$system_prefs}', \n\t\t\t\tsite_member_preferences = '{$member_prefs}',\n\t\t\t\tsite_template_preferences = '{$template_prefs}'\n\t\t\t\tWHERE site_id = " . $this->EE->config->item('site_id'); } //print_r($updates); foreach ($updates as $sql) { $this->EE->db->query($sql); } return $this->index($this->EE->lang->line('settings_saved')); }
$bbcode_tpl = htmlspecialchars($row['bbcode_tpl']); break; case 'modify': $sql = 'SELECT bbcode_id FROM ' . BBCODES_TABLE . ' WHERE bbcode_id = ' . $bbcode_id; $result = $_CLASS['core_db']->sql_query($sql); if (!($row = $_CLASS['core_db']->sql_fetchrow($result))) { trigger_error('BBCODE_NOT_EXIST'); } $_CLASS['core_db']->sql_freeresult($result); // No break here // No break here case 'create': $bbcode_match = htmlspecialchars(strip_slashes($_POST['bbcode_match'])); $bbcode_tpl = strip_slashes($_POST['bbcode_tpl']); break; } // Do major work switch ($mode) { case 'edit': case 'add': adm_page_header($_CLASS['core_user']->lang['BBCODES']); ?> <h1><?php echo $_CLASS['core_user']->lang['BBCODES']; ?> </h1> <p><?php
<?php include 'login.php'; validate_creds(); include 'header.html'; ?> <h1>View Visits</h1> <div class='content'> <?php //specialization('Diagnostician', 1); if (isset($_POST['specialization'])) { specilization(trim(strip_slashes($_POST['specialization'])), 1); } function specialization($spec, $number) { $conn2 = new mysqli('stardock.cs.virginia.edu', 'cs4750igs3pw', 'fall2015', 'cs4750igs3pw'); $sql2 = "SELECT Name, Specialization FROM Physician NATURAL JOIN `Physician Visit` WHERE `Specialization` = '{$spec}' AND `Visit ID` = '{$number}'"; $result2 = $conn2->query($sql2); if ($conn2->connect_error) { die("Connection failed: " . $conn2->connect_error); } else { while ($row2 = $result2->fetch_assoc()) { foreach ($row2 as $key2 => $value2) { echo "<p>{$key2} => {$value2}</p>"; } } } } $conn = new mysqli('stardock.cs.virginia.edu', 'cs4750igs3pw', 'fall2015', 'cs4750igs3pw'); if ($conn->connect_error) {
/** * Return total count 'on first page' results And data sorted by brands * @param array $data * @param array $result_array * @return int * @author Ruslan Ushakov */ public static function get_ofp_total_count($data, &$result_array) { $sum_ofp = 0; $brands_ofp = array(); $terms_ofp = array(); $brands_terms_ofp = array(); if (!empty($data)) { foreach ($data as $product) { if (!empty($product) && !empty($product->ofp_by_ranking) && $product->ofp_by_ranking == 't') { $brand = strip_slashes($product->brand_name); if (array_key_exists($brand, $brands_ofp)) { ++$brands_ofp[$brand]; } else { $brands_ofp[$brand] = 1; } $term = strip_slashes($product->keyword); if (array_key_exists($term, $terms_ofp)) { ++$terms_ofp[$term]; } else { $terms_ofp[$term] = 1; } if (array_key_exists($term . '_' . $brand, $brands_terms_ofp)) { ++$brands_terms_ofp[$term . '_' . $brand]; } else { $brands_terms_ofp[$term . '_' . $brand] = 1; } ++$sum_ofp; } } } $result_array = array('brands' => $brands_ofp, 'terms' => $terms_ofp, 'brand_terms' => $brands_terms_ofp); return $sum_ofp; }
function setting() { $this->data['welcome'] = $this; $sess = $this->session->all_userdata(); $uid = $sess[0]->id; $tab = $this->uri->segment(3); $this->data['tab'] = $tab; $this->data['flavorData'] = $this->videos_model->getFlavorData(); $optionData = $this->videos_model->getOptionData($uid); $this->data['optionData'] = @unserialize(strip_slashes($optionData)); switch ($tab) { case "Flavors": $this->show_view('video_settings', $this->data); break; case "Player": $this->data['playerData'] = $this->videos_model->getPlayerData($uid); $this->show_view('video_settings', $this->data); break; case "country": $this->data['countryData'] = $this->videos_model->getCountryList(); $this->show_view('video_settings', $this->data); break; default: $this->data['tab'] = 'Flavors'; $this->show_view('video_settings', $this->data); } }
/** * Loads the settings from the database. * * @access private * @return void */ private function _load_settings_from_db() { $settings = new MCS_Settings(); // Load the settings from the database. $db_settings = $this->_ee->db->select('settings')->get_where('mailchimp_subscribe_settings', array('site_id' => $this->_site_id), 1); // If we have saved settings, parse them. if ($db_settings->num_rows() > 0) { $this->_ee->load->helper('string'); $site_settings = unserialize(strip_slashes($db_settings->row()->settings)); $settings->populate_from_array($site_settings); } $this->_settings = $settings; }
function get_settings($all_sites = FALSE) { $get_settings = $this->EE->db->query("SELECT settings FROM exp_extensions WHERE class = '".ucfirst(get_class($this))."' LIMIT 1"); $this->EE->load->helper('string'); if ($get_settings->num_rows() > 0 && $get_settings->row('settings') != '') { $settings = strip_slashes(unserialize($get_settings->row('settings'))); $settings = ($all_sites == TRUE) ? $settings : $settings[$this->EE->config->item('site_id')]; } else { $settings = array(); } return $settings; }
function get_variable($var_name, $type, $default = false, $var_type = 'string') { $variable = null; $type = strtoupper($type); switch ($type) { case 'GET': $variable = isset($_GET[$var_name]) ? $_GET[$var_name] : $default; break; case 'POST': $variable = isset($_POST[$var_name]) ? $_POST[$var_name] : $default; break; case 'REQUEST': $variable = isset($_REQUEST[$var_name]) ? $_REQUEST[$var_name] : $default; break; case 'COOKIE': $variable = isset($_COOKIE[$var_name]) ? $_COOKIE[$var_name] : $default; break; } if (is_null($variable) || $variable === $default) { return $default; } else { switch ($var_type) { case 'int': case 'integer': return is_numeric($variable) ? (int) $variable : $default; break; case 'array': if (!is_array($variable)) { return $default; } // need to add a function here to loop multi... arrays foreach ($variable as $key => $value) { $variable[$key] = strip_slashes(trim(modify_lines(str_replace('\\xFF', ' ', $value), "\n"))); } return $variable; break; case 'array:int': case 'array:integer': if (!is_array($variable)) { return $default; } // need to add a function here to loop multi... arrays foreach ($variable as $key => $value) { if (is_numeric($value)) { $variable[$key] = (int) $value; } } return $variable; break; default: return strip_slashes(trim(modify_lines(str_replace('\\xFF', ' ', $variable), "\n"))); break; } } }
<?php if (function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc()) { function strip_slashes($input) { if (!is_array($input)) { return stripslashes($input); } else { return array_map('strip_slashes', $input); } } $_GET = strip_slashes($_GET); $_POST = strip_slashes($_POST); $_COOKIE = strip_slashes($_COOKIE); $_REQUEST = strip_slashes($_REQUEST); } function customError($errno, $errstr) { echo "<b>Error:</b> [{$errno}] {$errstr}<br>"; echo "Ending Script"; die("Ending Script"); } set_error_handler("customError"); $myData = $_GET["data"]; $myFile = "todo.json"; $fileHandle = fopen($myFile, "w"); fwrite($fileHandle, $myData); fclose($fileHandle);
/** * Update safecracker to channel:form and convert old saef's while we're * at it - just in case they upgrade from below 2.0 */ private function _rename_safecracker_db() { ee()->db->update('actions', array('class' => 'Channel'), array('class' => 'Safecracker')); ee()->db->update('actions', array('method' => 'submit_entry'), array('class' => 'Channel', 'method' => 'insert_new_entry')); // Add the new settings table ee()->dbforge->add_field(array('channel_form_settings_id' => array('type' => 'int', 'constraint' => 10, 'unsigned' => TRUE, 'null' => FALSE, 'auto_increment' => TRUE), 'site_id' => array('type' => 'int', 'constraint' => 4, 'unsigned' => TRUE, 'null' => FALSE, 'default' => 0), 'channel_id' => array('type' => 'int', 'constraint' => 6, 'unsigned' => TRUE, 'null' => FALSE, 'default' => 0), 'default_status' => array('type' => 'varchar', 'constraint' => 50, 'null' => FALSE, 'default' => 'open'), 'require_captcha' => array('type' => 'char', 'constraint' => 1, 'null' => FALSE, 'default' => 'n'), 'allow_guest_posts' => array('type' => 'char', 'constraint' => 1, 'null' => FALSE, 'default' => 'n'), 'default_author' => array('type' => 'int', 'constraint' => 11, 'unsigned' => TRUE, 'null' => FALSE, 'default' => 0))); ee()->dbforge->add_key('channel_form_settings_id', TRUE); ee()->dbforge->add_key('site_id'); ee()->dbforge->add_key('channel_id'); ee()->smartforge->create_table('channel_form_settings'); // Grab the settings $settings_q = ee()->db->select('settings')->where('class', 'Safecracker_ext')->limit(1)->get('extensions'); if ($settings_q->num_rows() && $settings_q->row('settings')) { $settings = $settings_q->row('settings'); $settings = strip_slashes(unserialize($settings)); $settings = array_filter($settings); $valid_keys = array('override_status', 'allow_guests', 'logged_out_member_id', 'require_captcha'); // Settings all have their separate arrays, so we need to invert the // grouping to group by site_id and channel_id rather than by setting // name. $grouped_settings = array(); foreach ($settings as $setting_name => $sites) { // Old versions of safecracker have other keys such as license_key. // We aren't interested in those. if (!in_array($setting_name, $valid_keys)) { continue; } foreach ($sites as $site_id => $channels) { if (!isset($grouped_settings[$site_id])) { $grouped_settings[$site_id] = array(); } $channels = array_filter($channels); foreach ($channels as $channel_id => $value) { if (!isset($grouped_settings[$site_id][$channel_id])) { $grouped_settings[$site_id][$channel_id] = array(); } switch ($setting_name) { case 'allow_guests': $setting_name = 'allow_guest_posts'; case 'require_captcha': $value = $value ? 'y' : 'n'; break; case 'override_status': $setting_name = 'default_status'; break; case 'logged_out_member_id': $setting_name = 'default_author'; break; default: continue; // unknown setting name } $grouped_settings[$site_id][$channel_id][$setting_name] = $value; } } } // Now flatten that into a usable set of db rows $db_settings = array(); $default_settings = array('default_status' => 'closed', 'require_captcha' => 'n', 'allow_guest_posts' => 'n', 'default_author' => 0); foreach ($grouped_settings as $site_id => $channels) { foreach ($channels as $channel_id => $settings) { $db_settings[] = array_merge($default_settings, $settings, compact('site_id', 'channel_id')); } } if (!empty($db_settings)) { // and put them into the new table ee()->db->insert_batch('channel_form_settings', $db_settings); } } // drop the extension ee()->db->delete('extensions', array('class' => 'Safecracker_ext')); }
function do_register() { $username = $this->input->post('username'); if (strlen($username) < 6 || strlen($username) > 32) { echo '{"result" : "用户名不合法!" }'; return; } if (!ctype_alnum($username)) { echo '{"result" : "用户名只允许包含字母和数字!" }'; return; } $password = $this->input->post('password'); $email = $this->input->post('email'); if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { echo '{"result" : "邮箱不合法!" }'; return; } $invitecode = $this->input->post('code'); if ($username && $password && $email) { $user = $this->user_model->u_select($username); $old_email = $this->user_model->email_select($email); if ($user) { echo '{"result" : "用户名已存在!" }'; return; } elseif ($old_email) { echo '{"result" : "邮箱已存在!" }'; return; } else { if ($this->user_model->need_invite()) { if ($invitecode) { if (!$this->user_model->valid_code($invitecode)) { echo '{"result" : "邀请码无效!" }'; return; } } else { echo '{"result" : "请输入邀请码!" }'; return; } } $this->load->helper('string'); $username = strip_slashes(strip_quotes($username)); $this->load->helper('security'); $password = hash('md5', $password); if ($this->user_model->new_user($username, $password, $email, $invitecode)) { if ($this->user_model->need_activate() == 'true') { if ($this->do_send_mail($username)) { echo '{"result" : "success" }'; return; } else { echo '{"result" : "邮件发送失败!" }'; return; } } else { echo '{"result" : "success" }'; } } else { echo '{"result" : "数据库错误!" }'; return; } } } else { echo '{"result" : "缺少参数!" }'; return; } }
/** * Unserialize * * This function unserializes a data string, then converts any * temporary slash markers back to actual slashes * * @param array * @return string */ protected function _unserialize($data) { $data = @unserialize(strip_slashes($data)); if (is_array($data)) { array_walk_recursive($data, array(&$this, '_unescape_slashes')); return $data; } return is_string($data) ? str_replace('{{slash}}', '\\', $data) : $data; }
/** * Extension Settings * * Displays the extension settings form * * @access public * @param message * @return void */ function extension_settings($message = '') { if ($this->config->item('allow_extensions') != 'y') { show_error(lang('unauthorized_access')); } $file = $this->security->sanitize_filename($this->input->get_post('file')); if ($this->input->get_post('file') === FALSE or !preg_match("/^[a-z0-9][\\w.-]*\$/i", $file)) { show_error(lang('not_authorized')); } $this->lang->loadfile('admin'); $this->load->library('table'); $this->view->cp_page_title = lang('extension_settings'); $this->cp->set_breadcrumb(BASE . AMP . 'C=addons_extensions', lang('extensions')); $vars['message'] = $message; $vars['file'] = $file; $class_name = ucfirst($vars['file']) . '_ext'; $current = array(); /** --------------------------------------- /** Extensions Enabled /** ---------------------------------------*/ $this->db->select('settings'); $this->db->where('enabled', 'y'); $this->db->where('class', $class_name); $this->db->limit(1); $query = $this->db->get('extensions'); if ($query->num_rows() > 0 && $query->row('settings') != '') { $current = strip_slashes(unserialize($query->row('settings'))); } $name = strtolower($vars['file']); $this->addons->get_files('extensions'); $ext_path = $this->addons->_packages[$name]['extension']['path']; /** ----------------------------- /** Call Extension File /** -----------------------------*/ if (!class_exists($class_name)) { if (file_exists($ext_path . 'ext.' . $name . '.php')) { @(include_once $ext_path . 'ext.' . $name . '.php'); } if (!class_exists($class_name)) { show_error(lang('not_authorized')); } } $OBJ = new $class_name(); foreach (array('description', 'settings_exist', 'docs_url', 'name', 'version') as $meta_item) { ${$meta_item} = !isset($OBJ->{$meta_item}) ? '' : $OBJ->{$meta_item}; } if ($name == '') { $name = ucwords(str_replace('_', ' ', $extension_name)); } $vars['name'] = $name; // ----------------------------------- // Fetch Extension Language file // // If there are settings, then there is a language file // because we need to know all the various variable names in the settings // form. I was tempted to give these language files a prefix but I // decided against it for the sake of simplicity and the fact that // a module might have extension's bundled with them and it would make // sense to have the same language file for both. // ----------------------------------- $this->lang->loadfile(strtolower($vars['file'])); /** --------------------------------------- /** Creating Their Own Settings Form? /** ---------------------------------------*/ if (method_exists($OBJ, 'settings_form') === TRUE) { // we're going to wipe the view vars here in a sec $file = $vars['file']; // add the package and view paths $this->load->add_package_path($ext_path, FALSE); // reset view variables $vars = array('_extension_name' => $name); // fetch the content $vars['_extension_settings_body'] = $OBJ->settings_form($current); // restore our package paths $this->load->remove_package_path($ext_path); // load it up, kapowpow! $this->view->cp_heading = lang('extension_settings') . ': ' . $name; $this->cp->render('addons/extensions_settings_custom', $vars); return; } foreach ($OBJ->settings() as $key => $options) { if (isset($current[$key])) { $value = $current[$key]; } elseif (is_array($options)) { $value = $options[2]; } elseif (is_string($options)) { $value = $options; } else { $value = ''; } $sub = ''; $details = ''; $selected = ''; if (isset($subtext[$key])) { foreach ($subtext[$key] as $txt) { $sub .= lang($txt); } } if (!is_array($options)) { $vars['fields'][$key] = array('type' => 'i', 'value' => array('name' => $key, 'value' => str_replace("\\'", "'", $value), 'id' => $key), 'subtext' => $sub, 'selected' => $selected); continue; } switch ($options[0]) { case 's': case 'ms': // Select fields foreach ($options[1] as $k => $v) { $details[$k] = lang($v); } $selected = $value; break; case 'r': case 'c': // Radio buttons and checkboxes foreach ($options[1] as $k => $v) { $checked = ($k == $value or is_array($value) && in_array($k, $value)) ? TRUE : FALSE; $details[] = array('name' => $options[0] == 'c' ? $key . '[]' : $key, 'value' => $k, 'id' => $key . '_' . $k, 'label' => $v, 'checked' => $checked); } break; case 't': // Textareas // The "kill_pipes" index instructs us to turn pipes into newlines if (isset($options['1']['kill_pipes']) && $options['1']['kill_pipes'] === TRUE) { $text = str_replace('|', NL, $value); } else { $text = $value; } $rows = isset($options['1']['rows']) ? $options['1']['rows'] : '20'; $text = str_replace("\\'", "'", $text); $details = array('name' => $key, 'value' => $text, 'rows' => $rows, 'id' => $key); break; case 'i': // Input fields $details = array('name' => $key, 'value' => str_replace("\\'", "'", $value), 'id' => $key); break; } $vars['fields'][$key] = array('type' => $options[0], 'value' => $details, 'subtext' => $sub, 'selected' => $selected); } $this->view->hidden = array('file' => $vars['file']); $this->view->cp_heading = lang('extension_settings') . ': ' . $name; $this->cp->render('addons/extensions_settings', $vars); }
/** * Install/Update Our Extension Hooks for Extension * * Tells ExpressionEngine what extension hooks we wish to use for this extension. If an extension * is part of a module, then it is the module's class name with the '_extension' suffix added on * to it. Stand-alone extensions are just the class name. * * @access public * @return null */ function update_extension_hooks() { if (!is_array($this->hooks) or sizeof($this->hooks) == 0) { return TRUE; } /** -------------------------------------------- /** First, Upgrade any EE 1.x Hooks to EE 2.x Format /** --------------------------------------------*/ if (APP_VER >= 2.0) { ee()->db->query("UPDATE exp_extensions SET class = '" . ee()->db->escape_str($this->extension_name) . "' \n \t\t\t\t\t WHERE class IN ('" . ee()->db->escape_str($this->class_name . '_extension') . "')"); } /** -------------------------------------------- /** Determine Existing Methods. And, if $this->settings is empty retrieve and use /** --------------------------------------------*/ $exists = array(); $query = ee()->db->query("SELECT method" . ($this->settings == '' ? ', settings' : '') . " FROM exp_extensions \n \t\t\t\t\t\t \t\tWHERE class = '" . ee()->db->escape_str($this->extension_name) . "'"); foreach ($query->result_array() as $row) { $exists[] = $row['method']; if ($this->settings == '' and !empty($row['settings'])) { ee()->load->helper('string'); $this->settings = strip_slashes(unserialize($row['settings'])); } } /** -------------------------------------------- /** Find Missing and Insert /** --------------------------------------------*/ $current_methods = array(); foreach ($this->hooks as $data) { // Default exp_extension fields, overwrite with any from array $data = array_merge($this->extension_defaults, $data); $current_methods[] = $data['method']; if (!in_array($data['method'], $exists)) { $data['class'] = $this->extension_name; // Every so often, EE rather stupidly sends no $settings argument to the constructor, so // our new hooks will not have any settings, so we have to fix that here. Frustrating. if ($data['settings'] == '' or $data['settings'] == 's:0:"";') { $data['settings'] = serialize($this->settings); } ee()->db->query(ee()->db->insert_string('exp_extensions', $data)); } else { unset($data['settings']); ee()->db->query(ee()->db->update_string('exp_extensions', $data, array('class' => $this->extension_name, 'method' => $data['method']))); } } /** -------------------------------------------- /** Remove Old Hooks /** --------------------------------------------*/ foreach (array_diff($exists, $current_methods) as $method) { ee()->db->query("DELETE FROM exp_extensions \n\t\t\t\t\t\t\t WHERE class = '" . ee()->db->escape_str($this->extension_name) . "' \n\t\t\t\t\t\t\t AND method = '" . ee()->db->escape_str($method) . "'"); } }
<div class="box-footer"> <button class="btn btn-primary btn-sm" type="submit" name="submit" value="Save"><?php echo $welcome->loadPo('Save'); ?></button> </div> </form> </div><!-- /.box --> </div> <?php } ?> <!-- Flavors section ends --> <!-- Player section starts --> <?php if($tab == 'Player') {?> <div class="tab-pane active" id="tab_Player"> <form action="<?php echo base_url() ?>video/setting_player" id="playerSettingForm" method="post" accept-charset="utf-8" enctype="multipart/form-data" accept-charset="utf-8" onsubmit="upload_logo_video();" > <input type="hidden" id="redirect_url" name="redirect_url" value="<?php echo current_full_url(); ?>" /> <div class="box-group" id="accordion"> <?php $data_player = @unserialize(strip_slashes($playerData)); ?> <input type="hidden" name="logo_imghiddennw" id="logo_imghiddennw" value="<?php echo $data_player['file']; ?>"/> <div class="panel box box-solid"> <div class="box-header"> <h4 class="box-title"> <a data-toggle="collapse" data-parent="#accordion" href="#collapseOne"> <?php echo $welcome->loadPo('General')." ".$welcome->loadPo('Settings'); ?> </a> </h4> </div> <div id="collapseOne" class="panel-collapse collapse in"> <div class="box-body"> <div class="row"> <div class="form-group col-lg-6"> <div class="input select"> <label for="playerPlayerType"><?php echo $welcome->loadPo('Player')." ".$welcome->loadPo('Type'); ?> </label>
break; case 'radio': $viewFields .= PHP_EOL . "\n <div class=\"form-group<?php echo form_error('{$field_name}') ? ' error' : ''; ?>\">\n <?php echo form_label(lang('{$module_name_lower}_field_{$field_name}'){$required}, '', array('class' => 'control-label', 'id' => '{$form_name}_label')); ?>\n <div class='controls' aria-labelled-by='{$form_name}_label'>\n <label class='radio' for='{$form_name}_option1'>\n <input id='{$form_name}_option1' name='{$form_name}' type='radio' " . ($required_attribute ? "required='required' " : "") . "value='option1' <?php echo set_radio('{$form_name}', 'option1', isset(\${$module_name_lower}->{$field_name}) && \${$module_name_lower}->{$field_name} == 'option1'); ?> />\n Radio option 1\n </label>\n <label class='radio' for='{$form_name}_option2'>\n <input id='{$form_name}_option2' name='{$form_name}' type='radio' " . ($required_attribute ? "required='required' " : "") . "value='option2' <?php echo set_radio('{$form_name}', 'option2', isset(\${$module_name_lower}->{$field_name}) && \${$module_name_lower}->{$field_name} == 'option2'); ?> />\n Radio option 2\n </label>\n <span class='help-inline'><?php echo form_error('{$field_name}'); ?></span>\n </div>\n </div>"; break; case 'select': // Use CI form helper here as it makes selects/dropdowns easier $select_options = array(); if (set_value("db_field_length_value{$counter}") != null) { $select_options = explode(',', set_value("db_field_length_value{$counter}")); } $viewFields .= PHP_EOL . ' <?php // Change the values in this array to populate your dropdown as required $options = array('; foreach ($select_options as $key => $option) { $viewFields .= ' ' . strip_slashes($option) . ' => ' . strip_slashes($option) . ','; } $viewFields .= "\n );\n echo form_dropdown(array('name' => '{$form_name}'" . ($required_attribute ? ", 'required' => 'required'" : "") . "), \$options, set_value('{$form_name}', isset(\${$module_name_lower}->{$field_name}) ? \${$module_name_lower}->{$field_name} : ''), lang('{$module_name_lower}_field_{$field_name}'){$required});\n ?>"; break; case 'checkbox': $viewFields .= PHP_EOL . "\n <div class=\"form-group<?php echo form_error('{$field_name}') ? ' error' : ''; ?>\">\n <div class='controls'>\n <label class='checkbox' for='{$form_name}'>\n <input type='checkbox' id='{$form_name}' name='{$form_name}' " . ($required_attribute ? "required='required' " : "") . " value='1' <?php echo set_checkbox('{$form_name}', 1, isset(\${$module_name_lower}->{$field_name}) && \${$module_name_lower}->{$field_name} == 1); ?> />\n <?php echo lang('{$module_name_lower}_field_{$field_name}'){$required}; ?>\n </label>\n <span class='help-inline'><?php echo form_error('{$field_name}'); ?></span>\n </div>\n </div>"; break; case 'input': case 'password': default: $type = $field_type == 'input' ? 'text' : 'password'; $db_field_type = set_value("db_field_type{$counter}"); $max = set_value("db_field_length_value{$counter}"); if ($max != null) { if (in_array($db_field_type, $realNumberTypes)) { // Constraints for real number types are expected to be in
public function test_strip_slashes() { $expected = array("Is your name O'reilly?", "No, my name is O'connor."); $str = array("Is your name O\\'reilly?", "No, my name is O\\'connor."); $this->assertEquals($expected, strip_slashes($str)); }