View file apanel/moduls/news_delete.php

File size: 3.56Kb
<?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']))
	 {
	      $nid = intval($_POST['nid']);
	      $sql = mysql_query("SELECT * FROM `q_news` WHERE `id_news` = '".$nid."' LIMIT 1;");
	      if (mysql_num_rows($sql) > 0) {
	      $array_news = mysql_fetch_array($sql);
	      
	      $page = isset($_GET['page']) ? $_GET['page'] : NULL;
	      switch($page)
	      {
	      case 'delete':
	      mysql_query("DELETE FROM `q_news_comm` WHERE `id_news` = '".$nid."';");
	      mysql_query("DELETE FROM `q_news_class` WHERE `id_news` = '".$nid."';");
	      mysql_query("DELETE FROM `q_news` WHERE `id_news` = '".$nid."';");
	      echo '<span class="green">Новость удалена</span>';
	      echo '<script type="text/javascript">location="apanel.php?page=news&mode=open";</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_delete_news" style="margin-bottom: 10px; font-size: 12px; text-align: center;"></div>
	      <div id="menu_delete_city" style="padding-top: 5px; text-align: center;">
	      Вы действительно хотите удалить новость "<strong><?php echo htmlspecialchars($array_news['title'], ENT_QUOTES); ?></strong>"?<br/>
	      <a class="red" href="javascript:void(0)" id="delete_news_update">[удалить]</a> или <a class="b-modal_close arcticmodal-close" href="javascript:void(0)" id="delete_city_update">[отмена]</a>
	      </div>
	      <script type="text/javascript">
	      $(document).ready(function() {
		   $('#delete_news_update').click(function() {
		      $.ajax({
			type: "POST",
			url: "moduls/news_delete.php?page=delete",
			data: { auth_admin: <?php echo $_SESSION['auth_admin']; ?>, nid: <?php echo $nid; ?> },
			beforeSend: function() {
			     $("#status_delete_news").html('<img src="../images/ajax.gif" alt="" />');
			},
			success: function(data) {
			     $("#status_delete_news").html(data);
			     setTimeout(function() {
			          $.arcticmodal('close')
			     }, 1000);
			},
			error: function() {
			     $("#status_delete_news").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;
	      }
	      }
	 }
?>