Вход Регистрация
Файл: system/modules/stiker.php
Строк: 162
<?php
/* 
    Appointment: Подарки
    File: gifts.php 
    Данный код защищен авторскими правами
*/
if(!defined('MOZG'))
    die(
'Hacking attempt!');

if(
$ajax == 'yes')
    
NoAjaxQuery();

if(
$logged){
    
$act $_GET['act'];
    
$user_id $user_info['user_id'];

    switch(
$act){
        
        
//################### Страница всех  ###################//
        
case "view":
            
NoAjaxQuery();
            
$for_user_id intval($_POST['user_id']);
            
            
$sql_ $db->super_query("SELECT SQL_CALC_FOUND_ROWS gid, img, price FROM `".PREFIX."_stiker_list` ORDER by `gid` DESC"1);
          echo 
"<table><tr><td><div style='margin-top:10px; width:150px; border-radius:8px; height:20px; text-align:center;background:rgb(154,205,50);padding:10px;'><a href=""   onClick="gifts.box('{user-id}'); return false">Отправить подарок</a></div></td><td><div style='margin-top:10px;width:100px;border-radius:8px; height:20px;text-align:center;background:rgb(154,205,50);padding:10px;'><a href=""   onClick="stiker.box('{user-id}'); return false">Прикрепить стикер</a></div></td><td><div style='margin-top:10px;width:100px; height:20px;border-radius:8px;text-align:center;background:rgb(154,205,50);padding:10px;'><a href=""   onClick="znak.box('{user-id}'); return false">Прикрепить значек</a></div></td><tr></table>";
            foreach(
$sql_ as $stik){
     
                echo 
"<a href="" class="stik_one" onMouseOver="stiker.showstik('{$stik['img']}')" onMouseOut="stiker.showhide('{$stik['img']}')" onClick="stiker.select('{$stik['img']}''{$for_user_id}'); return false"><img src="/uploads/gifts/{$stik['img']}.png" /><div class="stik_count no_display" id="{$stik['img']}"><span style='color:#ff0000;'>{$stik['price']} голос</span></div></a>";
            }
            
                
$row $db->super_query("SELECT user_balance FROM `".PREFIX."_users` WHERE user_id = '{$user_id}'");
            
            echo 
"<style>#box_bottom_left_text{padding-top:6px;float:left}</style><script>$('#box_bottom_left_text').html('У Вас <b>{$row['user_balance']} голос.</b>');</script>";
            
            die();
        break;
        
        
//################### Отправка  в БД ###################//
        
case "send":
            
NoAjaxQuery();
            
$for_user_id intval($_POST['for_user_id']);
            
$stik intval($_POST['stik']);
            
$privacy intval($_POST['privacy']);
            if(
$privacy OR $privacy 3$privacy 1;
            
$msg ajax_utf8(textFilter($_POST['msg']));
            
$stiks $db->super_query("SELECT price FROM `".PREFIX."_stiker_list` WHERE img = '".$stik."'");
            
$str_date time();
            
            
//Выводим текущий баланс свой
            
$row $db->super_query("SELECT user_balance FROM `".PREFIX."_users` WHERE user_id = '{$user_id}'");
            if(
$stiks['price'] AND $user_id != $for_user_id){
                if(
$row['user_balance'] >= $stiks['price']){
                    
$db->query("INSERT INTO `".PREFIX."_stiker` SET uid = '{$for_user_id}', stik = '{$stik}', msg = '{$msg}', privacy = '{$privacy}', gdate = '{$str_date}', from_uid = '{$user_id}', status = 1");
                    
$db->query("UPDATE `".PREFIX."_users` SET user_balance = user_balance-{$stiks['price']} WHERE user_id = '{$user_id}'");
                    
$db->query("UPDATE `".PREFIX."_users` SET user_stik = user_stik+1 WHERE user_id = '{$for_user_id}'");
                    
                        
//Вставляем событие в моментальные оповещания
                        
$row_owner $db->super_query("SELECT user_last_visit FROM `".PREFIX."_users` WHERE user_id = '{$for_user_id}'");
                        
$update_time $server_time 70;
                        
                        if(
$row_owner['user_last_visit'] >= $update_time){
                            
                            
$action_update_text "<img src="/uploads/stiker/{$stik}.png" align="right" width="50">";
                            
                            
$db->query("INSERT INTO `".PREFIX."_updates` SET for_user_id = '{$for_user_id}', from_user_id = '{$user_info['user_id']}', type = '13', date = '{$str_date}', text = '{$action_update_text}', user_photo = '{$user_info['user_photo']}', user_search_pref = '{$user_info['user_search_pref']}', lnk = '/stiker{$user_info['user_id']}'");
    
                            
mozg_create_cache("user_{$for_user_id}/updates"1);
        
                            }                        
                    
                    
//Добавляем +1 юзеру для оповещания
                    
$cntCacheNews mozg_cache("user_{$for_user_id}/new_stiker");
                    
mozg_create_cache("user_{$for_user_id}/new_stiker", ($cntCacheNews+1));
                    
                    
mozg_mass_clear_cache_file("user_{$for_user_id}/profile_{$for_user_id}|user_{$for_user_id}/stiker");
                    
                    
//Отправка уведомления на E-mail
                    
if($config['news_mail_6'] == 'yes'){
                        
$rowUserEmail $db->super_query("SELECT user_name, user_email FROM `".PREFIX."_users` WHERE user_id = '".$for_user_id."'");
                        if(
$rowUserEmail['user_email']){
                            include_once 
ENGINE_DIR.'/classes/mail.php';
                            
$mail = new dle_mail($config);
                            
$rowMyInfo $db->super_query("SELECT user_search_pref FROM `".PREFIX."_users` WHERE user_id = '".$user_id."'");
                            
$rowEmailTpl $db->super_query("SELECT text FROM `".PREFIX."_mail_tpl` WHERE id = '9'");
                            
$rowEmailTpl['text'] = str_replace('{%user%}'$rowUserEmail['user_name'], $rowEmailTpl['text']);
                            
$rowEmailTpl['text'] = str_replace('{%user-friend%}'$rowMyInfo['user_search_pref'], $rowEmailTpl['text']);
                            
$rowEmailTpl['text'] = str_replace('{%rec-link%}'$config['home_url'].'stiker'.$for_user_id$rowEmailTpl['text']);
                            
$mail->send($rowUserEmail['user_email'], 'Вам отправили новый стикер'$rowEmailTpl['text']);
                        }
                    }        
                } else
                    echo 
'1';
            }
            die();
        break;
        
        
//################### Удаление ###################//
        
case "del":
            
NoAjaxQuery();
            
$gid intval($_POST['gid']);
            
$row $db->super_query("SELECT uid FROM `".PREFIX."_stiker` WHERE gid = '{$gid}'");
            if(
$user_id == $row['uid']){
                
$db->query("DELETE FROM `".PREFIX."_stiker` WHERE gid = '{$gid}'");
                
$db->query("UPDATE `".PREFIX."_users` SET user_stiks = user_stiks-1 WHERE user_id = '{$user_id}'");
                
mozg_mass_clear_cache_file("user_{$user_id}/profile_{$user_id}|user_{$user_id}/stiker");
            }
            die();
        break;
        
        default:
        
            
//################### Вывод у пользователей пользователя ###################//
            
$metatags['title'] = $lang['stiks'];
            
$uid intval($_GET['uid']);
            
            if(
$_GET['page'] > 0$page intval($_GET['page']); else $page 1;
            
$gcount 15;
            
$limit_page = ($page-1)*$gcount;
            
            
$owner $db->super_query("SELECT user_name, user_stik FROM `".PREFIX."_users` WHERE user_id = '{$uid}'");
            
            
$tpl->load_template('stiker/head.tpl');
            
$tpl->set('{uid}'$uid);
            if(
$user_id == $uid){
                
$tpl->set('[owner]''');
                
$tpl->set('[/owner]''');
                
$tpl->set_block("'\[not-owner\](.*?)\[/not-owner\]'si","");
            } else {
                
$tpl->set('[not-owner]''');
                
$tpl->set('[/not-owner]''');
                
$tpl->set_block("'\[owner\](.*?)\[/owner\]'si","");
            }
            
$tpl->set('{name}'gramatikName($owner['user_name']));
            
$tpl->set('{stik-num}''<span id="num">'.$owner['user_stik'].'</span> '.gram_record($owner['user_stik'], 'stiks'));
            if(
$owner['user_stik']){
                
$tpl->set('[yes]''');
                
$tpl->set('[/yes]''');
                
$tpl->set_block("'\[no\](.*?)\[/no\]'si","");
            } else {
                
$tpl->set('[no]''');
                
$tpl->set('[/no]''');
                
$tpl->set_block("'\[yes\](.*?)\[/yes\]'si","");
            }

            if(
$_GET['new'] AND $user_id == $uid){
                
$tpl->set('[new]''');
                
$tpl->set('[/new]''');
                
$tpl->set_block("'\[no-new\](.*?)\[/no-new\]'si","");
                
$sql_where "AND status = 1";
                
$gcount 50;
                
mozg_create_cache("user_{$user_id}/new_stiker"'');
            } else {
                
$tpl->set('[no-new]''');
                
$tpl->set('[/no-new]''');
                
$tpl->set_block("'\[new\](.*?)\[/new\]'si","");
            }
            
            
$tpl->compile('info');
            if(
$owner['user_stik']){
                
$sql_ $db->super_query("SELECT tb1.gid, stik, from_uid, msg, gdate, privacy, tb2.user_search_pref, user_photo, user_last_visit FROM `".PREFIX."_stiker` tb1, `".PREFIX."_users` tb2 WHERE tb1.uid = '{$uid}' AND tb1.from_uid = tb2.user_id {$sql_where} ORDER by `gdate` DESC LIMIT {$limit_page}{$gcount}"1);
                
$tpl->load_template('stiker/stiker.tpl');
                foreach(
$sql_ as $row){
                    
$tpl->set('{id}'$row['gid']);
                    
$tpl->set('{uid}'$row['from_uid']);
                    if(
$row['privacy'] == OR $user_id == $row['from_uid'] OR $user_id == $uid AND $row['privacy'] != 3){
                        
$tpl->set('{author}'$row['user_search_pref']);
                        
$tpl->set('{msg}'stripslashes($row['msg']));
                        
$tpl->set('[link]''<a href="/profile/'.$row['from_uid'].'" onClick="Page.Go(this.href); return false">');
                        
$tpl->set('[/link]''</a>');
                        
OnlineTpl($row['user_last_visit']);
                    } else {
                        
$tpl->set('{author}''Неизвестный отправитель');
                        
$tpl->set('{msg}''');
                        
$tpl->set('{online}''');
                        
$tpl->set('[link]''');
                        
$tpl->set('[/link]''');
                    }
                    
$tpl->set('{stik}'$row['stik']);
                    
megaDate($row['gdate'], 11);
                    
$tpl->set('[privacy]''');
                    
$tpl->set('[/privacy]''');
                    if(
$row['privacy'] == AND $user_id == $uid){
                        
$tpl->set('{msg}'stripslashes($row['msg']));
                        
$tpl->set_block("'\[privacy\](.*?)\[/privacy\]'si","");
                    }
                    if(
$row['privacy'] == OR $user_id == $row['from_uid'] OR $user_id == $uid AND $row['privacy'] != 3)
                        if(
$row['user_photo'])
                            
$tpl->set('{ava}''/uploads/users/'.$row['from_uid'].'/50_'.$row['user_photo']);
                        else
                            
$tpl->set('{ava}''{theme}/images/no_ava_50.png');
                    else
                        
$tpl->set('{ava}''{theme}/images/no_ava_50.png');
                        
                    if(
$user_id == $uid){
                        
$tpl->set('[owner]''');
                        
$tpl->set('[/owner]''');
                    } else
                        
$tpl->set_block("'\[owner\](.*?)\[/owner\]'si","");
                        
                    if(
$sql_where)
                        
$db->query("UPDATE `".PREFIX."_stiker` SET status = 0 WHERE gid = '{$row['gid']}'");
                        
                    
$tpl->compile('content');
                }
                
navigation($gcount$owner['user_stik'], "/stiker{$uid}?page=");
                
                if(
$sql_where AND !$sql_)
                    
msgbox('''<br /><br />Новых стикеров еще нет.<br /><br /><br />''info_2');
            }
    }
    
$tpl->clear();
    
$db->free();
} else {
    
$user_speedbar $lang['no_infooo'];
    
msgbox(''$lang['not_logged'], 'info');
}
?>
Онлайн: 0
Реклама