function update_portfolio_event_handler($values, $action)
{
    $portfolio = load_portfolio_array();
    $existing_record = portfolio_record_lookup($portfolio, $values["lookupSymbol"]);
    switch ($action) {
        case "buy":
            if (isset($existing_record)) {
                // Update existing record in portfolio
                $existing_record["quantity"] = $existing_record["quantity"] + $values["quantity"];
                $existing_record["price_paid"] = $values["lookupAsk"];
                save_portfolio($portfolio, $existing_record, $values["lookupSymbol"]);
            } else {
                // Set new record to portfolio
                $portfolio_record = array('symbol' => $values["lookupSymbol"], 'name' => $values["lookupName"], 'quantity' => $values["quantity"], 'price_paid' => $values["lookupAsk"]);
                save_portfolio($portfolio, $portfolio_record);
            }
            set_message(AlertType::Success, "You successfuly bought " . $values["quantity"] . " " . $values["lookupName"] . " shares.");
            break;
        case "sell":
            // Update existing record in portfolio
            $existing_record["quantity"] = $existing_record["quantity"] - $values["quantity"];
            save_portfolio($portfolio, $existing_record, $values["lookupSymbol"]);
            set_message(AlertType::Success, "You successfuly sold " . $values["quantity"] . " " . $values["lookupName"] . " shares.");
            break;
    }
}
Ejemplo n.º 2
0
 function view($uuid, $extra = null)
 {
     $data = array();
     $data['scene_data'] = $this->simiangrid->get_scene($uuid);
     if ($data['scene_data'] == null) {
         $data['scene_data'] = $this->simiangrid->get_scene_by_name($uuid);
         if ($data['scene_data'] != null) {
             $uuid = $data['scene_data']['SceneID'];
         } else {
             push_message(set_message('sg_region_unknown', $uuid), 'error');
             return redirect('region');
         }
     }
     $data['uuid'] = $uuid;
     $data['tab'] = '';
     if ($extra == "stats") {
         $data['tab'] = 'stats';
     } else {
         if ($extra == "admin_actions") {
             $data['tab'] = 'admin_actions';
         }
     }
     $this->_scene_extra_info($uuid, $data);
     $data['title'] = $data['scene_data']['Name'];
     $data['page'] = 'regions';
     $x = $data['scene_data']['MinPosition']['0'] / 256;
     $y = $data['scene_data']['MinPosition']['1'] / 256;
     $data['meta'] = generate_open_graph(site_url("region/view/{$uuid}"), $this->config->item('grid_name_short') . " region " . $data['scene_data']['Name'], $this->config->item('tile_host') . "map-1-{$x}-{$y}-objects.png", "simulator");
     parse_template('region/view', $data);
 }
Ejemplo n.º 3
0
 private function modify_constants()
 {
     $res = FALSE;
     $constants = $this->constant_manager_model->get_all();
     foreach ($constants as $cons) {
         $key = $cons['constant_key'];
         //check if user has been deleted
         $delete_string = "delete_" . $key;
         $post_delete = $this->input->post($delete_string);
         if ($post_delete === "on") {
             $this->constant_manager_model->delete($key);
             $res = TRUE;
             continue;
         }
         $changed_string = "changed_" . $key;
         $post_changed = $this->input->post($changed_string);
         if ($post_changed !== "on") {
             continue;
         }
         $value_string = "value_" . $key;
         $post_value = $this->input->post($value_string);
         $value = trim($post_value);
         if ($value) {
             $this->constant_manager_model->set($key, $value);
             $res = TRUE;
         }
     }
     if ($res) {
         set_message($this->lang->line("modified_successfully"));
     }
     return redirect(get_link("admin_constant"));
 }
Ejemplo n.º 4
0
 public function delete($id, $company_id = NULL)
 {
     $company_id = $company_id ? $company_id : $this->comp_id;
     $this->db->where('id', $id);
     $this->db->where('company_id', $company_id);
     $this->db->limit(1, 0);
     $this->db->delete('products');
     return $this->db->affected_rows() > 0 ? set_message($this->lang->line('db_deleted_record')) : set_message($this->lang->line('db_delete_error'));
 }
