View file jpmobile/moduls/avatar/selected_my.php

File size: 1.52Kb
<?php
include('../../adm/cgf.php');
if ($_SESSION['user_login'] == '')
{
 echo 'Ошибка! Файл не может быть загружен!';
 exit;
}
if (!is_file($cms.'user/'.$_SESSION['user_login'].'/profile.php'))
{
echo 'Ошибка загрузки';
exit;
}

if ($_GET['select'] == '' and $_GET['del'] != '' and is_file($cms.'moduls/avatar/user_avatar/'.$_SESSION['user_login'].'/'.$_GET['del']))
{
@unlink($cms.'moduls/avatar/user_avatar/'.$_SESSION['user_login'].'/'.$_GET['del']);
}

if ($_GET['select'] != '' and $_GET['del'] == '' and is_file($cms.'moduls/avatar/user_avatar/'.$_SESSION['user_login'].'/'.$_GET['select']))
{
  $fp = fopen ($cms.'user/'.$_SESSION['user_login'].'/avatar.txt', "w+");
  fwrite ($fp, 'moduls/avatar/user_avatar/'.$_SESSION['user_login'].'/'.$_GET['select']);
  fclose ($fp);

$act['data'] = date("d.m.Y");
$act['time'] = date("H:i");

$activ = 'Смена фото.';
include($cms.'moduls/act/act_add.php');

echo 'Фото успешно выбрано!';
$_SESSION['ava_ok'] = 1;
}

else
{          $dir = opendir ($cms.'moduls/avatar/user_avatar/'.$_SESSION['user_login'].'/');
          while ($file = readdir ($dir))
         { if (( $file != ".") && ($file != ".."))
          {
           echo '
           <a href="?del='.$file.'">Удалить</a><br>
           <a href="?select='.$file.'">
           <img
           src="/moduls/avatar/user_avatar/'.$_SESSION['user_login'].'/'.$file.'"
           width="125"  alt="" border="0">
           </a> <hr>
           ';
          }
         }
          closedir ($dir);

}



?>