<?php /* * ReDonate is more free software. It is licensed under the WTFPL, which * allows you to do pretty much anything with it, without having to * ask permission. Commercial use is allowed, and no attribution is * required. We do politely request that you share your modifications * to benefit other developers, but you are under no enforced * obligation to do so :) * * Please read the accompanying LICENSE document for the full WTFPL * licensing text. */ if (!isset($_APP)) { die("Unauthorized."); } $sChangeRequest->sSubscription->uCurrency = $sChangeRequest->uNewCurrency; $sChangeRequest->sSubscription->uAmount = $sChangeRequest->uNewAmount; $sChangeRequest->sSubscription->InsertIntoDatabase(); $sChangeRequest->uIsConfirmed = true; $sChangeRequest->InsertIntoDatabase(); flash_notice("The change was successfully applied."); redirect("/manage/{$sChangeRequest->sSubscription->sEmailAddress}/{$sChangeRequest->sSubscription->sSettingsKey}");
function delete($type, $id = 0) { if (!isAjax()) { $this->output->set_output(_('You can\'t delete chapters from outside the admin panel through this link.')); log_message("error", "Controller: series.php/remove: failed serie removal"); return false; } $id = intval($id); switch ($type) { case "serie": $comic = new Comic(); $comic->where('id', $id)->get(); $title = $comic->name; if (!$comic->remove()) { flash_notice('error', sprintf(_('Failed to delete the series %s.'), $title)); log_message("error", "Controller: series.php/remove: failed serie removal"); $this->output->set_output(json_encode(array('href' => site_url("admin/series/manage")))); return false; } flash_notice('notice', 'The serie ' . $comic->name . ' has been removed'); $this->output->set_output(json_encode(array('href' => site_url("admin/series/manage")))); break; case "chapter": $chapter = new Chapter($id); $title = $chapter->chapter; if (!($comic = $chapter->remove())) { flash_notice('error', sprintf(_('Failed to delete chapter %s.'), $chapter->comic->chapter)); log_message("error", "Controller: series.php/remove: failed chapter removal"); $this->output->set_output(json_encode(array('href' => site_url("admin/series/series/" . $comic->stub)))); return false; } set_notice('notice', 'Chapter deleted.'); $this->output->set_output(json_encode(array('href' => site_url("admin/series/serie/" . $comic->stub)))); break; case "page": $page = new Page($this->input->post('id')); $page->get_chapter(); $page->chapter->get_comic(); if (!($data = $page->remove_page())) { log_message("error", "Controller: series.php/remove: failed page removal"); return false; } $this->output->set_output(json_encode(array('href' => site_url("admin/series/serie/" . $page->chapter->comic->stub . "/" . $page->chapter->id)))); break; case "allpages": $chapter = new Chapter($id); $chapter->get_comic(); if (!$chapter->remove_all_pages()) { log_message("error", "Controller: series.php/remove: failed all pages removal"); return false; } $this->output->set_output(json_encode(array('href' => site_url("admin/series/serie/" . $chapter->comic->stub . "/" . $chapter->id)))); break; } }
* ReDonate is more free software. It is licensed under the WTFPL, which * allows you to do pretty much anything with it, without having to * ask permission. Commercial use is allowed, and no attribution is * required. We do politely request that you share your modifications * to benefit other developers, but you are under no enforced * obligation to do so :) * * Please read the accompanying LICENSE document for the full WTFPL * licensing text. */ if (!isset($_APP)) { die("Unauthorized."); } if (!empty($_POST['submit'])) { if (empty($_POST['name'])) { flash_error("You did not enter a valid campaign name."); } if (count(get_errors(false)) == 0) { $sCampaign = new Campaign(0); $sCampaign->uName = $_POST['name']; $sCampaign->uOwnerId = $sCurrentUser->sId; $sCampaign->uCreationDate = time(); $sCampaign->uAllowOneTime = isset($_POST['allow_once']); $sCampaign->uUrlName = Campaign::GenerateUrlName($_POST['name']); $sCampaign->InsertIntoDatabase(); flash_notice("Your campaign was successfully created. You should add a payment method now."); redirect("/dashboard/{$sCampaign->uUrlName}"); } } $sPageTitle = "Create new campaign"; $sPageContents = NewTemplater::Render("campaign/create", $locale->strings, array());
if ($sCampaign->VerifyAdministratorAccess($_SESSION['user_id']) === false) { throw new RouterException("Not authorized to administrate this campaign."); } if (!empty($_POST['submit'])) { if (empty($_POST['address'])) { flash_error("You did not enter a valid address or account ID."); } if (!isset($_POST['method']) || $_POST['method'] == "") { flash_error("You did not select a valid payment method."); } elseif ($_POST['method'] == "0" && empty($_POST['customname'])) { flash_error("You did not enter a valid name for the payment method."); } elseif (PaymentMethod::CheckIfValidMethod($_POST['method']) === false) { flash_error("You did not select a valid payment method."); } elseif (PaymentMethod::ValidateAddress($_POST['method'], $_POST['address']) === false) { flash_error("The address you entered is invalid."); } if (count(get_errors(false)) == 0) { $sPaymentMethod = new PaymentMethod(0); $sPaymentMethod->uType = $_POST['method']; $sPaymentMethod->uAddress = $_POST['address']; $sPaymentMethod->uCampaignId = $sCampaign->sId; if ($_POST['method'] == 0) { $sPaymentMethod->uCustomName = $_POST['customname']; } $sPaymentMethod->InsertIntoDatabase(); flash_notice("The payment method was successfully added."); redirect("/dashboard/{$sCampaign->uUrlName}"); } } $sPageTitle = "Add payment method"; $sPageContents = NewTemplater::Render("campaign/addmethod", $locale->strings, array("name" => $sCampaign->sName, "urlname" => $sCampaign->sUrlName));
/** * * @author Woxxy * @param string $url * @return bool */ function get_file($url, $direct_url) { $this->clean(); if (function_exists('curl_init')) { $zip = $this->curl->simple_post($url, array('url' => site_url(), 'version' => get_setting('fs_priv_version'))); if (!$zip) { $zip = $this->curl->simple_get($direct_url); } } else { $zip = file_get_contents($direct_url); } if (!$zip) { log_message('error', 'upgrade_model get_file(): impossible to get the update from FoOlPod'); flash_notice('error', _('Can\'t get the update file from FoOlPod. It might be a momentary problem, or a problem with your server security configuration. Browse <a href="http://foolrulez.com/pod/human">http://foolrulez.com/pod/human</a> to check if it\'s a known issue.')); return FALSE; } if (!is_dir('content/cache/upgrade')) mkdir('content/cache/upgrade'); write_file('content/cache/upgrade/upgrade.zip', $zip); $this->unzip->extract('content/cache/upgrade/upgrade.zip'); return TRUE; }
function delete($type, $id = 0) { if (!isAjax()) { echo _('You can\'t delete chapters from outside the admin panel through this link.'); log_message("error", "Controller: comics.php/remove: failed comic removal"); return false; } $id = intval($id); switch ($type) { case("comic"): $comic = new Comic(); $comic->where('id', $id)->get(); if (!$comic->remove()) { log_message("error", "Controller: comics.php/remove: failed comic removal"); return false; } flash_notice('notice', 'The comic ' . $comic->name . ' has been removed'); echo json_encode(array('href' => site_url("admin/comics/manage"))); break; case("chapter"): $chapter = new Chapter($id); if (!$comic = $chapter->remove()) { log_message("error", "Controller: comics.php/remove: failed chapter removal"); return false; } set_notice('notice', 'Chapter deleted.'); echo json_encode(array('href' => site_url("admin/comics/comic/" . $comic->stub))); break; case("page"): $page = new Page($this->input->post('id')); $page->get_chapter(); $comic = new Chapter($chapter->comic_id); if (!$data = $page->remove_page()) { log_message("error", "Controller: comics.php/remove: failed page removal"); return false; } echo json_encode(array('href' => site_url("admin/comics/comic/" . $page->chapter->comic->stub . "/" . $page->chapter->id))); break; case("allpages"): $chapter = new Chapter($id); $chapter->get_comic(); if (!$chapter->remove_all_pages()) { log_message("error", "Controller: comics.php/remove: failed all pages removal"); return false; } echo json_encode(array('href' => site_url("admin/comics/comic/" . $chapter->comic->stub . "/" . $chapter->id))); break; } }
<?php /* * ReDonate is more free software. It is licensed under the WTFPL, which * allows you to do pretty much anything with it, without having to * ask permission. Commercial use is allowed, and no attribution is * required. We do politely request that you share your modifications * to benefit other developers, but you are under no enforced * obligation to do so :) * * Please read the accompanying LICENSE document for the full WTFPL * licensing text. */ if (!isset($_APP)) { die("Unauthorized."); } if (!empty($_SESSION['user_id'])) { flash_notice('Hi! It seems you are already logged in. Did you want to go to your <a href="/dashboard">Dashboard</a>?'); } $sPageContents = NewTemplater::Render("index", $locale->strings, array());
* obligation to do so :) * * Please read the accompanying LICENSE document for the full WTFPL * licensing text. */ if (!isset($_APP)) { die("Unauthorized."); } try { $sCampaign = Campaign::CreateFromQuery("SELECT * FROM campaigns WHERE `UrlName` = :UrlName", array(":UrlName" => $router->uParameters[1]), 30, true); } catch (NotFoundException $e) { throw new RouterException("Campaign does not exist."); } if ($sCampaign->VerifyAdministratorAccess($_SESSION['user_id']) === false) { throw new RouterException("Not authorized to administrate this campaign."); } if (!empty($_POST['default_currency']) && in_array($_POST['default_currency'], array("usd", "eur", "btc"))) { $sCampaign->uDefaultCurrency = $_POST['default_currency']; } if (isset($_POST['default_amount'])) { if (preg_match("/^([0-9]*[.,][0-9]+|[0-9]+)\$/", $_POST['default_amount']) == false) { flash_error("You did not enter a valid default amount."); } else { $sCampaign->uDefaultAmount = $_POST['default_amount']; } } if (count(get_errors(false)) == 0) { $sCampaign->InsertIntoDatabase(); flash_notice("Settings successfully changed."); } redirect("/dashboard/{$sCampaign->sUrlName}");
/** * Save FF Options * * This function saves author's friendfeed nickname and remote key * * @return nothing * */ function friendfeed_comments_save_ff() { if (!empty($_POST['ff_username'])) { update_option('ff_username', $_POST['ff_username']); } if (!empty($_POST['ff_remote_key'])) { update_option('ff_remote_key', $_POST['ff_remote_key']); } update_option('ff_send_admin_comment', $_POST['ff_send_admin_comment']); flash_notice(FF_DATA_SAVED_MSG); redirect(); }
* licensing text. */ if (!isset($_APP)) { die("Unauthorized."); } if (!empty($_SESSION['user_id'])) { flash_notice("You are already logged in."); redirect("/dashboard"); } if (!empty($_POST['submit'])) { if (empty($_POST['username'])) { flash_error("You did not enter a username."); } elseif (empty($_POST['password'])) { flash_error("You did not enter a password."); } else { try { $sUser = User::CreateFromQuery("SELECT * FROM users WHERE `Username` = :Username", array(":Username" => $_POST['username']), 0, true); if ($sUser->VerifyPassword($_POST['password'])) { $sUser->Authenticate(); flash_notice("Welcome back, {$sUser->sDisplayName}!"); redirect("/dashboard"); } else { flash_error("The password you entered is incorrect. Did you <a href=\"/forgot-password\">forget your password</a>?"); } } catch (NotFoundException $e) { flash_error("That username does not exist."); } } } $sPageContents = NewTemplater::Render("login/form", $locale->strings, array()); $sPageTitle = "Login";
function tools_logs_prune() { if (!isAjax()) { show_404(); } delete_files($this->config->item('log_path')); flash_notice('success', _('Your FoOlSlide logs have been pruned.')); $this->output->set_output(json_encode(array('href' => site_url('admin/system/tools')))); }
/* * ReDonate is more free software. It is licensed under the WTFPL, which * allows you to do pretty much anything with it, without having to * ask permission. Commercial use is allowed, and no attribution is * required. We do politely request that you share your modifications * to benefit other developers, but you are under no enforced * obligation to do so :) * * Please read the accompanying LICENSE document for the full WTFPL * licensing text. */ if (!isset($_APP)) { die("Unauthorized."); } if (!empty($_SESSION['user_id'])) { flash_notice("You are already logged in."); redirect("/dashboard"); } if (!empty($_POST['submit'])) { if (empty($_POST['username']) || !preg_match("/^[a-zA-Z0-9-.]+\$/", $_POST['username'])) { flash_error("You did not enter a valid username. Your username can only contain a-z, A-Z, 0-9, dots, and dashes."); } elseif (User::CheckIfUsernameExists($_POST['username']) || User::CheckIfDisplayNameExists($_POST['username'])) { flash_error("The username you entered is already in use. Please pick a different username."); } if (empty($_POST['email']) || !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) { flash_error("You did not enter a valid e-mail address."); } elseif (User::CheckIfEmailExists($_POST['email'])) { flash_error("The e-mail address you entered is already in use. Did you <a href=\"/forgot-password\">forget your password</a>?"); } if (empty($_POST['password']) || strlen($_POST['password']) < 8) { flash_error("You did not enter a valid password. Your password has to be at least 8 characters.");
function _submit($post) { $this->load->library('form_validation'); $this->form_validation->set_rules('db_type', _('Database type'), ''); $this->form_validation->set_rules('db_hostname', _('Database hostname'), ''); $this->form_validation->set_rules('db_name', _('Database name'), ''); $this->form_validation->set_rules('db_username', _('Database username'), ''); $this->form_validation->set_rules('db_password', _('Database password'), ''); $this->form_validation->set_rules('db_prefix', _('Database prefix'), ''); $this->form_validation->set_rules('username', _('Administrator username'), 'required|min_length[4]|max_length[20]'); $this->form_validation->set_rules('password', _('Administrator password'), 'required|min_length[5]|max_length[20]'); $this->form_validation->set_rules('email', _('Administrator email'), 'required|valid_email'); if ($this->form_validation->run() == FALSE) { return false; } if (!is_writable('content') && is_writable('content/themes')) { return false; } $config["hostname"] = $post["db_hostname"]; $config["database"] = $post["db_name"]; $config["username"] = $post["db_username"]; $config["password"] = $post["db_password"]; $config["dbprefix"] = $post["db_prefix"]; $config['dbdriver'] = $post["db_type"]; $config['pconnect'] = FALSE; $config['db_debug'] = FALSE; $config['cache_on'] = FALSE; $config['cachedir'] = ""; $config['char_set'] = "utf8"; $config['dbcollat'] = "utf8_general_ci"; $this->db = $this->load->database($config, TRUE); if ($this->db->conn_id == "") { // unable to connect set_notice('error', _('Connection with database not enstabilished: check the database fields.')); return false; } $config = read_file('assets/config.sample.php'); $config = str_replace("\$db['default']['dbdriver'] = ''", "\$db['default']['dbdriver'] = '" . addslashes($post["db_type"]) . "'", $config); $config = str_replace("\$db['default']['hostname'] = 'localhost'", "\$db['default']['hostname'] = '" . addslashes($post["db_hostname"]) . "'", $config); $config = str_replace("\$db['default']['username'] = ''", "\$db['default']['username'] = '******'", $config); $config = str_replace("\$db['default']['password'] = ''", "\$db['default']['password'] = '******'", $config); $config = str_replace("\$db['default']['database'] = ''", "\$db['default']['database'] = '" . addslashes($post["db_name"]) . "'", $config); $config = str_replace("\$db['default']['dbprefix'] = 'fs_'", "\$db['default']['dbprefix'] = '" . addslashes($post["db_prefix"]) . "'", $config); $random_string = random_string(20); $this->config->set_item('encryption_key', $random_string); $config = str_replace("\$config['encryption_key'] = ''", "\$config['encryption_key'] = '" . addslashes($random_string) . "'", $config); $manual_config = FALSE; if (!write_file('config.php', $config)) { $manual_config = TRUE; } $this->load->library('migration'); $this->migration->latest(); $this->load->library('session'); $this->load->library('tank_auth'); $this->load->library('datamapper'); load_settings(); $user = $this->tank_auth->create_user($post["username"], $post["email"], $post["password"], FALSE); if ($user !== FALSE) { $profile = new Profile(); $profile->where('user_id', $user['user_id'])->get(); $profile->group_id = 1; $profile->save(); } if (!is_dir('content/ads')) mkdir('content/ads'); if (!is_dir('content/cache')) mkdir('content/cache'); if (!is_dir('content/logs')) mkdir('content/logs'); if (!is_dir('content/comics')) mkdir('content/comics'); if ($manual_config) { $this->notices = array(); $data["config"] = $config; $this->viewdata['main_content_view'] = $this->load->view("install/manual_config", $data, TRUE); $this->load->view("admin/default", $this->viewdata); return 'stop'; } flash_notice('notice', _('FoOlSlide has installed successfully. Check the preferences and make sure you create a team entry for your own chapters.')); redirect('/admin/'); }
function advertising() { $this->viewdata["function_title"] = _("Advertising"); $form = array(); $form[] = array(_('Top banner'), array('type' => 'textarea', 'name' => 'fs_ads_top_banner', 'help' => _('Insert the HTML code provided by your advertiser above.'), 'preferences' => 'fs_ads')); $form[] = array(_('Top Banner Options'), array('type' => 'checkbox', 'name' => 'fs_ads_top_options', 'value' => array(array('type' => 'checkbox', 'name' => 'fs_ads_top_banner_active', 'placeholder' => '', 'preferences' => 'fs_ads', 'text' => _('Enable')), array('name' => 'fs_ads_top_banner_reload', 'placeholder' => '', 'preferences' => 'fs_ads', 'text' => _('Reload on Every Pageview'))), 'help' => _(''))); $form[] = array(_('Bottom banner'), array('type' => 'textarea', 'name' => 'fs_ads_bottom_banner', 'help' => _('Insert the HTML code provided by your advertiser above.'), 'preferences' => 'fs_ads')); $form[] = array(_('Bottom Banner Options'), array('type' => 'checkbox', 'name' => 'fs_ads_bottom_options', 'value' => array(array('type' => 'checkbox', 'name' => 'fs_ads_bottom_banner_active', 'placeholder' => '', 'preferences' => 'fs_ads', 'text' => _('Enable')), array('name' => 'fs_ads_bottom_banner_reload', 'placeholder' => '', 'preferences' => 'fs_ads', 'text' => _('Reload on Every Pageview'))), 'help' => _(''))); if ($post = $this->input->post()) { $this->_submit($post, $form); // this code is necessary to keep the ad well centered inside iframes $ad_before = '<!DOCTYPE html> <html> <head> <title>FoOlSlide ads</title> <style>body{margin:0; padding:0; overflow:hidden;}</style> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> </head> <body>'; $ad_after = '</body> </html>'; // available ads $ads = array('fs_ads_top_banner' => 'ads_top.html', 'fs_ads_bottom_banner' => 'ads_bottom.html'); // write an HTML file, so calling it will use less processor power than calling the database via Codeigniter // this recreates the files every time one saves foreach ($ads as $ad => $adfile) { if (!write_file('./content/ads/' . $adfile, $ad_before . $this->input->post($ad) . $ad_after)) { log_message('error', 'preferences.php/advertising: couldn\'t update HTML files'); flash_notice('error', _('Couldn\'t save the advertising code in the HTML')); } } redirect('admin/preferences/advertising'); } // create the form $table = tabler($form, FALSE); $data['form_title'] = _('Advertising'); $data['table'] = $table; // print out $this->viewdata["main_content_view"] = $this->load->view("admin/preferences/general.php", $data, TRUE); $this->load->view("admin/default.php", $this->viewdata); }
function remove_mod($user_id) { if (!isAjax()) { return false; } if (!$this->tank_auth->is_admin()) return false; $profile = new Profile(); if ($profile->change_group($user_id, 0)) { flash_notice('notice', _('You have removed the user from the moderators group.')); echo json_encode(array('href' => site_url('/admin/members/member/' . $user_id))); return true; } return false; }
* ask permission. Commercial use is allowed, and no attribution is * required. We do politely request that you share your modifications * to benefit other developers, but you are under no enforced * obligation to do so :) * * Please read the accompanying LICENSE document for the full WTFPL * licensing text. */ if (!isset($_APP)) { die("Unauthorized."); } try { $sCampaign = Campaign::CreateFromQuery("SELECT * FROM campaigns WHERE `UrlName` = :UrlName", array(":UrlName" => $router->uParameters[1]), 30, true); } catch (NotFoundException $e) { throw new RouterException("Campaign does not exist."); } if ($sCampaign->VerifyAdministratorAccess($_SESSION['user_id']) === false) { throw new RouterException("Not authorized to administrate this campaign."); } try { $sPaymentMethod = new PaymentMethod($router->uParameters[2]); } catch (NotFoundException $e) { throw new RouterException("Payment method does not exist."); } if ($sPaymentMethod->sCampaignId !== $sCampaign->sId) { throw new RouterException("Payment method does not belong to campaign."); } /* TODO: Implement object deletion in CPHP */ $database->CachedQuery("DELETE FROM payment_methods WHERE `Id` = :Id", array(":Id" => $sPaymentMethod->sId)); flash_notice("The payment method was successfully removed."); redirect("/dashboard/{$sCampaign->sUrlName}");
/* * ReDonate is more free software. It is licensed under the WTFPL, which * allows you to do pretty much anything with it, without having to * ask permission. Commercial use is allowed, and no attribution is * required. We do politely request that you share your modifications * to benefit other developers, but you are under no enforced * obligation to do so :) * * Please read the accompanying LICENSE document for the full WTFPL * licensing text. */ if (!isset($_APP)) { die("Unauthorized."); } if (!empty($_POST['submit'])) { if (empty($_POST['currency'])) { flash_error("Please select a valid currency."); } if (empty($_POST['amount']) || preg_match("([0-9]*[.,][0-9]+|[0-9]+)", $_POST['amount']) == false) { flash_error("Please enter a valid amount."); } if (count(get_errors(false)) == 0) { $sSubscription->uAmount = str_replace(",", ".", $_POST['amount']); $sSubscription->uCurrency = $_POST['currency']; $sSubscription->InsertIntoDatabase(); flash_notice("The monthly pledge amount for this subscription was successfully updated."); redirect("/manage/{$sSubscription->sEmailAddress}/{$sSubscription->sSettingsKey}"); } } $sPageTitle = "Change pledge amount"; $sPageContents = NewTemplater::Render("subscription/change_amount", $locale->strings, array("email" => $sSubscription->sEmailAddress, "key" => $sSubscription->sSettingsKey));
/* * ReDonate is more free software. It is licensed under the WTFPL, which * allows you to do pretty much anything with it, without having to * ask permission. Commercial use is allowed, and no attribution is * required. We do politely request that you share your modifications * to benefit other developers, but you are under no enforced * obligation to do so :) * * Please read the accompanying LICENSE document for the full WTFPL * licensing text. */ if (!isset($_APP)) { die("Unauthorized."); } if (!empty($_POST['submit'])) { $sSubscription->uIsActive = false; $sSubscription->InsertIntoDatabase(); $sLogEntry = new LogEntry(0); $sLogEntry->uType = LogEntry::UNSUBSCRIPTION; $sLogEntry->uIp = $_SERVER['REMOTE_ADDR']; $sLogEntry->uData = json_encode(array("email" => $sSubscription->sEmailAddress)); $sLogEntry->uCampaignId = $sSubscription->sCampaign->sId; $sLogEntry->uDate = time(); $sLogEntry->uSessionId = session_id(); $sLogEntry->InsertIntoDatabase(); flash_notice("We've unsubscribed you."); redirect("/manage/{$sSubscription->sEmailAddress}/{$sSubscription->sSettingsKey}"); } $sPageTitle = "Change pledge amount"; $sPageContents = NewTemplater::Render("subscription/unsubscribe", $locale->strings, array("email" => $sSubscription->sEmailAddress, "key" => $sSubscription->sSettingsKey, "name" => $sSubscription->sCampaign->sName));
function logoff() { $_SESSION['user'] = null; flash_notice('You have been logged out.'); check_authentication(); }
function _submit($post) { // validate the inputted data with the validation class $this->load->library('form_validation'); $this->form_validation->set_rules('db_type', _('Database type'), ''); $this->form_validation->set_rules('db_hostname', _('Database hostname'), ''); $this->form_validation->set_rules('db_name', _('Database name'), ''); $this->form_validation->set_rules('db_username', _('Database username'), ''); $this->form_validation->set_rules('db_password', _('Database password'), ''); $this->form_validation->set_rules('db_prefix', _('Database prefix'), ''); $this->form_validation->set_rules('username', _('Administrator username'), 'required|min_length[4]|max_length[20]'); $this->form_validation->set_rules('password', _('Administrator password'), 'required|min_length[5]|max_length[20]'); $this->form_validation->set_rules('email', _('Administrator email'), 'required|valid_email'); if ($this->form_validation->run() == FALSE) { return false; } if (!is_writable('content') && is_writable('content/themes')) { return false; } // we need to check database connection, and to do that we need to connect in first place $config["hostname"] = $post["db_hostname"]; $config["database"] = $post["db_name"]; $config["username"] = $post["db_username"]; $config["password"] = $post["db_password"]; $config["dbprefix"] = $post["db_prefix"]; $config['dbdriver'] = $post["db_type"]; $config['pconnect'] = FALSE; $config['db_debug'] = FALSE; $config['cache_on'] = FALSE; $config['cachedir'] = ""; $config['char_set'] = "utf8"; $config['dbcollat'] = "utf8_general_ci"; // load the co $this->db = $this->load->database($config, TRUE); // without conn_id we're not connected to the database if ($this->db->conn_id == "") { // unable to connect set_notice('error', _('Connection with database not enstabilished: check the database fields.')); return false; } // pick the sample config and replace entries so we can insert the database $config = read_file('assets/config.sample.php'); $config = str_replace("\$db['default']['dbdriver'] = ''", "\$db['default']['dbdriver'] = '" . addslashes($post["db_type"]) . "'", $config); $config = str_replace("\$db['default']['hostname'] = 'localhost'", "\$db['default']['hostname'] = '" . addslashes($post["db_hostname"]) . "'", $config); $config = str_replace("\$db['default']['username'] = ''", "\$db['default']['username'] = '******'", $config); $config = str_replace("\$db['default']['password'] = ''", "\$db['default']['password'] = '******'", $config); $config = str_replace("\$db['default']['database'] = ''", "\$db['default']['database'] = '" . addslashes($post["db_name"]) . "'", $config); $config = str_replace("\$db['default']['dbprefix'] = 'fs_'", "\$db['default']['dbprefix'] = '" . addslashes($post["db_prefix"]) . "'", $config); // create a random string of 20 letters and numbers for the encryption key $random_string = random_string(20); $this->config->set_item('encryption_key', $random_string); $config = str_replace("\$config['encryption_key'] = ''", "\$config['encryption_key'] = '" . addslashes($random_string) . "'", $config); // check if a manual config file must be made manually (due to no permissions on FoOlSlide root) $manual_config = FALSE; if (!write_file('config.php', $config)) { $manual_config = TRUE; } // load the necessary libraries // migrate to latest database $this->load->library('migration'); $this->migration->latest(); // load everything needed for a normal startup $this->load->library('session'); $this->load->library('tank_auth'); $this->load->library('datamapper'); // load the settings from the now filled database load_settings(); $user = $this->tank_auth->create_user($post["username"], $post["email"], $post["password"], FALSE); if ($user !== FALSE) { $profile = new Profile(); $profile->where('user_id', $user['user_id'])->get(); $profile->group_id = 1; $profile->save(); } // create the generic dirs that you can find in content folder if (!is_dir('content/ads')) { mkdir('content/ads'); } if (!is_dir('content/cache')) { mkdir('content/cache'); } if (!is_dir('content/logs')) { mkdir('content/logs'); } if (!is_dir('content/comics')) { mkdir('content/comics'); } // if install can't make that config.php file, tell the user to do it manually if ($manual_config) { $this->notices = array(); $data["config"] = $config; $this->viewdata['main_content_view'] = $this->load->view("install/manual_config", $data, TRUE); $this->load->view("install/default", $this->viewdata); return 'stop'; } // a nice notice to tell that FoOlSlide install was a success flash_notice('notice', _('FoOlSlide has installed successfully. Check the preferences and make sure you create a team for your own chapters.')); redirect('/admin/'); }
<?php /* * ReDonate is more free software. It is licensed under the WTFPL, which * allows you to do pretty much anything with it, without having to * ask permission. Commercial use is allowed, and no attribution is * required. We do politely request that you share your modifications * to benefit other developers, but you are under no enforced * obligation to do so :) * * Please read the accompanying LICENSE document for the full WTFPL * licensing text. */ if (!isset($_APP)) { die("Unauthorized."); } try { $sCampaign = Campaign::FindByUrlName($router->uParameters[1]); } catch (NotFoundException $e) { /* TODO: 404 via RouterException */ throw new RouterException("No such campaign."); } flash_notice("Thank you for your contribution!"); redirect("/campaign/{$sCampaign->sUrlName}");