Ejemplo n.º 5
0
 function email_detail($id)
 {
     $this->data["email"] = $this->email_model->get_email($id);
     if (!$this->email_model->is_mine()) {
         set_message("Email não encontrado");
         redirect(site_url("dashboard"));
     }
     $this->email_model->read_message($id);
     $this->load_view("../libraries/email/views/email_detail");
 }
Ejemplo n.º 6
0
 function inativar($id)
 {
     if (!$this->financeiro_model->is_mine($id)) {
         set_message("Este cliente não lhe pertence", 2);
     } else {
         $data["status"] = 3;
         $this->financeiro_model->update_data($data);
     }
     redirect(site_url("act/financeiro/clientes/gerenciar"));
 }
Ejemplo n.º 7
0
 function edit($idx = false)
 {
     if ($idx != $this->my_logged_data['id']) {
         redirect("admin/error");
     }
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         //ion
         $user = $this->ion_auth->user($idx)->row();
         if ($_POST['image_name']) {
             $fix_name = "up_" . $idx . "_" . time() . substr($_POST['image_name'], strrpos($_POST['image_name'], "."));
             $tmp_name = $this->config->item('dir_tmp_pages_image') . $_POST['image_name'];
             $new_name = $this->config->item('dir_pages_image') . $fix_name;
             $avt_name = $this->config->item('dir_pages_image') . "avatar_" . $fix_name;
             if (file_exists($tmp_name)) {
                 if (copy($tmp_name, $new_name)) {
                     $headline_img = $fix_name;
                     $this->utils->imgThumbnail($this->config->item('dir_pages_image'), $fix_name, 74, 74, 'avatar_', 'resize');
                     unlink($tmp_name);
                     if ($_POST['image_name_old']) {
                         unlink($this->config->item('dir_pages_image') . $_POST['image_name_old']);
                         unlink($this->config->item('dir_pages_image') . "avatar_" . $_POST['image_name_old']);
                     }
                 }
             }
         }
         $_data["first_name"] = $_POST['first_name'];
         $_data["last_name"] = $_POST['last_name'];
         $_data["email"] = $_POST['email'];
         $_data["phone"] = $_POST['phone'];
         if ($_POST['password']) {
             $_data["password"] = $_POST['password'];
             $pass_change_msg = " Password changed..  (affected in next login)";
         }
         $ion_update = $this->ion_auth->update($user->id, $_data);
         //print_r($_data);
         //exit;
         //debug();
         //echo $update;
         if ($ion_update) {
             if ($headline_img) {
                 $avatar["image"] = $headline_img;
                 $update = $this->model->UpdateData($avatar, "id='" . $_POST['idx'] . "'");
             }
             set_message("success", "Profile Saved." . $pass_change_msg);
             redirect("admin/user_profile/edit/" . $_POST['idx'] . "?tab=1");
         }
     } else {
         $arrDB = $this->model->GetRecordData("id='{$idx}'");
         $data["data"] = $arrDB;
     }
     $data["acc_active"] = "content";
     $data["module"] = $this->module;
     $data_layout["content"] = $this->load->view("user_profile/edit", $data, true);
     $this->load->view($this->admin_layout, $data_layout);
 }
Ejemplo n.º 8
0
 public function delete($id)
 {
     if ($id > 0) {
         $this->db->where('id', $id);
         $this->db->limit(1, 0);
         $this->db->delete('tblpayment_methods');
         return $this->db->affected_rows() > 0 ? set_message($this->lang->line('db_deleted_record')) : set_message($this->lang->line('db_delete_error'));
     } else {
         return set_message($this->lang->line('db_correct_id'), 'info');
     }
 }
