View file moduls/photo_desc.php

File size: 3.84Kb
<?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;");
	      
	      $page = isset($_GET['page']) ? $_GET['page'] : NULL;
	      switch($page)
	      {
	      case 'update':
	      $fid = intval($_POST['fid']);
	      $desc = function_sql($_POST['desc']);
	      
	      if (mysql_query("UPDATE `q_photo` SET `about` = '".(!empty($desc) ? $desc : '')."' WHERE `id_user` = '".$_SESSION['auth_id']."' AND `id_photo` = '".$fid."';")) echo '<div>Описание успешно изменено</div>';
	      break;
	      
	      default:
	      $arr_photo = mysql_fetch_array($sql);
	      $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: 330px;">
	      <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_desc_status">
	      <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>
	      <script type="text/javascript">
	      jQuery.fn.maxlength = function(options) {
		   var settings = jQuery.extend({
		   maxChars: 300, // максимальное колличество символов
		   leftChars: "символов" // текст в конце строки информера
		   }, options);
		   return this.each(function() {
		   var me = $(this);
		   var l = settings.maxChars;
		   me.bind('keydown keypress keyup',function(e) {
		   if(me.val().length>settings.maxChars) me.val(me.val().substr(0,settings.maxChars));
		   l = settings.maxChars - me.val().length;
		   me.next('span').html(l + ' ' + settings.leftChars);
		   });
		   me.after('Осталось <span class="maxlen">' + settings.maxChars + ' ' + settings.leftChars + '</span>');
		   });
	      };
	      </script>
	      <script type="text/javascript">
	      $(document).ready(function(){
		   $("#desc").maxlength();
	      });
	      </script>
	      <div style="padding-bottom: 10px; width: 310px;">
	      Описание фотографии<br/>
	      <textarea id="desc" style="width: 300px; max-width: 300px; min-width: 300px; padding: 3px;"><?php echo htmlspecialchars(function_bigword($arr_photo['about'], 32), ENT_QUOTES); ?></textarea>
	      </div>
	      <div style="padding-bottom: 10px; text-align: center;">
	      <input type="submit" class="submit" onclick="javascript:photo_desc_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;
	      }
	 }
?>