Example #1
0
 function token($token = FALSE)
 {
     $this->load->database();
     $sql = "SELECT * FROM `pw_reset` WHERE token = '" . $token . "'";
     $query = $this->db->query($sql);
     $result = $query->result();
     if ($result) {
         $lees = $result[0]->timestamp + 24 * 60 * 60;
         if (time() < $lees) {
             $new_password = substr(str_shuffle(strtolower(sha1(rand() . time() . "nekdotlggjaoudlpqwejvlfk"))), 0, 8);
             if ($result[0]->user == "1") {
                 $user = User::find_by_email($result[0]->email);
                 $user->set_password($new_password);
                 $user->save();
             } else {
                 $client = Client::find_by_email($result[0]->email);
                 $client->password = $client->set_password($new_password);
                 $client->save();
             }
             $sql = "DELETE FROM `pw_reset` WHERE `email`='" . $result[0]->email . "'";
             $query = $this->db->query($sql);
             $data["core_settings"] = Setting::first();
             $this->email->from($data["core_settings"]->email, $data["core_settings"]->company);
             $this->email->to($result[0]->email);
             $this->load->library('parser');
             $this->load->helper('file');
             $this->email->subject($data["core_settings"]->pw_reset_link_mail_subject);
             $parse_data = array('password' => $new_password, 'link' => base_url(), 'company' => $data["core_settings"]->company, 'logo' => '<img src="' . base_url() . '' . $data["core_settings"]->logo . '" alt="' . $data["core_settings"]->company . '"/>', 'invoice_logo' => '<img src="' . base_url() . '' . $data["core_settings"]->invoice_logo . '" alt="' . $data["core_settings"]->company . '"/>');
             $email = read_file('./application/views/' . $data["core_settings"]->template . '/templates/email_pw_reset.html');
             $message = $this->parser->parse_string($email, $parse_data);
             $this->email->message($message);
             $this->email->send();
             $this->session->set_flashdata('message', 'success:' . $this->lang->line('messages_password_reset'));
             redirect('forgotpass');
         }
     } else {
         redirect('login');
     }
 }
Example #2
0
 function index()
 {
     $core_settings = Setting::first();
     if ($core_settings->registration != 1) {
         redirect('login');
     }
     if ($_POST) {
         $this->load->library('parser');
         $this->load->helper('file');
         $this->load->helper('notification');
         $client = Client::find_by_email($_POST['email']);
         if ($client->inactive == 1) {
             $client = FALSE;
         }
         $check_company = Company::find_by_name($_POST['name']);
         if (!$client && !$check_company && $_POST['name'] != "" && $_POST['email'] != "" && $_POST['password'] != "" && $_POST['firstname'] != "" && $_POST['lastname'] != "" && $_POST['confirmcaptcha'] != "") {
             $client_attr = array();
             $company_attr['name'] = $_POST['name'];
             $company_attr['website'] = $_POST['website'];
             $company_attr['phone'] = $_POST['phone'];
             $company_attr['mobile'] = $_POST['mobile'];
             $company_attr['address'] = $_POST['address'];
             $company_attr['zipcode'] = $_POST['zipcode'];
             $company_attr['city'] = $_POST['city'];
             $company_attr['country'] = $_POST['country'];
             $company_attr['province'] = $_POST['province'];
             $company_attr['vat'] = $_POST['vat'];
             $company_attr['reference'] = $core_settings->company_reference;
             $core_settings->company_reference = $core_settings->company_reference + 1;
             $core_settings->save();
             $company = Company::create($company_attr);
             if (!$company) {
                 $this->session->set_flashdata('message', 'success:' . $this->lang->line('messages_registration_error'));
                 redirect('register');
             }
             $lastclient = Client::last();
             $client_attr = array();
             $client_attr['email'] = $_POST['email'];
             $client_attr['firstname'] = $_POST['firstname'];
             $client_attr['lastname'] = $_POST['lastname'];
             $client_attr['phone'] = $_POST['phone'];
             $client_attr['mobile'] = $_POST['mobile'];
             $client_attr['address'] = $_POST['address'];
             $client_attr['zipcode'] = $_POST['zipcode'];
             $client_attr['city'] = $_POST['city'];
             $modules = Module::find('all', array('order' => 'sort asc', 'conditions' => array('type = ?', 'client')));
             $client_attr['access'] = "";
             foreach ($modules as $value) {
                 if ($value->name == "Projects" || $value->name == "Messages" || $value->name == "Tickets" || $value->name == "Invoices") {
                     $client_attr['access'] .= $value->id . ",";
                 }
             }
             $client_attr['company_id'] = $company->id;
             $client = Client::create($client_attr);
             if ($client) {
                 $client->password = $client->set_password($_POST['password']);
                 $client->save();
                 $company->client_id = $client->id;
                 $company->save();
                 $this->email->from($core_settings->email, $core_settings->company);
                 $this->email->to($client_attr['email']);
                 $this->email->subject($this->lang->line('application_your_account_has_been_created'));
                 $parse_data = array('link' => base_url() . 'login/', 'company' => $core_settings->company, 'company_reference' => $company->reference, 'logo' => '<img src="' . base_url() . '' . $core_settings->logo . '" alt="' . $core_settings->company . '"/>', 'invoice_logo' => '<img src="' . base_url() . '' . $core_settings->invoice_logo . '" alt="' . $core_settings->company . '"/>');
                 $email = read_file('./application/views/' . $core_settings->template . '/templates/email_create_account.html');
                 $message = $this->parser->parse_string($email, $parse_data);
                 $this->email->message($message);
                 $this->email->send();
                 send_notification($core_settings->email, $this->lang->line('application_new_client_has_registered'), $this->lang->line('application_new_client_has_registered') . ': <br><strong>' . $company_attr['name'] . '</strong><br>' . $client_attr['firstname'] . ' ' . $client_attr['lastname'] . '<br>' . $client_attr['email']);
                 $this->session->set_flashdata('message', 'success:' . $this->lang->line('messages_registration_success'));
                 redirect('login');
             } else {
                 $this->session->set_flashdata('message', 'success:' . $this->lang->line('messages_registration_error'));
                 redirect('login');
             }
         } else {
             $this->view_data['error'] = $this->lang->line('messages_email_already_taken');
             $this->theme_view = 'login';
             $this->content_view = 'auth/register';
             $this->view_data['form_action'] = 'register';
             $this->view_data['registerdata'] = $_POST;
         }
     } else {
         $this->view_data['error'] = 'false';
         $this->theme_view = 'login';
         $this->content_view = 'auth/register';
         $this->view_data['form_action'] = 'register';
     }
 }
