1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
* You may not change or alter any portion of this comment or credits |
4
|
|
|
* of supporting developers from this source code or any supporting source code |
5
|
|
|
* which is considered copyrighted (c) material of the original comment or credit authors. |
6
|
|
|
* |
7
|
|
|
* This program is distributed in the hope that it will be useful, |
8
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
9
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* SmallWorld |
14
|
|
|
* |
15
|
|
|
* @package \XoopsModules\Smallworld |
16
|
|
|
* @license GNU GPL (https://www.gnu.org/licenses/gpl-2.0.html/) |
17
|
|
|
* @copyright The XOOPS Project (https://xoops.org) |
18
|
|
|
* @copyright 2011 Culex |
19
|
|
|
* @author Michael Albertsen (http://culex.dk) <[email protected]> |
20
|
|
|
* @link https://github.com/XoopsModules25x/smallworld |
21
|
|
|
* @since 1.0 |
22
|
|
|
*/ |
23
|
|
|
|
24
|
|
|
use XoopsModules\Smallworld; |
25
|
|
|
|
26
|
|
|
require_once __DIR__ . '/header.php'; |
27
|
|
|
|
28
|
|
|
/** @var \XoopsModules\Smallworld\Helper $helper */ |
29
|
|
|
require_once $helper->path('include/functions.php'); |
30
|
|
|
if ($GLOBALS['xoopsUser'] && ($GLOBALS['xoopsUser'] instanceof \XoopsUser)) { |
|
|
|
|
31
|
|
|
$prevLogStat = $GLOBALS['xoopsLogger']->activated; |
32
|
|
|
$GLOBALS['xoopsLogger']->activated = false; |
33
|
|
|
$userID = $GLOBALS['xoopsUser']->getVar('uid'); |
34
|
|
|
$swDB = new Smallworld\SwDatabase(); |
35
|
|
|
|
36
|
|
|
$uploaddir = XOOPS_ROOT_PATH . '/uploads/avatars/'; |
37
|
|
|
//$file = $uploaddir . basename($_FILES['smallworld_uploadfile']['name']); |
38
|
|
|
|
39
|
|
|
// Generate new name for file |
40
|
|
|
$f = explode('.', basename(stripslashes($_FILES['smallworld_uploadfile']['name']))); |
41
|
|
|
$newname = time() . mt_rand(0000, 9999) . '.' . $f[1]; |
42
|
|
|
$newfile = $uploaddir . basename($newname); |
43
|
|
|
// Save new name to users profile in DB |
44
|
|
|
$dbuserimage = 'avatars/' . basename(stripslashes($newfile)); |
45
|
|
|
$swDB->updateSingleValue('smallworld_user', $userID, 'userimage', $dbuserimage); |
46
|
|
|
$swDB->updateSingleValue('smallworld_admin', $userID, 'userimage', $dbuserimage); |
47
|
|
|
|
48
|
|
|
// Return json array [0] = succes text and [1]= basename of the new file name... |
49
|
|
|
if (move_uploaded_file($_FILES['smallworld_uploadfile']['tmp_name'], $newfile)) { |
50
|
|
|
echo json_encode(['success', basename(stripslashes($newfile))]); |
51
|
|
|
} else { |
52
|
|
|
echo 'error'; |
53
|
|
|
} |
54
|
|
|
// now restore the logger |
55
|
|
|
//$GLOBALS['xoopsLogger']->activated = $prevLogStat; |
56
|
|
|
} |
57
|
|
|
|
This error could be the result of:
1. Missing dependencies
PHP Analyzer uses your
composer.json
file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects thecomposer.json
to be in the root folder of your repository.Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the
require
orrequire-dev
section?2. Missing use statement
PHP does not complain about undefined classes in
ìnstanceof
checks. For example, the following PHP code will work perfectly fine:If you have not tested against this specific condition, such errors might go unnoticed.