Example #1
0
 public function sign_up()
 {
     $cellphone = $this->input->post('username') ? $this->input->post('username') : '0';
     // pr(var_dump($this->validate_username($cellphone)));
     $this->form_validation->set_rules('email', $this->lang->line('create_user_validation_email_label'), 'required|valid_email|is_unique[' . 'users' . '.email]');
     $this->form_validation->set_rules('username', $this->lang->line('create_user_validation_phone_label'), 'is_unique[' . 'users' . '.username]');
     $this->form_validation->set_rules('company', $this->lang->line('create_user_validation_company_label'), 'required');
     $this->form_validation->set_rules('password', $this->lang->line('create_user_validation_password_label'), 'required|min_length[' . $this->config->item('min_password_length', 'ion_auth') . ']|max_length[' . $this->config->item('max_password_length', 'ion_auth') . ']|matches[password_confirm]');
     $this->form_validation->set_rules('password_confirm', $this->lang->line('create_user_validation_password_confirm_label'), 'required');
     if ($this->form_validation->run() == true) {
         $username = $this->input->post('username');
         $password = $this->input->post('password');
         $email = strtolower($this->input->post('email'));
         $additional_data = array('company' => $this->input->post('company'), 'phone' => $this->input->post('username'));
         $group = array('1');
         // Sets user to admin. No need for array('1', '2') as user is always set to member by default
         $user_id = $this->ion_auth->register($username, $password, $email, $additional_data, $group);
         set_flash('Thank you ! you have just registered at Smart Tailor .give phone / password to login');
         if ($user_id > 0) {
             $comp_data = array('id' => $user_id, 'name' => $this->input->post('company'), 'phone' => $this->input->post('username'), 'email' => $email);
             $this->registerdb->adding_default_records($comp_data);
             redirect('auth', 'refresh');
         } else {
             pr('error while registring new username');
         }
     } else {
         $this->data['message'] = validation_errors() ? validation_errors() : ($this->ion_auth->errors() ? $this->ion_auth->errors() : $this->session->flashdata('message'));
         $this->render_page();
     }
 }
Example #2
0
function redirect($url, $flash_message = NULL)
{
    if ($flash_message) {
        set_flash($flash_message);
    }
    header("Location: {$url}");
    exit;
}
 public function export_challenges()
 {
     global $init;
     require_once PATH_CORE . '/classes/research.class.php';
     $rObj = new research();
     $str = $rObj->exportChallenges();
     set_flash(array('notice' => $str));
     redirect(url_for($this->name, 'index'));
 }
 public function syncallocations()
 {
     global $init;
     require_once PATH_CORE . '/classes/cron.class.php';
     $cObj = new cron($init['apiKey']);
     $cObj->forceJob('facebookAllocations');
     echo 'Completed';
     set_flash(array('notice' => "Finished synching allocations"));
     redirect(url_for($this->name, 'index'));
 }
Example #5
0
 public function remove($client_id)
 {
     is_valid_id($client_id, 'client') ? '' : show_error($this->lang->line('not_valid_id'));
     $is_remove = $this->relation->remove($client_id);
     if ($is_remove) {
         set_flash($this->lang->line('db_client_removed'));
         redirect('dashboard', 'refresh');
     } else {
         set_flash($this->lang->line('db_client_remove_error'));
         redirect('dashboard', 'refresh');
     }
 }
function valid_ctrl_action($ctrl, $action)
{
    if (!$ctrl || !$action) {
        return false;
    }
    if (!file_exists(PATH_CONSOLE . '/controllers/' . strtolower($ctrl) . '_controller.php')) {
        set_flash(array('error' => 'Unknown controller or you do not have permission to access this controller.'));
        //redirect();
        return false;
    } else {
        require_once 'controllers/' . strtolower($ctrl) . '_controller.php';
    }
    return in_array($action, array_diff(get_class_methods(ucfirst($ctrl) . 'Controller'), get_class_methods('AppController')));
}
Example #7
0
 public function auth()
 {
     $user = $this->input->post("uid", true);
     $pass = $this->input->post("pwd", true);
     $user = $user ? $user : "";
     $pass = $pass ? $pass : "";
     set_flash("uid", $user);
     set_flash("pass", $pass);
     if (empty($user)) {
         set_message("error", "User Name tidak boleh kosong!!");
         redirect("login");
     }
     if (empty($pass)) {
         set_message("error", "Password tidak boleh kosong!!");
         redirect("login");
     }
     /*
     if(empty($cap)):
     	set_message("error","Isi captcha sesuai dengan gambar!!");
     	redirect("login");
     endif;
     */
     /*
     $code=$_SESSION["captcha"]["code"];
     if(strtolower($code)!=strtolower($cap)):
     	set_message("error","Isi captcha sesuai dengan gambar!!");
     	redirect("login");
     endif;
     */
     //$password = $this->ion_auth_model->hash_password($this->input->post('pwd'));
     $ret = $this->lauth->login($user, b64encode($pass));
     // $ret=$this->login_model->check_login($user,$pass);
     if ($ret) {
         // echo "asd";exit;
         session_regenerate_id();
         $userSess = $_SESSION[$this->lauth->appname]["userdata"]["user"];
         // pre($userSess);exit;
         //$_SESSION[$this->lauth->appname]["groupdata"]=$this->conn->GetRow("select * from b_tb_group where idx=".$_SESSION[$this->lauth->appname]["userdata"]["user"]["group_id"]);
         //$_SESSION[$this->lauth->appname]["leveldata"]=$this->conn->GetRow("select * from tb_user_level where kd_level=".$userSess["user_level_id"]);
     }
     if (!$this->lauth->logged_in()) {
         redirect("login");
     } else {
         redirect("admin/dashboard");
     }
 }
Example #8
0
 /**
  * The user registration form will be processed by this action.
  */
 public function action_create()
 {
     $data = \Input::post('user');
     /**
      * $data is an array of required user properties, eg.
      * - username
      * - password
      * - email
      */
     try {
         $user = new \Model_User($data);
         $user->save();
         $user->send_confirmation_instructions();
     } catch (\Orm\ValidationFailed $ex) {
         \Session::set_flash('error', $ex->getMessage());
         \Response::redirect('/signup');
     } catch (Exception $ex) {
         Session:
         set_flash('Oops, something went wrong.');
     }
 }
