funchat/modules/ajaxpm/admin/addcategory.apnl.php
2025-06-02 10:01:12 +02:00

81 lines
No EOL
3.6 KiB
PHP

<?php
/**
* Project: astat - simple site engine
* File: /modules/news/addcategory.apnl.php
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* @link http://www.astat.org SVN: $URL: file:///var/local/svn/astat/trunk/modules/news/admin/addcategory.apnl.php $
* @copyright 2009 becast.at
* @author Bernhard Jaud <bernhard at becast dot at>
* @package astat core
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @version $Id: addcategory.apnl.php 96 2010-02-17 21:56:41Z genuineparts $
*/
If (!defined("in_BL_ADMIN")) {
die("Dieses Script kann nicht ausserhalb des Frameworks laufen!");
}
$session->page_begin("add news Category", True);
class addcategory_news_panel extends admin_module{
function output(){
global $config, $db,$panel, $root, $session, $core;
$fail=FALSE;
if(isset($_POST['send'])&& $_POST['send']==1){
if(isset($_POST['name'])&& $_POST['name']!=""){
$userfile_name = $_FILES['picture']['name'];
$userfile_tmp = $_FILES['picture']['tmp_name'];
$userfile_size = $_FILES['picture']['size'];
$userfile_type = $_FILES['picture']['type'];
$filedir = $root.'/newsimages/';
$size = 120;
if (isset($_FILES['picture']['name']) && $_FILES['picture']['name']!=""){
$prod_img = $filedir.$userfile_name;
$ret=$core->upload_file($prod_img, $userfile_tmp, $size, $size, TRUE, TRUE);
if($ret!==TRUE){
$panel->admin_message("Fehler", "Das Bild konnte nicht hochgeladen wrden <br /> Der Fehler war: ". $ret,TRUE,"addcategory_news");
}
}
$name=$db->escape($_POST['name']);
$active=$db->escape($_POST['active']);
$db->query("INSERT INTO `" . $config["prefix"]. "news_category` (`name`,`picture`,`active`) VALUES ('".$name."','".$userfile_name."','".$active."')");
$panel->admin_message("Danke", "Die Kategorie wurde erfolgreich eingetragen!.",TRUE,"addcategory_news");
}else{
$fail="<span style=\"text-align: center; color: red;\">Der Kategoriename muss angegeben werden!</span>";
}
}elseif(!isset($_POST['send']) || $fail){
$panel->title="Kategorie hinzuf&uuml;gen";
$panel->form(array("action"=>$config["path"]."/admin/index.php?panel=addcategory_news"),FALSE,"enctype=\"multipart/form-data\"");
if($fail){
$panel->content.=$fail;
}
$panel->content.="<h3>Kategoriename:</h3>";
$panel->field(array("name"=>"name","typ"=>"text","value"=>$_POST["name"]));
$panel->content.="<h3>Kategoriebild:</h3>";
$panel->field(array("name"=>"picture","typ"=>"file","value"=>$_POST["picture"]));
$panel->content.="<br />";
$panel->content.="<h3>Aktiv:</h3>";
$panel->select(array("Nein"=>"false","Ja"=>"true"),$_POST["active"],"active");
$panel->content.="<br />";
$panel->field(array("name"=>"send","typ"=>"hidden","value"=>"1"));
$panel->content.="<br />";
$panel->submit();
$panel->formClose();
}
}
}
?>