Example #1
0
 /**
  * Is Registered?
  *
  * @return bool
  **/
 public function is_registered()
 {
     if (!IS_CORE && ee()->config->item('license_number') == '') {
         return FALSE;
     }
     $cached = ee()->cache->get('software_registration', Cache::GLOBAL_SCOPE);
     $exp_response = md5(ee()->config->item('license_number') . ee()->config->item('license_contact'));
     if (!$cached or $cached != $exp_response) {
         // restrict the call to certain pages for performance and user experience
         $class = ee()->router->fetch_class();
         $method = ee()->router->fetch_method();
         if ($class == 'homepage' or $class == 'admin_system' && $method == 'software_registration') {
             $payload = array('contact' => ee()->config->item('license_contact'), 'license_number' => IS_CORE ? 'CORE LICENSE' : ee()->config->item('license_number'), 'domain' => ee()->config->item('site_url'), 'server_name' => isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : '', 'ee_version' => ee()->config->item('app_version'), 'php_version' => PHP_VERSION);
             if (!($registration = $this->_do_ping('http://ping.ellislab.com/register.php', $payload))) {
                 // save the failed request for a day only
                 ee()->cache->save('software_registration', $exp_response, 60 * 60 * 24, Cache::GLOBAL_SCOPE);
             } else {
                 if ($registration != $exp_response) {
                     // may have been a server error, save the failed request for a day
                     ee()->cache->save('software_registration', $exp_response, 60 * 60 * 24, Cache::GLOBAL_SCOPE);
                 } else {
                     // keep for two weeks
                     ee()->cache->save('software_registration', $registration, 60 * 60 * 24 * 7 * 2, Cache::GLOBAL_SCOPE);
                 }
             }
         }
     }
     // hard fail only when no valid license is entered or it doesn't even match a valid pattern
     if (ee()->config->item('license_number') == '' or !valid_license_pattern(ee()->config->item('license_number'))) {
         return FALSE;
     }
     return TRUE;
 }
Example #2
0
echo ' - ';
echo lang('build') . ' ' . APP_BUILD;
?>
 - &copy; <?php 
echo lang('copyright');
?>
 2003 - <?php 
echo date('Y');
?>
 <a href="<?php 
echo $this->cp->masked_url('http://ellislab.com/');
?>
" rel="external">EllisLab, Inc.</a><br />

	<?php 
$license = valid_license_pattern(config_item('license_number')) ? config_item('license_number') : lang('invalid_license');
echo lang('license_number') . ': ' . $license . ' - ' . mailto(config_item('license_contact'));
?>
	<br>
	<?php 
echo str_replace("%x", $this->benchmark->elapsed_time('total_execution_time_start', 'total_execution_time_end'), lang('page_rendered'));
echo ' - ';
echo str_replace("%x", $this->db->query_count, lang('queries_executed'));
?>
</div> <!-- footer -->


<div id="idle-modal" class="pageContents">
	<p id="idle-description" class="shun"><?php 
