|
|
|
จะจำกัดขนาดภาพที่อัพโหลดยังไงคับ ทำแล้วมันอัพโหลดได้ทุกขนาดเลยคับ |
|
|
|
|
|
|
|
เอาโค๊ดเก่ามาแก้ครับ
|
|
|
|
|
Date :
2010-07-02 14:04:15 |
By :
Dragons_first |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
<?
session_start();
if(!isset($useradmin)){
header("Location: index.php" );
}else{
require_once("../include/headeradmin1.php");
require_once("../include/check_data.php");
require_once("../include/connect_db.php");
require_once("../include/function.php");
header_admin1();
}
echo"<LINK href='../template.css' type='text/css' rel='stylesheet'>";
if (check_useradmin())
{
if(empty($news_name)||empty($detail)||empty($picture))
{
echo "<center><b class='redbig'>¡Ãسһé͹ÃÒÂÅÐàÍÕ´ãËé¤Ãº¶éǹ <br><BR><a href='javascript: history.back(-1)'><b class='redbig'><< ¡ÅѺ </b></a></b></center>";
require_once("../include/footeradmin.php");
exit;
}
// ¹Ó¿Ñ§¡ìªÑè¹ Ramdom password ÁÒãªéà¾×èÍ¡Ó˹´ª×èÍä¿Åì»éͧ¡Ñ¹¡Òëéӡѹ
function random_password($len)
{
srand((double)microtime()*10000000);
$chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
$ret_str = "";
$num = strlen($chars);
for($i = 0; $i < $len; $i++)
{
$ret_str.= $chars[rand()%$num];
$ret_str.="";
}
return $ret_str;
}
// echo random_password(8);
$passw = random_password(7);
$path="../news_images";
$filenewcon = strstr($picture,'.');
$now = date("Dgis");
if(empty($picture))
{
echo"¡ÃسÒàÅ×Í¡ä¿Åì";
}
else
{
copy( $picture ,"$path/$passw$now$filenewcon");
$url="admin/$path/$passw$now$filenewcon";
}
//¨º¿Ñ§¡ìªÑ¹
if(insert_news($news_name,$detail,$url))
{
echo "<center><b class='bluebig'>à¾ÔèÁ¢èÒÇàÃ×èͧ '$news_name' ã¹°Ò¹¢éÍÁÙÅàÊÃç¨àÃÕºÃéÍÂáÅéÇ</b></center>";
echo "<META HTTP-EQUIV='Refresh' CONTENT='1;URL=managenews_form.php '>";
}else{
echo " <center><b class='redbig'>¢èÒÇàÃ×èͧ '$news_name' äÁèÊÒÁÒöà¾ÔèÁã¹°Ò¹¢éÍÁÙÅä´é</b></center>";
}
}
else
{
echo "<center><b class='redbig'>¤Ø³äÁèÁÕÊÔ·¸Ôà¢éÒÁÒã¹Êèǹ¹Õé </b></center>";
}
require_once("../include/footeradmin.php");
?>
|
|
|
|
|
Date :
2010-07-02 14:23:47 |
By :
วินัย |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
function insert_news($news_name,$detail,$picture)
{
$conn=connect_db("gismapping");
//=======================================================
$strsql="select MAX(news_id) from news";
$result = mysql_query($strsql,$conn);
$row=mysql_fetch_row($result);
$news_id=$row[0];
$news_id++;
//=====================================================
$date=date("Y-m-d");
//$status="1";
//=====================================================
if(!$conn)
{
return "!!!¼Ô´¾ÅÒ´ äÁèÊÒÁÒöµÔ´µè͡Ѻ°Ò¹¢éÍÁÙÅä´é ¡ÃسҾÂÒÂÒÁÍÕ¡¤ÃÑé§";
exit;
}
$sql="insert into news values ($news_id,'$news_name','$detail','$date','$picture')";
$result = mysql_query($sql);
if(!$result)
return("!!! ¼Ô´¾ÅÒ´ äÁèÊÒÁÒöà¾ÔèÁ ÃÒ¡Òà ä´é ");
else
return true;
}
|
|
|
|
|
Date :
2010-07-02 14:24:58 |
By :
วินัย |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<?php
require_once 'function.php';
$template = new Template();
$arr_template_key = array(
1 => ' topic1 ',
2 => ' topic2 ',
3 => ' topic3 ',
4 => ' topic4 '
// 5 => 'topic'
);
$arr_dir_key = array(
1 => 'thump', // thumpnals
2 => 'post', // posted
3 => 'tmp_file' // tempararies
);
$arr_file_exc = array( // change here.
'template_exc' => 'hot_news.tpl', //
'tmp_file_exc' => 'hot_news_fetch.tpl',
'real_file_exc' => 'hot_news_real.tpl',
'--' => ' - -'
);
// globals
$globlas_key = $GLOBALS['title_assign_template']['new_products'];
if($_POST && isset($_POST['submited'])){
$arr_template_tmp = array(); $i = 0;
while($i < sizeof($arr_template_key)){
$arr_template_tmp[$i]['status_icon'] = $_POST['status'][$i];
$arr_template_tmp[$i]['file_name'] = $_FILES['file']['name'][$i];
$arr_template_tmp[$i]['file_tmp'] = $_FILES['file']['tmp_name'][$i];
$arr_template_tmp[$i]['file_type'] = $_FILES['file']['type'][$i];
$arr_template_tmp[$i]['file_size'] = $_FILES['file']['size'][$i];
$arr_template_tmp[$i]['topic_name'] = isset($_POST['topic_name'][$i])? htmlspecialchars($_POST['topic_name'][$i]) : ' ';
$arr_template_tmp[$i]['details'] = isset($_POST['details'][$i])? htmlspecialchars($_POST['details'][$i]) : ' ';
$arr_template_tmp[$i]['key_alt'] = isset($_POST['key_alt'][$i])? htmlspecialchars($_POST['key_alt'][$i]) : ' ';
$arr_template_tmp[$i]['url'] = isset($_POST['url'][$i])? htmlspecialchars($_POST['url'][$i]) : ' ';
++$i;
}
// print'<pre>';
// print_r($arr_template_tmp); print'</pre>';
// create directory
$arr_key = array_search($globlas_key, $GLOBALS['title_assign_template']);
if(!opendir($arr_key)) mkdir($arr_key, 0775); $i = 1;
while($i <= sizeof($arr_dir_key)){
mkdir($arr_key.'/'.$arr_dir_key[$i],0775);
$i++;
}
// image
/////////////// ดูตรงนี้เป็นตัวอย่างครับ
for($i = 0, $key_assign = 1; $i <= sizeof($arr_template_key); $i++){
if($_FILES and ($arr_template_tmp[$i]['file_type'] == 'image/jpeg') and ($arr_template_tmp[$i]['file_size'] < 116000)) copy($arr_template_tmp[$i]['file_tmp'], $arr_key.'/'.$arr_dir_key[1].'/'.$key_assign.'__'.substr(md5(md5('pic_'.$key_assign)), 1, 13));
++$key_assign;
}
// write file
// if(sizeof(scandir($arr_key.'/'.$arr_dir_key[1]))){
// array_push($arr_template_tmp, scandir($arr_key.'/'.$arr_dir_key[1]));
// print_r(scandir($arr_key.'/'.$arr_dir_key[1]));
// }
$file = File::write($arr_key.'/'.$arr_dir_key[2].'/'.md5($arr_key).'.post',
serialize($arr_template_tmp), FILE_MODE_WRITE);
if($file) copy($arr_key.'/'.$arr_dir_key[2].'/'.md5($arr_key).'.post',
$arr_key.'/'.$arr_dir_key[3].'/'.substr(md5($arr_key),0,12).'_tmp.post');
}// end post
// read
$arr_key = array_search($globlas_key, $GLOBALS['title_assign_template']);
if(file_exists($arr_key.'/'.$arr_dir_key[2].'/'.md5($arr_key).'.post')){
$read = File::readAll($arr_key.'/'.$arr_dir_key[2].'/'.md5($arr_key).'.post');
$arr_serialize = unserialize($read);
}
if(sizeof(scandir($arr_key.'/'.$arr_dir_key[1]))){
$arr_thumps_template = array();
for($i =1, $key_assign = 1; $i <= sizeof($arr_template_key); $i++){
$arr_thumps_template[$i] = $arr_key.'/'.$arr_dir_key[1].'/'.$key_assign.'__'.substr(md5(md5('pic_'.$key_assign)), 1, 13);
++$key_assign;
}
}
// $template->assign('arr_template_key' ,$arr_template_key);
$template->assign('arr_serialize' ,$arr_serialize);
$template->assign('arr_thumps_template' ,$arr_thumps_template);
$template->assign('title_assign_template',$GLOBALS['title_assign_template']);
$template->display($arr_file_exc['template_exc']);
File::write($arr_file_exc['real_file_exc'],$template->fetch($arr_file_exc['tmp_file_exc']),FILE_MODE_WRITE);
//end
?>
|
|
|
|
|
Date :
2010-07-02 14:47:41 |
By :
mrjidjad |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
กลัวไม่เข้าใจ
// image
/////////////// ดูตรงนี้เป็นตัวอย่างครับ
for($i = 0, $key_assign = 1; $i <= sizeof($arr_template_key); $i++){
if($_FILES and ($arr_template_tmp[$i]['file_type'] == 'image/jpeg') and ($arr_template_tmp[$i]['file_size'] < 116000)) copy($arr_template_tmp[$i]['file_tmp'], $arr_key.'/'.$arr_dir_key[1].'/'.$key_assign.'__'.substr(md5(md5('pic_'.$key_assign)), 1, 13));
++$key_assign;
}
// สังเกต $arr_template_tmp[$i]['file_size'] < 116000
|
|
|
|
|
Date :
2010-07-02 14:50:14 |
By :
mrjidjad |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 01
|