예제 #1
0
 public static function suggestUserName($username, XenForo_Model_User $userModel)
 {
     if (preg_match('#[^0-9]([0-9]+)$#', $username, $matches, PREG_OFFSET_CAPTURE)) {
         $i = $matches[1][0];
         $origName = trim(substr($username, 0, $matches[1][1]));
     } else {
         $i = 2;
         $origName = $username;
     }
     while ($userModel->getUserByName($username)) {
         $username = $origName . ' ' . $i++;
     }
     return $username;
 }
예제 #2
0
<?php

if ($slug == "handleUpload") {
    $pluginUsername = $params[0];
    $u = new XenForo_Model_User();
    $pluginUserID = $u->getUserIdFromUser($u->getUserByName($pluginUsername));
    $pluginName = $params[1];
    $dbQuery = Database::select('plugins', 'pid', array('pname = ? AND pauthor_id = ?', $pluginName, $pluginUserID));
    $pluginID = $dbQuery->fetchColumn();
    if ((User::$role == User::ROLE_GUEST || User::$uid != $pluginUserID) && User::$role != User::ROLE_ADMIN) {
        $httpError = 403;
    } else {
        if ($dbQuery->rowCount() != 1) {
            $httpError = 404;
        } else {
            // okay, let's do this
            // get down on it
            $tempFile = $_FILES['Filedata']['tmp_name'];
            $fileMd5 = md5_file($tempFile);
            $newFileName = $fileMd5;
            $fileDir = '/home2/bukkit/fill/uploads/';
            if (file_exists($fileDir . $newFileName)) {
                echo 'File exists';
                exit;
            }
            $a = Database::select('plugin_downloads', '*', array('dfname = ?', $_FILES['Filedata']['name']));
            $lastNum = 0;
            if ($a->rowCount() == 0) {
                Database::insert('plugin_downloads', array('pid' => $pluginID, 'dfname' => $_FILES['Filedata']['name'], 'dfriendlyname' => 'notdoneyet', 'ddesc' => 'notdoneyet'));
                $a = Database::select('plugin_downloads', '*', array('dfname = ?', $_FILES['Filedata']['name']));
                $pluginFileRow = $a->fetch(PDO::FETCH_ASSOC);