<?php 
	session_start(); 
	require_once('inc/conn.php');
	require_once('inc/constant.php');
	require_once('inc/ls_syscode.php');
	require_once('inc/check.php');
	$opendb=new mydb();
	require_once('inc/char_set.php'); 
	
	require_once('generalpicrequire.php');  //generalpic类型选择语句, 表名、图片文件存储目录、字段变量名 存储变量在此定义

	$id=$_GET['id'];
	$ls=$_GET['ls'];
	$thisPicW=240;
	$thisPicH=240;
	
	$title_sql = "select * from ls_config";
	$title_query = $opendb->query($title_sql);
	$title_value = mysql_fetch_assoc($title_query);
	
	$pos = strpos($title_value['companyName'], '-', 1);
	$subCompanyName = substr($title_value['companyName'], (mb_strlen($title_value['companyName'],'utf-8') - $pos) * -1 );

if($ls=="insert")
{
	$genOper="添加";
	$modiGeneralpicsTitle=$_POST['modiGeneralpicsTitle'];
	$modiGeneralpicsText=$_POST['modiGeneralpicsText'];
	$folderPic=($_POST['Pic']==""?"images/picture.gif":"../".$folder2."/".$_POST['Pic']);
	$Pic=($_POST['Pic']==""?"":$_POST['Pic']);
}else{
	$genOper="修改";
	$generalpics_sql="select * from ".$generalTable." where ID=".$id." ";
	$generalpics_query=$opendb->query($generalpics_sql);
	$generalpics_rows=mysql_fetch_assoc($generalpics_query);
	$modiGeneralpicsTitle=$generalpics_rows[$generalpicsTitle];
	$modiGeneralpicsText=$generalpics_rows[$generalpicsText];
	$folderPic="../".$folder2."/".$generalpics_rows[$generalpicsPic];
	$Pic=$generalpics_rows[$generalpicsPic];
}
	$ls_msg=$genOper.$showstr."";


?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<link href="css/admin.css" rel="stylesheet" type="text/css">
        <script language="JavaScript" src="js/jquery.js"></script>
		<script language="JavaScript" src="js/ls.js"></script>
		<title>无标题文档</title>
		<link rel="stylesheet" href="kindeditor-4.1.10/themes/default/default.css" />
	<link rel="stylesheet" href="kindeditor-4.1.10/plugins/code/prettify.css" />
	<script charset="utf-8" src="kindeditor-4.1.10/kindeditor.js"></script>
	<script charset="utf-8" src="kindeditor-4.1.10/lang/zh_CN.js"></script>
	<script charset="utf-8" src="kindeditor-4.1.10/plugins/code/prettify.js"></script>
	<script>
		KindEditor.ready(function(K) {
			var editor1 = K.create('textarea[name="modiGeneralpicsText"]', {
				cssPath : 'kindeditor-4.1.10/plugins/code/prettify.css',
				uploadJson : 'kindeditor-4.1.10/php/upload_json.php',
				fileManagerJson : 'kindeditor-4.1.10/php/file_manager_json.php',
				allowFileManager : true,
				afterBlur: function(){
					this.sync();
					},
				afterCreate : function() {
					var self = this;
					K.ctrl(document, 13, function() {
						self.sync();
						K('form[name=example]')[0].submit();
					});
					K.ctrl(self.edit.doc, 13, function() {
						self.sync();
						K('form[name=example]')[0].submit();
					});
				}
			});
			prettyPrint();
		});
	</script>
	</head>

	<body>
		<table width="96%" border="0" align="center" cellpadding="1" cellspacing="1" bgcolor="#6396d6">
			<tr>
				<td height="18" background="images/admin_bg.gif"><div align="center"><font color="#ffffff"><strong>修改<?=$showstr?>图片</strong></font></div>
				</td>
			</tr>
			<tr>
				<td height="213" valign="top" bgcolor="#dee7ff"><br>
				 <form name="myform" enctype="multipart/form-data" method="post" action="savegeneralpics.php?gen=<?=$gen?>" >
					<input type="hidden" value="<?php echo $ls;?>" name="ls">
					<input type="hidden" value="<?php echo $id;?>" name="id">
					<input type="hidden" value="<?php echo $Pic;?>" name="Pic">
					<input type="hidden" name="ChangecatePagePic" value="no">
					<table border="0" width="96%" align="center">
						<tr>
							<td>提示：<font color="#FF0000"><?php echo $ls_msg; ?></font></td>
							<td align="right"><img src="images/shao.gif">&nbsp;<a href="generalpics.php?gen=<?=$gen?>"><u>返回</u></a></td>
						</tr>
					</table>
					<table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
					  <tr bgcolor="#B9DAFF">
					    <td height="28" colspan="4"></td>
				      </tr>
					  <tr bgcolor="#f4f4f4">
					    <td style="padding-left:50px;" >缩略图：</td>
					    <td width="45%" style="padding-left:10px;" ><div id="preview"><img src="<?php echo $folderPic."?i=".rand();?>" width="<?=(isset($thisPicW)?$thisPicW:$SmallPicW)?>" height="<?=(isset($thisPicH)?$thisPicH:$SmallPicH)?>" border="1" name="pic" style="float:left;" /></div> <span style="padding-left:50px;">*</span><br />
