Esempio n. 1
0
 /**
  * delete
  *
  * @return \Phalcon\Http\ResponseInterface
  */
 public function deleteAction()
 {
     $hash_id = $this->request->get('id', 'string', '');
     $res_file = ResFile::findFirst(['hash_id = :hash_id: and user_id = :user_id:', 'bind' => ['hash_id' => $hash_id, 'user_id' => $this->current_user->id]]);
     if ($res_file) {
         Filesystem::delete(public_path() . '/' . $res_file->path);
         $res_file->delete();
         // active
         UserActive::record('file-delete', $this->current_user->id);
     }
     return $this->response->redirect('file/lists');
 }
Esempio n. 2
0
 protected function execute(array $arguments)
 {
     if (isset($arguments[0])) {
         if (strlen($arguments[0]) > 140) {
             throw new InvalidArgumentException('String too long');
         }
         global $config;
         // dir
         $qr_dir = 'temp/qr/' . date('Y/m/d');
         $qr_abs_dir = public_path() . '/' . $qr_dir;
         if (!Filesystem::isDirectory($qr_dir)) {
             Filesystem::makeDirectory($qr_dir, 0755, true);
         }
         $qr_file_name = md5('qr-code' . $arguments[0]) . '.png';
         $qr_path = $qr_abs_dir . '/' . $qr_file_name;
         // QR
         $qrCode = new \Endroid\QrCode\QrCode();
         $qrCode->setText($arguments[0])->setSize(300)->setPadding(10)->setErrorCorrection('high')->setForegroundColor(array('r' => 0, 'g' => 0, 'b' => 0, 'a' => 0))->setBackgroundColor(array('r' => 255, 'g' => 255, 'b' => 255, 'a' => 0))->save($qr_path);
         return $config->application->domain . '/' . $qr_dir . '/' . $qr_file_name;
     }
     throw new InvalidArgumentException('strings invalid');
 }
Esempio n. 3
0
 /**
  * var
  */
 public function varAction()
 {
     $hash_id = $this->request->get('pk', 'string', '');
     $name = $this->request->get('name', 'string', '');
     $value = $this->request->get('value', 'string', '');
     $type = $this->request->get('type', 'string', 'add/edit');
     $workflow = $this->workflow->findFirst($hash_id, $this->current_user->id);
     if ($workflow) {
         $var = WorkflowVar::findFirst(['wf_id = :wf_id: and name = :name:', 'bind' => ['wf_id' => $workflow->id, 'name' => $name]]);
         if ($type == 'del') {
             // 删除文件
             if (stristr($var->value, $this->config->application->domain . '/temp/var/') !== false) {
                 $path = str_replace($this->config->application->domain, '', $var->value);
                 Filesystem::delete(public_path() . $path);
             }
             $var->delete();
             return $this->ajaxResponse(0);
         }
         if (!$var) {
             $var = new WorkflowVar();
             $var->wf_id = $workflow->id;
         }
         $var->name = $name;
         $var->value = $value;
         $var->save();
         $error = 0;
     } else {
         $error = 1;
     }
     return $this->ajaxResponse($error);
 }