Exemplo n.º 1
0
 public function edit($option_name = NULL)
 {
     if (empty($option_name)) {
         flashmsg('You must specify an option to edit.', 'error');
         redirect('/editor/options');
     }
     $option_name = $this->data['option_name'] = $option_name;
     $option_value = $this->data['option_value'] = $this->settings->get_setting($option_name);
     $this->form_validation->set_rules('option_value', 'Option Value', 'required|trim|xss_clean');
     if ($this->form_validation->run() === TRUE) {
         // The settings library returns false if nothing is actually being updated
         // so avoid it by checking to see if the value is different or not
         if ($option_value == $this->input->post('option_value')) {
             flashmsg('Option edited successfully.', 'success');
             redirect('/editor/options');
         }
         $edit_setting = $this->settings->edit_setting($option_name, $this->input->post('option_value'));
         if ($edit_setting === TRUE) {
             flashmsg('Option edited successfully.', 'success');
             redirect('/editor/options');
         } else {
             flashmsg('There was an error while trying to update the option.', 'error');
         }
     }
     $this->data['meta_title'] = 'Edit Option';
 }
Exemplo n.º 2
0
 public function comment($id = NULL)
 {
     $settings = $this->data['settings'] = $this->settings->get_settings();
     $user = $this->data['user'] = $this->ion_auth->get_user(user_id());
     $project = $this->data['project'] = $this->core->get_project($id);
     if ($project->client != $user->id) {
         flashmsg('Project does not exist', 'error');
         redirect('client/projects');
     }
     if (isset($_POST['new_update'])) {
         // Quick and dirty - add a new update
         $this->form_validation->set_rules('title', 'Comment Title', 'required|trim|xss_clean');
         $this->form_validation->set_rules('description', 'Comment Description', 'required|trim|xss_clean');
         if ($this->form_validation->run() == TRUE) {
             $query = $this->db->query("INSERT INTO project_updates (project_id, title, description) VALUES ('{$project->id}', 'Comment by Client: {$_POST['title']}', '{$_POST['description']}')");
             if ($query) {
                 // Send Email
                 $email_data['user'] = $user->username;
                 $email_data['project_name'] = $project->name;
                 foreach ($this->core->get_admin_emails() as $email) {
                     $this->email->from($settings['company_email'], $settings['site_name']);
                     $this->email->to($email);
                     $this->email->subject('New Comment on Project');
                     $this->email->message($this->load->view('emails/project_comment', $email_data, true));
                     $this->email->send();
                 }
                 flashmsg('Project Comment added successfully to ' . $project->name . '.', 'success');
                 redirect('/client/projects/comment/' . $id);
             }
         }
     }
     $this->data['updates'] = $this->core->get_updates($id);
     $this->data['meta_title'] = 'Comment on Project';
 }
