Просмотр файла pages/avatars.php

Размер файла: 2.83Kb
<?php
/*\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\//
// Sitchi CMS - Mobile Content Management System //
// The author:  Nikoloz Sitchinava [sitchi]      //
// Link:        http://sitchicms.num.ge          //
// Skype:       SitchiCMS                        //
// License:     LICENSE.txt (see attached file)  //
// Version:     VERSION.txt (see attached file)  //
//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
define('_SITCHICMS', 1);
$root_path='../'; 
require $root_path.'includes/db_connect.php'; 
require $root_path.'includes/start.php';
require $root_path.'includes/header.php';
require $root_path.'includes/functions.php';
require $root_path.'includes/head.php'; // თავი
$lng_avat = load_lng('avatar');
if (!isset($_GET['act']))$_GET['act']='';
$act=htmlspecialchars(trim($_GET['act']));
switch ($act) 
{
default:
head(''.$lng['1_12'].'');
aut_off();
err();
echo'<div class="hdr"><b>'.$lng_avat['1_2'].'</b></div>';
if (isset($_GET['yes']))
{
msg('<div class="menu">'.$lng_avat['1_1'].'</div>');
}
echo'<div class="egmenu">';
echo''.$lng_avat['1_3'].': '.avatars($user['id']);
echo'<form action="avatars.php?act=create_avatar" method="POST" enctype="multipart/form-data">' .
'<input type="hidden" name="MAX_FILE_SIZE" value="1048576">' .
''.$lng_avat['1_4'].'(jpg|png|gif):<br/><input name="file" type="file" accept="image/*,image/gif,image/png,image/jpeg"><br/>' .
'<input name="submit" type="submit" value="'.$lng['1_73'].'"></form></div>';
echo'<a href="profile.php">'.$lng['1_4'].'</a>';
require $root_path.'includes/end.php'; // დასასრული
break;
/** ავატარის დამატება **/
case 'create_avatar':
if(isset($_FILES['file']))
{
$parts = pathinfo($_FILES['file']['name']);
$imgc= @imagecreatefromjpeg($_FILES['file']['tmp_name']);
if ($_FILES['file']['size']>1024*1024)
{
$err[] = '<div class="errmenu">'.$lng_avat['1_6'].'</div>';
}
if ($parts['extension']!=='gif' && $parts['extension']!=='png' && $parts['extension']!=='jpg')
{
$err[] = '<div class="errmenu">'.$lng_avat['1_7'].'</div>';
}
if (@imagesx($imgc)>256 || @imagesy($imgc)>256)
{
$err[] = '<div class="errmenu">'.$lng_avat['1_8'].'</div>';
}
if(!isset($err))
{
@unlink($root_path.'files/avatars/'.$user['id'].'.jpg');
@unlink($root_path.'files/avatars/'.$user['id'].'.gif');
@unlink($root_path.'files/avatars/'.$user['id'].'.png');
copy($_FILES['file']['tmp_name'], $root_path.'files/avatars/'.$user['id'].'.'.$parts['extension']);
header("Location: avatars.php?&yes".SID);
}else{
head(''.$lng['1_61'].'');
aut_off();
err();
echo'<a href="avatars.php">'.$lng['1_50'].'</a><br/>';
echo'<a href="profile.php">'.$lng['1_4'].'</a>';
require $root_path.'includes/end.php'; // დასასრული
}}
break;
}
require $root_path.'includes/end.php'; // დასასრული
?>