Example #1
0
 public function delete($id = null)
 {
     $user = Session::read('member');
     if ($user == "") {
         return $this->redirect('/');
     }
     $remove = File::remove('all', array('conditions' => array('documents_doc_id' => (string) $id)));
     $remove = Documents::remove('all', array('conditions' => array('_id' => (string) $id)));
     return $this->redirect('ex::dashboard');
 }
Example #2
0
 public function settings($option = null)
 {
     $title = "User settings";
     $ga = new GoogleAuthenticator();
     $user = Session::read('default');
     if ($user == "") {
         return $this->redirect('/login');
     }
     $id = $user['_id'];
     $details = Details::find('first', array('conditions' => array('user_id' => (string) $id)));
     $uploadOk = 1;
     $qrCodeUrl = $ga->getQRCodeGoogleUrl(COMPANY_URL . "-" . $details['username'], $details['secret']);
     if ($this->request->data) {
         $imageFileType = pathinfo($this->request->data['file']['name'], PATHINFO_EXTENSION);
         if ($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" && $imageFileType != "gif") {
             $msg = "Sorry, only JPG, JPEG, PNG & GIF files are allowed.";
             $uploadOk = 0;
             return $this->redirect('Users::settings', compact('msg'));
         }
         if ($uploadOk = 1) {
             $option = $this->request->data['option'];
             $data = array($option => $this->request->data['file'], $option . '.verified' => 'No');
             $field = 'details_' . $option . '_id';
             $remove = File::remove('all', array('conditions' => array($field => (string) $details->_id)));
             $fileData = array('file' => $this->request->data['file'], 'details_' . $option . '_id' => (string) $details->_id);
             $details = Details::find('first', array('conditions' => array('user_id' => (string) $id)))->save($data);
             $file = File::create();
             if ($file->save($fileData)) {
                 $this->redirect('ex::dashboard');
             }
         }
         $TOTP = $details['TOTP.Validate'];
         $secret = $details['secret'];
     }
     $details = Details::find('first', array('conditions' => array('user_id' => (string) $id)));
     $image_address = File::find('first', array('conditions' => array('details_address_id' => (string) $details['_id'])));
     if ($image_address['filename'] != "") {
         $imagename_address = $image_address['_id'] . '_' . $image_address['filename'];
         $path = LITHIUM_APP_PATH . '/webroot/documents/' . $imagename_address;
         file_put_contents($path, $image_address->file->getBytes());
     }
     $image_government = File::find('first', array('conditions' => array('details_government_id' => (string) $details['_id'])));
     if ($image_government['filename'] != "") {
         $imagename_government = $image_government['_id'] . '_' . $image_government['filename'];
         $path = LITHIUM_APP_PATH . '/webroot/documents/' . $imagename_government;
         file_put_contents($path, $image_government->file->getBytes());
     }
     $image_bank = File::find('first', array('conditions' => array('details_bank_id' => (string) $details['_id'])));
     if ($image_bank['filename'] != "") {
         $imagename_bank = $image_bank['_id'] . '_' . $image_bank['filename'];
         $path = LITHIUM_APP_PATH . '/webroot/documents/' . $imagename_bank;
         file_put_contents($path, $image_bank->file->getBytes());
     }
     $settings = Settings::find('first');
     return compact('details', 'user', 'title', 'qrCodeUrl', 'secret', 'option', 'imagename_address', 'imagename_government', 'imagename_bank', 'settings', 'msg');
 }
Example #3
0
 public function save()
 {
     //		print_r($this->request->data);
     if ($this->request->data) {
         $data = $this->request->data;
         $fileData = array('file' => $this->request->data['blob'], 'details_video_id' => (string) $data['video-id']);
         $field = 'details_video_id';
         $remove = File::remove('all', array('conditions' => array($field => (string) $data['video-id'])));
         Documents::find('first', array('conditions' => array('_id' => (string) $data['video-id'])))->save($data);
         $file = File::create();
         if ($file->save($fileData)) {
             $msg = "Upload OK";
         }
     }
     return $this->render(array('json' => array('success' => 0)));
 }