Exemplo n.º 3
0
 public function index()
 {
     $user = $this->data['user'] = $this->ion_auth->get_user(user_id());
     if (isset($_POST['update_password'])) {
         $this->form_validation->set_rules('old_password', 'Old Password', 'required');
         $this->form_validation->set_rules('new_password', 'Password', 'min_length[' . $this->config->item('min_password_length', 'ion_auth') . ']|max_length[' . $this->config->item('max_password_length', 'ion_auth') . ']|matches[new_password_confirm]|trim|xss_clean');
         $this->form_validation->set_rules('new_password_confirm', 'Password Confirmation', 'trim|xss_clean');
         if ($this->form_validation->run() === TRUE) {
             if ($this->ion_auth->change_password($user->email, $_POST['old_password'], $_POST['new_password'])) {
                 flashmsg('Your password has been updated successfully.', 'success');
                 redirect('/client/profile');
             } else {
                 flashmsg('Your password failed to be updated.', 'error');
                 redirect('/client/profile');
             }
         }
     }
     $this->form_validation->set_rules('email', 'Email', 'required|valid_email');
     if ($this->form_validation->run() === TRUE) {
         $this->ion_auth->update_user(user_id(), array('email' => $_POST['email'], 'first_name' => $_POST['first_name'], 'last_name' => $_POST['last_name'], 'company' => $_POST['company'], 'phone' => $_POST['phone'], 'address' => $_POST['address'], 'timezone' => $_POST['timezone']));
         flashmsg('Your profile has been updated successfully.', 'success');
         redirect('/client/profile');
     }
     $timezones = array('America/Phoenix', 'America/Adak', 'America/Anchorage', 'America/Anguilla', 'America/Antigua', 'America/Araguaina', 'America/Argentina/Buenos_Aires', 'America/Argentina/Catamarca', 'America/Argentina/ComodRivadavia', 'America/Argentina/Cordoba', 'America/Argentina/Jujuy', 'America/Argentina/La_Rioja', 'America/Argentina/Mendoza', 'America/Argentina/Rio_Gallegos', 'America/Argentina/Salta', 'America/Argentina/San_Juan', 'America/Argentina/San_Luis', 'America/Argentina/Tucuman', 'America/Argentina/Ushuaia', 'America/Aruba', 'America/Asuncion', 'America/Atikokan', 'America/Atka', 'America/Bahia', 'America/Bahia_Banderas', 'America/Barbados', 'America/Belem', 'America/Belize', 'America/Blanc-Sablon', 'America/Boa_Vista', 'America/Bogota', 'America/Boise', 'America/Buenos_Aires', 'America/Cambridge_Bay', 'America/Campo_Grande', 'America/Cancun', 'America/Caracas', 'America/Catamarca', 'America/Cayenne', 'America/Cayman', 'America/Chicago', 'America/Chihuahua', 'America/Coral_Harbour', 'America/Cordoba', 'America/Costa_Rica', 'America/Creston', 'America/Cuiaba', 'America/Curacao', 'America/Danmarkshavn', 'America/Dawson', 'America/Dawson_Creek', 'America/Denver', 'America/Detroit', 'America/Dominica', 'America/Edmonton', 'America/Eirunepe', 'America/El_Salvador', 'America/Ensenada', 'America/Fort_Wayne', 'America/Fortaleza', 'America/Glace_Bay', 'America/Godthab', 'America/Goose_Bay', 'America/Grand_Turk', 'America/Grenada', 'America/Guadeloupe', 'America/Guatemala', 'America/Guayaquil', 'America/Guyana', 'America/Halifax', 'America/Havana', 'America/Hermosillo', 'America/Indiana/Indianapolis', 'America/Indiana/Knox', 'America/Indiana/Marengo', 'America/Indiana/Petersburg', 'America/Indiana/Tell_City', 'America/Indiana/Vevay', 'America/Indiana/Vincennes', 'America/Indiana/Winamac', 'America/Indianapolis', 'America/Inuvik', 'America/Iqaluit', 'America/Jamaica', 'America/Jujuy', 'America/Juneau', 'America/Kentucky/Louisville', 'America/Kentucky/Monticello', 'America/Knox_IN', 'America/Kralendijk', 'America/La_Paz', 'America/Lima', 'America/Los_Angeles', 'America/Louisville', 'America/Lower_Princes', 'America/Maceio', 'America/Managua', 'America/Manaus', 'America/Marigot', 'America/Martinique', 'America/Matamoros', 'America/Mazatlan', 'America/Mendoza', 'America/Menominee', 'America/Merida', 'America/Metlakatla', 'America/Mexico_City', 'America/Miquelon', 'America/Moncton', 'America/Monterrey', 'America/Montevideo', 'America/Montreal', 'America/Montserrat', 'America/Nassau', 'America/New_York', 'America/Nipigon', 'America/Nome', 'America/Noronha', 'America/North_Dakota/Beulah', 'America/North_Dakota/Center', 'America/North_Dakota/New_Salem', 'America/Ojinaga', 'America/Panama', 'America/Pangnirtung', 'America/Paramaribo', 'America/Phoenix', 'America/Port-au-Prince', 'America/Port_of_Spain', 'America/Porto_Acre', 'America/Porto_Velho', 'America/Puerto_Rico', 'America/Rainy_River', 'America/Rankin_Inlet', 'America/Recife', 'America/Regina', 'America/Resolute', 'America/Rio_Branco', 'America/Rosario', 'America/Santa_Isabel', 'America/Santarem', 'America/Santiago', 'America/Santo_Domingo', 'America/Sao_Paulo', 'America/Scoresbysund', 'America/Shiprock', 'America/Sitka', 'America/St_Barthelemy', 'America/St_Johns', 'America/St_Kitts', 'America/St_Lucia', 'America/St_Thomas', 'America/St_Vincent', 'America/Swift_Current', 'America/Tegucigalpa', 'America/Thule', 'America/Thunder_Bay', 'America/Tijuana', 'America/Toronto', 'America/Tortola', 'America/Vancouver', 'America/Virgin', 'America/Whitehorse', 'America/Winnipeg', 'America/Yakutat', 'America/Yellowknife');
     $this->data['timezones'] = array_combine($timezones, $timezones);
     $this->data['meta_title'] = 'Your Profile';
 }
