} if (isset($_GET['fileid'])) { if (App::isAction('delete')) { $model = loadModel($_GET['fileid'], FileModel::SC_DELETE_ACTION); if ($model->save()) { App::user()->saveFilesCount(); App::setFlash('Deleted successfully', 'success', '/files/'); } } elseif (App::isAction('download')) { $model = loadModel($_GET['fileid']); if ($model->userid != App::user()->userid) { App::setFlash('Access denied', 'warning', '/files/'); } if (!file_exists($model->getFilePath())) { App::setFlash('Unexpected error. Please contact webmaster.', 'warning', '/files/'); } @ob_end_clean(); header('Content-Type: application/force-download'); header('Content-Disposition: attachment; filename="' . $model->upload_name . '"'); header('Content-Transfer-Encoding: binary'); header('Accept-Ranges: bytes'); header('Cache-control: private'); header('Pragma: private'); header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); header('Content-Length: ' . $model->size); readfile($model->getFilePath()); die; } } $files = FileModel::model()->findByAttributes(array('userid' => App::user()->userid, 'statusid' => FileModel::SC_STATUS_ACTIVE), array('limit' => 9999)); App::smarty()->assign('files', $files)->display('files.tpl');
<?php use protect\classes\App; require_once 'protect/init.php'; App::checkAccess(); $model = App::user(); if (isset($_POST['UserModel'])) { $model->setAttributes($_POST['UserModel'], App::isAjaxRequest()); if (App::isAjaxRequest()) { echo json_encode($model->getError()); die; } if ($model->save()) { App::setFlash('Successfully updated', 'success', '/index'); } else { App::setFlash('Please correct the following errors', 'danger'); } } App::smarty()->assign('model', $model)->display('edit_profile.tpl');
<?php use protect\classes\App; require_once 'protect/init.php'; if (isset($_SESSION['userid'])) { if (isset($_COOKIE['token'])) { unset($_COOKIE['token']); setcookie('token', null, -1); } unset($_SESSION['userid']); App::setFlash('Goodbye ' . App::user()->username, 'success', '/'); }
/** Set Uploaded object and fill attributes * @param $name */ public function setUploadedFile($name) { $this->_uploadedFile = new UploadedFile($name, $this); $a = $this->_uploadedFile->toArray(false); $this->setAttributes(array('userid' => App::user()->userid, 'upload_name' => $a['name'], 'extension' => $this->_uploadedFile->getFileExtension(), 'size' => $a['size'], 'mime_type' => $a['type']), true); }
<?php use protect\classes\App; use protect\classes\models\FileModel; require_once 'protect/init.php'; App::checkAccess(); if (App::user()->isUserFilesLimit()) { App::setFlash('Reached the limit of files', 'danger', '/files/'); } /** @var FileModel $model */ $model = new FileModel(); if (isset($_FILES['FileModel'])) { $model->setUploadedFile('file'); if ($model->save()) { App::user()->saveFilesCount(); App::setFlash('Uploaded successfully', 'success', '/files'); } else { App::setFlash($model->getErrorsAsString(), 'danger'); } } App::smarty()->assign('model', $model)->display('upload.tpl');
<?php use protect\classes\App; require_once 'protect/init.php'; if (!App::user()) { App::smarty()->display('main.tpl'); } else { App::smarty()->display('userinfo.tpl'); }