Пример #1
0
 $link = @mysql_connect(arr::get(Session::instance()->get('kms-database'), 'dbhost'), arr::get(Session::instance()->get('kms-database'), 'uname'), arr::get(Session::instance()->get('kms-database'), 'pwd'));
 if (!$link) {
     KMS::stop('<strong>ERROR:</strong> Could not connect to MySQL database. Click back to verify your MySQL settings.<br /><br /><strong>MySQL Error:</strong> ' . mysql_error(), $_POST);
 }
 $db = mysql_select_db(arr::get(Session::instance()->get('kms-database'), 'dbname'), $link);
 if (!$db) {
     $error = mysql_error();
     mysql_close($link);
     KMS::stop('<strong>ERROR:</strong> Could not connect to MySQL database. Click back to verify your MySQL settings.<br /><br /><strong>MySQL Error:</strong> ' . $error, $_POST);
 }
 foreach ($db_schema as $sql) {
     $response = @mysql_query($sql, $link);
     if (!$response) {
         $error = mysql_error();
         mysql_close($link);
         KMS::stop('<strong>ERROR:</strong> Could not connect to MySQL database. Click back to verify your MySQL settings.<br /><br /><strong>MySQL Error:</strong> ' . $error);
     }
 }
 mysql_close($link);
 // add site and user data
 $site = ORM::factory('site');
 $site->domain = arr::get(Session::instance()->get('kms-config'), 'domain');
 $site->description = arr::get(Session::instance()->get('kms-config'), 'domain_description');
 $site->save();
 $site_id = $site->id;
 $user = ORM::factory('user');
 $user->username = arr::get(Session::instance()->get('kms-config'), 'admin');
 $user->password = sha1(arr::get(Session::instance()->get('kms-config'), 'admin_pwd'));
 $user->first_name = arr::get(Session::instance()->get('kms-config'), 'first_name');
 $user->last_name = arr::get(Session::instance()->get('kms-config'), 'last_name');
 $user->email = arr::get(Session::instance()->get('kms-config'), 'email');
Пример #2
0
 /**
  * Edits a site variable
  */
 public function action_variable_edit()
 {
     $id = arr::get($this->_data, 'id');
     unset($this->_data['id']);
     $this->_redirect = Route::url('kms-admin', array('action' => 'resources', 'section' => 'variables', 'id' => $id));
     $resource = KMS::instance('site')->variables->find($id);
     if (!$resource->loaded()) {
         KMS::stop('Unable to load resource');
     }
     $resource->values($this->_data);
     $this->_store = $resource->check();
     if ($this->_store) {
         try {
             $resource->save();
             $this->_message("The site variable <strong>{$resource->name}</strong> was successfully updated");
             $this->_details = "The variable `{$resource->name}` was edited";
             $this->_identifier = "site_variables.{$resource->id}";
         } catch (Exception $e) {
             $this->_message('The variable name (' . arr::get($this->_data, 'name') . ') is already in use. Please enter a unique variable name.', 'error');
             $this->_store = FALSE;
         }
     } else {
         $msg = 'ERROR: The following errors occurred:<br />';
         foreach ($resource->validate()->errors('validate') as $error) {
             $msg .= ' - ' . ucfirst($error) . '<br />';
         }
         $this->_message($msg, 'error');
     }
 }
Пример #3
0
 /**
  * No testing needed at this time
  */
 public function testStop()
 {
     //die( (string) KMS::stop('Unittesting 123', array('args'), 'KMS Error', TRUE) );
     $stopped = (string) KMS::stop('Unittesting 123', array('args'), 'KMS Error', TRUE);
     $this->assertContains('Unittesting', $stopped);
 }
Пример #4
0
 /**
  * Loads template pages
  */
 public function action_templates()
 {
     switch (Request::$current->param('section')) {
         case 'overview':
             $this->template->title = 'Site Templates';
             $template = KMS::instance('site')->templates->find_all();
             $this->template->content = View::factory('kms/template-overview', compact('template'));
             break;
         case 'add':
             $this->template->title = 'Adding Template';
             $template = array();
             if (KMS::Session()->path('ua.status') === 'failed') {
                 $template = KMS::Session()->path('ua.fields');
             }
             $this->template->content = View::factory('kms/template-add', compact('template'));
             break;
         case 'edit':
             $this->template->title = 'Editing Template';
             $template = KMS::instance('site')->templates->find(Request::$current->param('id'));
             if (!$template->loaded()) {
                 KMS::stop('The requested template was not found');
             }
             if (KMS::Session()->path('ua.status') === 'failed') {
                 $template->values(KMS::Session()->path('ua.fields'));
             }
             $template = $template->as_array();
             $this->template->content = View::factory('kms/template-edit', compact('template'));
             break;
         case 'delete':
             $template = KMS::instance('site')->templates->find(Request::$current->param('id'));
             if (!$template->loaded()) {
                 KMS::stop('The requested template was not found');
             }
             $template = $template->as_array();
             $this->template->title = 'Delete Template';
             $this->template->content = View::factory('kms/template-delete', compact('template'));
             break;
         default:
             Request::$current->redirect(Route::url('kms-admin', array('action' => 'templates', 'section' => 'overview')));
     }
 }