Exemplo n.º 4
0
 function _check_permissions()
 {
     if (!$this->ion_auth->is_admin()) {
         flashmsg('You do not have the correct permissions to view that.', 'error');
         redirect('auth/login');
     }
 }
Exemplo n.º 5
0
function admin_auth_check()
{
    if (!is_admin()) {
        flashmsg('You must be admin to access this', 'error');
        redirect('auth/login');
    }
}
 static function connect()
 {
     if (empty($_SESSION['db-connect'])) {
         return;
     }
     $conn =& $GLOBALS['config']['db-connect'][$_SESSION['db-connect']];
     if (empty($conn)) {
         return;
     }
     # Close the previous connection
     @mysql_close();
     # Attempt to connect
     $purl = parse_url($conn);
     $l = mysql_connect($purl['host'] . ':' . $purl['port'], $purl['user'], $purl['pass'], true);
     $ok = $l !== FALSE;
     if ($ok) {
         $ok = (bool) mysql_select_db(trim($purl['path'], '/'), $l);
     }
     if ($ok) {
         $ok = (bool) mysql_query('SET NAMES "' . MYSQL_CODEPAGE . '" COLLATE "' . MYSQL_COLLATE . '";', $l);
     }
     if (!$ok) {
         flashmsg('err', 'Citadel Connect: ":conn" failed! Error: ":error". Using the default connection instead', array(':conn' => $conn, ':error' => mysql_error($l)));
         mysql_close($l);
         connectToDb();
         return;
     }
     # Warn
     flashmsg('info', 'Citadel Connect: Using ":db"', array(':db' => $_SESSION['db-connect']));
 }
Exemplo n.º 7
0
 public function index()
 {
     if (isset($_POST['run_cron'])) {
         $output = shell_exec('crontab -l');
         file_put_contents('tmp/crontab.txt', $output . '0 */24 * * * php -q index.php cron generate_recurring_invoices' . PHP_EOL);
         echo exec('crontab tmp/crontab.txt');
         flashmsg('Cron has been ran successfully.', 'success');
     }
     $this->data['monthly_income'] = $this->core->get_monthly_income(date('m'));
     $this->data['meta_title'] = 'Admin Dashboard';
 }
Exemplo n.º 8
0
 public function index()
 {
     if (isset($_POST['update_gateway'])) {
         if ($this->core->update_gateway(strtolower($_POST['gateway']), $_POST)) {
             flashmsg($_POST['gateway'] . ' gateway settings have been updated successfully.', 'success');
             redirect('/admin/gateways');
         } else {
             flashmsg('Payment gateway failed to be updated, try again.', 'error');
             redirect('/admin/gateways');
         }
     }
     $this->data['gateways'] = $this->core->get_gateways();
     $this->data['meta_title'] = 'Manage Gateways';
 }