Ejemplo n.º 9
0
 function add_new_people($p_id = false)
 {
     $this->load->library('form_validation');
     $this->form_validation->set_error_delimiters('<div class="error">', '</div>');
     $this->form_validation->set_rules('first_name', 'Name', 'required|min_length[1]|max_length[100]');
     $this->form_validation->set_rules('last_name', 'Name', 'required|min_length[1]|max_length[100]');
     $this->form_validation->set_rules('company_name', 'company name', 'min_length[1]|max_length[100]');
     $this->form_validation->set_rules('mobile', 'Mobile', 'regex_match[/^[0-9]{10}$/]');
     $this->form_validation->set_rules('email', 'Email', 'valid_email');
     $this->form_validation->set_rules('address1', 'Address', 'required|min_length[1]|max_length[200]');
     $this->form_validation->set_rules('city', 'city', 'required');
     if ($this->form_validation->run() == FALSE) {
         set_message(validation_errors());
         redirect_back();
         return 0;
     } else {
         $first_name = strtoupper($this->input->post('first_name'));
         $last_name = strtoupper($this->input->post('last_name'));
         $company_name = strtoupper($this->input->post('company_name'));
         $email = $this->input->post('email');
         $sec_email = $this->input->post('sec_email');
         $mobile = $this->input->post('mobile');
         $phone = $this->input->post('phone');
         $website = $this->input->post('website');
         $skype = $this->input->post('skype');
         $industry = $this->input->post('industry');
         $address1 = $this->input->post('address1');
         $address2 = $this->input->post('address2');
         $city = $this->input->post('city');
         $state = $this->input->post('state');
         $country = $this->input->post('country');
         $note = $this->input->post('note');
         if ($this->session->userdata('role') != 'admin') {
             $companyid = $this->session->userdata('companyid');
         } else {
             $companyid = $this->input->post('companyid');
         }
         $people_data = array('company_name' => $company_name, 'first_name' => $first_name, 'last_name' => $last_name, 'email' => $email, 'sec_email' => $sec_email, 'mobile' => $mobile, 'phone' => $phone, 'website' => $website, 'skype' => $skype, 'industry' => $industry, 'address1' => $address1, 'address2' => $address2, 'city' => $city, 'state' => $state, 'country' => $country, 'note' => $note);
         if ($p_id) {
             $updated_at = date('Y-m-d H:i:s');
             $people_data['updated_at'] = $updated_at;
             $this->db->where('people_id', $p_id);
             $res = $this->db->update('people', $people_data);
             return $res;
         } else {
             $created_at = date('Y-m-d H:i:s');
             $people_data['created_at'] = $created_at;
             $this->db->insert('people', $people_data);
             $people_id = $this->db->insert_id();
             return $people_id;
         }
     }
 }
Ejemplo n.º 10
0
 function auth_user()
 {
     $ci =& get_instance();
     // getting the CI instance
     $auth = $ci->session->userdata('auth');
     if ($auth == 1) {
         return true;
     } else {
         set_message("You are not logged in.", $type = 'info');
         redirect('/');
     }
 }
Ejemplo n.º 11
0
 function register()
 {
     $post_client = $this->input->post('client', TRUE);
     $post_sample = $this->input->post('samples', TRUE);
     if (empty($post_sample["client_id"])) {
         if ($this->client_model->create($post_client)) {
             $post_sample["client_id"] = $this->client_model->object->id;
         }
     }
     $this->amostra_model->create_or_edit($post_sample);
     set_message("Operação realizada com sucesso");
     redirect(site_url("act/amostras/amostra/index"));
 }
Ejemplo n.º 12
0
 public function delete_expense($id)
 {
     // delete all expense by id
     $this->expense_model->_table_name = "tbl_expense";
     // table name
     $this->expense_model->_primary_key = "expense_id";
     // $id
     $this->expense_model->delete($id);
     $type = "success";
     $message = "Expense Information Successfully Delete!";
     set_message($type, $message);
     redirect('admin/expense/add_expense');
     //redirect page
 }
