Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

file 399 lines (345 sloc) 11.824 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399
<?php
/**
* simplify the task of processing form fields, redirecting to the pages.
*
* The Form class is meant to simplify the task of keeping
* track of errors in user submitted forms and the form
* field values that were entered correctly.
*
* PHP version 5
* LICENSE: This source file is subject to LGPL license
* that is available through the world-wide-web at the following URI:
* http://www.gnu.org/copyleft/lesser.html
* @author Ushahidi Team <team@ushahidi.com>
* @package Ushahidi - http://source.ushahididev.com
* @module Admin Dashboard Controller
* @copyright Ushahidi - http://www.ushahidi.com
* @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General
* Public License (LGPL)
*/
 require_once("install.php");
 require_once("form.php");
  
 class Process
 {
public function __construct()
{
$this->_index();
}

/**
* Call up all the processors.
*/
public function _index()
{
if(isset($_POST['basic_db_info'])) {
$this->_proc_basic_db_info();
}else if(isset($_POST['advanced_db_info'])){
$this->_proc_advanced_db_info();
}else if(isset($_POST['advanced_general_settings'])){
$this->_proc_general_settings();
}else if(isset($_POST['basic_general_settings'])){
$this->_proc_basic_general_settings();
}else if(isset($_POST['basic_admin_pass'])){
$this->_proc_basic_admin_pass();
}else if(isset($_POST['advanced_mail_server_settings'])){
$this->_proc_mail_server();
}else if(isset($_POST['advanced_map_config'])){
$this->_proc_map();
}else if(isset($_POST['advanced_admin_pass'])){
$this->_proc_advanced_admin_pass();
}else if(isset($_POST['advanced_perm_pre_check'])){
$this->_proc_advanced_pre_perm_check();
}else if(isset($_POST['basic_perm_pre_check'])){
$this->_proc_basic_pre_perm_check();
} else {
header("Location:.");
}
}

/**
* Process basic database info.
*/
public function _proc_basic_db_info()
{
global $form, $install;

$status = $install->_install_db_info(
$_POST['username'],
$_POST['password'],
$_POST['host'],
'mysql',
$_POST['db_name'],
$_POST['table_prefix'],
$_POST['base_path']
);


// No errors
if ($status == 0)
{
// Make sure users get to the basic general settings page from the basic db info page
$_SESSION['basic_general_settings'] = 'basic_db_info';

// Send the database info to the next page for updating the settings table.
$_SESSION['username'] = $_POST['username'];
$_SESSION['password'] = $_POST['password'];
$_SESSION['host'] = $_POST['host'];
$_SESSION['db_name'] = $_POST['db_name'];
$_SESSION['table_prefix'] = $_POST['table_prefix'];
header("Location:basic_general_settings.php");
}

// Errors exist
else if ($status == 1 )
{
$_SESSION['value_array'] = $_POST;
$_SESSION['error_array'] = $form->get_error_array();
header("Location:basic_db_info.php");
}

}

/**
* Process advanced database info.
*/
public function _proc_advanced_db_info(){
global $form, $install;
$status = $install->_install_db_info(
$_POST['username'],
$_POST['password'],
$_POST['host'],
'mysql',
$_POST['db_name'],
$_POST['table_prefix'],
$_POST['base_path']
);

//no errors
if( $status == 0 ) {

// Make sure users get to the advanced general settings page from the advanced db info page
$_SESSION['general_settings'] = 'advanced_db_info';

// Send the database info to the next page for updating the settings table.
$_SESSION['username'] = $_POST['username'];
$_SESSION['password'] = $_POST['password'];
$_SESSION['host'] = $_POST['host'];
$_SESSION['db_name'] = $_POST['db_name'];
$_SESSION['table_prefix'] = $_POST['table_prefix'];

header("Location:advanced_general_settings.php");

}else if($status == 1 ) {
$_SESSION['value_array'] = $_POST;
$_SESSION['error_array'] = $form->get_error_array();
header("Location:advanced_db_info.php");
}
}

/**
* Process the general settings.
*/
public function _proc_general_settings() {
global $form, $install;

$status = $install->_general_settings(
$_POST['site_name'],
$_POST['site_tagline'],
$_POST['select_language'],
$_POST['site_email'],
$_POST['table_prefix'],
$_POST['enable_clean_url']
);

//no errors
if( $status == 0 ) {
// Make sure users get to the mail settings page from the advanced general settings page
$_SESSION['mail_server'] = 'general_settings';

// set it up in case someone wants to go to the previous page.
$_SESSION['site_name'] = $_POST['site_name'];
$_SESSION['site_tagline'] = $_POST['site_tagline'];
$_SESSION['select_language'] = $_POST['select_language'];
$_SESSION['site_email'] = $_POST['site_email'];
$_SESSION['table_prefix'] = $_POST['table_prefix'];

header("Location:advanced_mail_server_settings.php");
}else if($status == 1 ) {
$_SESSION['value_array'] = $_POST;
$_SESSION['error_array'] = $form->get_error_array();

header("Location:advanced_general_settings.php");
}
}

/*
* Process the general settings.
*/
public function _proc_basic_general_settings() {
global $form, $install;

$status = $install->_general_settings(
$_POST['site_name'],
$_POST['site_tagline'],
$_POST['select_language'],
$_POST['site_email'],
$_POST['table_prefix'],
$_POST['enable_clean_url']
);

//no errors
if( $status == 0 ) {
// Make sure users get to the basic password info from the general settings page.
$_SESSION['basic_admin_pass'] = 'basic_general_settings';

// set it up in case someone want to goes the previous page.
$_SESSION['site_name'] = $_POST['site_name'];
$_SESSION['site_tagline'] = $_POST['site_tagline'];
$_SESSION['select_language'] = $_POST['select_language'];
$_SESSION['site_email'] = $_POST['site_email'];
$_SESSION['table_prefix'] = $_POST['table_prefix'];

header("Location:basic_admin_pass.php");
}else if($status == 1 ) {
$_SESSION['value_array'] = $_POST;
$_SESSION['error_array'] = $form->get_error_array();

header("Location:basic_general_settings.php");
}
}

/**
* Process the mail server.
*/
public function _proc_mail_server() {
global $form, $install;

$status = $install->_mail_server(
$_POST['site_alert_email'],
$_POST['mail_server_username'],
$_POST['mail_server_pwd'],
$_POST['mail_server_port'],
$_POST['mail_server_host'],
$_POST['select_mail_server_type'],
$_POST['select_mail_server_ssl'],
$_POST['table_prefix']
);

//no errors
if( $status == 0 ) {

// Make sure users get to the map settings page from the mail server page
$_SESSION['map_settings'] = 'mail_server';

$_SESSION['site_alert_email'] = $_POST['site_alert_email'];
$_SESSION['mail_server_username'] = $_POST['mail_server_username'];
$_SESSION['mail_server_pwd'] = $_POST['mail_server_pwd'];
$_SESSION['mail_server_port'] = $_POST['mail_server_port'];
$_SESSION['mail_server_host'] = $_POST['mail_server_host'];
$_SESSION['select_mail_server_type'] = $_POST['select_mail_server_type'];
$_SESSION['select_mail_server_ssl'] = $_POST['select_mail_server_ssl'];
$_SESSION['table_prefix'] = $_POST['table_prefix'];

header("Location:advanced_map_configuration.php");
}else if($status == 1 ) {
$_SESSION['value_array'] = $_POST;
$_SESSION['error_array'] = $form->get_error_array();
header("Location:advanced_mail_server_settings.php");
}
}

/**
* Process the map details.
*/
public function _proc_map() {
global $form, $install;

$status = $install->_map_info(
$_POST['select_map_provider'],
$_POST['map_provider_api_key'],
$_POST['table_prefix']
);

//no errors
if( $status == 0 ) {

// Make sure users get to the advanced password info page from the advanced map settings page
$_SESSION['advanced_admin_pass'] = 'map_settings';

// send the database info to the next page for updating the settings table.
$_SESSION['select_map_provider'] = $_POST['select_map_provider'];
$_SESSION['map_provider_api_key'] = $_POST['map_provider_api_key'];
$_SESSION['table_prefix'] = $_POST['table_prefix'];

header("Location:advanced_admin_pass.php");
}else if($status == 1 ) {
$_SESSION['value_array'] = $_POST;
$_SESSION['error_array'] = $form->get_error_array();
header("Location:advanced_map_configuration.php");
}
}

/**
* Process the pre permission check for basic installer mode.
*/
public function _proc_basic_pre_perm_check() {
global $install,$form;
$status = $install->_check_writable_dir();
$status += $install->_check_modules();
if($status == 0 )
{
// Make sure users get to the basic db info page from the basic summary page
$_SESSION['basic_db_info'] = 'basic_summary';
header("Location:basic_db_info.php");
}
else
{
$_SESSION['value_array'] = $_POST;
$_SESSION['error_array'] = $form->get_error_array();
header("Location:basic_summary.php");
}
}

/**
* Process the pre permission check for advanced installer mode.
* +Check for required PHP libraries
*/
public function _proc_advanced_pre_perm_check() {
global $install, $form, $modules;
$status = $install->_check_writable_dir();
$status += $install->_check_modules_advanced();
if($status == 0 ) {

// Make sure users get to the advanced db info page from the advanced summary page
$_SESSION['advanced_db_info'] = 'advanced_summary';

header("Location:advanced_db_info.php");
}else{
$_SESSION['value_array'] = $_POST;
$_SESSION['error_array'] = $form->get_error_array();
header("Location:advanced_summary.php");
}
}

/**
* Process the admin password for the basic installer mode
*
*/
public function _proc_basic_admin_pass()
{
global $install, $form;
$status = $install->_password_info(
$_POST['admin_password'],
$_POST['admin_password_again'],
$_POST['table_prefix']
);

// No errors
if ($status == 0)
{
// Make sure that we're moving from the password information page before moving to the finished page
$_SESSION['basic_finished'] = 'basic_admin_pass';

// Set this info just incase someone wants to go to the previous page from the finished page
$_SESSION['admin_password'] = $_POST['admin_password'];
$_SESSION['admin_password_again'] = $_POST['admin_password_again'];
$_SESSION['table_prefix'] = $_POST['table_prefix'];
header("Location: basic_finished.php");
}

// We have errors
else if($status ==1)
{
$_SESSION['value_array'] = $_POST;
$_SESSION['error_array'] = $form->get_error_array();
header("Location: basic_admin_pass.php");
}


}

/**
* Process password information for the advanced installer mode
*
*/
public function _proc_advanced_admin_pass()
{
global $install, $form;
$status = $install->_password_info(
$_POST['admin_password'],
$_POST['admin_password_again'],
$_POST['table_prefix']
);

// No errors
if ($status == 0)
{
// Make sure that we're moving from the password information page before moving to the finished page
$_SESSION['advanced_finished'] = 'advanced_admin_pass';

// Set this info just incase someone wants to go to the previous page from the finished page
$_SESSION['admin_password'] = $_POST['admin_password'];
$_SESSION['admin_password_again'] = $_POST['admin_password_again'];
$_SESSION['table_prefix'] = $_POST['table_prefix'];
header("Location: advanced_finished.php");
}

// We have errors
else if($status ==1)
{
$_SESSION['value_array'] = $_POST;
$_SESSION['error_array'] = $form->get_error_array();
header("Location: advanced_admin_pass.php");
}
}

 }
 $process = new Process();
?>
Something went wrong with that request. Please try again.