View file moduls/photo_top.php

File size: 3.01Kb
<?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_id']) && (intval($_POST['user_id']) == $_SESSION['auth_id']))
	 {
	      $fid = intval($_POST['fid']);
	      $sql = mysql_query("SELECT * FROM `q_photo` WHERE `id_photo` = '".$fid."' LIMIT 1;");
	      $arr_photo = mysql_fetch_array($sql);
	      
	      $page = isset($_GET['page']) ? $_GET['page'] : NULL;
	      switch($page)
	      {
	      case 'update':
	      mysql_query("UPDATE `q_photo` SET `preor` = '0' WHERE `id_user` = '".$_SESSION['auth_id']."';");
	      if (mysql_query("UPDATE `q_photo` SET `preor` = '1' WHERE `id_user` = '".$_SESSION['auth_id']."' AND `id_photo` = '".$fid."';")) echo '<div>Данная фотография установлена<br/>в качестве главной на Вашей странице</div>';
	      $name_photo = explode('.', $arr_photo['name']);
	      $name_photo = str_replace($name_photo[0], $name_photo[0].'_s', $arr_photo['name']);
	      mysql_query("UPDATE `q_users` SET `avatar` = '".function_sql($name_photo)."' WHERE `id_user` = '".$_SESSION['auth_id']."';");
	      break;
	      
	      default:
	      $name_photo = explode('.', $arr_photo['name']);
	      $name_photo_p = str_replace($name_photo[0], $name_photo[0].'_p', $arr_photo['name']);
	      ?>
	      <div class="box_bg" style="width: 340px;">
	      <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="photo_top_status">
	      <div>Вы действительно хотите сделать это фото главным?</div>
	      <div style="padding: 10px 0; text-align: center;">
	      <img class="photo_bor" src="<?php echo DIR_PHOTOS; ?>/<?php echo $arr_photo['id_user']; ?>/<?php echo $name_photo_p; ?>" alt="" />
	      </div>
	      <div style="padding-bottom: 10px; text-align: center;">
	      <input type="submit" class="submit" onclick="javascript:photo_top_update('<?php echo $fid; ?>')" value="Установить" />
	      </div>
	      </div>
	      </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;
	      }
	 }
?>