View file apanel/moduls/news_comments_delete.php

File size: 3.45Kb
<?php
/**********************************************/
/* Автор скрипта: Александр Есин              */
/* E-Mail: [email protected] ([email protected]) */
/* ICQ: 6464729                               */
/* Site: http://ticlove.ru                    */
/**********************************************/
?>
<?php define ('SECURED', true); ?>
<?php require (dirname(__FILE__).'/../../_inc/sql.php'); ?>
<?php require (dirname(__FILE__).'/../../_inc/config.php'); ?>
<?php require (dirname(__FILE__).'/../../_inc/function.php'); ?>
<?php
	 if (!empty($_SESSION['auth_admin']) && (intval($_POST['auth_admin']) == $_SESSION['auth_admin']))
	 {
	      $cid = intval($_POST['cid']);
	      $sql = mysql_query("SELECT * FROM `q_news_comm` WHERE `id_news_comm` = '".$cid."' LIMIT 1;");
	      if (mysql_num_rows($sql) > 0) {
	      $array_comm = mysql_fetch_array($sql);
	      
	      $page = isset($_GET['page']) ? $_GET['page'] : NULL;
	      switch($page)
	      {
	      case 'delete':
	      mysql_query("UPDATE `q_news` SET `comments` = `comments` - '1' WHERE `id_news` = '".$array_comm['id_news']."';");
	      mysql_query("DELETE FROM `q_news_comm` WHERE `id_news_comm` = '".$cid."';");
	      echo '<span class="green">Комментарий удален</span>';
	      echo '<script type="text/javascript">location="apanel.php?page=news&mode=comments&news_id='.$array_comm['id_news'].'";</script>';
	      break;
	      
	      default:
	      ?>
	      <div class="box_bg" style="width: 370px;">
	      <div class="box_title">
	      <div class="left" style="padding-top: 2px; padding-left: 10px;">Удаление комментария</div><div class="box_close right b-modal_close arcticmodal-close"></div>
	      </div>
	      <div class="clear"></div>
	      <div class="box_conetnt">
	      <div style="padding: 10px;">
	      <div id="status_comm_delete" style="margin-bottom: 10px; font-size: 12px; text-align: center;"></div>
	      Вы действительно хотите удалить комментарий "<strong>ID: <?php echo $cid; ?></strong>"?<br/>
	      <a class="red" href="javascript:void(0)" id="delete_comm_delete">[удалить]</a> или <a class="b-modal_close arcticmodal-close" href="javascript:void(0)">[отмена]</a>
	      <script type="text/javascript">
	      $(document).ready(function() {
		   $('#delete_comm_delete').click(function() {
		      $.ajax({
			type: "POST",
			url: "moduls/news_comments_delete.php?page=delete",
			data: { auth_admin: <?php echo $_SESSION['auth_admin']; ?>, cid: <?php echo $cid; ?> },
			beforeSend: function() {
			     $("#status_comm_delete").html('<img src="../images/ajax.gif" alt="" />');
			},
			success: function(data) {
			     $("#status_comm_delete").html(data);
			     setTimeout(function() {
			          $.arcticmodal('close')
			     }, 1000);
			},
			error: function() {
			     $("#status_comm_delete").html('<span class="red">Произошла неизвестная ошибка.' + '<br/>' + 'Возможно, проблемы с подключением к интернету.</span>');
			}
			});
		   });
	      });
	      </script>
	      </div>
	      </div>
	      <div class="box_footer">
	      <div class="right"><button class="submit_red b-modal_close arcticmodal-close">Отмена</button></div>
	      </div>
	      <div class="clear"></div>
	      </div>
	      <?php
	      break;
	      }
	      }
	 }
?>