Exemplo n.º 9
0
 /**
  * Check the group of the current user and make sure
  * they have access to the controller being requested
  */
 private function _check_permissions()
 {
     $this->load->library('user_agent');
     $this->load->model('group_model', 'group');
     if (logged_in()) {
         $user = $this->ion_auth->get_user();
         $user_group = $user->group;
     } else {
         $user_group = 'guest';
     }
     $permissions = json_decode($this->group->get_by('name', $user_group)->permissions);
     if (!isset($permissions->{$this->router->class})) {
         flashmsg('You do not have the correct permissions to view that.', 'error');
         if ($this->agent->is_referral()) {
             redirect($this->agent->referrer());
         } else {
             redirect(base_url());
         }
     }
 }
Exemplo n.º 10
0
 public function delete($id = NULL)
 {
     $group = $this->data['group'] = $this->group->get($id);
     if (empty($id) || empty($group)) {
         flashmsg('You must specify a group to delete.', 'error');
         redirect('editor/groups');
     }
     $this->form_validation->set_rules('confirm', 'Confirmation', 'required');
     $this->form_validation->set_rules('id', 'Group ID', 'required|is_natural');
     if ($this->form_validation->run() === TRUE) {
         // Do we really want to deactivate?
         if ($this->input->post('confirm') == 'yes') {
             if ($this->group->update($id, array('deleted' => 1))) {
                 flashmsg('Group deleted successfully.', 'success');
                 redirect('editor/groups');
             } else {
                 flashmsg('There was an error while trying to delete the group.', 'error');
             }
         } else {
             redirect('editor/groups');
         }
     }
     $this->data['meta_title'] = 'Delete Group';
 }
Exemplo n.º 11
0
 function deactivate($id = NULL)
 {
     $user = $this->data['user'] = $this->ion_auth->get_user($id);
     if (empty($id) || empty($user)) {
         flashmsg('You must specify a user to deactivate.', 'error');
         redirect('/admin/clients');
     }
     $this->form_validation->set_rules('confirm', 'confirmation', 'required');
     $this->form_validation->set_rules('id', 'user ID', 'required|is_natural');
     if ($this->form_validation->run() === TRUE) {
         // Do we really want to deactivate?
         if ($this->input->post('confirm') == 'yes') {
             // Do we have a valid request?
             if ($this->_valid_csrf_nonce() === FALSE || $id != $this->input->post('id')) {
                 show_404();
             }
             // Do we have the right userlevel?
             if ($this->ion_auth->logged_in() && $this->ion_auth->is_admin()) {
                 $this->ion_auth->deactivate($id);
             }
             // Redirect them back to the admin page
             flashmsg('User deactivated successfully.', 'success');
             redirect('/admin/clients');
         } else {
             redirect('/admin/clients');
         }
     }
     // Insert csrf check
     $this->data['csrf'] = $this->_get_csrf_nonce();
     $this->data['meta_title'] = 'Deactivate User';
 }
