У меня возникла проблема, из-за которой я пытаюсь загрузить новый аватар в профиль своего сайта и возвращает следующее:
Не удалось загрузить ресурс: сервер ответил со статусом 500 (Внутренний серверОшибка)
Это видно при опросе действия над chrome с помощью опции inspect element.
Это влияет не только на это изображение, но и на все медиа загрузки на сайт.Мне удалось получить изображения обложки для загрузки, изменив разрешения для исходной папки хранения, чтобы включить чтение и запись, однако это не работает с другими носителями.Моей первой мыслью было, что, возможно, это произошло потому, что я пытаюсь добавить подпапку, в которой папка не работала, однако в случае с изображением обложки это по крайней мере сбрасывало тег в таблице sql.
В приложении указан код, в котором аватары упоминаются в файле, указанном в коде ошибки 500 из хрома.
Где может быть проблема ????
Спасибо всем
<?php
global $K;
$user = & $GLOBALS['user'];
$page = & $GLOBALS['page'];
$page->loadLanguage('global.php');
$page->loadLanguage('settings.php');
$designer = new designer();
if (!$user->is_logged) {
echo('ERROR:'.$page->lang('global_txt_no_session'));
return;
if ($ajax_action == 'removeavatar') {
$codeprofile = isset($_POST['copr']) ? (trim($_POST['copr'])) : '';
$codeprofile = $the_sanitaze->str_nohtml($codeprofile, 11);
$type_profile = isset($_POST['typr']) ? (trim($_POST['typr'])) : 0;
$type_profile = $the_sanitaze->int($type_profile);
if (!$error && empty($codeprofile)) { $error = TRUE; $txterror .= 'Error. '; }
if (!$error && $type_profile < 0) { $error = TRUE; $txterror .= 'Error'; }
}
if ($ajax_action == 'uploadavatar') {
$codeprofile = isset($_POST['code_profile']) ? (trim($_POST['code_profile'])) : '';
$codeprofile = $the_sanitaze->str_nohtml($codeprofile, 11);
$type_profile = isset($_POST['type_profile']) ? (trim($_POST['type_profile'])) : 0;
$type_profile = $the_sanitaze->int($type_profile);
$the_avatar = $_FILES['the_avatar_new'];
if (!is_uploaded_file($the_avatar['tmp_name'])) { $error = TRUE; $txterror .= 'Error. '; }
if (!$error && empty($codeprofile)) { $error = TRUE; $txterror .= 'Error. '; }
if (!$error && $type_profile < 0) { $error = TRUE; $txterror .= 'Error'; }
}
echo('OK');
return;
}
if ($ajax_action == 'removeavatar') {
switch ($type_profile) {
case 0:
$avatar_previous = $page->db2->fetch_field("SELECT avatar FROM users WHERE code='".$codeprofile."' LIMIT 1");
$page->db2->query("UPDATE users SET avatar='', avatar_media='' WHERE code='".$codeprofile."' LIMIT 1");
$space_avatar = '<img src="'.$K->STORAGE_URL_AVATARS.'min4/'.$K->DEFAULT_AVATAR_USER.'" id="the-photo-avatar">';
$ico_avatar_top = $K->STORAGE_URL_AVATARS.'min1/'.$K->DEFAULT_AVATAR_USER;
$json_result = array('space_avatar'=>$space_avatar, 'icoavatartop'=>$ico_avatar_top);
if (!empty($avatar_previous)) {
$the_file = $K->STORAGE_DIR_AVATARS.'min1/'.$codeprofile.'/'.$avatar_previous;
if (file_exists($the_file)) @unlink($the_file);
$the_file = $K->STORAGE_DIR_AVATARS.'min2/'.$codeprofile.'/'.$avatar_previous;
if (file_exists($the_file)) @unlink($the_file);
$the_file = $K->STORAGE_DIR_AVATARS.'min3/'.$codeprofile.'/'.$avatar_previous;
if (file_exists($the_file)) @unlink($the_file);
$the_file = $K->STORAGE_DIR_AVATARS.'min4/'.$codeprofile.'/'.$avatar_previous;
if (file_exists($the_file)) @unlink($the_file);
$the_file = $K->STORAGE_DIR_AVATARS.'originals/'.$codeprofile.'/'.$avatar_previous;
if (file_exists($the_file)) @unlink($the_file);
}
break;
case 1:
$avatar_previous = $page->db2->fetch_field("SELECT avatar FROM pages WHERE code='".$codeprofile."' LIMIT 1");
$page->db2->query("UPDATE pages SET avatar='', avatar_media='' WHERE code='".$codeprofile."' LIMIT 1");
$space_avatar = '<img src="'.$K->STORAGE_URL_AVATARS_PAGE.'min4/'.$K->DEFAULT_AVATAR_PAGE.'" id="the-photo-avatar">';
$json_result = array('space_avatar'=>$space_avatar);
if (!empty($avatar_previous)) {
$the_file = $K->STORAGE_DIR_AVATARS_PAGE.'min1/'.$codeprofile.'/'.$avatar_previous;
if (file_exists($the_file)) @unlink($the_file);
$the_file = $K->STORAGE_DIR_AVATARS_PAGE.'min2/'.$codeprofile.'/'.$avatar_previous;
if (file_exists($the_file)) @unlink($the_file);
$the_file = $K->STORAGE_DIR_AVATARS_PAGE.'min3/'.$codeprofile.'/'.$avatar_previous;
if (file_exists($the_file)) @unlink($the_file);
$the_file = $K->STORAGE_DIR_AVATARS_PAGE.'min4/'.$codeprofile.'/'.$avatar_previous;
if (file_exists($the_file)) @unlink($the_file);
$the_file = $K->STORAGE_DIR_AVATARS_PAGE.'originals/'.$codeprofile.'/'.$avatar_previous;
if (file_exists($the_file)) @unlink($the_file);
}
break;
}
echo(json_encode($json_result));
return;
}
if ($ajax_action == 'uploadavatar') {
$avatar_previous = '';
switch ($type_profile) {
case 0:
$avatar_previous = $page->db2->fetch_field("SELECT avatar FROM users WHERE code='".$codeprofile."' LIMIT 1");
break;
case 1:
$avatar_previous = $page->db2->fetch_field("SELECT avatar FROM pages WHERE code='".$codeprofile."' LIMIT 1");
break;
}
$error = FALSE;
/*
if ($the_avatar['size'] > $K->SIZE_IMAGEN_AVATAR || $the_avatar['size'] == 0){
$error = TRUE;
$msgerror = $designer->boxAlert($page->lang('setting_avatar_alert_up_title'), $page->lang('setting_avatar_alert_large_msg'), $page->lang('setting_txt_close'));
break;
}
*/
if (!$error) {
$file_extension = pathinfo($the_avatar['name'], PATHINFO_EXTENSION);
if (!isValidExtension($file_extension, 'png, jpg')) {
$error = TRUE;
$msgerror = $designer->boxAlert($page->lang('setting_avatar_alert_up_title'), $page->lang('setting_avatar_alert_format_msg'), $page->lang('setting_txt_close'));
}
}
if (!$error) {
switch ($type_profile) {
case 0:
$the_pholder_avatar_0 = $K->STORAGE_DIR_AVATARS.'originals/'.$codeprofile;
$the_pholder_avatar_1 = $K->STORAGE_DIR_AVATARS.'min1/'.$codeprofile;
$the_pholder_avatar_2 = $K->STORAGE_DIR_AVATARS.'min2/'.$codeprofile;
- $the_pholder_avatar_3 = $K->STORAGE_DIR_AVATARS.'min3/'.$codeprofile;
$the_pholder_avatar_4 = $K->STORAGE_DIR_AVATARS.'min4/'.$codeprofile;
break;
case 1:
$the_pholder_avatar_0 = $K->STORAGE_DIR_AVATARS_PAGE.'originals/'.$codeprofile;
$the_pholder_avatar_1 = $K->STORAGE_DIR_AVATARS_PAGE.'min1/'.$codeprofile;
$the_pholder_avatar_2 = $K->STORAGE_DIR_AVATARS_PAGE.'min2/'.$codeprofile;
$the_pholder_avatar_3 = $K->STORAGE_DIR_AVATARS_PAGE.'min3/'.$codeprofile;
$the_pholder_avatar_4 = $K->STORAGE_DIR_AVATARS_PAGE.'min4/'.$codeprofile;
break;
}
if (!file_exists($the_pholder_avatar_0)) {
mkdir($the_pholder_avatar_0, 0777, true);
$findex = fopen($the_pholder_avatar_0.'/index.html', "a");
}
if (!file_exists($the_pholder_avatar_1)) {
mkdir($the_pholder_avatar_1, 0777, true);
$findex = fopen($the_pholder_avatar_1.'/index.html', "a");
}
if (!file_exists($the_pholder_avatar_2)) {
mkdir($the_pholder_avatar_2, 0777, true);
$findex = fopen($the_pholder_avatar_2.'/index.html', "a");
}
if (!file_exists($the_pholder_avatar_3)) {
mkdir($the_pholder_avatar_3, 0777, true);
$findex = fopen($the_pholder_avatar_3.'/index.html', "a");
}
if (!file_exists($the_pholder_avatar_4)) {
mkdir($the_pholder_avatar_4, 0777, true);
$findex = fopen($the_pholder_avatar_4.'/index.html', "a");
}
$code = getCode(5, 1);
$code .= '-'.getCode(6, 1);
$code .= '-'.getCode(7, 1);
$name_file = $code.'.'.$file_extension;
move_uploaded_file($the_avatar['tmp_name'], $the_pholder_avatar_0.'/'.$name_file);
$thumbnail = new imagen($the_pholder_avatar_0.'/'.$name_file);
$thumbnail->resizeImage($K->widthAvatar1, $K->heightAvatar1, 'crop');
$thumbnail->saveImage($the_pholder_avatar_1.'/'.$name_file);
$thumbnail = new imagen($the_pholder_avatar_0.'/'.$name_file);
$thumbnail->resizeImage($K->widthAvatar2, $K->heightAvatar2, 'crop');
$thumbnail->saveImage($the_pholder_avatar_2.'/'.$name_file);
$thumbnail = new imagen($the_pholder_avatar_0.'/'.$name_file);
$thumbnail->resizeImage($K->widthAvatar3, $K->heightAvatar3, 'crop');
$thumbnail->saveImage($the_pholder_avatar_3.'/'.$name_file);
$thumbnail = new imagen($the_pholder_avatar_0.'/'.$name_file);
$thumbnail->resizeImage($K->widthAvatar4, $K->heightAvatar4, 'crop');
$thumbnail->saveImage($the_pholder_avatar_4.'/'.$name_file);
switch ($type_profile) {
case 0:
$page->db2->query("UPDATE users SET avatar='".$name_file."' WHERE code='".$codeprofile."' LIMIT 1");
break;
case 1:
$page->db2->query("UPDATE pages SET avatar='".$name_file."' WHERE code='".$codeprofile."' LIMIT 1");
break;
}
}
if ($error) {
$msg_return = 'ERROR:'.$msgerror;
} else {
$np = new newpost();
if ($type_profile == 0) $np->moreInfo($codeprofile, 0, 0, $codeprofile, 0, '', '', '');
if ($type_profile == 1) $np->moreInfo($codeprofile, 1, 1, $codeprofile, 0, '', '', '');
$code_media = $np->attachImagesFromServer($the_pholder_avatar_0.'/'.$name_file, $file_extension);
$np->setMessage('');
$np->setTypePost(6);
$np->save();
if ($type_profile == 0) $page->db2->query("UPDATE users SET avatar_media='".$code_media."' WHERE code='".$codeprofile."' LIMIT 1");
if ($type_profile == 1) $page->db2->query("UPDATE pages SET avatar_media='".$code_media."' WHERE code='".$codeprofile."' LIMIT 1");
switch ($type_profile) {
case 0:
$space_avatar = '<a href="'.$K->SITE_URL.$user->info->user_username.'/photo/'.$code_media.'" class="zoomeer" data-id="'.$code_media.'" data-image="'.$K->STORAGE_URL_AVATARS.'originals/'.$codeprofile.'/'.$name_file.'" data-place="avatar-user"><img src="'.$K->STORAGE_URL_AVATARS.'min4/'.$codeprofile.'/'.$name_file.'" id="the-photo-avatar"></a>';
$ico_avatar_top = $K->STORAGE_URL_AVATARS.'min1/'.$codeprofile.'/'.$name_file;
$json_result = array('space_avatar'=>$space_avatar, 'icoavatartop'=>$ico_avatar_top);
if (!empty($avatar_previous)) {
$the_file = $K->STORAGE_DIR_AVATARS.'min1/'.$codeprofile.'/'.$avatar_previous;
if (file_exists($the_file)) @unlink($the_file);
$the_file = $K->STORAGE_DIR_AVATARS.'min2/'.$codeprofile.'/'.$avatar_previous;
if (file_exists($the_file)) @unlink($the_file);
$the_file = $K->STORAGE_DIR_AVATARS.'min3/'.$codeprofile.'/'.$avatar_previous;
if (file_exists($the_file)) @unlink($the_file);
$the_file = $K->STORAGE_DIR_AVATARS.'min4/'.$codeprofile.'/'.$avatar_previous;
if (file_exists($the_file)) @unlink($the_file);
$the_file = $K->STORAGE_DIR_AVATARS.'originals/'.$codeprofile.'/'.$avatar_previous;
if (file_exists($the_file)) @unlink($the_file);
}
break;
case 1:
$puname = $page->db2->fetch_field("SELECT puname FROM pages WHERE code='".$codeprofile."' LIMIT 1");
$space_avatar = '<a href="'.$K->SITE_URL.$puname.'/photo/'.$code_media.'" class="zoomeer" data-id="'.$code_media.'" data-image="'.$K->STORAGE_URL_AVATARS_PAGE.'originals/'.$codeprofile.'/'.$name_file.'" data-place="avatar-user"><img src="'.$K->STORAGE_URL_AVATARS_PAGE.'min4/'.$codeprofile.'/'.$name_file.'" id="the-photo-avatar"></a>';
$json_result = array('space_avatar'=>$space_avatar);
if (!empty($avatar_previous)) {
$the_file = $K->STORAGE_DIR_AVATARS_PAGE.'min1/'.$codeprofile.'/'.$avatar_previous;
if (file_exists($the_file)) @unlink($the_file);
$the_file = $K->STORAGE_DIR_AVATARS_PAGE.'min2/'.$codeprofile.'/'.$avatar_previous;
if (file_exists($the_file)) @unlink($the_file);
$the_file = $K->STORAGE_DIR_AVATARS_PAGE.'min3/'.$codeprofile.'/'.$avatar_previous;
if (file_exists($the_file)) @unlink($the_file);
$the_file = $K->STORAGE_DIR_AVATARS_PAGE.'min4/'.$codeprofile.'/'.$avatar_previous;
if (file_exists($the_file)) @unlink($the_file);
$the_file = $K->STORAGE_DIR_AVATARS_PAGE.'originals/'.$codeprofile.'/'.$avatar_previous;
if (file_exists($the_file)) @unlink($the_file);
}
break;
}
$msg_return = json_encode($json_result);
}
echo($msg_return);
return;
}
}
?>