| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 |
|
|---|
| 25 |
|
|---|
| 26 |
require_once('../includes/config/settings.php'); |
|---|
| 27 |
|
|---|
| 28 |
|
|---|
| 29 |
function __autoload($class) { |
|---|
| 30 |
global $SETTINGS; |
|---|
| 31 |
if (is_file($SETTINGS['fspath'] . 'classes/pages/' . $class . '.php')) { |
|---|
| 32 |
require_once($SETTINGS['fspath'] . 'classes/pages/' . $class . '.php'); |
|---|
| 33 |
} elseif (is_file($SETTINGS['fspath'] . 'classes/misc/' . $class . '.php')) { |
|---|
| 34 |
require_once($SETTINGS['fspath'] . 'classes/misc/' . $class . '.php'); |
|---|
| 35 |
} else { die('Class ' . $class . ' not found.'); } |
|---|
| 36 |
} |
|---|
| 37 |
|
|---|
| 38 |
|
|---|
| 39 |
$WARNINGS = Array(); |
|---|
| 40 |
|
|---|
| 41 |
|
|---|
| 42 |
require_once($SETTINGS['fspath'] . 'includes/config/version.php'); |
|---|
| 43 |
|
|---|
| 44 |
require_once($SETTINGS['fspath'] . 'includes/config/bots.php'); |
|---|
| 45 |
|
|---|
| 46 |
$F = new Format(); |
|---|
| 47 |
require($SETTINGS['fspath'] . 'includes/lang/' . $SETTINGS['language'] . '.php'); |
|---|
| 48 |
|
|---|
| 49 |
$C = new Connection(); |
|---|
| 50 |
Member::session(); |
|---|
| 51 |
if (isset($_SESSION['lang']) && $_SESSION['lang'] != '') { |
|---|
| 52 |
include($SETTINGS['fspath'] . 'includes/lang/' . $_SESSION['lang'] . '.php'); |
|---|
| 53 |
} |
|---|
| 54 |
|
|---|
| 55 |
require($SETTINGS['fspath'] . 'includes/input.php'); |
|---|
| 56 |
|
|---|
| 57 |
|
|---|
| 58 |
$_pref = '../'; |
|---|
| 59 |
$html = Page::start(); |
|---|
| 60 |
|
|---|
| 61 |
if (isset($INPUT['commit']) && $INPUT['commit'] == 'y') { |
|---|
| 62 |
|
|---|
| 63 |
// check if user has permission; required: write; independent from id |
|---|
| 64 |
if (Member::checkRights('Uploadavatar', 'w')) { |
|---|
| 65 |
|
|---|
| 66 |
if (is_array($_FILES['avatarfile']) && is_uploaded_file($_FILES['avatarfile']['tmp_name'])) { |
|---|
| 67 |
|
|---|
| 68 |
if ($_FILES['avatarfile']['size'] <= 512000) { |
|---|
| 69 |
|
|---|
| 70 |
if (in_array($_FILES['avatarfile']['type'], Array('image/gif', 'image/png', 'image/jpg', 'image/jpeg'))) { |
|---|
| 71 |
|
|---|
| 72 |
$_size = @getimagesize($_FILES['avatarfile']['tmp_name']); |
|---|
| 73 |
if ($_size[2] <= 3 && $_size[2] >= 1) { |
|---|
| 74 |
|
|---|
| 75 |
if ($_size[0] <= 100 && $_size[1] <= 100) { |
|---|
| 76 |
|
|---|
| 77 |
$_FILES['avatarfile']['name'] = preg_replace('/[^0-9a-zA-Z\.\/_\-]/', '_', $_FILES['avatarfile']['name']); |
|---|
| 78 |
|
|---|
| 79 |
$_found = 0; |
|---|
| 80 |
if ($handle = @opendir($SETTINGS['fspath'] . 'images/avatars')) { |
|---|
| 81 |
while (($file = @readdir($handle)) !== FALSE) { |
|---|
| 82 |
if ($file == $_FILES['avatarfile']['name']) { |
|---|
| 83 |
$_found = 1; |
|---|
| 84 |
} |
|---|
| 85 |
} |
|---|
| 86 |
closedir($handle); |
|---|
| 87 |
} |
|---|
| 88 |
if ($_found === 0) { |
|---|
| 89 |
|
|---|
| 90 |
if (@move_uploaded_file($_FILES['avatarfile']['tmp_name'], $SETTINGS['fspath'] . 'images/avatars/' . $_FILES['avatarfile']['name'])) { |
|---|
| 91 |
|
|---|
| 92 |
$div = $html->body->addChild('div', $LANG['upload_avatar_success']); |
|---|
| 93 |
$div->addAttribute('class', 'message'); |
|---|
| 94 |
} else { |
|---|
| 95 |
|
|---|
| 96 |
$div = $html->body->addChild('div', $LANG['error_avatar_move']); |
|---|
| 97 |
$div->addAttribute('class', 'message'); |
|---|
| 98 |
} |
|---|
| 99 |
} else { |
|---|
| 100 |
|
|---|
| 101 |
$div = $html->body->addChild('div', $LANG['error_avatar_filename']); |
|---|
| 102 |
$div->addAttribute('class', 'message'); |
|---|
| 103 |
} |
|---|
| 104 |
} else { |
|---|
| 105 |
|
|---|
| 106 |
$div = $html->body->addChild('div', $LANG['error_avatar_dimension']); |
|---|
| 107 |
$div->addAttribute('class', 'message'); |
|---|
| 108 |
} |
|---|
| 109 |
} else { |
|---|
| 110 |
|
|---|
| 111 |
$div = $html->body->addChild('div', $LANG['error_avatar_filetype']); |
|---|
| 112 |
$div->addAttribute('class', 'message'); |
|---|
| 113 |
} |
|---|
| 114 |
} else { |
|---|
| 115 |
|
|---|
| 116 |
$div = $html->body->addChild('div', $LANG['error_avatar_filetype']); |
|---|
| 117 |
$div->addAttribute('class', 'message'); |
|---|
| 118 |
} |
|---|
| 119 |
} else { |
|---|
| 120 |
|
|---|
| 121 |
$div = $html->body->addChild('div', $LANG['error_avatar_filesize']); |
|---|
| 122 |
$div->addAttribute('class', 'message'); |
|---|
| 123 |
} |
|---|
| 124 |
} else { |
|---|
| 125 |
|
|---|
| 126 |
$div = $html->body->addChild('div', $LANG['error_avatar_file_missing']); |
|---|
| 127 |
$div->addAttribute('class', 'message'); |
|---|
| 128 |
} |
|---|
| 129 |
} else { |
|---|
| 130 |
$div = $html->body->addChild('div', $LANG['error_permission_denied']); |
|---|
| 131 |
$div->addAttribute('class', 'message'); |
|---|
| 132 |
} |
|---|
| 133 |
} else { |
|---|
| 134 |
|
|---|
| 135 |
// check if user has permission; required: read; independent from id |
|---|
| 136 |
if (Member::checkRights('Uploadavatar', 'r')) { |
|---|
| 137 |
|
|---|
| 138 |
$html->body->addElement(new XMLElement($LANG['upload_avatar_hints'])); |
|---|
| 139 |
$form = new Form($_SERVER['PHP_SELF'], 'uploadform', 'multipart/form-data'); |
|---|
| 140 |
$form->addInput('hidden', 'commit', 'y'); |
|---|
| 141 |
$form->addInput('hidden', 'MAX_FILE_SIZE', '51200'); |
|---|
| 142 |
$form->addInput('file', 'avatarfile'); |
|---|
| 143 |
$form->addChild('br'); |
|---|
| 144 |
$form->addChild('br'); |
|---|
| 145 |
$form->addInput('reset', 'reset', $LANG['Reset']); |
|---|
| 146 |
$form->addInput('submit', 'submit', $LANG['Submit']); |
|---|
| 147 |
$html->body->addElement($form->get()); |
|---|
| 148 |
} else { |
|---|
| 149 |
$div = $html->body->addChild('div', $LANG['error_permission_denied']); |
|---|
| 150 |
$div->addAttribute('class', 'message'); |
|---|
| 151 |
} |
|---|
| 152 |
} |
|---|
| 153 |
|
|---|
| 154 |
$html->body->addChild('br'); |
|---|
| 155 |
$html->body->addChild('br'); |
|---|
| 156 |
$div = $html->body->addChild('div'); |
|---|
| 157 |
$div->addAttribute('align', 'center'); |
|---|
| 158 |
$a = $div->addChild('a', $LANG['Close_Window']); |
|---|
| 159 |
$a->addAttribute('href', 'javascript:self.close()'); |
|---|
| 160 |
|
|---|
| 161 |
|
|---|
| 162 |
Page::send($html); |
|---|
| 163 |
|
|---|
| 164 |
?> |
|---|