Beispiel #1
0
/**
 * @return The themed html string for any errors currently registered.
*/
function theme_errors()
{
    // Pop and check errors
    $errors = error_list();
    if (empty($errors)) {
        return '';
    }
    $output = '<fieldset><ul>';
    // Loop through errors
    foreach ($errors as $error) {
        $output .= '<li>' . $error . '</li>';
    }
    $output .= '</ul></fieldset>';
    return $output;
}
Beispiel #2
0
 /**
  * Function used to add custom field in upload form
  */
 function add_custom_field($array)
 {
     global $db, $LANG;
     foreach ($array as $key => $attr) {
         if ($key == 'name' || $key == 'title') {
             if (empty($attr)) {
                 e(sprintf(lang('cust_field_err'), $key));
             }
         }
         if (!error_list()) {
             if (!empty($attr)) {
                 $fields_array[] = 'custom_field_' . $key;
                 $value_array[] = mysql_clean($attr);
             }
             if ($key == 'db_field') {
                 $db->execute("ALTER TABLE " . tbl('video') . " ADD `" . $attr . "` TEXT NOT NULL");
             }
         }
     }
     if (!error_list()) {
         $db->insert(tbl("custom_fields"), $fields_array, $value_array);
     }
 }
Beispiel #3
0
/**
 * How do we want to name the admin user?
 */