echo lang('session_idle_description');
?>
Example #3
0
 /**
  * Perform the installation
  *
  * @access	private
  * @return	null
  */
 function _do_install()
 {
     // Assign the _POST array values
     $this->_assign_install_values();
     $this->load->library('javascript');
     // Start our error trapping
     $errors = array();
     // Blank fields?
     foreach (array('license_number', 'db_hostname', 'db_username', 'db_name', 'site_label', 'webmaster_email', 'username', 'password', 'email_address') as $val) {
         if ($this->userdata[$val] == '') {
             $errors[] = $this->lang->line('empty_fields');
             break;
         }
     }
     // Usernames must be at least 4 chars in length
     if ($this->userdata['username'] != '' and strlen($this->userdata['username']) < 4) {
         $errors[] = $this->lang->line('username_short');
     }
     // Passwords must be at least 5 chars in length
     if ($this->userdata['password'] != '' and strlen($this->userdata['password']) < 5) {
         $errors[] = $this->lang->line('password_short');
     }
     // Passwords must match
     if ($this->userdata['password'] != $this->userdata['password_confirm']) {
         $errors[] = $this->lang->line('password_no_match');
     }
     if (!valid_license_pattern($this->userdata['license_number'])) {
         $errors[] = $this->lang->line('invalid_license_number');
     }
     //  Is password the same as username?
     $lc_user = strtolower($this->userdata['username']);
     $lc_pass = strtolower($this->userdata['password']);
     $nm_pass = strtr($lc_pass, 'elos', '3105');
     if ($this->userdata['username'] != '' and $this->userdata['password'] != '') {
         if ($lc_user == $lc_pass or $lc_user == strrev($lc_pass) or $lc_user == $nm_pass or $lc_user == strrev($nm_pass)) {
             $errors[] = $this->lang->line('password_not_unique');
         }
     }
     // Is email valid?
     if ($this->userdata['email_address'] != '' and !valid_email($this->userdata['email_address'])) {
         $errors[] = "The email address you submitted is not valid";
     }
     // And webmaster email?
     if ($this->userdata['webmaster_email'] != '' and !valid_email($this->userdata['webmaster_email'])) {
         $errors[] = "The webmaster email address you submitted is not valid";
     }
     // Set the screen name
     if ($this->userdata['screen_name'] == '') {
         $this->userdata['screen_name'] = $this->userdata['username'];
     }
     // check screen name and username for valid format
     if (strlen($this->userdata['username']) > 50 or preg_match("/[\\|'\"!<>\\{\\}]/", $this->userdata['username'])) {
         $errors[] = "Username is invalid. Must be less than 50 characters and cannot include the following characters: " . htmlentities('|\'"!<>{}');
     }
     if (preg_match('/[\\{\\}<>]/', $this->userdata['screen_name'])) {
         $errors[] = "Screen Name is invalid. Must not include the following characters: " . htmlentities('{}<>');
     }
     // DB Prefix has some character restrictions
     if (!preg_match("/^[0-9a-zA-Z\$_]*\$/", $this->userdata['db_prefix'])) {
         $errors[] = $this->lang->line('database_prefix_invalid_characters');
     }
     // The DB Prefix should not include "exp_"
     if (strpos($this->userdata['db_prefix'], 'exp_') !== FALSE) {
         $errors[] = $this->lang->line('database_prefix_contains_exp_');
     }
     // Table names cannot be longer than 64 characters, our longest is 26
     if (strlen($this->userdata['db_prefix']) > 30) {
         $errors[] = $this->lang->line('database_prefix_too_long');
     }
     // Connect to the database.  We pass a multi-dimensional array since
     // that's what is normally found in the database config file
     $db[$this->active_group] = array('hostname' => $this->userdata['db_hostname'], 'username' => $this->userdata['db_username'], 'password' => $this->userdata['db_password'], 'database' => $this->userdata['db_name'], 'dbdriver' => $this->userdata['dbdriver'], 'pconnect' => $this->userdata['db_conntype'] == 1 ? TRUE : FALSE, 'dbprefix' => $this->userdata['db_prefix'] == '' ? 'exp_' : preg_replace("#([^_])/*\$#", "\\1_", $this->userdata['db_prefix']), 'swap_pre' => 'exp_', 'db_debug' => TRUE, 'cache_on' => FALSE, 'autoinit' => FALSE, 'char_set' => 'utf8', 'dbcollat' => 'utf8_general_ci');
     if (!$this->_db_connect($db, TRUE)) {
         $errors[] = $this->lang->line('database_no_connect');
     }
     // Does the specified database schema type exist?
     if (!file_exists(APPPATH . 'schema/' . $this->userdata['dbdriver'] . '_schema' . EXT)) {
         $errors[] = $this->lang->line('unreadable_dbdriver');
     }
     // Were there errors?
     // If so we display the form and pass the userdata array to it
     if (count($errors) > 0) {
         $str = '';
         foreach ($errors as $val) {
             $str .= '<p>' . $val . '</p>';
         }
         $this->userdata['errors'] = $str;
         $this->userdata['extra_header'] = $this->_install_form_extra_header(json_encode($this->theme_required_modules));
         $this->_set_output('install_form', $this->userdata);
         return FALSE;
     }
     // --------------------------------------------------------------------
     // Load the DB schema
     require APPPATH . 'schema/' . $this->userdata['dbdriver'] . '_schema' . EXT;
     $this->schema = new EE_Schema();
     // Assign the userdata array to the schema class
     $this->schema->userdata =& $this->userdata;
     $this->schema->theme_path =& $this->theme_path;
     // Time
     $this->schema->now = $this->now;
     $this->schema->year = $this->year;
     $this->schema->month = $this->month;
     $this->schema->day = $this->day;
     // --------------------------------------------------------------------
     // Safety check: Is the user trying to install to an existing installation?
     // This can happen if someone mistakenly nukes their config.php file
     // and then trying to run the installer...
     $query = $this->db->query($this->schema->sql_find_like());
     if ($query->num_rows() > 0 and !isset($_POST['install_override'])) {
         $fields = '';
         foreach ($_POST as $key => $value) {
             // special handling for optional modules array
             if ($key == 'modules') {
                 foreach ($value as $k => $v) {
                     if (get_magic_quotes_gpc()) {
                         $v = stripslashes($v);
                     }
                     $fields .= '<input type="hidden" name="modules[]" value="' . str_replace("'", "&#39;", htmlspecialchars($v)) . '" />' . "\n";
                 }
             } else {
                 if (get_magic_quotes_gpc()) {
                     $value = stripslashes($value);
                 }
                 $fields .= '<input type="hidden" name="' . str_replace("'", "&#39;", htmlspecialchars($key)) . '" value="' . str_replace("'", "&#39;", htmlspecialchars($value)) . '" />' . "\n";
             }
         }
         $stuff = array('hidden_fields' => $fields, 'action' => $this->set_qstr('do_install'));
         $this->_set_output('install_warning', $stuff);
         return;
     }
     // --------------------------------------------------------------------
     // No errors?  Move our tanks to the front line and prepare for battle!
     // We no longer need this:
     unset($this->userdata['password_confirm']);
     unset($_POST['password_confirm']);
     // We assign some values to the Schema class
     $this->schema->default_entry = $this->_default_channel_entry();
     // Encrypt the password and unique ID
     $this->userdata['unique_id'] = random_string('encrypt');
     $this->userdata['password'] = sha1($this->userdata['password']);
     // --------------------------------------------------------------------
     // This allows one to override the functions in Email Data below, thus allowing custom speciality templates
     if (file_exists($this->theme_path . $this->userdata['theme'] . '/speciality_templates' . EXT)) {
         require $this->theme_path . $this->userdata['theme'] . '/speciality_templates' . EXT;
     }
     // Load the email template
     require_once EE_APPPATH . '/language/' . $this->userdata['deft_lang'] . '/email_data' . EXT;
     // Install Database Tables!
     if (!$this->schema->install_tables_and_data()) {
         $this->_set_output('error', array('error' => $this->lang->line('improper_grants')));
         return FALSE;
     }
     // Write the config file
     // it's important to do this first so that our site prefs and config file
     // visible for module and accessory installers
     if ($this->_write_config_data() == FALSE) {
         $this->_set_output('error', array('error' => $this->lang->line('unwritable_config')));
         return FALSE;
     }
     if ($this->_write_db_config($db) == FALSE) {
         $this->_set_output('error', array('error' => $this->lang->line('unwritable_database')));
         return FALSE;
     }
     // Install Accessories! (so exciting an exclaimation mark is needed!)
     if (!$this->_install_accessories()) {
         // This happens if they don't have any accessories - can't scold them for that
     }
     // Add any modules required by the theme to the required modules array
     if ($this->userdata['theme'] != '' && isset($this->theme_required_modules[$this->userdata['theme']])) {
         $this->required_modules = array_merge($this->required_modules, $this->theme_required_modules[$this->userdata['theme']]);
     }
     // Install Modules!
     if (!$this->_install_modules()) {
         $this->_set_output('error', array('error' => $this->lang->line('improper_grants')));
         return FALSE;
     }
     // Install Site Theme!
     // This goes last because a custom installer might create Member Groups besides the default five,
     // which might affect the Template Access permissions.
     if ($this->userdata['theme'] != '' && !$this->_install_site_theme()) {
         $this->_set_output('error', array('error' => $this->lang->line('improper_grants')));
         return FALSE;
     }
     // Build our success links
     $vars['installer_path'] = '/' . SYSDIR . '/installer';
     $vars['site_url'] = rtrim($this->userdata['site_url'], '/') . '/' . $this->userdata['site_index'];
     $vars['cp_url'] = $this->userdata['cp_url'];
     // If errors are thrown, this is were we get the "human" names for those modules
     $vars['module_names'] = $this->userdata['modules'];
     // A flag used to determine if module install errors need to be shown in the view
     $vars['errors'] = count($this->module_install_errors);
     // The list of errors into a variable passed into the view
     $vars['error_messages'] = $this->module_install_errors;
     // Woo hoo! Success!
     $this->_set_output('install_success', $vars);
 }
Example #4
0
 /**
  * Validates format of submitted license number
  *
  * @return vool
  **/
 public function _valid_license_pattern($license)
 {
     $valid_pattern = valid_license_pattern($license);
     if (!$valid_pattern) {
         $this->form_validation->set_message('_valid_license_pattern', lang('invalid_license_number'));
         return FALSE;
     }
     return TRUE;
 }