Ejemplo n.º 13
0
 public function delete($id, $company_id = NULL)
 {
     $company_id = $company_id ? $company_id : $this->comp_id;
     if ($id > 0) {
         $this->db->where('id', $id);
         $this->db->where('is_system !=', '1');
         $this->db->where('company_id', $company_id);
         $this->db->limit(1, 0);
         $this->db->delete($this->table['name']);
         return $this->db->affected_rows() > 0 ? set_message($this->lang->line('db_deleted_record')) : set_message($this->lang->line('db_delete_error'));
     } else {
         return set_message($this->lang->line('db_delete_error'), 'info');
     }
 }
function openid_check($ci, $callback_url, &$data)
{
    if (!isset($data)) {
        $data = array();
    }
    $ci->lang->load('openid');
    $ci->config->load('openid');
    $ci->openid->set_request_to($callback_url);
    $response = $ci->openid->getResponse();
    switch ($response->status) {
        case Auth_OpenID_CANCEL:
            push_message($ci->lang->line('openid_cancel'), 'error', $ci);
            break;
        case Auth_OpenID_FAILURE:
            push_message(set_message('openid_failure', $response->message), 'error', $ci);
            break;
        case Auth_OpenID_SUCCESS:
            $openid = $response->getDisplayIdentifier();
            $esc_identity = htmlspecialchars($openid, ENT_QUOTES);
            $data['openid_identifier'] = $openid;
            $sreg_resp = Auth_OpenID_SRegResponse::fromSuccessResponse($response);
            $sreg = $sreg_resp->contents();
            $ax_resp = new Auth_OpenID_AX_FetchResponse();
            $ax = $ax_resp->fromSuccessResponse($response);
            if (isset($sreg['email'])) {
                $data['email'] = $sreg['email'];
            }
            if ($ax) {
                if (isset($ax->data['http://axschema.org/contact/email'])) {
                    $data['email'] = $ax->getSingle('http://axschema.org/contact/email');
                }
                if (isset($ax->data['http://axschema.org/namePerson/first'])) {
                    $first_name = $ax->getSingle('http://axschema.org/namePerson/first');
                } else {
                    $first_name = "Sample";
                }
                if (isset($ax->data['http://axschema.org/namePerson/last'])) {
                    $last_name = $ax->getSingle('http://axschema.org/namePerson/last');
                } else {
                    $last_name = "Avatar";
                }
                if ($first_name != null && $last_name != null) {
                    $data['username'] = "******";
                }
            }
            return true;
    }
    return false;
}
Ejemplo n.º 15
0
function login_user()
{
    if (isset($_POST['submit'])) {
        $username = escape_string($_POST['username']);
        $password = escape_string($_POST['password']);
        $query = query("SELECT * FROM user WHERE username = '******' AND password = '******'");
        confirm($query);
        if (mysqli_num_rows($query) == 0) {
            set_message("Contrasena y usuario no es valida.");
            redirect("index.php");
        } else {
            redirect("public/main.php");
        }
    }
}
Ejemplo n.º 16
0
 public function send()
 {
     if ($_SERVER['REQUEST_METHOD'] == "POST") {
         $this->_valid();
         $this->load->model('contact_model');
         //die($message);
         $this->contact_model->save();
         $msg = set_message(json_decode(EMAIL_CONTACT_MESSAGE), 'txtConsult', 'sin codigo');
         $this->email->from($this->input->post('txtEmail'), $this->input->post('txtName'));
         $this->email->to(EMAIL_CONTACT_TO);
         $this->email->subject(EMAIL_CONTACT_SUBJECT);
         //$this->email->message(json_decode(EMAIL_CONTACT_MESSAGE), 'txtConsult', 'sin codigo');
         $this->email->message($msg);
         die(json_encode($this->email->send()));
     }
 }
Ejemplo n.º 17
0
 function save_role()
 {
     if (check_if_post()) {
         $actual_string = $this->input->post('role-name');
         $role_name = preg_replace('/[^a-zA-Z0-9]/', '_', $actual_string);
         $role_name = strtolower($role_name);
         $this->load->model('rolepermission_m', 'rm');
         $role_added = $this->rm->add_new_role($actual_string, $role_name);
         if ($role_added) {
             set_message('Role added: ' . $actual_string);
         } else {
             set_message('Role already exist.');
         }
         redirect('rolepermission/role/add_role');
     }
 }