Exemplo n.º 12
0
 public function pay($id = NULL)
 {
     if ($id == NULL) {
         flashmsg('You must select an invoice to make a payment', 'error');
         redirect('client/invoices');
     }
     $user = $this->data['user'] = $this->ion_auth->get_user(user_id());
     $gateways = $this->data['gateways'] = $this->core->get_gateways();
     $invoice = $this->data['invoice'] = $this->core->get_invoice($id);
     $settings = $this->data['settings'] = $this->settings->get_settings();
     if ($invoice->client_id != $user->id) {
         flashmsg('Invoice does not exist', 'error');
         redirect('client/invoices');
     }
     if (isset($_POST['submit'])) {
         if (!isset($_POST['gateway'])) {
             flashmsg('You must select a gateway to make a payment with', 'error');
             redirect('client/invoices/pay/' . $id);
         }
         if ($_POST['gateway'] == 'paypal') {
             if (intval(str_replace('$', '', $_POST['amount'])) > intval(str_replace('$', '', $invoice->amount_due))) {
                 flashmsg('You cannot make a payment for more than the amount due', 'error');
                 redirect('client/invoices/pay/' . $id);
             }
             $this->paypal_lib->add_field('business', $gateways['paypal']->login);
             $this->paypal_lib->add_field('return', site_url('client/invoices/success/paypal'));
             $this->paypal_lib->add_field('cancel_return', site_url('client/invoices/cancel/paypal'));
             $this->paypal_lib->add_field('notify_url', site_url('client/invoices/ipn/paypal'));
             $this->paypal_lib->add_field('item_name', $invoice->invoice_description);
             $this->paypal_lib->add_field('item_number', $invoice->invoice_id);
             $this->paypal_lib->add_field('amount', $_POST['amount']);
             $this->paypal_lib->button('Continue & Pay!');
             $this->data['paypal_form'] = $this->paypal_lib->paypal_form('paypal_form');
         } else {
             if ($_POST['gateway'] == 'stripe') {
                 require_once APPPATH . 'libraries/Stripe.php';
                 /* Testing config only, you can use your own if you want
                 				$config['stripe_key_test_public'] = 'pk_OyHpP2uvEQIInEC6ghAvIg9dexjne';
                 				$config['stripe_key_test_secret'] = 'xuRKxPH0GLEU6VwEeqI5L3VFiayQiiiA';
                 			*/
                 $config['stripe_key_live_public'] = $gateways['stripe']->auth2;
                 $config['stripe_key_live_secret'] = $gateways['stripe']->auth1;
                 $config['stripe_verify_ssl'] = true;
                 // this needs to be ran in an ssl environment
                 $config['stripe_test_mode'] = false;
                 // if you want to test the gateway, set true or false
                 $stripe = new Stripe($config);
                 if (isset($_POST['stripe_charge'])) {
                     $charge = $stripe->charge_card(intval(str_replace('$', '', $_POST['amount'])) * 100, array('number' => $_POST['number'], 'exp_month' => $_POST['exp_month'], 'exp_year' => $_POST['exp_year'], 'cvc' => $_POST['cvc'], 'name' => $user->first_name . ' ' . $user->last_name), $invoice->invoice_description);
                     $result = json_decode($charge);
                     if (!$result->error) {
                         $this->core->make_stripe_payment($invoice, $result, $_POST['amount']);
                         $pay_data['user'] = $user->username;
                         $pay_data['payment_amount'] = $_POST['amount'];
                         $pay_data['invoice_id'] = $invoice->invoice_id;
                         foreach ($this->core->get_admin_emails() as $email) {
                             $this->email->from($settings['company_email'], $settings['site_name']);
                             $this->email->to($email);
                             $this->email->subject('New Payment!');
                             $this->email->message($this->load->view('emails/new_payment', $pay_data, true));
                             $this->email->send();
                         }
                         flashmsg('Your payment of <b>' . $_POST['amount'] . '</b> to invoice #' . $invoice->invoice_id . ' has been successfully processed via Stripe', 'success');
                         redirect('client/invoices');
                     } else {
                         flashmsg($result->error->message, 'error');
                         redirect('client/invoices/pay/' . $id);
                     }
                 } else {
                     $this->data['stripe_form'] = true;
                 }
             }
         }
     }
     $this->data['meta_title'] = 'Make Payment on Invoice #' . $this->data['invoice']->invoice_id;
 }
Exemplo n.º 13
0
 function activate($id, $code = FALSE)
 {
     if ($code !== FALSE) {
         $activation = $this->ion_auth->activate($id, $code);
     } else {
         if ($this->ion_auth->is_admin()) {
             // An admin can activate a user without a code
             $activation = $this->ion_auth->activate($id);
         }
     }
     if ($activation) {
         // Redirect them to the auth page
         flashmsg($this->ion_auth->messages(), 'success');
         if ($this->ion_auth->is_admin()) {
             redirect('admin/users');
         } else {
             redirect('auth');
         }
     } else {
         // Redirect them to the forgot password page
         flashmsg($this->ion_auth->errors(), 'error');
         if ($this->ion_auth->is_admin()) {
             redirect('admin/users');
         } else {
             redirect('admin/users/forgot_password');
         }
     }
 }
