Пример #1
3
function parseData($d)
{
    $oldx = -1;
    $oldy = -1;
    $startx = -1;
    $starty = -1;
    $relative = true;
    $data = explode(' ', $d);
    foreach ($data as $pos) {
        if ($pos == 'M') {
            $relative = false;
            continue;
        }
        if ($pos == 'm') {
            $relative = true;
            continue;
        }
        if (strpos($pos, ',') !== false) {
            list($x, $y) = explode(',', $pos);
            if ($startx == -1 && $starty == -1) {
                //echo '// float startx = ' . $x . ";\n";
                //echo '// float starty = ' . $y . ";\n";
                $startx = $x;
                $starty = $y;
            } else {
                if ($relative) {
                    $x = $oldx + $x;
                    $y = $oldy + $y;
                }
            }
            if ($oldx != -1 && $oldy != -1) {
                gencode($oldx, $oldy, $x, $y);
            }
            $oldx = $x;
            $oldy = $y;
        }
    }
    gencode($oldx, $oldy, $startx, $starty);
}
Пример #2
0
 public function add($id = "")
 {
     $this->is_user_allowed();
     if (isset($_POST)) {
         $emailAddress = trim($this->input->get_post('email', TRUE));
         $filter = array('userName' => $emailAddress, 'userEmail' => $emailAddress);
         $res = $this->users->get_details($filter);
         $res_count = count($res);
         if ($res_count > 0 && $emailAddress !== "") {
             $data = array('reg_msg' => "The users email already exist, please try another one");
             $this->session->set_userdata($data);
             redirect('manageCompanies');
         }
         $contact_person = $this->input->get_post('c_person', TRUE);
         $cmpny = $this->input->get_post('inputCName', TRUE);
         $company_code = $this->input->get_post('inputCcode', TRUE);
         $ctype = $this->input->get_post('inputCType', TRUE);
         $foodtype = $this->input->get_post('inputFType', TRUE);
         $nms = $this->company_type->get_companyName($ctype);
         $ctype_name = $nms[0]->company_type_name;
         if ($foodtype == "0") {
             $c_foodtype = "N/A";
         } else {
             $filter = array('vehicleId' => $foodtype);
             $q = $this->foodtypes->get_details($filter);
             $c_foodtype = $q[0]->vehicleName;
         }
         $phone = $this->input->get_post('phone', TRUE);
         $uname = $ctype . "ADM" . gencode(4);
         $pass = genBigcode(8);
         /*$filter=array('userName' => $emailAddress);
           	  		$available_users=count($this->users->get_details($filter));
         		
           		while($available_users>0)
           		{
             		$uname=$ctype."ADM".gencode(4);
         			$filter=array('userName' => $uname);
           	    		$cde=count($this->users->get_details($filter));
           		}*/
         if (empty($id)) {
             $code = genBigcode(6);
             $filter = array('activationcode' => $code);
             $cde = count($this->users->get_details($filter));
             while ($cde > 0) {
                 $code = genBigcode(6);
                 $filter = array('activationcode' => $code);
                 $cde = count($this->users->get_details($filter));
             }
             $url = site_url() . "activate/{$code}";
             $message = "Dear {$contact_person},\r\nYou have been created as the administrator for {$cmpny}.......\r\n\r\nCompany details::\r\n Company Name: {$cmpny}\r\n  Company Code: {$company_code}\r\n Company Type: {$ctype_name}";
             if ($c_foodtype !== "N/A") {
                 $message .= "\r\n Vehicle Type: {$c_foodtype}";
             }
             $message .= "\r\n\r\nYour Login credentials ::\r\n Username: {$emailAddress}\r\n  Password: {$pass}\r\nPlease click on the link bellow to activate your accoutnt:{$url}.\r\n\r\nThis email was atomaticaly generated by the system";
             $this->email->set_newline("\r\n");
             $this->email->from($this->forwardemail, $this->nicename);
             $this->email->subject('Account registration request');
             $this->email->message($message);
             $this->email->to($emailAddress);
             if (!$this->email->send()) {
                 $data = array('reg_msg' => "Could not create company account. The email server is not responding. Please try again later or contact admin.");
                 $this->session->set_userdata($data);
                 redirect('manageCompanies');
             } else {
                 $resp = $this->c->add_company($c_foodtype);
                 if ($resp == TRUE) {
                     $filter = array('company_name' => $cmpny, 'company_code' => $company_code);
                     $rsp = $this->c->get_details($filter);
                     $c_id = $rsp[0]->company_id;
                     $affiliation = $rsp[0]->affiliation;
                     $details = array('usersFullnames' => $contact_person, 'userName' => $emailAddress, 'userEmail' => $emailAddress, 'company_id' => $c_id, 'userPassword' => md5($pass), 'userRights' => 1, 'user_role' => 1, 'activationcode' => $code, 'is_active' => 0);
                     //add_company
                     $data = array('reg_msg' => "Company and default user created. Login credentials sent to {$emailAddress}.");
                     $this->users->add_user($details);
                     $this->session->set_userdata($data);
                     redirect('manageCompanies');
                 }
             }
         } else {
             $resp = $this->c->update_dets($c_foodtype, $id);
             if ($resp == TRUE) {
                 redirect('manageCompanies');
             }
         }
     }
 }