Ejemplo n.º 18
0
 function vincular_facebook()
 {
     $this->load->model("user_model");
     $data = $this->get_facebook_login_link();
     if (!empty($data["user_profile"])) {
         $data_ = array();
         $data_["name"] = $data["user_profile"]['name'];
         $data_["facebook_id"] = $data["user_profile"]['id'];
         $this->user_model->vinculate_facebook($data_);
         $this->user_model->login($user_insert->username, false, $data["user_profile"]['id']);
         set_message("Vinculado com sucesso");
     } else {
         set_message("Falha ao vincular", 2);
     }
     redirect(site_url("profile"));
 }
Ejemplo n.º 19
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");
     }
 }
Ejemplo n.º 20
0
 public function update($data, $company_id = NULL)
 {
     $company_id = $company_id ? $company_id : $this->comp_id;
     $data['company_id'] = $company_id;
     $this->db->where('id', $data['id']);
     $this->db->where('company_id', $company_id);
     $this->db->update('currency', $data);
     if ($data['default'] == '1') {
         $this->db->where('id !=', $data['id']);
         $this->db->where('company_id', $company_id);
         $this->db->set('default', '0');
         $this->db->update('currency');
     }
     if ($this->db->insert_id() > 1) {
         return set_message(lang('db_updated_record'));
     }
     return set_message(lang('db_update_error'), 'error');
 }
Ejemplo n.º 21
0
 public function init()
 {
     $this->module_name = "pin";
     $this->module_position = 0;
     module_config::register_css('pin', 'pin.css');
     module_config::register_js('pin', 'pin.js');
     $this->version = 2.11;
     //2.11 css tweak
     if (isset($_REQUEST['pin_process']) && module_security::is_logged_in() && module_pin::can_i('edit', 'Header Pin')) {
         switch ($_REQUEST['pin_process']) {
             case 'pin_save':
                 switch ($_REQUEST['pin_action']) {
                     case 'modify':
                         if ($_REQUEST['pin_id'] && $_REQUEST['current_title']) {
                             $this->update_pin($_REQUEST['pin_id'], false, $_REQUEST['current_title']);
                             set_message('Pin modified successfully');
                             redirect_browser($_REQUEST['current_url']);
                         }
                         break;
                     case 'delete':
                         if ($_REQUEST['pin_id']) {
                             $this->delete_pin($_REQUEST['pin_id']);
                             set_message('Pin deleted successfully');
                             redirect_browser($_REQUEST['current_url']);
                         }
                         break;
                     case 'add':
                         if ($_REQUEST['current_url'] && $_REQUEST['current_title']) {
                             $pin_id = $this->add_pin($_REQUEST['current_url'], $_REQUEST['current_title']);
                             if ($pin_id) {
                                 set_message('Pin added successfully');
                             } else {
                                 set_message('Pin already exists');
                             }
                             redirect_browser($_REQUEST['current_url']);
                         }
                         break;
                 }
                 break;
         }
     }
 }
Ejemplo n.º 22
0
 function _proses_message($ok, $url_ok = false, $url_error = false)
 {
     $url_ok = $url_ok ? $url_ok : $this->module;
     $url_error = $url_error ? $url_error : $this->module;
     if (!$this->input->is_ajax_request()) {
         if ($ok) {
             set_message("success", $this->msg_ok);
             redirect($url_ok);
         } else {
             set_message("error", $this->msg_fail);
             redirect($url_error);
         }
     } else {
         if ($ok) {
             print "ok";
         } else {
             print "failed";
         }
     }
 }
