コード例 #1
0
ファイル: files.php プロジェクト: somov/test_app_itm_ee
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');
コード例 #2
0
ファイル: signup.php プロジェクト: somov/test_app_itm_ee
<?php

require_once 'protect/init.php';
use protect\classes\App;
use protect\classes\models\UserModel;
/*if exists uploadImage render  render json image info */
if (isset($_POST['uploadImage'])) {
    $image = new \protect\classes\UploadedFile('image');
    echo json_encode($image->toArray());
    die;
}
$model = new UserModel();
if (isset($_POST['UserModel'])) {
    $model->setAttributes($_POST['UserModel'], App::isAjaxRequest());
    if (App::isAjaxRequest()) {
        echo json_encode($model->getError());
        die;
    }
    if ($model->save()) {
        App::setFlash('User successfully registered. You can sign.', 'success', '/index');
    } else {
        App::setFlash('Please correct the following errors', 'danger');
    }
}
App::smarty()->assign('model', $model)->display('signup.tpl');
コード例 #3
0
ファイル: error.php プロジェクト: somov/test_app_itm_ee
<?php

use protect\classes\App;
require_once 'protect/init.php';
$errorCode = isset($_GET['e']) && is_numeric($_GET['e']) ? $_GET['e'] : 0;
$error = array('code' => $errorCode);
switch ($errorCode) {
    case 0:
        $error['message'] = _("Unexpected error. Please contact webmaster.");
        break;
    case 404:
        $error['message'] = _("Unable to process your request. Not found.");
        break;
}
App::smarty()->assign('error', $error);
App::smarty()->display('error.tpl');
コード例 #4
0
<?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');
コード例 #5
0
ファイル: login.php プロジェクト: somov/test_app_itm_ee
<?php

use protect\classes\App;
use protect\classes\models\UserModel;
use protect\classes\Redirect;
/**
 * @var UserModel $user
 */
require_once 'protect/init.php';
if (isset($_POST['inputName'])) {
    $user = UserModel::model()->findByAttributes(array('loginname' => $_POST['inputName'], 'email' => $_POST['inputName']), array('operator' => 'OR'));
    #Значит пользователь не найден
    #Means user not found
    $error = !$user;
    $error = $error ? true : strcmp($user->password, md5($_POST['inputPassword'])) !== 0;
    if ($error) {
        App::smarty()->assign('login_error', _('Invalid password or UserName'));
    } else {
        App::setFlash('Welcome ' . $user->username);
        $_SESSION['userid'] = $user->userid;
        if (isset($_POST['inputRememberMe'])) {
            setcookie('token', $user->getRememberMeToken(), time() + 60 * 60 * 24 * 30);
        }
        Redirect::go('/');
    }
}
App::smarty()->display('login.tpl');
コード例 #6
0
ファイル: upload.php プロジェクト: somov/test_app_itm_ee
<?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');
コード例 #7
0
ファイル: index.php プロジェクト: somov/test_app_itm_ee
<?php

use protect\classes\App;
require_once 'protect/init.php';
if (!App::user()) {
    App::smarty()->display('main.tpl');
} else {
    App::smarty()->display('userinfo.tpl');
}