示例#1
0
 /**
  * 做一个login
  */
 public function login()
 {
     if (IS_AJAX && 'submit' == I('post.submit')) {
         //login 操作
         $username = I('post.username');
         $userpass = I('post.userpass');
         //表单令牌
         if (token_check() == false) {
             printJson(array('tk' => form_token()), 1, '请求超时,请重试');
         }
         $mod = Factory::getModel('bt_user');
         $where = sprintf("username='******' AND deleted=0", $username);
         $row = $mod->field('id,userpass,salt')->where($where)->find();
         if (empty($row)) {
             printJson(array('tk' => form_token()), 1, '账号不存在');
         }
         if ($row['userpass'] != md5($userpass . $row['salt'])) {
             printJson(array('tk' => form_token()), 1, '账号或者密码不正确');
         }
         $row['username'] = $username;
         session_regenerate_id();
         $user_cls = load_class('UserModel');
         $user_cls->setSessionUser($row);
         printJson(1);
     }
     $turl = urldecode(I('get.url', url('DiskTop', 'index')));
     $this->assign('turl', $turl);
     $this->display();
 }
 public function _initialize()
 {
     /* 检测需要验证 user_id,auth_token 的节点*/
     $check = str_replace('_', '', strtolower(CONTROLLER_NAME)) . '/' . ACTION_NAME;
     if (in_array_case($check, C('AUTH_TOKEN_CHECK'))) {
         token_check();
     }
 }
示例#3
0
文件: pafm.php 项目: net32/pafm
        case 'copy':
            token_check();
            exit(doCopy($subject, $path));
        case 'move':
            token_check();
            exit(doMove($subject, $path));
        case 'moveList':
            exit(moveList($subject, $path, $to));
        case 'installCodeMirror':
            exit(installCodeMirror());
        case 'fileExists':
            exit(file_exists($path . '/' . $subject));
        case 'getfs':
            exit(getFs($path . '/' . $subject));
        case 'remoteCopy':
            token_check();
            exit(doRemoteCopy($path));
    }
}
$_SESSION['token'] = $token;
$_SESSION['token_time'] = time();
/** no action; list current directory **/
getDirContents($path);
// helper functions
function isNull()
{
    foreach (func_get_args() as $value) {
        if (!strlen($value)) {
            return true;
        }
    }
示例#4
0
文件: index.php 项目: book000/mcmn
function admin_delete_directory()
{
    //パラメータ検証
    if (!isset($_GET['path']) or !preg_match('/' . PATH_CHARACTER . '/', $_GET['path']) or preg_match('/\\.\\.\\//', $_GET['path'])) {
        $_GET['path'] = null;
    }
    if (!isset($_GET['name']) or !preg_match('/' . PATH_CHARACTER . '/', $_GET['name']) or preg_match('/\\.\\.\\//', $_GET['name'])) {
        $_GET['name'] = null;
    }
    if (isset($_POST['exec']) and $_POST['exec'] == 'delete_directory') {
        //ワンタイムトークン比較
        if (!token_check()) {
            error('不正なアクセスです。');
        }
        //入力データ検証
        if ($_POST['path'] != '' and !preg_match('/' . PATH_CHARACTER . '/', $_POST['path'])) {
            error('パスは半角英数字で入力してください。');
        } elseif (preg_match('/\\.\\.\\//', $_GET['path'])) {
            error('パスの入力内容が不正です。');
        }
        if ($_POST['name'] == '') {
            error('ディレクトリ名が入力されていません。');
        } elseif (!preg_match('/' . PATH_CHARACTER . '/', $_POST['name'])) {
            error('ディレクトリ名は半角英数字で入力してください。');
        } elseif (preg_match('/\\.\\.\\//', $_GET['name'])) {
            error('ディレクトリ名の入力内容が不正です。');
        } elseif (mb_strlen($_POST['name'], 'UTF-8') > 255) {
            error('ディレクトリ名は255文字以内で入力してください。');
        }
        //ディレクトリ削除
        if (!remove_dir(TARGET_DIR . $_POST['path'] . $_POST['name'])) {
            error('ディレクトリ ' . TARGET_DIR . $_POST['path'] . $_POST['name'] . ' を削除できません。');
        }
        //リダイレクト
        header('Location: ' . HTTP_URL . MAIN_FILE . '?exec=' . $_POST['exec'] . '&path=' . str_replace('%2F', '/', urlencode($_POST['path'])));
        exit;
    }
    //ワンタイムトークン作成
    $token = token_create();
    //データ表示
    print_header(CSS_FILE);
    echo "<div id=\"menu\">\n";
    echo "<h2>MCMN Server メニュー</h2>\n";
    echo "<ul>\n";
    echo "<li><a href=\"" . HTTP_URL . MAIN_FILE . "\">戻る</a></li>\n";
    echo "</ul>\n";
    echo "</div>\n";
    echo "<h2>ディレクトリ削除</h2>\n";
    echo "<ul>\n";
    echo "<li>ディレクトリ <code>" . TARGET_DIR . $_GET['path'] . $_GET['name'] . "</code> を削除します。</li>\n";
    echo "</ul>\n";
    echo "<form action=\"" . HTTP_URL . MAIN_FILE . "?mode=delete_directory&amp;path=" . urlencode($_GET['path']) . "&amp;name=" . urlencode($_GET['name']) . "\" method=\"post\">\n";
    echo "<fieldset>\n";
    echo "<legend>ディレクトリ削除フォーム</legend>\n";
    echo "<input type=\"hidden\" name=\"token\" value=\"" . $token . "\" />\n";
    echo "<input type=\"hidden\" name=\"exec\" value=\"delete_directory\" />\n";
    echo "<input type=\"hidden\" name=\"path\" value=\"" . $_GET['path'] . "\" />\n";
    echo "<input type=\"hidden\" name=\"name\" value=\"" . $_GET['name'] . "\" />\n";
    echo "<p><input type=\"submit\" value=\"削除する\" /></p>\n";
    echo "</fieldset>\n";
    echo "</form>\n";
    print_footer();
    return;
}