Ejemplo n.º 23
0
 public function set_action($id)
 {
     $data['application_status'] = $this->input->post('application_status', TRUE);
     if ($data['application_status'] == 2) {
         $atdnc_data = $this->application_model->array_from_post(array('employee_id', 'leave_category_id'));
         $leave_start_date = $this->input->post('leave_start_date', TRUE);
         $leave_end_date = $this->input->post('leave_end_date', TRUE);
         if ($leave_start_date == $leave_end_date) {
             $this->admin_model->_table_name = 'tbl_attendance';
             $this->admin_model->_order_by = 'attendance_id';
             $check_leave_date = $this->admin_model->get_by(array('employee_id' => $atdnc_data['employee_id'], 'date' => $leave_end_date), FALSE);
             if (empty($check_leave_date)) {
                 $atdnc_data['date'] = $leave_start_date;
                 $atdnc_data['attendance_status'] = '3';
                 $this->admin_model->_table_name = 'tbl_attendance';
                 $this->admin_model->_primary_key = "attendance_id";
                 $this->admin_model->save($atdnc_data);
             }
         } else {
             for ($l = $leave_start_date; $l <= $leave_end_date; $l++) {
                 $this->admin_model->_table_name = 'tbl_attendance';
                 $this->admin_model->_order_by = 'attendance_id';
                 $check_leave_date = $this->admin_model->get_by(array('employee_id' => $atdnc_data['employee_id'], 'date' => $l), FALSE);
                 if (empty($check_leave_date)) {
                     $atdnc_data['date'] = $l;
                     $atdnc_data['attendance_status'] = '3';
                     $this->admin_model->_table_name = 'tbl_attendance';
                     $this->admin_model->_primary_key = "attendance_id";
                     $this->admin_model->save($atdnc_data);
                 }
             }
         }
     }
     $where = array('application_list_id' => $id);
     $this->application_model->set_action($where, $data, 'tbl_application_list');
     $type = "success";
     $message = "Application Status Successfully Changed!";
     set_message($type, $message);
     redirect('admin/application_list');
     //redirect page
 }
function handle_row($row, $conn)
{
    global $row_tmp;
    $url = $row['url'];
    $content = get_url_content($url);
    if ($content == null) {
        return;
    } else {
        $row_tmp[$url] = array();
        // 更新最後檢查的時間,先存入暫時的陣列
        date_default_timezone_set('Asia/Taipei');
        $row_tmp[$url]['last_check'] = date('Y/m/d l H:i:s', time());
        // 日期減一,先存入暫時的陣列
        $row_tmp[$url]['remaining'] = $row['remaining'] - 1;
        // 檢查推文數量是否有變化,先存入暫時的陣列
        $row_tmp[$url]['push_count'] = substr_count($content, "push-content");
        // 偵測到這篇文章有新增推文的話,就設定信件內容,等等再寄出
        if ($row_tmp[$url]['push_count'] != $row['push_count']) {
            set_message($row);
        }
    }
}
Ejemplo n.º 25
0
 function view($uuid, $extra = null)
 {
     $data = array();
     $data['scene_data'] = $this->simiangrid->get_scene($uuid);
     if ($data['scene_data'] == null) {
         $data['scene_data'] = $this->simiangrid->get_scene_by_name($uuid);
         if ($data['scene_data'] != null) {
             $uuid = $data['scene_data']['SceneID'];
         } else {
             push_message(set_message('sg_region_unknown', $uuid), 'error');
             return redirect('region');
         }
     }
     $data['uuid'] = $uuid;
     $data['tab'] = '';
     if ($extra == "stats") {
         $data['tab'] = 'stats';
     }
     $this->_scene_extra_info($uuid, $data);
     $data['title'] = $data['scene_data']['Name'];
     $data['page'] = 'regions';
     parse_template('region/view', $data);
 }