function create_admin_user()
{
    global $output, $mybb, $errors, $db, $lang;
    $mybb->input['action'] = "adminuser";
    // If no errors then check for errors from last step
    if (!is_array($errors)) {
        if (empty($mybb->input['bburl'])) {
            $errors[] = $lang->config_step_error_url;
        }
        if (empty($mybb->input['bbname'])) {
            $errors[] = $lang->config_step_error_name;
        }
        if (is_array($errors)) {
            configure();
        }
    }
    $output->print_header($lang->create_admin, 'admin');
    echo <<<EOF
\t\t<script type="text/javascript">\t
\t\tfunction comparePass()
\t\t{
\t\t\tvar parenttr = \$('#adminpass2').closest('tr');
\t\t\tvar passval = \$('#adminpass2').val();
\t\t\tif(passval && passval != \$('#adminpass').val())
\t\t\t{
\t\t\t\tif(!parenttr.next('.pass_peeker').length)
\t\t\t\t{
\t\t\t\t\tparenttr.removeClass('last').after('<tr class="pass_peeker"><td colspan="2">{$lang->admin_step_nomatch}</td></tr>');
\t\t\t\t}
\t\t\t} else {
\t\t\t\tparenttr.addClass('last').next('.pass_peeker').remove();
\t\t\t}
\t\t}
\t\t</script>
\t\t
EOF;
    if (is_array($errors)) {
        $error_list = error_list($errors);
        echo $lang->sprintf($lang->admin_step_error_config, $error_list);
        $adminuser = $mybb->get_input('adminuser');
        $adminemail = $mybb->get_input('adminemail');
    } else {
        require MYBB_ROOT . 'inc/config.php';
        $db = db_connection($config);
        echo $lang->admin_step_setupsettings;
        $adminuser = $adminemail = '';
        $settings = file_get_contents(INSTALL_ROOT . 'resources/settings.xml');
        $parser = new XMLParser($settings);
        $parser->collapse_dups = 0;
        $tree = $parser->get_tree();
        $groupcount = $settingcount = 0;
        // Insert all the settings
        foreach ($tree['settings'][0]['settinggroup'] as $settinggroup) {
            $groupdata = array('name' => $db->escape_string($settinggroup['attributes']['name']), 'title' => $db->escape_string($settinggroup['attributes']['title']), 'description' => $db->escape_string($settinggroup['attributes']['description']), 'disporder' => (int) $settinggroup['attributes']['disporder'], 'isdefault' => $settinggroup['attributes']['isdefault']);
            $gid = $db->insert_query('settinggroups', $groupdata);
            ++$groupcount;
            foreach ($settinggroup['setting'] as $setting) {
                $settingdata = array('name' => $db->escape_string($setting['attributes']['name']), 'title' => $db->escape_string($setting['title'][0]['value']), 'description' => $db->escape_string($setting['description'][0]['value']), 'optionscode' => $db->escape_string($setting['optionscode'][0]['value']), 'value' => $db->escape_string($setting['settingvalue'][0]['value']), 'disporder' => (int) $setting['disporder'][0]['value'], 'gid' => $gid, 'isdefault' => 1);
                $db->insert_query('settings', $settingdata);
                $settingcount++;
            }
        }
        if (my_substr($mybb->get_input('bburl'), -1, 1) == '/') {
            $mybb->input['bburl'] = my_substr($mybb->get_input('bburl'), 0, -1);
        }
        $db->update_query("settings", array('value' => $db->escape_string($mybb->get_input('bbname'))), "name='bbname'");
        $db->update_query("settings", array('value' => $db->escape_string($mybb->get_input('bburl'))), "name='bburl'");
        $db->update_query("settings", array('value' => $db->escape_string($mybb->get_input('websitename'))), "name='homename'");
        $db->update_query("settings", array('value' => $db->escape_string($mybb->get_input('websiteurl'))), "name='homeurl'");
        $db->update_query("settings", array('value' => $db->escape_string($mybb->get_input('cookiedomain'))), "name='cookiedomain'");
        $db->update_query("settings", array('value' => $db->escape_string($mybb->get_input('cookiepath'))), "name='cookiepath'");
        $db->update_query("settings", array('value' => $db->escape_string($mybb->get_input('contactemail'))), "name='adminemail'");
        $db->update_query("settings", array('value' => 'contact.php'), "name='contactlink'");
        write_settings();
        echo $lang->sprintf($lang->admin_step_insertesettings, $settingcount, $groupcount);
        // Save the acp pin
        $pin = addslashes($mybb->get_input('pin'));
        $file = @fopen(MYBB_ROOT . "inc/config.php", "a");
        @fwrite($file, "/**\n * Admin CP Secret PIN\n *  If you wish to request a PIN\n *  when someone tries to login\n *  on your Admin CP, enter it below.\n */\n\n\$config['secret_pin'] = '{$pin}';");
        @fclose($file);
        include_once MYBB_ROOT . "inc/functions_task.php";
        $tasks = file_get_contents(INSTALL_ROOT . 'resources/tasks.xml');
        $parser = new XMLParser($tasks);
        $parser->collapse_dups = 0;
        $tree = $parser->get_tree();
        $taskcount = 0;
        // Insert scheduled tasks
        foreach ($tree['tasks'][0]['task'] as $task) {
            $new_task = array('title' => $db->escape_string($task['title'][0]['value']), 'description' => $db->escape_string($task['description'][0]['value']), 'file' => $db->escape_string($task['file'][0]['value']), 'minute' => $db->escape_string($task['minute'][0]['value']), 'hour' => $db->escape_string($task['hour'][0]['value']), 'day' => $db->escape_string($task['day'][0]['value']), 'weekday' => $db->escape_string($task['weekday'][0]['value']), 'month' => $db->escape_string($task['month'][0]['value']), 'enabled' => $db->escape_string($task['enabled'][0]['value']), 'logging' => $db->escape_string($task['logging'][0]['value']));
            $new_task['nextrun'] = fetch_next_run($new_task);
            $db->insert_query("tasks", $new_task);
            $taskcount++;
        }
        // For the version check task, set a random date and hour (so all MyBB installs don't query mybb.com all at the same time)
        $update_array = array('hour' => rand(0, 23), 'weekday' => rand(0, 6));
        $db->update_query("tasks", $update_array, "file = 'versioncheck'");
        echo $lang->sprintf($lang->admin_step_insertedtasks, $taskcount);
        $views = file_get_contents(INSTALL_ROOT . 'resources/adminviews.xml');
        $parser = new XMLParser($views);
        $parser->collapse_dups = 0;
        $tree = $parser->get_tree();
        $view_count = 0;
        // Insert admin views
        foreach ($tree['adminviews'][0]['view'] as $view) {
            $fields = array();
            foreach ($view['fields'][0]['field'] as $field) {
                $fields[] = $field['attributes']['name'];
            }
            $conditions = array();
            if (isset($view['conditions'][0]['condition']) && is_array($view['conditions'][0]['condition'])) {
                foreach ($view['conditions'][0]['condition'] as $condition) {
                    if (!$condition['value']) {
                        continue;
                    }
                    if ($condition['attributes']['is_serialized'] == 1) {
                        $condition['value'] = my_unserialize($condition['value']);
                    }
                    $conditions[$condition['attributes']['name']] = $condition['value'];
                }
            }
            $custom_profile_fields = array();
            if (isset($view['custom_profile_fields'][0]['field']) && is_array($view['custom_profile_fields'][0]['field'])) {
                foreach ($view['custom_profile_fields'][0]['field'] as $field) {
                    $custom_profile_fields[] = $field['attributes']['name'];
                }
            }
            $new_view = array("uid" => 0, "type" => $db->escape_string($view['attributes']['type']), "visibility" => (int) $view['attributes']['visibility'], "title" => $db->escape_string($view['title'][0]['value']), "fields" => $db->escape_string(my_serialize($fields)), "conditions" => $db->escape_string(my_serialize($conditions)), "custom_profile_fields" => $db->escape_string(my_serialize($custom_profile_fields)), "sortby" => $db->escape_string($view['sortby'][0]['value']), "sortorder" => $db->escape_string($view['sortorder'][0]['value']), "perpage" => (int) $view['perpage'][0]['value'], "view_type" => $db->escape_string($view['view_type'][0]['value']));
            $db->insert_query("adminviews", $new_view);
            $view_count++;
        }
        echo $lang->sprintf($lang->admin_step_insertedviews, $view_count);
        echo $lang->admin_step_createadmin;
    }
    echo $lang->sprintf($lang->admin_step_admintable, $adminuser, $adminemail);
    $output->print_footer('final');
}
Beispiel #4
0
    case 'spam_comment':
        $cid = mysql_clean($_POST['cid']);
        $rating = $myquery->spam_comment($cid);
        if (msg()) {
            $msg = msg_list();
            $msg = $msg[0];
        }
        if (error()) {
            $err = error_list();
            $err = $err[0];
        }
        $ajax['msg'] = $msg;
        $ajax['err'] = $err;
        echo json_encode($ajax);
        break;
    case 'remove_spam':
        $cid = mysql_clean($_POST['cid']);
        $rating = $myquery->remove_spam($cid);
        if (msg()) {
            $msg = msg_list();
            $msg = $msg[0];
        }
        if (error()) {
            $err = error_list();
            $err = $err[0];
        }
        $ajax['msg'] = $msg;
        $ajax['err'] = $err;
        echo json_encode($ajax);
        break;
}
Beispiel #5
0
 */