Example #3
0
require_once "includesmain/database.php";
require_once "includesmain/class.php";
require_once "includesmain/client.php";
require_once "includesmain/class_session.php";
require_once "securimage/securimage.php";
require_once "includesmain/datemanager.php";
$securimage = new Securimage();
$activesession = ClassSession::getactivesession();
$classtojoin = Classes::find_by_id($_GET['join']);
$sessiontojoin = ClassSession::find_by_id($classtojoin->sessionid);
if (isset($_POST['p_firstname'])) {
    if (!$securimage->check($_POST['captcha_code'])) {
        $captchaerror = TRUE;
    } else {
        $mailtotest = $database->escape_value($_POST['email']);
        $alreadyclient = Client::find_by_email($mailtotest);
        if ($alreadyclient) {
            if ($_POST['k_firstname'] == $alreadyclient->k_firstname) {
                $kidalreadyregistered = true;
            }
        }
        if (!$kidalreadyregistered) {
            Client::addclienttodatabase($_POST['clsid'], $_POST['p_firstname'], $_POST['p_lastname'], $_POST['k_firstname'], $_POST['k_lastname'], $_POST['phone'], $_POST['email'], $_POST['coupon']);
            $insertedid = $database->insert_id();
            redirect_to('view-details.php?tclt=' . $insertedid . '&cls=' . $_POST['clsid']);
        } else {
            redirect_to('complete.php');
        }
    }
}
include 'includes/pagestructure.php';
Example #4
0
 function index()
 {
     $this->load->helper('notification');
     $this->load->helper('string');
     $emailconfig = Setting::first();
     if ($emailconfig->ticket_config_active == "1") {
         $emailconfig->ticket_config_timestamp = time();
         $emailconfig->save();
         // this shows basic IMAP, no TLS required
         $config['login'] = $emailconfig->ticket_config_login;
         $config['pass'] = $emailconfig->ticket_config_pass;
         $config['host'] = $emailconfig->ticket_config_host;
         $config['port'] = $emailconfig->ticket_config_port;
         $config['mailbox'] = $emailconfig->ticket_config_mailbox;
         if ($emailconfig->ticket_config_imap == "1") {
             $flags = "/imap";
         } else {
             $flags = "/pop3";
         }
         if ($emailconfig->ticket_config_ssl == "1") {
             $flags .= "/ssl";
         }
         $config['service_flags'] = $flags . $emailconfig->ticket_config_flags;
         $this->load->library('peeker', $config);
         //attachment folder
         $bool = $this->peeker->set_attachment_dir('files/media/');
         //Search Filter
         $this->peeker->set_search($emailconfig->ticket_config_search);
         if ($this->peeker->search_and_count_messages() != "0") {
             log_message('error', 'Postmaster fetched ' . $this->peeker->search_and_count_messages() . ' new email tickets.');
             $id_array = $this->peeker->get_ids_from_search();
             //walk trough emails
             foreach ($id_array as $email_id) {
                 $ticket = false;
                 $email = $this->peeker->get_message($email_id);
                 $email->rewrite_html_transform_img_tags('files/media/');
                 $emailbody = utf8_encode(nl2br($email->get_plain()));
                 $emailaddr = $email->get_from_array();
                 $emailaddr = $emailaddr[0]->mailbox . '@' . $emailaddr[0]->host;
                 //get next ticket number
                 $settings = Setting::first();
                 $ticket_reference = $settings->ticket_reference;
                 $settings->ticket_reference = $settings->ticket_reference + 1;
                 $settings->save();
                 if (preg_match('/(?<=\\[Ticket\\#)(.+)(?=\\])/is', $email->get_subject(), $matches)) {
                     $ticket = Ticket::find_by_reference($matches[1]);
                 }
                 if ($ticket) {
                     log_message('error', 'Fetched email merged to ticket #' . $matches[1]);
                     $article_attributes = array('ticket_id' => $ticket->id, 'internal' => '0', 'from' => $email->get_from() . ' - ' . $emailaddr, 'reply_to' => $emailaddr, 'to' => $email->get_to(), 'cc' => $email->get_cc(), 'subject' => htmlspecialchars($email->get_subject()), 'message' => $emailbody, 'datetime' => time());
                     if ($ticket->status == "closed") {
                         $ticket->status = 'reopened';
                         $ticket->updated = '1';
                         $ticket->save();
                     }
                     $ticket->updated = '1';
                     $ticket->save();
                     $article = TicketHasArticle::create($article_attributes);
                     if (isset($ticket->user->email)) {
                         send_ticket_notification($ticket->user->email, '[Ticket#' . $ticket->reference . '] - ' . $ticket->subject, $emailbody, $ticket->id);
                     }
                     //Attachments
                     $parts = $email->get_parts_array();
                     if ($email->has_attachment()) {
                         foreach ($parts as $part) {
                             $savename = $email->get_fingerprint() . random_string('alnum', 8) . $part->get_filename();
                             $orgname = $part->get_filename();
                             $part->filename = $savename;
                             $attributes = array('article_id' => $article->id, 'filename' => $orgname, 'savename' => $savename);
                             $attachment = ArticleHasAttachment::create($attributes);
                         }
                         $email->save_all_attachments('files/media/');
                     }
                 } else {
                     //Ticket Attributes
                     $ticket_attributes = array('reference' => $ticket_reference, 'from' => $email->get_from() . ' - ' . $emailaddr, 'subject' => $email->get_subject(), 'text' => $emailbody, 'updated' => "1", 'created' => time(), 'user_id' => $settings->ticket_default_owner, 'type_id' => $settings->ticket_default_type, 'status' => $settings->ticket_default_status, 'queue_id' => $settings->ticket_default_queue);
                     //check if sender is client
                     $client = Client::find_by_email($emailaddr);
                     if (isset($client)) {
                         $ticket_attributes['client_id'] = $client->id;
                         $ticket_attributes['company_id'] = $client->company->id;
                     }
                     //create Ticket
                     $ticket = Ticket::create($ticket_attributes);
                     //Attachments
                     $parts = $email->get_parts_array();
                     if ($email->has_attachment()) {
                         foreach ($parts as $part) {
                             $savename = $email->get_fingerprint() . random_string('alnum', 8) . $part->get_filename();
                             $orgname = $part->get_filename();
                             $part->filename = $savename;
                             $attributes = array('ticket_id' => $ticket->id, 'filename' => $orgname, 'savename' => $savename);
                             $attachment = TicketHasAttachment::create($attributes);
                         }
                         $email->save_all_attachments('files/media/');
                     }
                     send_ticket_notification($ticket->user->email, '[Ticket#' . $ticket->reference . '] - ' . $ticket->subject, $emailbody, $ticket->id);
                     log_message('error', 'New ticket created #' . $ticket->reference);
                 }
                 if ($emailconfig->ticket_config_delete == "1") {
                     $email->set_delete();
                     $email->expunge();
                     $this->peeker->delete_and_expunge($email_id);
                 }
             }
         }
         $this->peeker->close();
         // tell the story of the connection (only for debuging)
         //echo "<pre>"; print_r($this->peeker->trace()); echo "</pre>";
     }
     die;
 }