public static function create($chapter_num, $chapter_key) { Database::setup(); $chapter = R::dispense(Model_Chapter::$table_name); $chapter->chapter_num = $chapter_num; $chapter->chapter_key = $chapter_key; try { R::store($chapter); } catch (Exception $e) { return false; } return true; }
public static function create($phase_number = 0, $score_audio = 0, $score_text1 = 0, $score_maps = 0, $score_text2 = 0, $score_sharing = 0) { Database::setup(); $chapter_score = R::dispense(Model_ChapterScore::$table_name); $chapter_score->phase_number = $phase_number; $chapter_score->score_audio = $score_audio; $chapter_score->score_text1 = $score_text1; $chapter_score->score_maps = $score_maps; $chapter_score->score_text2 = $score_text1; $chapter_score->score_sharing = $score_sharing; try { R::store($chapter_score); } catch (Exception $e) { return false; } return true; }
{ echo $prompt; return addslashes(rtrim(fgets(STDIN), "\n")); } echo "Hello, welcome to the notes setup script\n"; $name = readValue("What is the name of the database setup from the cpanel?\n"); $user = readValue("What is the username of the database setup from the cpanel?\n"); $pass = readValue("What is the password of this username setup from the cpanel?\n"); //echo "A netid of someone who will be able to login to the site's admin panel is needed.\n"; //$netid = readValue( "The netid for that person is?\n" ); $url = readValue("What will the url for the site be?\n"); if (strpos($url, "http://") === false) { $url = "http://{$url}"; } if ($url[strlen($url) - 1] === "/") { $url .= "login.php"; } else { $url .= "/login.php"; } //For each placeholder in copyConfig.txt, replace placeholder with the actual text $str = file_get_contents("./copyConfig.php"); $replace = array("#NAME#" => $name, "#USER#" => $user, "#PASS#" => $pass, "#URL#" => $url); foreach ($replace as $key => $value) { $str = str_replace($key, $value, $str); } //put the newly generated php code for config into config.php, creating it if it does not exist file_put_contents("./config.php", $str); //Now the database can be setup require_once "./database.php"; Database::setup();
public static function deleteAll() { Database::setup(); $userBean = R::dispense(Model_User::$table_name); R::wipe($userBean); }
private function validate($array = array()) { if (count($array)) { $this->request->post = $array; } if (empty($this->request->post['db_host'])) { $errors['db_host'] = $this->config->get('LANG_ERROR_DB_HOSTNAME'); } if (empty($this->request->post['db_user'])) { $errors['db_user'] = $this->config->get('LANG_ERROR_DB_USERNAME'); } if (empty($this->request->post['db_prefix'])) { $errors['db_prefix'] = $this->config->get('LANG_ERROR_DB_PREFIX'); } if (empty($this->request->post['db_name'])) { $errors['db_database'] = $this->config->get('LANG_ERROR_DB_DBNAME'); } if (!empty($this->request->post['db_host']) && !empty($this->request->post['db_user']) && !empty($this->request->post['db_prefix']) && !empty($this->request->post['db_name'])) { try { Database::setup(array('hostname' => $this->request->post['db_host'], 'username' => $this->request->post['db_user'], 'password' => $this->request->post['db_password'], 'database' => $this->request->post['db_name'], 'prefix' => $this->request->post['db_prefix'])); } catch (\Exception $e) { $errors['db_connection'] = $e->getMessage(); } } if (empty($this->request->post['username'])) { $errors['username'] = $this->config->get('LANG_ERROR_USERNAME_EMPTY'); } else { if (in_array(strtolower($this->request->post['username']), array('admin', 'administrator', 'webmaster', 'shop', 'gebruiker', 'username', 'beheerder', 'sysadmin', 'sumo'))) { $errors['username'] = $this->config->get('LANG_ERROR_USERNAME_WEAK'); } } if (empty($this->request->post['password'])) { $errors['password'] = $this->config->get('LANG_ERROR_PASSWORD_EMPTY'); } else { if (strlen($this->request->post['password']) <= 5 || ctype_alpha($this->request->post['password']) || stristr($this->request->post['username'], $this->request->post['password'])) { $errors['password'] = $this->config->get('LANG_ERROR_PASSWORD_WEAK'); } } if (!filter_var($this->request->post['email'], FILTER_VALIDATE_EMAIL)) { $errors['email'] = $this->config->get('LANG_ERROR_EMAIL_INVALID'); } if (empty($this->request->post['category'])) { $errors['category'] = $this->config->get('LANG_ERROR_CATEGORY'); } if (empty($this->request->post['country_id'])) { $errors['country_id'] = $this->config->get('LANG_ERROR_COUNTRY'); } else { if ($this->request->post['country_id'] > 239) { $errors['country_id'] = $this->config->get('LANG_ERROR_COUNTRY'); } } if (empty($this->request->post['store_name'])) { $errors['store_name'] = $this->config->get('LANG_ERROR_NAME'); } if (empty($this->request->post['store_email']) || !filter_var($this->request->post['store_email'], FILTER_VALIDATE_EMAIL)) { $errors['store_email'] = $this->config->get('LANG_ERROR_STORE_MAIL'); } if (count($errors)) { $this->errors = $errors; return false; } return true; }
<?php require_once "{$dir}/server/config.php"; require_once "{$dir}/server/database/database.php"; // Load the database $db_filename = ''; if (preg_match('#sqlite://(.+)#', $db_path, $matches)) { list(, $db_filename) = $matches; } $db = new Database($db_path); if ($db->tables() == array()) { // Setup the initial database configuration $db->setup("{$dir}/server/init.sql"); $db->query("\n INSERT INTO user\n (username, status)\n VALUES ('shiftspace', 1)\n "); } // Set up the user session session_register('user'); $user = $_SESSION['user']; if (empty($user) && !empty($_COOKIE['auth'])) { list($username, $password) = explode(':', $_COOKIE['auth']); $user = $db->row("\n SELECT *\n FROM user\n WHERE username = '******'\n AND password = '******'\n "); if (!empty($user)) { $_SESSION['user'] = $user; } } if (!empty($_GET['v'])) { $client_version = $_GET['v']; } $server = 'http://' . $_SERVER['SERVER_NAME'] . dirname($_SERVER['PHP_SELF']) . '/'; if (get_magic_quotes_gpc()) { function strip_quotes(&$var)