Exemplo n.º 14
0
 public function open($id = NULL)
 {
     if (empty($id)) {
         flashmsg('You must specify a ticket to re-open.', 'error');
         redirect('/admin/tickets');
     }
     $ticket = $this->data['ticket'] = $this->core->get_ticket($id);
     $this->form_validation->set_rules('confirm', 'confirmation', 'required');
     $this->form_validation->set_rules('id', 'ticket ID', 'required|is_natural');
     if ($this->form_validation->run() === TRUE) {
         // Do we really want to deactivate?
         if ($this->input->post('confirm') == 'yes') {
             $this->core->open_ticket($ticket->code);
             flashmsg('Ticket re-opened successfully.', 'success');
             redirect('/admin/tickets');
         } else {
             redirect('/admin/tickets');
         }
     }
     $this->data['meta_title'] = 'Re-Open Ticket #' . $this->data['ticket']->code;
 }
    /** Bundle update event handler
     * Creates/updates the injection file and the script
     * @param int|null $bid Bundle Id
     * @param int|null $iid Inject Id (additional lookup)
     */
    protected function _updateBundle($bid = null, $iid = null)
    {
        # Fetch the bundle info
        $q_bundle = $this->db->query('SELECT `b`.`bid`, `b`.`one_iid`, `b`.`exec`
			 FROM `botnet_webinjects_bundle` `b`
			    LEFT JOIN `botnet_webinjects_bundle_members` `bm` USING(`bid`)
			 WHERE
			    (:bid IS NULL OR `b`.`bid`=:bid) AND
			    (:iid IS NULL OR `bm`.`iid`=:iid OR `b`.`one_iid`=:iid)
			 ;', array(':bid' => $bid, ':iid' => $iid));
        while ($bundle = $q_bundle->fetchObject()) {
            $bundle->exec = unserialize($bundle->exec);
            # Get the injects: either from BundleMap or One_iid
            $q_injects = $this->db->query('SELECT
				    `i`.`iid`,
				    `i`.`name`,
				    `i`.`inject`
				 FROM `botnet_webinjects` `i`
				    CROSS JOIN (
				        `botnet_webinjects_bundle` `b`
				        LEFT JOIN `botnet_webinjects_bundle_members` `bm` USING(`bid`)
				    ) ON(`i`.`iid` = `b`.`one_iid` OR `i`.`iid` = `bm`.`iid`)
				 WHERE
				    `b`.`bid` = :bid AND
				    `i`.`state` = "on" AND
				    `bm`.`enabled` = 1
				 ;', array(':bid' => $bundle->bid));
            # Generate the bundle merged file
            $bundle_fname = $bundle->bid . '.txt';
            $bundle_fpath = self::WEBINJECTS_PATH . '/' . $bundle_fname;
            $bundle_f = @fopen($bundle_fpath, 'w');
            if (!$bundle_f) {
                flashmsg('err', LNG_FLASHMSG_WRITE_FAILED, array(':name' => $bundle_fpath));
                return;
            }
            while ($inj = $q_injects->fetchObject()) {
                fwrite($bundle_f, "\r\n\r\n\r\n; INJECT #{$inj->iid}: {$inj->name}\r\n\r\n{$inj->inject}\r\n");
            }
            fclose($bundle_f);
            # Create the script-like entry in `botnet_webinjects_bundle_execlim`
            $this->db->query('DELETE FROM `botnet_webinjects_bundle_execlim` WHERE `bid`=:bid;', array(':bid' => $bundle->bid));
            $d_ins = (object) array('bid' => $bundle->bid, 'name' => null, 'val' => null);
            $q_ins = $this->db->prepare('INSERT INTO `botnet_webinjects_bundle_execlim` SET `bid`=:bid, `name`=:name, `val`=:val');
            $q_ins->bindParam(':bid', $d_ins->bid, PDO::PARAM_INT);
            $q_ins->bindParam(':name', $d_ins->name, PDO::PARAM_STR);
            $q_ins->bindParam(':val', $d_ins->val, PDO::PARAM_STR);
            foreach (array('botnets' => 'botnet', 'botids' => 'botid', 'countries' => 'country') as $k => $name) {
                if (empty($bundle->exec[$k])) {
                    $d_ins->name = $name;
                    $d_ins->val = null;
                    $q_ins->execute();
                } else {
                    foreach ($bundle->exec[$k] as $val) {
                        $d_ins->name = $name;
                        $d_ins->val = $val;
                        $q_ins->execute();
                    }
                }
            }
            # Update the bundle mtime
            $this->db->query('UPDATE `botnet_webinjects_bundle` SET `mtime`=:now WHERE `bid`=:bid;', array(':now' => time(), ':bid' => $bundle->bid));
        }
    }
Exemplo n.º 16
0
 public function aptitudes($action = NULL, $id = NULL)
 {
     $this->view = 'editor/characters/aptitudes/index';
     if ($action != NULL) {
         $this->view = 'editor/characters/aptitudes/' . $action;
     }
     if ($action == 'create') {
         $this->form_validation->set_rules('name', 'Name', 'required|trim|xss_clean');
         $this->form_validation->set_rules('description', 'Description', 'required|trim|xss_clean');
         $this->form_validation->set_rules('damage', 'Damage', 'required|trim|xss_clean');
         $this->form_validation->set_rules('class', 'Class', 'required|trim|xss_clean');
         $this->form_validation->set_rules('zodiac', 'Zodiac', 'required|trim|xss_clean');
         $this->form_validation->set_rules('race', 'Race', 'required|trim|xss_clean');
         $this->form_validation->set_rules('level', 'Level', 'required|trim|xss_clean');
         if ($this->form_validation->run() == TRUE && $this->aptitudes->insert(array('name' => $this->input->post('name'), 'description' => $this->input->post('description'), 'damage' => $this->input->post('damage'), 'class' => $this->input->post('class'), 'zodiac' => $this->input->post('zodiac'), 'race' => $this->input->post('race'), 'level' => $this->input->post('level'), 'attributes' => $this->_parse_attributes($_POST)))) {
             // Creating the aptitude was successful, redirect them back to the admin page
             flashmsg('Ability created successfully.', 'success');
             redirect('/editor/characters/aptitudes');
         }
     } else {
         if ($action == 'edit') {
             $aptitude = $this->data['aptitude'] = $this->aptitudes->get($id);
             if (empty($id) || empty($aptitude)) {
                 flashmsg('You must specify a aptitude to edit.', 'error');
                 redirect('/editor/characters/aptitudes');
             }
             $this->form_validation->set_rules('name', 'Name', 'required|trim|xss_clean');
             $this->form_validation->set_rules('description', 'Description', 'required|trim|xss_clean');
             $this->form_validation->set_rules('damage', 'Damage', 'required|trim|xss_clean');
             $this->form_validation->set_rules('class', 'Class', 'required|trim|xss_clean');
             $this->form_validation->set_rules('zodiac', 'Zodiac', 'required|trim|xss_clean');
             $this->form_validation->set_rules('race', 'Race', 'required|trim|xss_clean');
             $this->form_validation->set_rules('level', 'Level', 'required|trim|xss_clean');
             if ($this->form_validation->run() == TRUE && $this->aptitudes->update($id, array('name' => $this->input->post('name'), 'description' => $this->input->post('description'), 'damage' => $this->input->post('damage'), 'class' => $this->input->post('class'), 'zodiac' => $this->input->post('zodiac'), 'race' => $this->input->post('race'), 'level' => $this->input->post('level'), 'attributes' => $this->_parse_attributes($_POST)))) {
                 // Editing the aptitude was successful, redirect them back to the admin page
                 flashmsg('Ability has been updated successfully.', 'success');
                 redirect('/editor/characters/aptitudes');
             }
         } else {
             if ($action == 'delete') {
                 $aptitude = $this->data['aptitude'] = $this->aptitudes->get($id);
                 if (empty($id) || empty($aptitude)) {
                     flashmsg('You must specify a aptitude to delete.', 'error');
                     redirect('/editor/characters/aptitudes');
                 }
                 $this->form_validation->set_rules('confirm', 'confirmation', 'required');
                 $this->form_validation->set_rules('id', 'aptitude ID', 'required|is_natural');
                 if ($this->form_validation->run() === TRUE) {
                     // Do we really want to delete?
                     if ($this->input->post('confirm') == 'yes') {
                         // Do we have a valid request?
                         if ($this->_valid_csrf_nonce() === FALSE || $id != $this->input->post('id')) {
                             show_404();
                         }
                         // Do we have the right userlevel?
                         if ($this->ion_auth->logged_in() && $this->ion_auth->is_admin()) {
                             $this->aptitudes->delete($id);
                         }
                         // Redirect them back to the admin page
                         flashmsg('Ability deleted successfully.', 'success');
                         redirect('/editor/characters/aptitudes');
                     } else {
                         redirect('/editor/characters/aptitudes');
                     }
                 }
                 $this->data['csrf'] = $this->_get_csrf_nonce();
             }
         }
     }
     $all_classes = $this->classes->get_all();
     $classes = array('*' => 'Any');
     foreach ($all_classes as $class) {
         $classes[$class->id] = $class->name;
     }
     $this->data['classes'] = $classes;
     $all_zodiacs = $this->zodiacs->get_all();
     $zodiacs = array('*' => 'Any');
     foreach ($all_zodiacs as $zodiac) {
         $zodiacs[$zodiac->id] = $zodiac->name;
     }
     $this->data['zodiacs'] = $zodiacs;
     $all_races = $this->races->get_all();
     $races = array('*' => 'Any');
     foreach ($all_races as $race) {
         $races[$race->id] = $race->name;
     }
     $this->data['races'] = $races;
     $this->data['attributes'] = $this->attributes->get_all();
     $this->data['aptitudes'] = $this->aptitudes->get_all();
     $this->data['meta_title'] = 'Character Aptitudes';
 }
Exemplo n.º 17
0
 public function create()
 {
     if (isset($_POST['new_invoice'])) {
         $this->form_validation->set_rules('client', 'Client', 'required');
         $this->form_validation->set_rules('project_id', 'Project', 'required');
         $this->form_validation->set_rules('id', 'Invoice ID', 'required|trim|xss_clean|integer');
         $this->form_validation->set_rules('description', 'Invoice Description', 'required|trim|xss_clean');
         $this->form_validation->set_rules('amount_paid', 'Amount Paid', 'trim|xss_clean|decimal');
         if (isset($_POST['recurring'])) {
             if (intval($_POST['recurring'])) {
                 $this->form_validation->set_rules('recur_length', 'Recur Length', 'trim|xss_clean|less_than[31]|max_length[2]|is_natural_no_zero|required');
             }
         }
         if (isset($_POST['custom_date'])) {
             if (intval($_POST['custom_date'])) {
                 $this->form_validation->set_rules('date', 'Date', 'required|callback_is_valid_date');
             }
         }
         if ($this->form_validation->run() == TRUE) {
             $gen = $this->core->generate_invoice($_POST);
             if ($gen) {
                 $project = $this->core->get_project($_POST['project_id']);
                 $settings = $this->data['settings'] = $this->settings->get_settings();
                 $client = $this->ion_auth->get_user($project->client);
                 // Send Email
                 $email_data['project_name'] = $project->name;
                 $email_data['invoice_amount'] = $this->core->calculate_total($this->core->parse_invoice_items_to_array($_POST));
                 $this->email->from($settings['company_email'], $settings['site_name']);
                 $this->email->to($client->email);
                 $this->email->subject('New Invoice Billed To You');
                 $this->email->message($this->load->view('emails/new_invoice', $email_data, true));
                 $this->email->send();
                 flashmsg('Invoice created successfully.', 'success');
                 redirect('/admin/invoices');
             }
         }
     }
     $all_clients = $this->core->get_clients();
     $clients = array('' => 'Select one');
     foreach ($all_clients as $client) {
         $clients[$client->id] = $client->first_name . ' ' . $client->last_name;
     }
     $this->data['clients'] = $clients;
     $this->data['meta_title'] = 'Create new Invoice';
 }