Example #4
0
 public function companyupload($id = null, $type = "corporation")
 {
     $company = Companies::find('first', array('conditions' => array('hash' => $id)));
     if (count($company) == 0) {
         return $this->redirect('kyc::index');
     }
     $uploadOk = 1;
     if ($this->request->data) {
         $extension = pathinfo($this->request->data['file']['name'], PATHINFO_EXTENSION);
         $allowed = array('jpg', 'jpeg', 'png', 'gif');
         if (!in_array(strtolower($extension), $allowed)) {
             $msg = "Sorry, only JPG, PNG, GIF file is allowed.";
             $uploadOk = 0;
         }
         if (strtolower($extension) == 'pdf') {
             $msg = "Please do not upload PDF file.";
             $uploadOk = 0;
         }
         $size = round($this->request->data['file']['size'] / 1024 / 1024, 2);
         if ($size >= 10) {
             $msg = "Sorry, File too large, should be less than 10 MB. It is " . $size . "MB!";
             $uploadOk = 0;
         }
         if ($uploadOk == 1) {
             $option = $this->request->data['option'];
             $data = array($option => $this->request->data['file'], $option . '.verified' => 'No', $option . '.IP' => $_SERVER['REMOTE_ADDR']);
             $field = 'details_' . $option . '_id';
             $remove = File::remove('all', array('conditions' => array($field => (string) $company['_id'])));
             $path = LITHIUM_APP_PATH . '\\webroot\\documents\\';
             $resizedFile = $path . $this->request->data['file']['name'];
             $resizedFileServer = 'https://' . $_SERVER['SERVER_NAME'] . '/documents/' . $this->request->data['file']['name'];
             $resize = $this->smart_resize_image($this->request->data['file']['tmp_name'], null, 1024, 0, true, $resizedFile, false, false, 100);
             if ($resize == false) {
                 $msg = "File format different, cannot verify.";
                 $uploadOk = 0;
             }
             $fileData = array('file' => file_get_contents($resizedFile), 'filename' => $this->request->data['file']['name'], 'metadata' => array('filename' => $this->request->data['file']['name']), 'details_' . $option . '_id' => (string) $document['_id']);
             Companies::find('first', array('conditions' => array('_id' => (string) $company['_id'])))->save($data);
             $file = File::create();
             if ($file->save($fileData)) {
                 $msg = "Upload OK";
             }
             unlink($resizedFile);
         }
     }
     $image_corporation = File::find('first', array('conditions' => array('details_corporation_id' => (string) $company['_id'])));
     if ($image_corporation['filename'] != "") {
         $imagename_corporation = $image_corporation['_id'] . '_' . $image_corporation['filename'];
         $path = LITHIUM_APP_PATH . '/webroot/documents/' . $imagename_corporation;
         file_put_contents($path, $image_corporation->file->getBytes());
     }
     $image_articles = File::find('first', array('conditions' => array('details_articles_id' => (string) $company['_id'])));
     if ($image_articles['filename'] != "") {
         $imagename_articles = $image_articles['_id'] . '_' . $image_articles['filename'];
         $path = LITHIUM_APP_PATH . '/webroot/documents/' . $imagename_articles;
         file_put_contents($path, $image_articles->file->getBytes());
     }
     $image_resolution = File::find('first', array('conditions' => array('details_resolution_id' => (string) $company['_id'])));
     if ($image_resolution['filename'] != "") {
         $imagename_resolution = $image_resolution['_id'] . '_' . $image_resolution['filename'];
         $path = LITHIUM_APP_PATH . '/webroot/documents/' . $imagename_resolution;
         file_put_contents($path, $image_resolution->file->getBytes());
     }
     $image_directors = File::find('first', array('conditions' => array('details_directors_id' => (string) $company['_id'])));
     if ($image_directors['filename'] != "") {
         $imagename_directors = $image_directors['_id'] . '_' . $image_directors['filename'];
         $path = LITHIUM_APP_PATH . '/webroot/documents/' . $imagename_directors;
         file_put_contents($path, $image_directors->file->getBytes());
     }
     return compact('company', 'countries', 'imagename_corporation', 'imagename_articles', 'imagename_resolution', 'imagename_directors', 'msg', 'type');
 }