/** * @return \Phalcon\Http\ResponseInterface */ public function processAction() { if ($this->request->isPost()) { $content = $this->request->get('content'); $format_type = $this->request->get('format_type', 'string', ''); $tags = $this->request->get('tags', 'string', ''); if ($content & $format_type) { if ($hash_id = $this->request->get('id', 'string', '')) { $text = ResText::findFirst(['hash_id = :hash_id: and user_id = :user_id:', 'bind' => ['hash_id' => $hash_id, 'user_id' => $this->current_user->id]]); $text->content = $content; $text->tags = $tags; $text->save(); // active UserActive::record('text-edit', $this->current_user->id); } else { $text = new ResText(); $text->hash_id = strtolower(Str::random()); $text->user_id = $this->current_user->id; $text->content = $content; $text->format_type = $format_type; $text->tags = $tags; $text->create(); // active UserActive::record('text-create', $this->current_user->id); } } } return $this->response->redirect('text/lists'); }
protected function execute(array $arguments) { if (isset($arguments[0]) && Str::isUrl($arguments[0]) && ($wf_id = (int) $GLOBALS['workflow_id'])) { WorkflowRepository::component_result($wf_id, 'image-view', $arguments[0]); return ''; } throw new InvalidArgumentException('strings invalid'); }
/** * @return \Phalcon\Http\ResponseInterface */ public function processAction() { if ($this->request->isPost() && $this->request->isAjax()) { $title = $this->request->get('title'); $code = $this->request->get('code'); if ($code && $title) { if ($hash_id = $this->request->get('id', 'string', '')) { $workflow = $this->workflow->findFirst($hash_id, $this->current_user->id); $workflow->title = $title; $workflow->code_snippets = $code; $result = $workflow->save(); // active UserActive::record('workflow-edit', $this->current_user->id); } else { $workflow = new Workflow(); $workflow->hash_id = strtolower(Str::random()); $workflow->user_id = $this->current_user->id; $workflow->title = $title; $workflow->code_snippets = $code; $workflow->enabled = 1; $workflow->state = 1; $result = $workflow->create(); // active UserActive::record('workflow-save', $this->current_user->id); } $variable = $this->request->get('variable'); foreach ($variable as $name => $value) { $var = WorkflowVar::findFirst(['wf_id = :wf_id: and name = :name:', 'bind' => ['wf_id' => $workflow->id, 'name' => $name]]); if ($var) { $var->delete(); } $var = new WorkflowVar(); $var->wf_id = $workflow->id; $var->name = $name; $var->value = $value; $var->save(); } $error = $result ? 0 : 1; } else { $error = 2; } } else { $error = 3; } return $this->ajaxResponse($error); }
protected function execute(array $arguments) { if (isset($arguments[0]) && Str::isUrl($arguments[0])) { global $di, $config; $check = $di->get('db')->prepare('SELECT * FROM fun_short_url WHERE url=? LIMIT 1'); $check->execute([$arguments[0]]); $url = $check->fetch(); if ($url) { $flag = $url['hash_id']; } else { $flag = Str::random(8); $insert = $di->get('db')->prepare('INSERT INTO fun_short_url (hash_id, url) VALUES (?, ?)'); $insert->execute([$flag, $arguments[0]]); } return $config->application->domain . '/url/' . $flag; } throw new InvalidArgumentException('strings invalid'); }
protected function execute(array $arguments) { if (isset($arguments[0]) && Str::isUrl($arguments[0])) { $url = 'error'; preg_match('/\\/url\\/([a-zA-Z]+)$/', $arguments[0], $flag); if (isset($flag[1])) { global $di; $check = $di->get('db')->prepare('SELECT * FROM fun_short_url WHERE hash_id=? LIMIT 1'); $check->execute([$flag[1]]); $url_res = $check->fetch(); if ($url_res) { $url = $url_res['url']; } } return $url; } throw new InvalidArgumentException('strings invalid'); }
/** * upload */ public function uploadAction() { if ($this->request->isPost()) { $upload_handler = new \Workflow\Utils\UploadHandler(['accept_file_types' => '/\\.(gif|jpe?g|png)$/i', 'script_url' => $this->config->application->domain, 'upload_dir' => public_path() . '/upload/image/' . date('Y/m/d/'), 'upload_url' => $this->config->application->domain . '/upload/image/' . date('Y/m/d/'), 'image_versions' => ['thumbnail' => ['max_width' => 320, 'max_height' => 320]]]); if ($response = $upload_handler->response) { foreach ($response['files'] as $file) { if (empty($file->error)) { $res_image = new ResImage(); $res_image->hash_id = strtolower(Str::random()); $res_image->user_id = $this->current_user->id; $res_image->path = str_replace($this->config->application->domain . '/', '', $file->url); $res_image->thumbnail_path = str_replace($this->config->application->domain . '/', '', $file->thumbnailUrl); $res_image->create(); // active UserActive::record('image-upload', $this->current_user->id); } } } } }
/** * upload */ public function uploadAction() { if ($this->request->isPost()) { $upload_handler = new \Workflow\Utils\UploadHandler(['accept_file_types' => '/\\.(pdf|doc|txt|xls|csv|md)$/i', 'script_url' => $this->config->application->domain, 'upload_dir' => public_path() . '/upload/file/' . date('Y/m/d/'), 'upload_url' => $this->config->application->domain . '/upload/file/' . date('Y/m/d/')]); if ($response = $upload_handler->response) { foreach ($response['files'] as $file) { if (empty($file->error)) { $res_file = new ResFile(); $res_file->hash_id = strtolower(Str::random()); $res_file->user_id = $this->current_user->id; $res_file->path = str_replace($this->config->application->domain . '/', '', $file->url); $res_file->type = $file->type; $res_file->create(); // active UserActive::record('file-upload', $this->current_user->id); } } } } }
public function testUrlParam() { $this->assertSame('s=http%3A%2F%2F&b=1', Str::urlParam(['s' => 'http://', 'b' => 1])); }
/** * shortcuts */ public function shortcutsAction() { if ($this->request->isPost()) { $name = $this->request->get('name'); $icon = $this->request->get('icon'); $path = $this->request->get('path'); if (empty($name) || empty($icon) || empty($path)) { return $this->ajaxResponse(1); } $shortcut = new Shortcut(); $shortcut->hash_id = strtoupper(Str::random()); $shortcut->user_id = $this->current_user->id; $shortcut->name = $name; $shortcut->icon = $icon; $shortcut->path = $path; $shortcut->create(); return $this->ajaxResponse(0); } $shortcut = Shortcut::find(["user_id = :user_id:", 'bind' => ['user_id' => $this->current_user->id]]); $this->view->setVar('shortcut', $shortcut); }