Example #9
0
 function admin_crontab()
 {
     $module['picture'] = "administration/iconAttendance.gif";
     $module['name'] = __("Crontab");
     $module['description'] = __("Manage all yours jobs");
     //if (from() !== "administration.controller.php") {
     $this->javascript = array("jquery.1.3.2.js");
     if ($_SERVER['REQUEST_METHOD'] == "POST") {
         if (!empty($_POST['crontab']['command'])) {
             $regexp = $this->buildRegexp();
             $ligne = $_POST['crontab']['minute'] . " " . $_POST['crontab']['hour'] . " " . $_POST['crontab']['dayofmonth'] . " " . $_POST['crontab']['month'] . " " . $_POST['crontab']['dayofweek'] . " " . $_POST['crontab']['command'];
             if (preg_match("/{$regexp}/", $ligne)) {
                 set_flash("success", "Added", "This tasks has beend added in the crontab");
                 $this->add($_POST['crontab']['minute'], $_POST['crontab']['hour'], $_POST['crontab']['dayofmonth'], $_POST['crontab']['month'], $_POST['crontab']['dayofweek'], $_POST['crontab']['command'], "commentaire =)");
                 header("location: " . $_SERVER['REQUEST_URI']);
                 die;
             } else {
                 set_flash("error", "Error", "This crontab is not valid : " . $ligne);
                 $ret = array();
                 foreach ($_POST['crontab'] as $var => $val) {
                     $ret[] = "crontab:" . $var . ":" . $val;
                 }
                 $param = implode("/", $ret);
                 header("location: " . LINK . __CLASS__ . "/" . __FUNCTION__ . "/" . $param);
                 die;
             }
         }
         if (!empty($_POST['crontab']['delete'])) {
             set_flash("success", "Removed", "This task has been removed");
             $this->delete($_POST['crontab']['delete']);
         }
     }
     //$this->layout_name = "admin";
     $this->title = __("Crontab");
     $this->ariane = "> <a href=\"" . LINK . "administration/\">" . __("Administration") . "</a> > " . $this->title;
     $data = $this->view();
     $this->set("data", $data);
     //}
     return $module;
 }
Example #10
0
 public function logs()
 {
     $db = $this->di['db']->sql(DB_DEFAULT);
     // update param for the daemon
     if ($_SERVER['REQUEST_METHOD'] == "POST") {
         if (!empty($_POST['daemon_main']['refresh_time']) && !empty($_POST['daemon_main']['thread_concurency']) && !empty($_POST['daemon_main']['max_delay'])) {
             $table = [];
             $table['daemon_main'] = $_POST['daemon_main'];
             $table['daemon_main']['id'] = 1;
             $gg = $db->sql_save($table);
             if (!$gg) {
                 set_flash("error", "Error", "Impossible to update the params of Daemon");
             } else {
                 set_flash("success", "Success", "The params of Daemon has been updated");
             }
             header("location: " . LINK . "Server/listing/logs");
         }
     }
     $this->di['js']->code_javascript("var objDiv = document.getElementById('data_log'); objDiv.scrollTop = objDiv.scrollHeight;");
     $sql = "SELECT * FROM `daemon_main` WHERE id =1";
     $res = $db->sql_query($sql);
     $ob = $db->sql_fetch_object($res);
     $data['log_file'] = $ob->log_file;
     $data['log'] = __("Log file doens't exist yet !");
     if (file_exists($ob->log_file)) {
         $data['log'] = file_get_contents($ob->log_file);
     }
     $_GET['daemon_main']['thread_concurency'] = $ob->thread_concurency;
     $data['thread'] = array();
     for ($i = 1; $i <= 128; $i++) {
         $tmp = [];
         $tmp['id'] = $i;
         $tmp['libelle'] = $i;
         $data['thread_concurency'][] = $tmp;
     }
     $_GET['daemon_main']['refresh_time'] = $ob->refresh_time;
     $data['thread'] = array();
     for ($i = 1; $i <= 60; $i++) {
         $tmp = [];
         $tmp['id'] = $i;
         $tmp['libelle'] = $i;
         $data['refresh_time'][] = $tmp;
     }
     $_GET['daemon_main']['max_delay'] = $ob->max_delay;
     $data['thread'] = array();
     for ($i = 1; $i <= 60; $i++) {
         $tmp = [];
         $tmp['id'] = $i;
         $tmp['libelle'] = $i;
         $data['max_delay'][] = $tmp;
     }
     //$data[''] = ;
     $this->set('data', $data);
 }
Example #11
0
 function stop($param)
 {
     $id_cleaner = $param[0];
     $db = $this->di['db']->sql(DB_DEFAULT);
     $this->view = false;
     $this->layout_name = false;
     $sql = "SELECT * FROM cleaner_main where id ='" . $id_cleaner . "'";
     $res = $db->sql_query($sql);
     if ($db->sql_num_rows($res) !== 1) {
         $msg = I18n::getTranslation(__("Impossible to find the cleaner with the id : ") . "'" . $id_cleaner . "'");
         $title = I18n::getTranslation(__("Error"));
         set_flash("error", $title, $msg);
         header("location: " . LINK . "cleaner/index");
         exit;
     }
     $ob = $db->sql_fetch_object($res);
     if ($this->isRunning($ob->pid)) {
         $msg = I18n::getTranslation(__("The cleaner with pid : '" . $ob->pid . "' successfully stopped "));
         $title = I18n::getTranslation(__("Success"));
         set_flash("success", $title, $msg);
         $cmd = "kill " . $ob->pid;
         shell_exec($cmd);
         shell_exec("echo '[" . date("Y-m-d H:i:s") . "] CLEANER STOPED !' >> " . $ob->log_file);
     } else {
         $msg = I18n::getTranslation(__("Impossible to find the cleaner with the pid : ") . "'" . $ob->pid . "'");
         $title = I18n::getTranslation(__("Cleaner was already stopped or in error"));
         set_flash("caution", $title, $msg);
     }
     sleep(1);
     if (!$this->isRunning($ob->pid)) {
         $sql = "UPDATE cleaner_main SET pid ='0' WHERE id = '" . $id_cleaner . "'";
         $db->sql_query($sql);
     } else {
         throw new Exception('PMACTRL-875 : Impossible to stop cleaner with pid : "' . $ob->pid . '"');
     }
     header("location: " . LINK . "cleaner/index");
 }