include '../includes/config.inc.php';
//Getting mode..
$mode = post('mode');
if (!$mode) {
    $mode = get('mode');
}
$mode = mysql_clean($mode);
switch ($mode) {
    case 'send_photo_pm':
        $array = $_POST;
        $array['is_pm'] = true;
        $array['from'] = userid();
        $cbpm->send_pm($array);
        if (error()) {
            $errors = error_list();
            $response = array('error' => $errors[0]);
        }
        if (msg()) {
            $success = msg_list();
            $response = array('success' => $success[0]);
        }
        echo json_encode($response);
        break;
    case 'delete_photo':
        $id = mysql_clean($_POST['id']);
        $photo = $cbphoto->get_photo($id);
        $item = get_collection_item($photo['collection_id'], $photo['photo_id']);
        $redirect_to = $cbcollection->get_next_prev_item($item['ci_id'], $item['collection_id'], 'next');
        $response = array('success' => true, 'redirect_to' => $cbphoto->photo_links($redirect_to[0], 'view_photo'));
        /* Delete photo */
Beispiel #6
0
function form_input($type, $name, $values = array(), array $errors = array(), array $attributes = array(), $class = '')
{
    $class .= error_class($errors, $name);
    $html = '<input type="' . $type . '" name="' . $name . '" id="form-' . $name . '" ' . form_value($values, $name) . ' class="' . $class . '" ';
    $html .= implode(' ', $attributes) . '/>';
    if (in_array('required', $attributes)) {
        $html .= '<span class="form-required">*</span>';
    }
    $html .= error_list($errors, $name);
    return $html;
}
function create_admin_user()
{
    global $output, $mybb, $errors, $db, $lang;
    $mybb->input['action'] = "adminuser";
    // If no errors then check for errors from last step
    if (!is_array($errors)) {
        if (empty($mybb->input['bburl'])) {
            $errors[] = $lang->config_step_error_url;
        }
        if (empty($mybb->input['bbname'])) {
            $errors[] = $lang->config_step_error_name;
        }
        if (is_array($errors)) {
            configure();
        }
    }
    $output->print_header($lang->create_admin, 'admin');
    if (is_array($errors)) {
        $error_list = error_list($errors);
        echo $lang->sprintf($lang->admin_step_error_config, $error_list);
        $adminuser = $mybb->input['adminuser'];
        $adminemail = $mybb->input['adminemail'];
    } else {
        require MYBB_ROOT . 'inc/config.php';
        $db = db_connection($config);
        echo $lang->admin_step_setupsettings;
        $settings = file_get_contents(INSTALL_ROOT . 'resources/settings.xml');
        $parser = new XMLParser($settings);
        $parser->collapse_dups = 0;
        $tree = $parser->get_tree();
        // Insert all the settings
        foreach ($tree['settings'][0]['settinggroup'] as $settinggroup) {
            $groupdata = array('name' => $db->escape_string($settinggroup['attributes']['name']), 'title' => $db->escape_string($settinggroup['attributes']['title']), 'description' => $db->escape_string($settinggroup['attributes']['description']), 'disporder' => intval($settinggroup['attributes']['disporder']), 'isdefault' => $settinggroup['attributes']['isdefault']);
            $gid = $db->insert_query('settinggroups', $groupdata);
            ++$groupcount;
            foreach ($settinggroup['setting'] as $setting) {
                $settingdata = array('name' => $db->escape_string($setting['attributes']['name']), 'title' => $db->escape_string($setting['title'][0]['value']), 'description' => $db->escape_string($setting['description'][0]['value']), 'optionscode' => $db->escape_string($setting['optionscode'][0]['value']), 'value' => $db->escape_string($setting['settingvalue'][0]['value']), 'disporder' => intval($setting['disporder'][0]['value']), 'gid' => $gid, 'isdefault' => 1);
                $db->insert_query('settings', $settingdata);
                $settingcount++;
            }
        }
        if (my_substr($mybb->input['bburl'], -1, 1) == '/') {
            $mybb->input['bburl'] = my_substr($mybb->input['bburl'], 0, -1);
        }
        $db->update_query("settings", array('value' => $db->escape_string($mybb->input['bbname'])), "name='bbname'");
        $db->update_query("settings", array('value' => $db->escape_string($mybb->input['bburl'])), "name='bburl'");
        $db->update_query("settings", array('value' => $db->escape_string($mybb->input['websitename'])), "name='homename'");
        $db->update_query("settings", array('value' => $db->escape_string($mybb->input['websiteurl'])), "name='homeurl'");
        $db->update_query("settings", array('value' => $db->escape_string($mybb->input['cookiedomain'])), "name='cookiedomain'");
        $db->update_query("settings", array('value' => $db->escape_string($mybb->input['cookiepath'])), "name='cookiepath'");
        $db->update_query("settings", array('value' => $db->escape_string($mybb->input['contactemail'])), "name='adminemail'");
        $db->update_query("settings", array('value' => 'mailto:' . $db->escape_string($mybb->input['contactemail'])), "name='contactlink'");
        write_settings();
        echo $lang->sprintf($lang->admin_step_insertesettings, $settingcount, $groupcount);
        include_once MYBB_ROOT . "inc/functions_task.php";
        $tasks = file_get_contents(INSTALL_ROOT . 'resources/tasks.xml');
        $parser = new XMLParser($tasks);
        $parser->collapse_dups = 0;
        $tree = $parser->get_tree();
        // Insert scheduled tasks
        foreach ($tree['tasks'][0]['task'] as $task) {
            $new_task = array('title' => $db->escape_string($task['title'][0]['value']), 'description' => $db->escape_string($task['description'][0]['value']), 'file' => $db->escape_string($task['file'][0]['value']), 'minute' => $db->escape_string($task['minute'][0]['value']), 'hour' => $db->escape_string($task['hour'][0]['value']), 'day' => $db->escape_string($task['day'][0]['value']), 'weekday' => $db->escape_string($task['weekday'][0]['value']), 'month' => $db->escape_string($task['month'][0]['value']), 'enabled' => $db->escape_string($task['enabled'][0]['value']), 'logging' => $db->escape_string($task['logging'][0]['value']));
            $new_task['nextrun'] = fetch_next_run($new_task);
            $db->insert_query("tasks", $new_task);
            $taskcount++;
        }
        echo $lang->sprintf($lang->admin_step_insertedtasks, $taskcount);
        $views = file_get_contents(INSTALL_ROOT . 'resources/adminviews.xml');
        $parser = new XMLParser($views);
        $parser->collapse_dups = 0;
        $tree = $parser->get_tree();
        // Insert admin views
        foreach ($tree['adminviews'][0]['view'] as $view) {
            $fields = array();
            foreach ($view['fields'][0]['field'] as $field) {
                $fields[] = $field['attributes']['name'];
            }
            $conditions = array();
            if (is_array($view['conditions'][0]['condition'])) {
                foreach ($view['conditions'][0]['condition'] as $condition) {
                    if (!$condition['value']) {
                        continue;
                    }
                    if ($condition['attributes']['is_serialized'] == 1) {
                        $condition['value'] = unserialize($condition['value']);
                    }
                    $conditions[$condition['attributes']['name']] = $condition['value'];
                }
            }
            $custom_profile_fields = array();
            if (is_array($view['custom_profile_fields'][0]['field'])) {
                foreach ($view['custom_profile_fields'][0]['field'] as $field) {
                    $custom_profile_fields[] = $field['attributes']['name'];
                }
            }
            $new_view = array("uid" => 0, "type" => $db->escape_string($view['attributes']['type']), "visibility" => intval($view['attributes']['visibility']), "title" => $db->escape_string($view['title'][0]['value']), "fields" => $db->escape_string(serialize($fields)), "conditions" => $db->escape_string(serialize($conditions)), "custom_profile_fields" => $db->escape_string(serialize($custom_profile_fields)), "sortby" => $db->escape_string($view['sortby'][0]['value']), "sortorder" => $db->escape_string($view['sortorder'][0]['value']), "perpage" => intval($view['perpage'][0]['value']), "view_type" => $db->escape_string($view['view_type'][0]['value']));
            $db->insert_query("adminviews", $new_view);
            $view_count++;
        }
        echo $lang->sprintf($lang->admin_step_insertedviews, $view_count);
        echo $lang->admin_step_createadmin;
    }
    echo $lang->sprintf($lang->admin_step_admintable, $adminuser, $adminemail);
    $output->print_footer('final');
}
Beispiel #8
0
/**
 * Function used to check weather erro exists or not
 */
function error($param = 'array')
{
    if (count(error_list()) > 0) {
        if ($param != 'array') {
            if ($param == 'single') {
                $param = 0;
            }
            $msg = error_list();
            return $msg[$param];
        }
        return error_list();
    } else {
        return false;
    }
}
Beispiel #9
0
 function db_configuration()
 {
     global $mybb, $output, $import_session, $db, $dboptions, $dbengines, $dbhost, $dbuser, $dbname, $tableprefix;
     // Just posted back to this form?
     if ($mybb->input['dbengine']) {
         $config_data = $mybb->input['config'][$mybb->input['dbengine']];
         if (strstr($mybb->input['dbengine'], "sqlite") !== false && (strstr($config_data['dbname'], "./") !== false || strstr($config_data['dbname'], "../") !== false)) {
             $errors[] = "You may not use relative URLs for SQLite databases. Please use a file system path (ex: /home/user/database.db) for your SQLite database.";
         } else {
             if (!file_exists(MYBB_ROOT . "inc/db_{$mybb->input['dbengine']}.php")) {
                 $errors[] = 'You have selected an invalid database engine. Please make your selection from the list below.';
             } else {
                 // Attempt to connect to the db
                 require_once MYBB_ROOT . "inc/db_{$mybb->input['dbengine']}.php";
                 switch ($mybb->input['dbengine']) {
                     case "sqlite":
                         $this->old_db = new DB_SQLite();
                         break;
                     case "pgsql":
                         $this->old_db = new DB_PgSQL();
                         break;
                     case "mysqli":
                         $this->old_db = new DB_MySQLi();
                         break;
                     default:
                         $this->old_db = new DB_MySQL();
                 }
                 $this->old_db->error_reporting = 0;
                 $connect_config['type'] = $mybb->input['dbengine'];
                 $connect_config['database'] = $config_data['dbname'];
                 $connect_config['table_prefix'] = $config_data['tableprefix'];
                 $connect_config['hostname'] = $config_data['dbhost'];
                 $connect_config['username'] = $config_data['dbuser'];
                 $connect_config['password'] = $config_data['dbpass'];
                 $connect_config['encoding'] = $config_data['encoding'];
                 $connection = $this->old_db->connect($connect_config);
                 if (!$connection) {
                     $errors[] = "Could not connect to the database server at '{$config_data['dbhost']}' with the supplied username and password. Are you sure the hostname and user details are correct?";
                 }
                 if (empty($errors)) {
                     // Need to check if it is actually installed here
                     $this->old_db->set_table_prefix($config_data['tableprefix']);
                     $check_table = "";
                     switch ($import_session['board']) {
                         case "ipb2":
                             $check_table = "forum_perms";
                             break;
                         case "mybb":
                             $check_table = "usergroups";
                             break;
                         case "phpbb2":
                             $check_table = "topics";
                             break;
                         case "phpbb3":
                             $check_table = "user_group";
                             break;
                         case "punbb":
                             $check_table = "groups";
                             break;
                         case "smf":
                         case "smf2":
                             $check_table = "boards";
                             break;
                         case "vbulletin3":
                             $check_table = "forumpermission";
                             break;
                         case "xmb":
                             $check_table = "vote_desc";
                             break;
                         case "bbpress":
                             $check_table = "usermeta";
                             break;
                     }
                     if ($check_table && !$this->old_db->table_exists($check_table)) {
                         $errors[] = "The {$this->plain_bbname} database could not be found in '{$config_data['dbname']}'.  Please ensure {$this->plain_bbname} exists at this database and with this table prefix.";
                     }
                 }
                 // No errors? Save import DB info and then return finished
                 if (!is_array($errors)) {
                     $output->print_header("{$this->plain_bbname} Database Configuration");
                     echo "<br />\nChecking database details... <span style=\"color: green\">success.</span><br /><br />\n";
                     flush();
                     $import_session['old_db_engine'] = $mybb->input['dbengine'];
                     $import_session['old_db_host'] = $config_data['dbhost'];
                     $import_session['old_db_user'] = $config_data['dbuser'];
                     $import_session['old_db_pass'] = $config_data['dbpass'];
                     $import_session['old_db_name'] = $config_data['dbname'];
                     $import_session['old_tbl_prefix'] = $config_data['tableprefix'];
                     $import_session['connect_config'] = serialize($connect_config);
                     $import_session['encode_to_utf8'] = intval($mybb->input['encode_to_utf8']);
                     // Create temporary import data fields
                     create_import_fields();
                     sleep(2);
                     $import_session['flash_message'] = "Successfully configured and connected to the database.";
                     return "finished";
                 }
             }
         }
     }
     $output->print_header("{$this->plain_bbname} Database Configuration");
     // Check for errors
     if (is_array($errors)) {
         $error_list = error_list($errors);
         echo "<div class=\"error\">\n\t\t\t      <h3>Error</h3>\n\t\t\t\t  <p>There seems to be one or more errors with the database configuration information that you supplied:</p>\n\t\t\t\t  {$error_list}\n\t\t\t\t  <p>Once the above are corrected, continue with the conversion.</p>\n\t\t\t\t  </div>";
     } else {
         echo "<p>Please enter the database details for your installation of {$this->plain_bbname} you want to merge from.</p>";
         if ($import_session['old_db_engine']) {
             $mybb->input['dbengine'] = $import_session['old_db_engine'];
         } else {
             $mybb->input['dbengine'] = $mybb->config['database']['type'];
         }
         if ($import_session['old_db_host']) {
             $mybb->input['config'][$mybb->input['dbengine']]['dbhost'] = $import_session['old_db_host'];
         } else {
             $mybb->input['config'][$mybb->input['dbengine']]['dbhost'] = 'localhost';
         }
         if ($import_session['old_tbl_prefix']) {
             $mybb->input['config'][$mybb->input['dbengine']]['tableprefix'] = $import_session['old_tbl_prefix'];
         } else {
             $prefix_suggestion = "";
             switch ($import_session['board']) {
                 case "ipb2":
                     $prefix_suggestion = "ibf_";
                     break;
                 case "mybb":
                     $prefix_suggestion = "mybb_";
                     break;
                 case "phpbb2":
                     $prefix_suggestion = "phpbb_";
                     break;
                 case "phpbb3":
                     $prefix_suggestion = "phpbb_";
                     break;
                 case "punbb":
                     $prefix_suggestion = "punbb_";
                     break;
                 case "smf":
                 case "smf2":
                     $prefix_suggestion = "smf_";
                     break;
                 case "vbulletin3":
                     $prefix_suggestion = "";
                     break;
                 case "xmb":
                     $prefix_suggestion = "xmb_";
                     break;
                 case "bbpress":
                     $prefix_suggestion = "bb_";
                     break;
             }
             $mybb->input['config'][$mybb->input['dbengine']]['tableprefix'] = $prefix_suggestion;
         }
         if ($import_session['old_db_user']) {
             $mybb->input['config'][$mybb->input['dbengine']]['dbuser'] = $import_session['old_db_user'];
         } else {
             $mybb->input['config'][$mybb->input['dbengine']]['dbuser'] = '';
         }
         if ($import_session['old_db_name']) {
             $mybb->input['config'][$mybb->input['dbengine']]['dbname'] = $import_session['old_db_name'];
         } else {
             $mybb->input['config'][$mybb->input['dbengine']]['dbname'] = '';
         }
     }
     $import_session['autorefresh'] = "";
     $mybb->input['autorefresh'] = "no";
     $output->print_database_details_table($this->plain_bbname);
     $output->print_footer();
 }
Beispiel #10
0
         $userquery->mark_requests_seen($uid);
     }
     break;
 case 'add_friend':
     $friend = post('uid');
     $userid = userid();
     $message = post('message');
     if ($userid) {
         $userquery->add_friend_request(array('userid' => $userid, 'friend_id' => $friend, 'message' => $message));
         if (msg()) {
             $msg = msg_list();
             $msg = $msg[0];
             echo json_encode(array('success' => 'ok', 'msg' => $msg));
         }
         if (error()) {
             $msg = error_list();
             echo json_encode(array('error' => $msg));
         }
         $msg;
     } else {
         echo json_encode(array('error' => array(lang('You are not logged in'))));
     }
     break;
 case 'confirm_friend':
     $rid = $_POST['rid'];
     $uid = userid();
     $cid = $userquery->confirm_friend($uid, $rid);
     if (error()) {
         $error = error('single');
         echo json_encode(array('err' => $error));
     } else {
Beispiel #11
0
        $attachmentswritable = @fopen(MYBB_ROOT . 'uploads/test.write', 'w');
        if (!$attachmentswritable) {
            $errors['attachments_check'] = 'The attachments directory (/uploads/) is not writable. Please adjust the <a href="http://wiki.mybb.com/index.php/CHMOD%20Files" target="_blank">chmod</a> permissions to allow it to be written to.';
            $checks['attachments_check_status'] = '<span class="fail"><strong>Not Writable</strong></span>';
            @fclose($attachmentswritable);
            $debug->log->trace0("Attachments directory not writable");
        } else {
            $checks['attachments_check_status'] = '<span class="pass">Writable</span>';
            @fclose($attachmentswritable);
            @my_chmod(MYBB_ROOT . 'uploads', '0777');
            @my_chmod(MYBB_ROOT . 'uploads/test.write', '0777');
            @unlink(MYBB_ROOT . 'uploads/test.write');
            $debug->log->trace0("Attachments directory writable");
        }
        if (!empty($errors)) {
            $output->print_warning(error_list($errors), "The MyBB Merge System Requirements check failed:");
        }
        echo '<p><div class="border_wrapper">
			<div class="title">Requirements Check</div>
		<table class="general" cellspacing="0">
		<thead>
			<tr>
				<th colspan="2" class="first last">Requirements</th>
			</tr>
		</thead>
		<tbody>
		<tr class="first">
			<td class="first">Merge System Version:</td>
			<td class="last alt_col">' . $checks['version_check_status'] . '</td>
		</tr>
		<tr class="alt_row">
Beispiel #12
0
    function _form_home()
    {
        global $core, $user, $style;
        $tree = $this->valid_tree();
        if (!$tree['tree_form']) {
            _fatal();
        }
        if ($tree['tree_parent']) {
            $sql = 'SELECT *
				FROM _tree
				WHERE tree_id = ' . (int) $tree['tree_parent'];
            $parent = $this->_fieldrow($sql);
            if ($tree['tree_level'] > 2) {
                $sql = 'SELECT *
					FROM _tree
					WHERE tree_id = ' . (int) $parent['tree_parent'];
                $subparent = $this->_fieldrow($sql);
            }
        }
        if ($tree['tree_node']) {
            $sql = 'SELECT *
				FROM _tree
				WHERE tree_id = ' . (int) $tree['tree_node'];
            $node = $this->_fieldrow($sql);
        }
        //
        $sql = 'SELECT *
			FROM _form_fields
			WHERE form_tree = ' . (int) $tree['tree_id'] . '
			ORDER BY form_order';
        $form = $this->_rowset($sql, 'form_alias');
        if (!count($form)) {
            $sql = 'SELECT *
				FROM _form_fields
				WHERE form_tree = 0
				ORDER BY form_order';
            $form = $this->_rowset($sql, 'form_alias');
        }
        $form['ctkey'] = array('form_required' => 1, 'form_regex' => '^([a-zA-Z]+)$', 'form_alias' => 'ctkey', 'form_type' => 'text', 'form_legend' => 'Imagen de seguridad');
        if (_button()) {
            $va = array();
            foreach ($form as $row) {
                $va[] = $row['form_alias'];
            }
            $v = $this->__($va);
            foreach ($form as $row) {
                if (empty($v[$row['form_alias']])) {
                    if ($row['form_required']) {
                        $this->error(sprintf(_lang('E_COMMENT_FIELD_EMPTY'), $row['form_legend']), false);
                    }
                    continue;
                }
                if (!empty($row['form_regex']) && !preg_match('#' . $row['form_regex'] . '#is', $v[$row['form_alias']])) {
                    $this->error(sprintf(_lang('E_COMMENT_FIELD_BAD'), $row['form_legend']), false);
                    if ($row['form_alias'] == 'ctkey') {
                        $v[$row['form_alias']] = '';
                    }
                }
            }
            if (!$this->errors()) {
                include XFS . 'core/xcf.php';
                $xcf = new captcha();
                if ($xcf->check($v['ctkey']) === false) {
                    $v['ctkey'] = '';
                    $this->error('E_COMMENT_INVALID_CAPTCHA');
                }
                unset($xcf);
            }
            if (!$this->errors()) {
                include XFS . 'core/emailer.php';
                $emailer = new emailer();
                $v['subject'] = preg_replace('#\\&([A-Za-z]+){1}(.*?)\\;#e', "substr('\\1', 0, 1)", $v['subject']);
                $emailer->from($v['email']);
                $emailer->set_subject($v['subject']);
                $emailer->use_template('contact_email', $core->v('default_lang'));
                foreach (explode(';', $tree['tree_form_email']) as $i => $address) {
                    $row_f = !$i ? 'email_address' : 'cc';
                    $emailer->{$row_f}($address);
                }
                $emailer->cc($core->v('default_email'));
                unset($v['ctkey']);
                $html = array();
                foreach ($form as $row) {
                    if (empty($v[$row['form_alias']])) {
                        continue;
                    }
                    if ($row['form_alias'] == 'message') {
                        $v['message'] = str_replace("\r\n", '<br />', $v['message']);
                    }
                    $html[] = '<strong>' . $row['form_legend'] . ':</strong><br />' . $v[$row['form_alias']];
                }
                $emailer->assign_vars(array('HTML_FIELDS' => implode('<br /><br />', $html), 'FROM_USERNAME' => $v['nombre'], 'FORM_ARTICLE' => $tree['tree_subject']));
                $emailer->send();
                $emailer->reset();
                //
                $style->assign_block_vars('sent', array('THANKS' => _lang('CONTACT_THANKS')));
            }
        }
        if (!_button() || $this->errors()) {
            if ($this->errors()) {
                $style->assign_block_vars('error', array('MESSAGE' => error_list($this->error)));
            }
            $ff = 'form_';
            $fff = 'alias|type';
            $style->assign_block_vars('form', array());
            foreach ($form as $row) {
                $style->assign_block_vars('form.row', array('ALIAS' => $row[$ff . 'alias'], 'REQUIRED' => $row[$ff . 'required'], 'LEGEND' => $row[$ff . 'legend'], 'TYPE' => $row[$ff . 'type'], 'ERROR' => isset($error[$row[$ff . 'alias']]), 'VALUE' => isset($v[$row[$ff . 'alias']]) ? $v[$row[$ff . 'alias']] : ''));
                foreach ($row as $row_k => $row_v) {
                    if (preg_match('#^' . $ff . '(' . $fff . ')$#is', $row_k)) {
                        if ($row_k == 'form_alias') {
                            $row_k = 'name';
                        }
                        $style->assign_block_vars('form.row.attrib', array('ATTRIB' => str_replace($ff, '', $row_k), 'VALUE' => $row_v));
                    }
                }
            }
        }
        //
        $s_css_page = '';
        if (@file_exists('./style/css/_tree_' . $this->alias_id($tree) . '.css')) {
            $s_css_page = $this->alias_id($tree) . '/';
        } elseif ($this->css_parent($tree)) {
            if (empty($tree['tree_css_var'])) {
                $tree['tree_css_var'] = 'parent';
            }
            $ary_css_var = false;
            switch ($tree['tree_css_var']) {
                case 'parent':
                case 'subparent':
                case 'node':
                    $ary_css_var = ${$tree['tree_css_var']};
                    break;
                default:
                    if (is_numeric($tree['tree_css_var'])) {
                        $sql = 'SELECT *
							FROM _tree
							WHERE tree_id = ' . (int) $tree['tree_css_var'];
                        if ($css_var_row = $this->_fieldrow($sql)) {
                            $ary_css_var = $css_var_row;
                        }
                    }
                    break;
            }
            if ($ary_css_var !== false) {
                $s_css_page = $this->alias_id($ary_css_var) . '/';
            }
        }
        //
        $tv = array('ADI' => $core->v('address') . 'container/images/a_' . ($this->css_parent($tree) ? $this->css_var($tree) : $tree['tree_id']) . '/', 'V_TREE' => $tree['tree_id'], 'V_CSS' => $s_css_page, 'V_SUBJECT' => $tree['tree_subject']);
        $this->as_vars($tv);
        //
        if ($tree['tree_alias'] != 'home') {
            if ($node['tree_id'] != $parent['tree_id']) {
                $this->navigation($node['tree_subject'], $this->alias_id($node));
            }
            if ($tree['tree_level'] > 2) {
                if ($parent['tree_id'] && $node['tree_id'] && $tree['tree_level'] > 3) {
                    $this->navigation('...');
                }
                $this->navigation($subparent['tree_subject'], $this->alias_id($subparent));
            }
            if ($parent['tree_id']) {
                $this->navigation($parent['tree_subject'], $this->alias_id($parent));
            }
            $this->navigation($tree['tree_subject'], $this->alias_id($tree));
        }
        //$tree['tree_subject'] = strip_tags($tree['tree_subject']);
        //
        $this->template = 'default.form';
        if (!empty($tree['tree_template']) && @file_exists('./style/pages/form.' . $tree['tree_template'] . '.htm')) {
            $this->template = 'pages/form.' . $tree['tree_template'];
        }
        return;
    }
Beispiel #13
0
	function get_errors()
	{
		return error_list($this->error, '$');
	}