Пример #3
0
 function register()
 {
     $this->is_user_allowed();
     $names = trim($this->input->get_post('names', TRUE));
     $uname = $userEmail = trim($this->input->get_post('userEmail', TRUE));
     $rights = trim($this->input->get_post('rights', TRUE));
     $roles = trim($this->input->get_post('rights', TRUE));
     //3;//trim($this->input->get_post('roles',TRUE));
     $pass = genBigcode(8);
     $uname = $ctype . "USR" . gencode(4);
     $filter = array('userName' => $uname);
     $cde = count($this->users->get_details($filter));
     while ($cde > 0) {
         //.date('Y')
         $uname = $ctype . "USR" . gencode(4);
         $filter = array('userName' => $uname);
         $cde = count($this->users->get_details($filter));
     }
     $filter = array('userEmail' => $userEmail, 'company_id' => $this->session->userdata('companyID'));
     // print_r($filter);
     //die();
     $count = count($this->users->get_details($filter));
     //print_r($count);
     //die();
     // $count=0;
     if ($count == 0) {
         $code = genBigcode(6);
         $filter = array('activationcode' => $code);
         $cde = count($this->users->get_details($filter));
         while ($cde > 0) {
             $code = genBigcode(6);
             $filter = array('activationcode' => $code);
             $cde = count($this->users->get_details($filter));
         }
         $url = site_url() . "activate/{$code}";
         $message = "Dear {$names},\r\nYou have been added as a user....... Your Login credentials are:\r\n Username: {$userEmail}\r\n  Password: {$pass}\r\nPlease click on the link bellow to activate your accoutnt:{$url}.\r\n\r\nThis email was atomaticaly generated by the system";
         $this->email->set_newline("\r\n");
         $this->email->from($this->forwardemail, $this->nicename);
         $this->email->subject('Account registration request');
         $this->email->message($message);
         $this->email->to($userEmail);
         if (!$this->email->send()) {
             $data = array('reg_msg' => "Could not create user account. The email server is not responding. Please try again later or contact admin.");
             $this->session->set_userdata($data);
             // echo "server error";
             // die();
             redirect('manageUsers');
         } else {
             // echo "adding user";
             //  die();
             $this->users->add($pass, $code, $uname);
             $data = array('reg_msg' => "User created and login credentials sent to {$userEmail}.");
             $this->session->set_userdata($data);
             redirect('manageUsers');
         }
     } else {
         // echo "user exists";
         //	  die();
         $data = array('reg_msg' => "An account with the email adddress: {$userEmail} already exists in our database.");
         $this->session->set_userdata($data);
         redirect('manageUsers');
     }
 }