Example #12
0
    function mailbox($param)
    {
        $this->layout_name = "admin";
        $this->data['options'] = array("all_mails", "inbox", "sent_mail", "trash", "compose", "msg");
        $this->data['display'] = array("All mails", "Inbox", "Sent mail", "Trash", "Compose", "Message");
        $this->data['request'] = $param[0];
        $this->data['send_to'] = $param;
        $db = $this->di['db']->sql(DB_DEFAULT);
        $user = $this->di['auth']->getUser();
        if (!in_array($param[0], $this->data['options'])) {
            exit;
        }
        $sql = "SELECT * FROM user_main a\r\n\t\tINNER JOIN geolocalisation_country b ON a.id_geolocalisation_country = b.id\r\n\t\tINNER JOIN geolocalisation_city c ON a.id_geolocalisation_city = c.id\r\n\t\t\r\nwhere a.id ='" . $db->sql_real_escape_string($user->id) . "'";
        $res = $db->sql_query($sql);
        $dfgwdfwdf = $db->sql_to_array($res);
        $this->data['user'] = $dfgwdfwdf[0];
        $i = 0;
        foreach ($this->data['options'] as $line) {
            if ($line === $this->data['request']) {
                $this->title = __($this->data['display'][$i]);
                $this->ariane = "> <a href=\"" . LINK . "user/\">" . __("Members") . "</a> > " . '<a href="' . LINK . 'user/profil/' . $user->id . '">' . $user->firstname . ' ' . $user->name . '</a>' . ' > ';
                $this->data['request'] != "all_mails" ? $this->ariane .= '<a href="' . LINK . 'user/mailbox/all_mails">' . __('Mailbox') . '</a>' : ($this->ariane .= __('Mailbox'));
                $this->data['request'] != "all_mails" ? $this->ariane .= ' > ' . $this->title : "";
                break;
            }
            $i++;
        }
        switch ($this->data['request']) {
            case "compose":
                if ($_SERVER['REQUEST_METHOD'] == "POST") {
                    if (!empty($_POST['mailbox_main']['id_user_main__to'])) {
                        $data = array();
                        $data['mailbox_main'] = $_POST['mailbox_main'];
                        $data['mailbox_main']['date'] = date('c');
                        $data['mailbox_main']['id_user_main__box'] = $user->id;
                        $data['mailbox_main']['id_user_main__from'] = $user->id;
                        $data['mailbox_main']['id_mailbox_etat'] = 2;
                        $data['mailbox_main']['id_history_etat'] = 1;
                        if ($db->sql_save($data)) {
                            $data['mailbox_main']['id_user_main__box'] = $_POST['mailbox_main']['id_user_main__to'];
                            if ($db->sql_save($data)) {
                                //send mail
                                I18n::SetDefault("en");
                                I18n::load("en");
                                $sql = "SELECT * FROM user_main WHERE id=" . $user->id;
                                $res = $db->sql_query($sql);
                                $ob = $db->sql_fetch_object($res);
                                $sql = "SELECT * FROM user_main WHERE id=" . $_POST['mailbox_main']['id_user_main__to'];
                                $res = $db->sql_query($sql);
                                $ob2 = $db->sql_fetch_object($res);
                                //send mail here
                                $subject = "[" . SITE_NAME . "] " . html_entity_decode($data['mailbox_main']['title'], ENT_COMPAT, 'UTF-8');
                                $msg = __('Hello') . ' ' . $ob2->firstname . ' ' . $ob2->name . ',<br />' . '<br /><br />' . '<a href="' . 'http://' . $_SERVER['SERVER_NAME'] . '/en/' . 'user/profil/inbox/' . $user->id . '">' . $ob->firstname . ' ' . $ob->name . '</a> sent you a message on Estrildidae.net.' . '<br /><br />' . '<b>Objet : ' . $data['mailbox_main']['title'] . '</b>' . '<br />' . '<b>Date : ' . date("F j, Y, H:i:s") . " CET</b>" . '<br /><br /><a href="' . 'http://' . $_SERVER['SERVER_NAME'] . '/en/' . 'user/mailbox/inbox/"><b>' . __('Click here to view the message') . '</b></a> ' . '<br /><br />' . __('You do not want to receive e-mails from Estrildidae member? Change notification settings for your account. Click here to report abuse.
Your use of Estrildidae is subject to the terms of use and privacy policy of Estrildidae! and the rules of the Estrildidae community.');
                                $headers = 'MIME-Version: 1.0' . "\r\n";
                                $headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";
                                // En-tetes additionnels
                                $headers .= 'To: ' . $ob2->firstname . ' ' . $ob2->name . ' <' . $ob2->email . '>' . "\r\n";
                                $headers .= 'From: ' . $ob->firstname . ' ' . $ob->name . ' via Estrildidae.net (no-reply)<*****@*****.**>' . "\r\n";
                                $msg = I18n::getTranslation($msg);
                                mail($ob2->email, $subject, $msg, $headers) or die("error mail");
                                //end mail
                                I18n::SetDefault("en");
                                $msg = I18n::getTranslation(__("Your message has been sent."));
                                $title = I18n::getTranslation(__("Success"));
                                set_flash("success", $title, $msg);
                                header("location: " . LINK . "user/mailbox/inbox/");
                                exit;
                            } else {
                                die("Problem insertion boite 2");
                            }
                        } else {
                            die("Problem insertion boite 1");
                        }
                    }
                }
                $this->javascript = array("jquery.1.3.2.js", "jquery.autocomplete.min.js");
                $this->di['js']->code_javascript[] = '$("#mailbox_main-id_user_main__to-auto").autocomplete("' . LINK . 'user/user_main/", {
					
					mustMatch: true,
					autoFill: false,
					max: 100,
					scrollHeight: 302,
					delay:1
					});
					$("#mailbox_main-id_user_main__to-auto").result(function(event, data, formatted) {
						if (data)
							$("#mailbox_main-id_user_main__to").val(data[1]);
					});


					';
                break;
            case 'inbox':
                $sql = "SELECT a.id,a.title,a.date,id_mailbox_etat,\r\n\t\t\t\t\tb.id as to_id, b.firstname as to_firstname, b.name as to_name, x.iso as to_iso,\r\n\t\t\t\t\tc.id as from_id, c.firstname as from_firstname, c.name as from_name, y.iso as from_iso\r\n\t\t\t\t\tFROM mailbox_main a\r\n\t\t\t\t\tINNER JOIN user_main b ON a.id_user_main__to = b.id\r\n\t\t\t\t\tINNER JOIN geolocalisation_country x on b.id_geolocalisation_country = x.id\r\n\t\t\t\t\tINNER JOIN user_main c ON a.id_user_main__from = c.id\r\n\t\t\t\t\tINNER JOIN geolocalisation_country y on c.id_geolocalisation_country = y.id\r\n\t\t\t\t\t\r\n\t\t\t\t\t\tWHERE id_user_main__box = '" . $user->id . "'\r\n\t\t\t\t\t\tAND id_user_main__to = '" . $user->id . "'\r\n\t\t\t\t\t\t\tAND id_history_etat = 1\r\n\t\t\t\t\t\t\tORDER BY date DESC";
                $res = $db->sql_query($sql);
                $this->data['mail'] = $db->sql_to_array($res);
                break;
            case 'sent_mail':
                $sql = "SELECT a.id,a.title,a.date,id_mailbox_etat,\r\n\t\t\t\t\tb.id as to_id, b.firstname as to_firstname, b.name as to_name, x.iso as to_iso,\r\n\t\t\t\t\tc.id as from_id, c.firstname as from_firstname, c.name as from_name, y.iso as from_iso\r\n\t\t\t\t\tFROM mailbox_main a\r\n\t\t\t\t\tINNER JOIN user_main b ON a.id_user_main__to = b.id\r\n\t\t\t\t\tINNER JOIN geolocalisation_country x on b.id_geolocalisation_country = x.id\r\n\t\t\t\t\tINNER JOIN user_main c ON a.id_user_main__from = c.id\r\n\t\t\t\t\tINNER JOIN geolocalisation_country y on c.id_geolocalisation_country = y.id\r\n\t\t\t\t\t\tWHERE id_user_main__box = '" . $user->id . "'\r\n\t\t\t\t\t\tAND id_user_main__from = '" . $user->id . "'\r\n\t\t\t\t\t\t\tAND id_history_etat = 1\r\n\t\t\t\t\t\t\tORDER BY date DESC";
                $res = $db->sql_query($sql);
                $this->data['mail'] = $db->sql_to_array($res);
                break;
            case 'all_mails':
                $sql = "SELECT a.id,a.title,a.date,id_mailbox_etat,\r\n\t\t\t\t\tb.id as to_id, b.firstname as to_firstname, b.name as to_name, x.iso as to_iso,\r\n\t\t\t\t\tc.id as from_id, c.firstname as from_firstname, c.name as from_name, y.iso as from_iso\r\n\t\t\t\t\tFROM mailbox_main a\r\n\t\t\t\t\tINNER JOIN user_main b ON a.id_user_main__to = b.id\r\n\t\t\t\t\tINNER JOIN geolocalisation_country x on b.id_geolocalisation_country = x.id\r\n\t\t\t\t\tINNER JOIN user_main c ON a.id_user_main__from = c.id\r\n\t\t\t\t\tINNER JOIN geolocalisation_country y on c.id_geolocalisation_country = y.id\r\n\t\t\t\t\t\r\n\t\t\t\t\t\tWHERE id_user_main__box = '" . $user->id . "'\r\n\t\t\t\t\t\t\tAND id_history_etat = 1\r\n\t\t\t\t\t\t\tORDER BY date DESC";
                $res = $db->sql_query($sql);
                $this->data['mail'] = $db->sql_to_array($res);
                break;
            case 'trash':
                $sql = "SELECT a.id,a.title,a.date,id_mailbox_etat,\r\n\t\t\t\t\tb.id as to_id, b.firstname as to_firstname, b.name as to_name, x.iso as to_iso,\r\n\t\t\t\t\tc.id as from_id, c.firstname as from_firstname, c.name as from_name, y.iso as from_iso\r\n\t\t\t\t\tFROM mailbox_main a\r\n\t\t\t\t\tINNER JOIN user_main b ON a.id_user_main__to = b.id\r\n\t\t\t\t\tINNER JOIN geolocalisation_country x on b.id_geolocalisation_country = x.id\r\n\t\t\t\t\tINNER JOIN user_main c ON a.id_user_main__from = c.id\r\n\t\t\t\t\tINNER JOIN geolocalisation_country y on c.id_geolocalisation_country = y.id\r\n\t\t\t\t\t\tWHERE id_user_main__box = '" . $user->id . "'\r\n\t\t\t\t\t\t\tAND id_history_etat = 3\r\n\t\t\t\t\t\t\tORDER BY date DESC";
                $res = $db->sql_query($sql);
                $this->data['mail'] = $db->sql_to_array($res);
                break;
            case 'msg':
                $sql = "SELECT a.id,a.title,a.date,a.text as msg,id_mailbox_etat,id_user_main__from,id_user_main__to,\r\n\t\t\t\t\tb.id as to_id, b.firstname as to_firstname, b.name as to_name, x.iso as to_iso,\r\n\t\t\t\t\tc.id as from_id, c.firstname as from_firstname, c.name as from_name, y.iso as from_iso\r\n\t\t\t\t\tFROM mailbox_main a\r\n\t\t\t\t\tINNER JOIN user_main b ON a.id_user_main__to = b.id\r\n\t\t\t\t\tINNER JOIN geolocalisation_country x on b.id_geolocalisation_country = x.id\r\n\t\t\t\t\tINNER JOIN user_main c ON a.id_user_main__from = c.id\r\n\t\t\t\t\tINNER JOIN geolocalisation_country y on c.id_geolocalisation_country = y.id\r\n\t\t\t\t\t\r\n\t\t\t\t\t\tWHERE a.id = '" . $db->sql_real_escape_string($param[1]) . "' \r\n\t\t\t\t\t\tAND id_user_main__box = '" . $user->id . "'\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\tAND id_history_etat = 1\r\n\t\t\t\t\t\t\tORDER BY date DESC";
                $res = $db->sql_query($sql);
                $this->data['mail'] = $db->sql_to_array($res);
                if ($this->data['mail'][0]['id_mailbox_etat'] == 2 && $user->id != $this->data['mail'][0]['id_user_main__from']) {
                    $sql = "UPDATE mailbox_main SET id_mailbox_etat = 1, `read`=now()\r\n\t\t\t\t\t\tWHERE id_user_main__from = '" . $this->data['mail'][0]['id_user_main__from'] . "'\r\n\t\t\t\t\t\tAND id_user_main__to = '" . $this->data['mail'][0]['id_user_main__to'] . "'\r\n\t\t\t\t\t\tAND date = '" . $this->data['mail'][0]['date'] . "'";
                    $db->sql_query($sql);
                }
                break;
            case 'delete':
                $del = array();
                /*
                 foreach ()
                 {
                
                 }
                 $sql = "
                */
                break;
        }
        $this->set("data", $this->data);
    }
    $params = $_REQUEST;
}
if (!isset($params['id']) || !is_numeric($params['id'])) {
    $params['id'] = 0;
}
if (!isset($_REQUEST['ctrl']) || $_REQUEST['ctrl'] == '') {
    $params['ctrl'] = 'main';
}
if (!isset($_REQUEST['action']) || $_REQUEST['action'] == '') {
    $params['action'] = 'index';
}
$ctrl = $params['ctrl'];
$action = $params['action'];
$id = $params['id'];
if (check_auth($ctrl, $action) === false) {
    set_flash(array('error' => 'You are not authorized to visit that page.'));
    redirect();
}
// This will setup the appropriate db class for you group/admin
$db = init_db($ctrl, $action);
/* LOAD POD SETTINGS */
$podid = isset($_REQUEST['pod']) ? $_REQUEST['pod'] : false;
$view = isset($_REQUEST['view']) ? $_REQUEST['view'] : false;
$pod_action = isset($_REQUEST['pod_action']) ? $_REQUEST['pod_action'] : 'index';
if ($podid && !is_numeric($podid) && preg_match('/^pod([0-9]+)$/', $podid, $match)) {
    $podid = $match[1];
}
if ($podid) {
    $podData = $poddb->get_pod($podid);
    $pod = load_pod($podData);
    if ($pod_action == 'load_item') {
Example #14
0
            if (!$acl->isAllowed($auth->getAccess(), $_SYSTEM['controller'] . "/" . $_SYSTEM['action'])) {
                if ($auth->getAccess() == 1) {
                    $url = ROUTE_LOGIN;
                    $msg = $_SYSTEM['controller'] . "/" . $_SYSTEM['action'] . "<br />" . __("You have to be registered to acces to this page");
                } else {
                    //die("here");
                    $url = ROUTE_DEFAULT;
                    $msg = $_SYSTEM['controller'] . "/" . $_SYSTEM['action'] . "<br />" . __("Your rank to this website is not enough to acess to this page");
                }
                set_flash("error", __("Acess denied"), __("Acess denied") . " : " . $msg);
                header("location: " . LINK . $url);
                exit;
            }
        }
    } else {
        set_flash("error", __("Error 404"), __("Page not found") . " : " . __("Sorry, the page you requested : \"" . $_SYSTEM['controller'] . "/" . $_SYSTEM['action'] . "\"is not on this server. Please contact us if you have questions or concerns"));
        header("location: " . LINK . "Error/_404");
        exit;
    }
}
DEBUG ? $_DEBUG->save("ACL loaded") : "";
//demarre l'application
FactoryController::rootNode($_SYSTEM['controller'], $_SYSTEM['action'], $_SYSTEM['param']);
$i = 10;
DEBUG ? $_DEBUG->save("Layout loaded") : "";
if (DEBUG && !IS_CLI && !IS_AJAX) {
    //ENVIRONEMENT
    $execution_time = microtime(true) - TIME_START;
    echo "<hr />";
    echo "Temps d'exéution de la page : " . round($execution_time, 5) . " seconds";
    echo "<br />Nombre de requette : " . $_DB->sql(DB_DEFAULT)->get_count_query();
 public function approve_completed_challenge()
 {
     // slight hack, since this now handles rejection as well
     if (isset($_POST['completed_challenge']['id']) && preg_match('/^[0-9]+$/', $_POST['completed_challenge']['id'])) {
         $id = $_POST['completed_challenge']['id'];
     } else {
         set_flash(array('error' => "Invalid {$group} -- {$action} -- id: {$id}."));
         redirect(url_for('street_team', 'completed_challenges'));
     }
     if ($_POST['reject']) {
         /*
         					 * 
         					//$_POST['completed_challenge[status]']='rejected'; // set status to rejected
         					// update to set comment text
         					if (($result = $this->db->update($_POST['completed_challenge'])) == 1) 
         					{
         */
         // grrr russell
         require_once PATH_CORE . '/classes/challenges.class.php';
         $cct = new ChallengeCompletedTable();
         $cc = $cct->getRowObject();
         if ($cc->load($id)) {
             $cc->status = 'rejected';
             $cc->update();
             set_flash(array('notice' => "Challenge submission {$id} rejected."));
             redirect(url_for('street_team', 'view_completed_challenge', $id));
         } else {
             set_flash(array('error' => 'Could not update your completed_challenge! Please try again. ' . $result));
             redirect(url_for('street_team', 'modify_completed_challenge', $id));
         }
     } elseif (isset($_POST['pointsAwarded'])) {
         // update to set comment text
         if (($result = $this->db->update($_POST['completed_challenge'])) == 1) {
         } else {
             set_flash(array('error' => 'Could not update your completed_challenge! Please try again. ' . $result));
             redirect(url_for('street_team', 'modify_completed_challenge', $id));
         }
         // djm:
         require_once PATH_CORE . '/classes/challenges.class.php';
         $cct = new ChallengeCompletedTable();
         $cct->approveChallenge($id, $_POST['pointsAwarded'], &$code);
         /*
         					if (($result = $this->db->update($_POST['completed_challenge'])) == 1) 
         					{
         						set_flash(array('notice' => 'Successfully updated completed_challenge.'));
         						redirect(url_for('street_team', 'view_completed_challenge', $id));
         					} else 
         					{
         						set_flash(array('error' => 'Could not update your completed_challenge! Please try again. '.$result));
         						redirect(url_for('street_team', 'review_completed_challenge', $id));
         					}*/
         set_flash(array('notice' => $code));
         redirect(url_for('street_team', 'view_completed_challenge', $id));
     } else {
         set_flash(array('error' => 'Form data not submitted properly, please try again.'));
         redirect(url_for('street_team', 'view_completed_challenge', $id));
     }
 }
 public function insert_survey_monkey_data()
 {
     require_once PATH_CORE . '/classes/researchSurveyMonkey.class.php';
     $surveyMonkeyTable = new SurveyMonkeyTable();
     $result = $surveyMonkeyTable->loadCSV();
     if (substr($result, 0, 5) == 'ERROR') {
         set_flash(array('error' => $result));
     } else {
         set_flash(array('notice' => $result));
     }
     redirect(url_for($this->name, 'index'));
 }
Example #17
0
<?php

session_start();
include 'filters/guest_filter.php';
require 'config/dbconnect.php';
require 'includes/functions.php';
if (!empty($_GET['user']) && is_used('firstname', $_GET['user'], 'users') && !empty($_GET['token'])) {
    $firstname = $_GET['user'];
    $token = $_GET['token'];
    $q = $db->prepare('SELECT email, password FROM users WHERE firstname = ?');
    $q->execute([$firstname]);
    $data = $q->fetch(PDO::FETCH_OBJ);
    $token_verif = sha1($firstname . $data->email . $data->password);
    if ($token == $token_verif) {
        $q = $db->prepare("UPDATE users SET active = '1' WHERE firstname = ?");
        $q->execute([$firstname]);
        set_flash('Votre compte à été activé.', 'success');
        redirect('profile.php');
    } else {
        set_flash('Paramètres invalides.', 'danger');
        redirect('index.php');
    }
} else {
    redirect('index.php');
}
Example #18
0
File: Auth.php Project: glial/glial
 public function authenticate($check_post = true)
 {
     if ($_SERVER['REQUEST_METHOD'] == "POST" && $check_post) {
         if (empty($_POST[self::$_tableName][self::$_login])) {
             return false;
         }
         if (empty($_POST[self::$_tableName][self::$_passwd])) {
             return false;
         }
         if (empty($_POST[self::$_tableName][self::$_login]) || empty($_POST[self::$_tableName][self::$_passwd])) {
             return true;
         }
         $Identity = self::$_dbLink->sql_real_escape_string($_POST[self::$_tableName][self::$_login]);
         $Credential = self::$_dbLink->sql_real_escape_string($_POST[self::$_tableName][self::$_passwd]);
         $hash_password = $this->hash_password($Identity, $Credential);
         if (LDAP_CHECK) {
             if ($ldap = $this->checkLdap($Identity, $Credential)) {
                 $sql = "select * from " . self::$_tableName . " where " . self::$_login . " = '" . $Identity . "'";
                 $res = self::$_dbLink->sql_query($sql);
                 $data = array();
                 if (self::$_dbLink->sql_num_rows($res) === 1) {
                     $ob = self::$_dbLink->sql_fetch_object($res);
                     $this->_user = $ob;
                     $data[self::$_tableName]['id'] = $ob->id;
                     $data[self::$_tableName][self::$_passwd] = $hash_password;
                     $data[self::$_tableName]['date_last_login'] = date('Y-m-d H:i:s');
                     $data[self::$_tableName]['date_last_connected'] = date('Y-m-d H:i:s');
                 } elseif (self::$_dbLink->sql_num_rows($res) === 0) {
                     $data[self::$_tableName]['date_last_login'] = date('Y-m-d H:i:s');
                     $data[self::$_tableName]['date_last_connected'] = date('Y-m-d H:i:s');
                     $data[self::$_tableName][self::$_passwd] = $hash_password;
                     $data[self::$_tableName][self::$_login] = $ldap['samaccountname'][0];
                     $data[self::$_tableName]['email'] = $ldap['mail'][0];
                     $data[self::$_tableName]['name'] = strtoupper($ldap['sn'][0]);
                     $data[self::$_tableName]['firstname'] = $ldap['givenname'][0];
                     $data[self::$_tableName]['ip'] = $_SERVER["REMOTE_ADDR"];
                     $data[self::$_tableName]['date_created'] = substr($ldap['whencreated'][0], 0, 4) . "-" . substr($ldap['whencreated'][0], 4, 2) . "-" . substr($ldap['whencreated'][0], 6, 2) . " " . substr($ldap['whencreated'][0], 8, 2) . ":" . substr($ldap['whencreated'][0], 10, 2) . ":" . substr($ldap['whencreated'][0], 12, 2);
                     $data[self::$_tableName]['id_group'] = 2;
                     $data[self::$_tableName]['is_valid'] = 0;
                 } else {
                     throw new \Exception('GLI-999 : Whilte list failed');
                 }
                 if (!self::$_dbLink->sql_save($data)) {
                     debug($data);
                     debug(self::$_dbLink->sql_error());
                     die;
                 }
                 $sql = "select * from " . self::$_tableName . " where " . self::$_login . " = '" . self::$_dbLink->sql_real_escape_string($ldap['samaccountname'][0]) . "'";
                 $res = self::$_dbLink->sql_query($sql);
                 $ob = self::$_dbLink->sql_fetch_object($res);
                 $this->_user = $ob;
                 $this->id_user = $ob->id;
                 setcookie(self::$_name_cookie_login, $ob->{self::$_login}, time() + AUTH_SESSION_TIME, '/', $_SERVER['SERVER_NAME'], false, true);
                 setcookie(self::$_name_cookie_passwd, $hash_password, time() + AUTH_SESSION_TIME, '/', $_SERVER['SERVER_NAME'], false, true);
                 return true;
             }
             return false;
         } else {
             $sql = "select * from " . self::$_tableName . " where " . self::$_login . " = '" . $Identity . "'";
             $res = self::$_dbLink->sql_query($sql);
             if (self::$_dbLink->sql_num_rows($res) === 1) {
                 $ob = self::$_dbLink->sql_fetch_object($res);
                 $this->id_user = $ob->id;
                 if ($hash_password === $ob->{self::$_passwd}) {
                     $this->_user = $ob;
                     setcookie(self::$_name_cookie_login, $ob->{self::$_login}, time() + AUTH_SESSION_TIME, '/', $_SERVER['SERVER_NAME'], false, true);
                     setcookie(self::$_name_cookie_passwd, $hash_password, time() + AUTH_SESSION_TIME, '/', $_SERVER['SERVER_NAME'], false, true);
                     return true;
                 }
             }
         }
     }
     if (empty($_POST[self::$_tableName][self::$_login])) {
         if (!empty($_COOKIE[self::$_name_cookie_login]) && !empty($_COOKIE[self::$_name_cookie_passwd])) {
             $sql = "select * from " . self::$_tableName . " where " . self::$_login . " = '" . self::$_dbLink->sql_real_escape_string($_COOKIE[self::$_name_cookie_login]) . "'";
             $res = self::$_dbLink->sql_query($sql);
             if (self::$_dbLink->sql_num_rows($res) === 1) {
                 $ob = self::$_dbLink->sql_fetch_object($res);
                 if ($_COOKIE[self::$_name_cookie_passwd] === $ob->{self::$_passwd}) {
                     //if (password_verify($ob->{self::$_passwd}, $_COOKIE[self::$_name_cookie_passwd]) ) {
                     $this->_user = $ob;
                     if ($ob->is_valid == 0) {
                         if ($_SERVER['REQUEST_METHOD'] === "GET") {
                             $msg = I18n::getTranslation(__("Hello,") . "<br />" . __("Thank you for registering.") . "<br />" . __("To finalise your registration, an administrator have to give you a role."));
                             $title = I18n::getTranslation(__("Restricted access"));
                             set_flash("caution", $title, $msg);
                         }
                     }
                     return true;
                 }
             }
         }
     }
     return false;
 }
Example #19
0
 public function update_kurta($kurta_id = '')
 {
     $kurta_id = isset($kurta_id) ? $kurta_id : $this->input->post('kurta_id');
     is_valid_id($kurta_id) ? '' : show_404();
     $data = $this->global_array();
     $data['heading'] = $this->lang->line('heading_kurta_update');
     $params = array('kurta_id' => $kurta_id);
     $data['client'] = $this->clientdb->get_kurta($params);
     foreach ($data['client'] as $key => $val) {
         $data['client']['kurta'][$key] = $val;
     }
     $client_id = $data['client']['kurta']['client_id'];
     unset($data['client']['kurta']['name']);
     unset($data['client']['kurta']['cellphone']);
     unset($data['client']['kurta']['city']);
     unset($data['client']['kurta']['address']);
     unset($data['client']['kurta']['id']);
     // pr($data);
     if ($this->input->post()) {
         if ($this->form_validation->run('kurta') == FALSE) {
             //failer
             $data['page'] = 'client/update_kurta2';
             $this->load->view('template', $data);
         } else {
             //successs
             $post_data = array('client_id' => $client_id, 'kurta_id' => $kurta_id, 'lambai' => $this->input->post('lambai') . " " . $this->input->post('lambai-x'), 'mora' => $this->input->post('mora') . " " . $this->input->post('mora-x'), 'shoulder' => $this->input->post('shoulder') . " " . $this->input->post('shoulder-x'), 'chatti' => $this->input->post('chatti') . " " . $this->input->post('chatti-x'), 'tera' => $this->input->post('tera') . " " . $this->input->post('tera-x'), 'collar' => $this->input->post('collar') . " " . $this->input->post('collar-x'), 'asteen' => $this->input->post('asteen') . " " . $this->input->post('asteen-x'), 'daman' => $this->input->post('daman') . " " . $this->input->post('daman-x'), 'shalwar' => $this->input->post('shalwar') . " " . $this->input->post('shalwar-x'), 'pancha' => $this->input->post('pancha') . " " . $this->input->post('pancha-x'));
             // pr($post_data);
             $res = $this->common->update($client_id, $post_data, 'kurta_pem');
             if ($res == true) {
                 set_flash("Record has been updated successfully !");
                 redirect('client');
             } else {
                 set_flash("error while updating record <span class='badge'>" . $client_id . "</span> !", 'error');
                 redirect('client');
             }
         }
     } else {
         $data['page'] = 'client/update_kurta2';
         $this->load->view('template', $data);
     }
 }
 public function create_pod()
 {
     $pod = $_POST['podform'];
     $this->db->db->selectDB('research');
     mysql_select_db('research', $this->db->db);
     $results = $this->db->query("SELECT * FROM research.Admin_DataStore WHERE type = 'model' AND name = '{$pod['model']}'");
     $model = mysql_fetch_assoc($results);
     $modeldata = json_decode($model['data'], true);
     $json = array();
     $json['header'] = $pod['header'];
     $json['body'] = $pod['body'];
     $json['footer'] = $pod['footer'];
     $json['model'] = $pod['model'];
     $json['name'] = $pod['name'];
     $json['type'] = $pod['type'];
     $json['podfile'] = $pod['podfile'];
     $json['fields'] = $modeldata['fields'];
     $sql = sprintf("INSERT INTO research.Admin_DataStore (type, name, data) VALUES (\"%s\", \"%s\", \"%s\")", 'pod', $pod['name'], mysql_real_escape_string(json_encode($json)));
     $this->db->query($sql);
     $this->skip_render = true;
     set_flash(array('notice' => 'Successfully created pod!'));
     redirect(url_for($this->name, 'index'));
     //header('Location: index.php');
 }
Example #21
0
 function index($params)
 {
     /*
      * SHOW TABLES
      * SHOW COLUMNS FROM table_name
      *
      */
     $this->layout_name = 'pmacontrol';
     $db = $this->di['db']->sql(DB_DEFAULT);
     $this->db_default = $db;
     $this->title = __("Compare");
     $this->ariane = "> " . '<a href="' . LINK . 'Plugins/index/">' . __('Plugins') . "</a> > " . $this->title;
     $redirect = false;
     if ($_SERVER['REQUEST_METHOD'] == "POST") {
         $id_server1 = empty($_POST['compare_main']['id_mysql_server__original']) ? "" : $_POST['compare_main']['id_mysql_server__original'];
         $id_server2 = empty($_POST['compare_main']['id_mysql_server__compare']) ? "" : $_POST['compare_main']['id_mysql_server__compare'];
         $db1 = empty($_POST['compare_main']['database__original']) ? "" : $_POST['compare_main']['database__original'];
         $db2 = empty($_POST['compare_main']['database__compare']) ? "" : $_POST['compare_main']['database__compare'];
         $out = $this->checkConfig($id_server1, $db1, $id_server2, $db2);
         if ($out !== true) {
             $extra = "";
             foreach ($out as $msg) {
                 $extra .= "<br />" . __($msg);
             }
             $msg = I18n::getTranslation(__("Please correct your paramaters !") . $extra);
             $title = I18n::getTranslation(__("Error"));
             set_flash("error", $title, $msg);
             $redirect = true;
         }
         header('location: ' . LINK . 'compare/index/compare_main:id_mysql_server__original:' . $id_server1 . '/compare_main:' . 'id_mysql_server__compare:' . $id_server2 . '/compare_main:' . 'database__original:' . $db1 . '/compare_main:' . 'database__compare:' . $db2);
     }
     $this->di['js']->addJavascript(array("jquery-latest.min.js", "jquery.browser.min.js", "jquery.autocomplete.min.js", "compare/index.js"));
     $sql = "SELECT * FROM mysql_server WHERE `error` = '' order by `name`";
     $servers = $db->sql_fetch_yield($sql);
     $data['server'] = [];
     foreach ($servers as $server) {
         $tmp = [];
         $tmp['id'] = $server['id'];
         $tmp['libelle'] = str_replace('_', '-', $server['name']) . " (" . $server['ip'] . ")";
         $data['server'][] = $tmp;
     }
     $data['listdb1'] = array();
     if (!empty($_GET['compare_main']['id_mysql_server__original'])) {
         $select1 = $this->getDatabaseByServer(array($_GET['compare_main']['id_mysql_server__original']));
         $data['listdb1'] = $select1['databases'];
     }
     $data['listdb2'] = array();
     if (!empty($_GET['compare_main']['id_mysql_server__compare'])) {
         $select1 = $this->getDatabaseByServer(array($_GET['compare_main']['id_mysql_server__compare']));
         $data['listdb2'] = $select1['databases'];
     }
     $data['display'] = false;
     if (count($data['listdb2']) != 0 && count($data['listdb1']) != 0) {
         if (!empty($_GET['compare_main']['database__original']) && !empty($_GET['compare_main']['database__compare'])) {
             $data['resultat'] = $this->analyse($_GET['compare_main']['id_mysql_server__original'], $_GET['compare_main']['database__original'], $_GET['compare_main']['id_mysql_server__compare'], $_GET['compare_main']['database__compare']);
             $data['display'] = true;
             //log
             $this->di['log']->warning('[Compare] ' . $_GET['compare_main']['id_mysql_server__original'] . ":" . $_GET['compare_main']['database__original'] . " vs " . $_GET['compare_main']['id_mysql_server__compare'] . ":" . $_GET['compare_main']['database__compare'] . "(" . $_SERVER["REMOTE_ADDR"] . ")");
         }
     }
     $this->set('data', $data);
 }
Example #22
0
File: login.php Project: Nynnii/syn
require 'includes/constants.php';
require 'includes/functions.php';
require 'initialization/locale.php';
//Si le formulaire de connexion a été soumis
if (isset($_POST['login'])) {
    //Si tous les champs sont remplis
    if (not_empty(['email', 'password'])) {
        extract($_POST);
        $q = $db->prepare("SELECT id, email, firstname, lastname FROM users WHERE email = :email AND password = :password AND active = '1'");
        $q->execute(['email' => $email, 'password' => sha1($password)]);
        $userHasBeenFound = $q->rowCount();
        if ($userHasBeenFound) {
            $user = $q->fetch(PDO::FETCH_OBJ);
            // On récupère les données utilisateurs
            $_SESSION['user_id'] = $user->id;
            $_SESSION['email'] = $user->email;
            $_SESSION['firstname'] = $user->firstname;
            $_SESSION['lastname'] = $user->lastname;
            redirect('profile.php?id=' . $user->id);
        } else {
            set_flash('Combinaison adresse mail, mot de passe incorrecte.', 'danger');
            save_input_data();
        }
    } else {
        clear_input_data();
    }
}
?>
	
<?php 
require "views/login.view.php";
Example #23
0
    public function add()
    {
        //df -Ph . | tail -1 | awk '{print $2}' => to know space
        $db = $this->di['db']->sql(DB_DEFAULT);
        if ($_SERVER['REQUEST_METHOD'] == "POST") {
            Crypt::$key = CRYPT_KEY;
            $storage_area['backup_storage_area'] = $_POST['backup_storage_area'];
            if (!Ssh::testAccount($storage_area['backup_storage_area']['ip'], $storage_area['backup_storage_area']['port'], $storage_area['backup_storage_area']['ssh_login'], $storage_area['backup_storage_area']['ssh_password'])) {
                foreach ($_POST['backup_storage_area'] as $var => $val) {
                    $ret[] = "backup_storage_area:" . $var . ":" . urlencode(html_entity_decode($val));
                }
                $param = implode("/", $ret);
                $title = I18n::getTranslation(__("Failed to connect on ssh/scp/sFtp"));
                $msg = I18n::getTranslation(__("Please check your hostname and you credentials !"));
                set_flash("error", $title, $msg);
                header("location: " . LINK . "backup/storageArea/add/" . $param);
                exit;
            }
            $storage_area['backup_storage_area']['ssh_login'] = Crypt::encrypt($storage_area['backup_storage_area']['ssh_login']);
            $storage_area['backup_storage_area']['ssh_password'] = Crypt::encrypt($storage_area['backup_storage_area']['ssh_password']);
            if (!($id_storage_area = $db->sql_save($storage_area))) {
                $error = $db->sql_error();
                $_SESSION['ERROR'] = $error;
                $title = I18n::getTranslation(__("Fail to add this storage area"));
                $msg = I18n::getTranslation(__("One or more problem came when you try to add this storage, please verify your informations"));
                set_flash("error", $title, $msg);
                foreach ($_POST['backup_storage_area'] as $var => $val) {
                    $ret[] = "backup_storage_area:" . $var . ":" . urlencode(html_entity_decode($val));
                }
                $param = implode("/", $ret);
                header("location: " . LINK . "backup/storageArea/add/" . $param);
                exit;
            } else {
                $this->getStorageSpace(array($id_storage_area));
                $title = I18n::getTranslation(__("Successfull"));
                $msg = I18n::getTranslation(__("You storage area has been successfull added !"));
                set_flash("success", $title, $msg);
            }
        }
        $this->di['js']->addJavascript(array("http://www.estrildidae.net/js/jquery.1.3.2.js", "jquery.autocomplete.min.js"));
        //$this->di['js']->addJavascript(array("jquery-latest.min.js", "jquery.autocomplete.min.js"));
        $this->di['js']->code_javascript('$("#backup_storage_area-id_geolocalisation_city-auto").autocomplete("' . LINK . 'user/city/ajax>yes", {
		extraParams: {
			country: function() {return $("#backup_storage_area-id_geolocalisation_country").val();}
		},
        mustMatch: true,
        autoFill: true,
        max: 100,
        scrollHeight: 302,
        delay:0
		});
		$("#backup_storage_area-id_geolocalisation_city-auto").result(function(event, data, formatted) {
			if (data)
				$("#backup_storage_area-id_geolocalisation_city").val(data[1]);
		});
		$("#backup_storage_area-id_geolocalisation_country").change( function() 
		{
			$("#backup_storage_area-id_geolocalisation_city-auto").val("");
			$("#backup_storage_area-id_geolocalisation_city").val("");
		} );

		');
        $sql = "SELECT id, libelle from geolocalisation_country where libelle != '' order by libelle asc";
        $res = $db->sql_query($sql);
        $this->data['geolocalisation_country'] = $db->sql_to_array($res);
        $this->set('data', $this->data);
    }
 private function run_update_widget_location($id, $locale)
 {
     // set widget to locale
     set_flash(array('notice' => "Assigning WidgetId:" . $id . " to locale: " . $locale . "...<br/> "));
     $q = $this->db->query("SELECT * FROM FeaturedWidgets WHERE locale='{$locale}';");
     if ($this->db->countQ($q) > 0) {
         $this->db->query("UPDATE FeaturedWidgets SET widgetid={$id} WHERE locale='{$locale}'");
         // echo "UPDATE FeaturedWidgets SET widgetid=$id WHERE locale='$locale'";
     } else {
         $this->db->query("INSERT INTO FeaturedWidgets (widgetid,locale,position) VALUES ({$id},'{$locale}',1);");
         //  echo "INSERT INTO FeaturedWidgets (widgetid,locale,position) VALUES ($id,'$locale',1);";
     }
     // clear out the cache for the story
     // require_once(PATH_CORE.'/classes/template.class.php');
     //$templateObj=new template($this->db);
     //$templateObj->resetCache('read',$siteContentId);
 }
 public function destroy_folderlink()
 {
     $id = $this->params['id'];
     if ($id === 0) {
         set_flash(array('error' => "Sorry no current folderlink for id: {$id}"));
         redirect(url_for($this->name, 'folderlinks'));
     }
     if (($result = $this->db->delete($id)) == 1) {
         set_flash(array('notice' => 'Successfully deleted folderlink.'));
         redirect(url_for('members', 'folderlinks'));
     } else {
         set_flash(array('error' => 'Could not delete folderlink. Please try again. ' . $result));
         redirect(url_for('members', 'folderlinks'));
     }
 }
