View file wu-engine/wu-actions/eshop_comment.php

File size: 1.79Kb
<?php
require_once('../wu_init.php');
require('../wu-functions/wu_functions.php');
if (!wu_token()) { exit('wu-error'); }
if (!USER_LOGGED) { exit('3'); }

if(isset($_POST['m']) && isset($_POST['text'])){
if(!empty($_POST['m']) && !empty($_POST['text'])){
$m = intval($_POST['m']);
$comm = mysqli_query($connect_db, "SELECT id,usr FROM ".DB_PREFIX."_es INNER JOIN ".DB_PREFIX."_users ON ".DB_PREFIX."_es.usr = ".DB_PREFIX."_users.uid WHERE id = '$m' LIMIT 1");
$msg = mysqli_real_escape_string($connect_db, $_POST['text']);
if (mysqli_num_rows($comm) > 0) {

$dtusr = mysqli_fetch_assoc(mysqli_query($connect_db, "SELECT uid,rat FROM ".DB_PREFIX."_users WHERE uid='$u_id' LIMIT 1"));
if ($dtusr['rat'] < 0) { exit('5'); }

if (stristr($msg, 'vk.com')) {
mysqli_query($connect_db, "UPDATE ".DB_PREFIX."_users SET rat=rat-1, `bn` = 'Автобан: нарушение пункта 4.15' WHERE uid='$u_id' LIMIT 1");
exit('4');
}

$comm = mysqli_fetch_assoc($comm);

if ($comm['usr'] != $u_id) {
//Отправка уведомления в личный кабинет и уведомления на E-mail
$msgz = 'К Вашему товару добавлен новый <a href="'.PROTOCOL.SITE.'/eshop_show/'.$m.'\">комментарий</a>';
mysqli_query($connect_db, "INSERT INTO `".DB_PREFIX."_notif` (usr,msg,st,dt) VALUES ('$comm[usr]','$msgz','1','$dt')");
wu_email_send_usr($comm['usr'], 'Новый комментарий к товару', $msgz);
}

mysqli_query($connect_db, "UPDATE ".DB_PREFIX."_us SET rat=rat+0.01 WHERE uid='$u_id' LIMIT 1");
mysqli_query($connect_db, "INSERT INTO ".DB_PREFIX."_es_c (m,t,usr,c,dt) VALUES ('$m','0','$u_id','$msg','$dt')");
wu_log_act(0, "Добавил комментарий к товару $m");

exit('1');
} else {
exit('3');
}
} else { exit('0'); }
} else { exit('3'); }
?>