<script type="text/javascript">
function preview(file)
{
var prevDiv = document.getElementById('preview');
if (file.files && file.files[0])
{
var reader = new FileReader();
reader.onload = function(evt){
prevDiv.innerHTML = '<img src="' + evt.target.result + '" width="<?php echo $SmallPicW ?>" height="<?php echo $SmallPicH?>" border="1" name="pic" style="float:left;" />';
}  
reader.readAsDataURL(file.files[0]);
}
else  
{
prevDiv.innerHTML = '<div class="img" style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale,src=\'' + file.value + '\'"></div>';
}
}
</script>
					      <br />
					      <div style="padding-left:80px;"> 
					        <?=$generalpicsTips?> 
				          </div></td>
                          <td width="43%" rowspan="3" valign="top"><table border="0" width="98%" align="center" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
						  <tr>
						    <td width="212" bgcolor="#f4f4f4" align="right" >标题<br /> Title</td>
						    <td width="760" valign="middle"  bgcolor="#f4f4f4" ><textarea name="newsTitle" id="newsTitle" cols="65" rows="3"><?php echo $generalpics_rows['newsTitle'];?></textarea></td>
					      </tr>
						  <tr>
						    <td bgcolor="#f4f4f4" align="right" >关键字<br /> Keywords</td>
						    <td  bgcolor="#f4f4f4"  ><textarea name="newsKeywords" id="newsKeywords" cols="65" rows="3"><?php echo $generalpics_rows['newsKeywords'];?></textarea></td>
					      </tr>
						  <tr>
						    <td bgcolor="#f4f4f4" align="right">描述<br /> Description<br />（默认取介绍前<font color="#FF0000">86</font>个字符）</td>
						    <td bgcolor="#f4f4f4" ><textarea name="newsDescription" cols="65" rows="6" id="newsDescription"><?php echo $generalpics_rows['newsDescription'];?></textarea></td>
					      </tr>
                          <tr>
						    <td colspan="2" bgcolor="#f4f4f4" align="center"><input type="submit" value="保存" onClick="
                        if($('#newsText').val().length >= 0){
                        	$('#newsDescription').val($('#modiGeneralpicsText').val().substr(0, 86).replace(/<[^>]+>/g,'').replace(/	/g, '').replace(/\n/g, ''));
                        }" /> &nbsp; 
                        <input name="重置" type="reset"  value="重置"  onclick="document.pic.src='<?php echo $folderPic?>';myform.ChangecatePagePic.value='no';" /> &nbsp; <input type="button" name="button" id="button" value="SEO"  onclick="
                            if(confirm('您确定要修改SEO设置吗？')){
                            $('#newsTitle').val($('#workshopTitle').val()+'<?php if(strpos($title_value['companyName'],"-")){echo " ".$subCompanyName;}else{echo " - ".$title_value['companyName'];}?>');
$('#newsKeywords').val('<?=$title_value['siteKeywords']?>');
$('#newsDescription').val($('#modiGeneralpicsText').val().substr(0, 86).replace(/<[^>]+>/g,'').replace(/	/g, '').replace(/\n/g, ''));
	}else{
		return false;
	}"/></td>
						    </tr>
					    </table></td>
				      </tr>
					  <tr bgcolor="#f4f4f4">
					    <td style="padding-left:50px;" >					      图片：</td>
					    <td style="padding-left:10px;" ><input type="file" name="productPic" style="width:300px;" onchange="preview(this);myform.ChangecatePagePic.value='yes';document.pic.src=myform.productPic.value;" /></td>
                      </tr>
					<tr bgcolor="#f4f4f4">
					    <td width="12%" style="padding-left:50px;">					      名称(标题) ：</td>
					    <td style="padding-left:10px;">
                        	<input name="modiGeneralpicsTitle" id="workshopTitle" type="text"  style="width:400px;" value="<?php echo $modiGeneralpicsTitle;?>" onblur="if($('#workshopTitle').val().length > 0){$('#newsTitle').val(this.value+'<?php if(strpos($title_value['companyName'],"-")){echo " ".$subCompanyName;}else{echo " - ".$title_value['companyName'];}?>'); 
                        $('#newsKeywords').val('<?=$title_value['siteKeywords']?>');}" />
                        </td>
                      </tr>
                      <?php file_exists("widget/generalpics/addmodi.php")?include "widget/generalpics/addmodi.php" :"" ?>
					  <tr bgcolor="#f4f4f4">
					    <td width="12%" style="padding-left:50px;">					      详细：</td>
					    <td colspan="2"   style="padding-left:10px;">
                        <?php
								/*require_once('fckeditor/fckeditor.php');
								$sBasePath=$_SERVER['PHP_SELF'];
								$sBasePath=substr($sBasePath,0,strpos($sBasePath,"ls_admin"));
								$sBasePath.="ls_admin/fckeditor/";
									
								$oFCKeditor=new FCKeditor('modiGeneralpicsText');
								$oFCKeditor->BasePath=$sBasePath;
								$oFCKeditor->Config['SkinPath']=$sBasePath.'editor/skins/silver/';
								//$oFCKeditor->Config['AutoDetectLanguage']=true;
								$oFCKeditor->ToolbarSet='Default';
								$oFCKeditor->Height='190';
								$oFCKeditor->Width = '96%' ;
								$oFCKeditor->Value=htmlspecialchars_decode($modiGeneralpicsText,ENT_QUOTES);
								$oFCKeditor->Create();*/
							?>
                       <textarea name="modiGeneralpicsText" id="modiGeneralpicsText" style="width:100%;height:300px;visibility:hidden;"><?php echo htmlspecialchars($modiGeneralpicsText); ?></textarea>
				      </tr>
					  <tr bgcolor="#B9DAFF">
					    <td height="25" align="center" >&nbsp;</td>
					    <td height="25" colspan="2" align="center"><input type="submit" value="保存" onClick="
                        if($('#newsText').val().length >= 0){
                        	$('#newsDescription').val($('#modiGeneralpicsText').val().substr(0, 86).replace(/<[^>]+>/g,'').replace(/	/g, '').replace(/\n/g, ''));
                        }" /> &nbsp; 
                        <input name="重置" type="reset"  value="重置"  onclick="document.pic.src='<?php echo $folderPic?>';myform.ChangecatePagePic.value='no';" /></td>
				      </tr>
				   </table>
					<br />
                 </form>
				</td>
			</tr>
		</table>
</body>
    <?  if($_SESSION["refreshModi"]){?>
	<script> document.execCommand('Refresh') ;</script>
	<? 
	$_SESSION["refreshModi"]=false;
	}?>
</html>