function page_emoticon_edit() {
global $adminlang;// แปลไทยในหน้า admin
global $cfg, $db;
global $html;
global $act, $page, $section, $subsec;
// retrieve info from db
$emo_id = form::getval("emo_id");
$sql = "select * from "._dbpre_."emoticon where emo_id = ".psql($emo_id).";";
$rs = $db->execute($sql);
if (!$db->errormsg()) {
if (!$rs->EOF) {
$emotxt = $rs->fields("emo_txt");
$emoimg = $rs->fields("emo_img");
} else {
die("Non id match");
}
} else {
die("Db error while editing emoticon");
}
// edit process------------------------------------------------------------------
if ($act == "do") {
$emotxt = form::postval("emotxt");
$emofile = form::fileval("emofile");
// check before add.--------------------------
$allow_submit = false;
$need_upload = false;
if ($emotxt != null) {
if ($emofile['type'] != null) {
$emofile_name = $emofile['name'];
$emofile_size = $emofile['size'];
$emofile_type = $emofile['type'];//result image/jpeg, image/png, image/gif
$emofile_ext = files::showfileext($emofile_name, "lower");
if (($emofile_ext == "jpg" || $emofile_ext == "jpeg") || $emofile_ext == "gif" || $emofile_ext == "png") {
//if ($emofile_size <= '20480') {
$allow_submit = true;
$need_upload = true;
//} else {
// You are uploading file size larger than we limit.
//}
} else {
$status = myhtml::displayerror("error_Please use file type as specified.");
}
} else {
// no file upload
$allow_submit = true;
}
} else {
$status = myhtml::displayerror("error_Please fill the form.");
}
// end check --------------------------
//อัปโหลด
if ($need_upload == true) {
$new_emofile_name = "emo-".$emo_id."-".tools::randompw("10").".".$emofile_ext;
$new_emo_path = "../".$cfg['site']['emoticon_path'];
if (move_uploaded_file($emofile['tmp_name'], $new_emo_path.$new_emofile_name)) {
$allow_submit = true;
} else {
$allow_submit = false;
$status = myhtml::displayerror("error_Error, please try gain.");
}
}
// update db
if ($allow_submit == true) {
$old_emo_img = "../".$emoimg;
$rec = array();
$rec['emo_txt'] = psql($emotxt);
if ($need_upload == true) {
$rec['emo_img'] = str_replace("../", "", $new_emo_path).$new_emofile_name;
}
$db->autoexecute(_dbpre_."emoticon", $rec, 'UPDATE', 'emo_id = '.psql($emo_id).'');
if (!$db->errormsg()) {
if ($need_upload == true) {
@unlink($old_emo_img);
$emoimg = str_replace("../", "", $new_emo_path).$new_emofile_name;
} else {
$emoimg = $emoimg;
}
$status = myhtml::displaysuccess("admin_Edit emoticon success.", "admin");
} else {
@unlink($new_emo_path.$new_emofile_name);
$status = myhtml::displayerror("error_Database error.");
}
}
}
// edit process------------------------------------------------------------------
$output = $html->h("2", $adminlang->trans("Edit"));
$output .= $html->div(@$status, array("class"=>"status-msg"));
$output .= "<form method=\"post\" action=\"?page=$page§ion=$section&emo_id=$emo_id&act=do\" enctype=\"multipart/form-data\">\n";
$output .= $html->div($adminlang->trans("from text:")." ", array("class"=>"form-name"))."\n";
$output .= $html->div($html->input("text", "emotxt", @$emotxt, array("size"=>"10"))." ".$html->span($adminlang->trans("text do not start with / (it is chat command)"),array("class"=>"txt_comment")), array("class"=>"form-input"))."\n";
$output .= $html->div($adminlang->trans("old image:")." ", array("class"=>"form-name"))."\n";
$output .= $html->div($html->img("../".$emoimg), array("class"=>"form-input"))."\n";
$output .= $html->div($adminlang->trans("to image:")." ", array("class"=>"form-name"))."\n";
$output .= $html->div($html->input("file", "emofile")." ".$html->span($adminlang->trans("jpg, gif"),array("class"=>"txt_comment")), array("class"=>"form-input"))."\n";
$output .= $html->div("", array("class"=>"form-name"))."\n";
$output .= $html->div($html->button("submit", "btnact","","submit"), array("class"=>"form-input"))."\n";
$output .= $html->div("", array("class"=>"clear"))."\n";
$output .= "</form>\n";
return $output;
}// page_emoticon_edit
function page_emoticon_delete() {
global $adminlang;// แปลไทยในหน้า admin
global $cfg, $db;
global $html;
global $act, $page, $section, $subsec;
$emo_id = form::postval("emo_id");
foreach ($emo_id as $id) {
$sql = "select * from "._dbpre_."emoticon where emo_id = ".psql($id)."";
$rs = $db->execute($sql);
if (!$db->errormsg()) {
while (!$rs->EOF) {
unlink("../".$rs->fields("emo_img"));
$db->execute("delete from "._dbpre_."emoticon where emo_id = ".psql($id)."");
if ($db->errormsg()) {die("DB error at ".$id);}
$rs->movenext();
}
} else {
die ("DB error while deleting emoticon.");
}
}
tool::redirect(_REFERER_);
}// page_emoticon_delete
?>
พอกดเลือกรูปแล้วกด อัพรูปมันขึ้น Code
Warning: move_uploaded_file(../images/emo/emo-6-evedegaset.gif): failed to open stream: Permission denied in /home/akyinth/domains/aky.in.th/public_html/room/admin/admin-emoticon.php on line 88 Warning: move_uploaded_file(): Unable to move '/tmp/phpWSwoI2' to '../images/emo/emo-6-evedegaset.gif' in /home/akyinth/domains/aky.in.th/public_html/room/admin/admin-emoticon.php on line 88