public function indexAction() { $token = $_GET['file_token']; if (preg_match('/^([A-Z0-9a-z]{7})$/i', $token) == false) { App_Headers::redirect(array()); } $query = "SELECT * FROM `uploads` WHERE `token` = '{$token}'"; $result = App_Db::getInstance()->getConn()->query($query); $imageModel = $result->fetchObject(); if (empty($imageModel) || !empty($imageModel) && $imageModel->is_deleted) { return null; } $time = date('Y-m-d H:i:s'); $query = "UPDATE `uploads` SET `is_deleted` = '1',`time_open`='{$time}' WHERE id = '{$imageModel->id}'"; $result = App_Db::getInstance()->getConn()->query($query); $imageData = base64_encode(file_get_contents($imageModel->src)); $src = 'data: ' . $this->getMimeType($imageModel->src) . ';base64,' . $imageData; self::delete($imageModel->src); $this->_view->image_src = $src; }
public function redirect(array $data, $absolute = false) { App_Headers::redirect($data, $absolute); }
public function returnJson() { $this->response->token = App_CSRFUtil::getInstance()->getToken(true); App_Headers::JSON(); echo json_encode($this->response); }