Ejemplo n.º 26
0
function lookup_symbol($key)
{
    $url = "http://careers-data.benzinga.com/rest/richquote?symbols=" . $key;
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 4);
    $json = curl_exec($ch);
    if (!$json) {
        set_message(AlertType::Danger, curl_error($ch));
    }
    curl_close($ch);
    $search_result = json_decode($json);
    $data = $search_result->{$key};
    $data = get_object_vars($data);
    // Check if error returned and display error message
    if (isset($data["error"])) {
        $data = get_object_vars($data["error"]);
        set_message(AlertType::Danger, $data["message"]);
    } else {
        return array($data["name"], $data["symbol"], $data["bidPrice"], $data["askPrice"]);
    }
}
Ejemplo n.º 27
0
 function user_validate($email, $password)
 {
     $result = $this->db->select('user_id,password,created')->from('users')->where('email', $email)->get();
     // check if the email is present.
     if ($result->num_rows() == 1) {
         $result_p = $result->result_array();
         $hash = $password . $result_p[0]['created'];
         // adding the created time to the hash for a unique string.
         $password_result = $this->db->select()->from('users')->where('email', $email)->where('password', hash('sha256', $hash))->get();
         if ($password_result->num_rows() == 1) {
             $user_data = $password_result->result_array();
             $user_data = $user_data[0];
             $session_array = array('auth' => 1, 'uid' => $user_data['user_id'], 'displayname' => $user_data['display_name'], 'email' => $user_data['email']);
             $this->session->set_userdata($session_array);
             return true;
         } else {
             set_message('Login credentials are wrong');
             redirect('/');
         }
     } else {
         set_message('Email entered is wrong');
         redirect('/');
     }
 }
Ejemplo n.º 28
0
function get_id($db, $data)
{
    $id = null;
    $username = null;
    if (!isset($data['id'])) {
        set_message('Virheellinen käyttäjä-ID', 1);
    } else {
        $id = mysql_real_escape_string($data['id']);
    }
    if (!is_null($id)) {
        $username = get_poet_username($id);
        if (is_null($username)) {
            set_message('Annetulla ID:llä ei löydy käyttäjää!', 1);
        }
    }
    if (is_null($username)) {
        echo '<div class="poems">';
        show_message();
        echo '</div>';
        create_site_bottom();
        die;
    }
    return $id;
}
Ejemplo n.º 29
0
<?php

/** 
 * Copyright: dtbaker 2012
 * Licence: Please check CodeCanyon.net for licence details. 
 * More licence clarification available here:  http://codecanyon.net/wiki/support/legal-terms/licensing-terms/ 
 * Deploy: 9809 f200f46c2a19bb98d112f2d32a8de0c4
 * Envato: 4ffca17e-861e-4921-86c3-8931978c40ca
 * Package Date: 2015-11-25 02:55:20 
 * IP Address: 67.79.165.254
 */
if (!module_change_request::can_i('delete', 'Change Requests')) {
    die('no perms');
}
$change_request_id = (int) $_REQUEST['change_request_id'];
$change_request = module_change_request::get_change_request($change_request_id);
if (!$change_request['website_id']) {
    die('no linked website');
}
$website_data = module_website::get_website($change_request['website_id']);
if (module_form::confirm_delete('change_request_id', "Really delete Change Request?", module_website::link_open($change_request['website_id']))) {
    module_change_request::delete_change_request($_REQUEST['change_request_id']);
    set_message("Change request deleted successfully");
    redirect_browser(module_website::link_open($change_request['website_id']));
}
Ejemplo n.º 30
-1
function send_image_to_client($image_name, $file_alloweds = false)
{
    // $model->screen_model->get_db();
    $ci =& get_instance();
    $session_user = unserialize(get_logged_user());
    // dump($session_user);
    // dump($_FILES[$image_name]);
    $file_name = md5(date("d_m_Y_H_m_s_u")) . "_" . str_replace(" ", "_", stripAccents($_FILES[$image_name]['name']));
    // $file_name = md5(date("Ymds"));
    $filename = $_FILES[$image_name]['tmp_name'];
    $handle = fopen($filename, "r");
    $data = fread($handle, filesize($filename));
    $POST_DATA = array('file' => base64_encode($data), 'name' => $file_name);
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, $session_user->upload_path . "upload.php");
    curl_setopt($curl, CURLOPT_TIMEOUT, 30);
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $POST_DATA);
    curl_setopt($curl, CURLOPT_HEADER, true);
    $response = curl_exec($curl);
    $httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
    curl_close($curl);
    if ($httpCode != 200) {
        set_message("Erro ao publicar foto: <br/>" . $response, 2);
    }
    // dump($response);
    return $file_name;
}