Example #26
0
    $data = find_code_by_id($_GET['id']);
    if (!$data) {
        $code = "";
    } else {
        $code = $data->code;
    }
} else {
    $code = "";
}
//Si le formulaire de connexion a été soumis
if (isset($_POST['save'])) {
    if (not_empty(['code'])) {
        extract($_POST);
        $q = $db->prepare('INSERT INTO codes(code) VALUES(?)');
        $success = $q->execute([$code]);
        if ($success) {
            //Afficher le code source
            $id = $db->lastInsertId();
            redirect('show_code.php?id=' . $id);
        } else {
            set_flash("Erreur lors de l'ajout du code source.");
            redirect("share_code.php");
        }
    } else {
        redirect('share_code.php');
    }
}
?>
	
<?php 
require "views/share_code.view.php";
Example #27
0
function set_flash_ok($message)
{
    $opts['flash_type'] = 'ok';
    set_flash($message, $opts);
}
Example #28
0
File: index.php Project: Nynnii/syn
            $errors[] = "Cette adresse mail est déjà utilisée";
        }
        if (count($errors) == 0) {
            //Envoi mail d'activation
            $to = $email;
            $subject = WEBSITE_NAME . " - Activation de compte";
            $password = sha1($password);
            $token = sha1($firstname . $email . $password);
            ob_start();
            require 'templates/email/activation_mail.php';
            $content = ob_get_clean();
            $headers = 'MIME-Version: 1.0' . "\r\n";
            $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
            mail($to, $subject, $content, $headers);
            //Informer l'utilisateur pour qu'il vérifie sa boite de reception
            set_flash("Mail d'activation envoye !", 'success');
            $q = $db->prepare('INSERT INTO users(firstname, lastname, status, class, email, password) 
									VALUES(:firstname, :lastname, :status, :class, :email, :password)');
            $q->execute(['firstname' => $firstname, 'lastname' => $lastname, 'status' => $status, 'class' => $class, 'email' => $email, 'password' => $password]);
            redirect('index.php');
        } else {
            save_input_data();
        }
    } else {
        $errors[] = "Tous les champs n'ont pas été rempli.";
        save_input_data();
    }
} else {
    clear_input_data();
    //Ne pré-rempli pas le formulaire d'inscription quand un utilisateur vient d'arriver sur la page.
}
Example #29
0
require 'initialization/locale.php';
if (!empty($_GET['id'])) {
    //Dans le cas où l'utilisateur existe, on va récupérer les infos sur lui en BDD en utilisant son id
    $user = find_user_by_id($_GET['id']);
    if (!$user) {
        redirect('index.php');
    }
} else {
    redirect('modify_profile.php?id=' . get_session('user_id'));
    //Sinon, on le redirige avec le bon id
}
//Si le formulaire de connexion a été soumis
if (isset($_POST['update'])) {
    $errors = [];
    //Si tous les champs sont remplis
    if (not_empty(['firstname', 'lastname'])) {
        extract($_POST);
        $q = $db->prepare('UPDATE users 
			SET firstname = :firstname, lastname = :lastname, sex = :sex, city = :city, country = :country, github = :github, employment_status = :employment_status, description = :description 
			WHERE id = :id');
        $q->execute(['firstname' => $firstname, 'lastname' => $lastname, 'sex' => $sex, 'city' => $city, 'country' => $country, 'github' => $github, 'employment_status' => !empty($employment_status) ? '1' : '0', 'description' => $description, 'id' => get_session('user_id')]);
        set_flash("Votre profil a été mis à jour.");
        redirect('profile.php?id=' . get_session('user_id'));
    } else {
        save_input_data();
        $errors[] = "Veuillez remplir tous les champs obligatoires (*)";
    }
} else {
    clear_input_data();
}
require 'views/modify_profile.view.php';
 function render($view = false)
 {
     if (!$view) {
         $view = $this->action;
     }
     if (!$this->skip_render) {
         // Set some local view variables
         $this->set_class_vars();
         // Load helper files
         foreach ($this->helpers as $helper) {
             $file = PATH_CONSOLE . '/helpers/' . $helper . '_helper.php';
             require_once $file;
         }
         if (file_exists(PATH_CONSOLE . '/views/' . strtolower($this->name) . '/' . $view . '.php')) {
             foreach ($this->render_vars as $name => $value) {
                 ${$name} = $value;
             }
             disp_header();
             require PATH_CONSOLE . '/views/' . strtolower($this->name) . '/' . $view . '.php';
             disp_footer();
         } else {
             set_flash(array('error' => 'Action does not exist.'));
             redirect(url_for($BASE_URL));
             // $this->name
         }
     }
     // Run after filter
     $this->after_filter();
 }