Редакция 167 | Редакция 178 | К новейшей редакции | Авторство | Сравнить с предыдущей | Последнее изменение | Открыть журнал | Скачать | RSS
<?php
/**
* Project: Ant: sources.list generator
* File: process.php
*
* This application 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 application 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
*
*/
require_once dirname(__FILE__)."/sign-valid.php";
$mode = abs(intval($_POST["mode"]));
$act = abs(intval($_POST["act"]));
$go = "./admin.php";
switch ($mode) {
case '0':
break;
case '1':
switch ($act) {
case '0':
break;
case '1':
// Добавление нового дистрибутива
$distname = mysql_real_escape_string($_POST["distName"]);
$distua = mysql_real_escape_string($_POST["distUA"]);
$disttype = abs(intval($_POST["distType"]));
$distlogo = 0;
if ($_FILES["distLOGO"]["type"]!=0) {
$folder = dirname(__FILE__)."/img/logo/".stripslashes($distua)."-orig.png";
$folderN = dirname(__FILE__)."/img/logo/".stripslashes($distua).".png";
$folderEM = dirname(__FILE__)."/img/logo/".stripslashes($distua)."-em.png";
if (move_uploaded_file($_FILES["distLOGO"]["tmp_name"],$folder)) {
chmod($folder, 0644);
list($width, $height) = GetImageSize($folder);
$percent = 32/$height;
$newwidth = $width * $percent;
$newheight = $height * $percent;
$output = ImageCreateTrueColor($newwidth, $newheight);
$source = ImageCreateFromPNG($folder);
ImageCopyResampled($output, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
ImagePNG($output, $folderEM);
$percent = 15/$height;
$newwidth = $width * $percent;
$newheight = $height * $percent;
$output = ImageCreateTrueColor($newwidth, $newheight);
ImageCopyResized($output, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
ImagePNG($output, $folderN);
unlink($folder);
$distlogo = 1;
}
}
$res =& $db->query("INSERT INTO distribution SET distname='$distname', distua='$distua', disttype='$disttype', distlogo='$distlogo'");
// ChangeLog recording
$res =& $db->query("SELECT * FROM dtype WHERE type_id='$disttype'");
$res->fetchInto($log, DB_FETCHMODE_ASSOC);
$title = "Добавлен новый дистрибутив";
$dinfo = "В Ant добавлена поддержка основанного на ".stripslashes($log["type"])."-пакетах дистрибутива ".$distname.".";
$res =& $db->query("INSERT INTO changelog SET log_record=NOW(), log_title='$title', log_desc='$dinfo'");
$go .= "?mode=".$mode."&action=0";
break;
case '2':
// Правка существующего дистрибутива
$distname = mysql_real_escape_string($_POST["distName"]);
$distua = mysql_real_escape_string($_POST["distUA"]);
$disttype = abs(intval($_POST["distType"]));
$distID = abs(intval($_POST["distID"]));
if ($_FILES["distLOGO"]["type"]!='') {
$folder = dirname(__FILE__)."/img/logo/".$distua."-orig.png";
$folderN = dirname(__FILE__)."/img/logo/".$distua.".png";
$folderEM = dirname(__FILE__)."/img/logo/".$distua."-em.png";
if (move_uploaded_file($_FILES["distLOGO"]["tmp_name"],$folder)) {
chmod ($folder, 0644);
list($width, $height) = GetImageSize($folder);
$percent = 32/$height;
$newwidth = $width * $percent;
$newheight = $height * $percent;
$output = ImageCreateTrueColor($newwidth, $newheight);
$black = ImageColorAllocate($output, 0, 0, 0);
$source = ImageCreateFromPNG($folder);
ImageCopyResampled($output, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
ImageColorTransparent($output, $black);
ImagePNG($output, $folderEM);
$percent = 15/$height;
$newwidth = $width * $percent;
$newheight = $height * $percent;
$output = ImageCreateTrueColor($newwidth, $newheight);
$black = ImageColorAllocate($output, 0, 0, 0);
ImageCopyResized($output, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
ImageColorTransparent($output, $black);
ImagePNG($output, $folderN);
unlink($folder);
$res =& $db->query("UPDATE distribution SET distlogo='1' WHERE dist_id='$distID'");
}
}
$res =& $db->query("UPDATE distribution SET distname='$distname', distua='$distua', disttype='$disttype' WHERE dist_id='$distID'");
$go .= "?mode=".$mode."&action=0";
break;
case '3':
// Удаление существующего дистрибутива
$distID = abs(intval($_POST["distID"]));
$distUA = $_POST["distUA"];
$folder1 = dirname(__FILE__)."/img/logo/".$distUA."-em.png";
$folder2 = dirname(__FILE__)."/img/logo/".$distUA.".png";
if (file_exists($folder1)) { unlink($folder1); }
if (file_exists($folder2)) { unlink($folder2); }
$res =& $db->query("SELECT * FROM distribution d JOIN dtype t ON d.disttype=t.type_id WHERE d.dist_id='$distID'");
$res->fetchInto($log, DB_FETCHMODE_ASSOC);
$res =& $db->query("DELETE FROM distribution WHERE dist_id='$distID'");
$res =& $db->query("DELETE FROM sect2dist WHERE dist_id='$distID'");
$res =& $db->query("DELETE FROM version WHERE dist_id='$distID'");
// ChangeLog recording
$title = "Удаление поддержки дистрибутива";
$dinfo = "Из Ant удалена поддержка основанного на ".stripslashes($log["type"])."-пакетах дистрибутива ".stripslashes($log["distname"]).".";
$res =& $db->query("INSERT INTO changelog SET log_record=NOW(), log_title='$title', log_desc='$dinfo'");
$go .= "?mode=".$mode."&action=0";
break;
}
break;
case '2':
switch ($act) {
case '0':
break;
case '1':
// Добавление новой версии дистрибутива
$versname = mysql_real_escape_string($_POST["versNam"]);
$versnumb = mysql_real_escape_string($_POST["versNum"]);
$verscode = mysql_real_escape_string($_POST["versCN"]);
$distname = abs(intval($_POST["distName"]));
$res =& $db->query("INSERT INTO version SET dist_id='$distname', vname='$versname', version='$versnumb', vcodename='$verscode'");
// ChangeLog recording
$res =& $db->query("SELECT * FROM distribution WHERE dist_id='$distname'");
$res->fetchInto($log, DB_FETCHMODE_ASSOC);
$title = "Добавлена новая версия ".$log["distname"];
$dinfo = "В Ant добавлена поддержка новой версии дистрибутива ".$log["distname"]." – ".$versnumb;
if ($versname!="") {
$dinfo .= " с кодовым названием “".$versname."”.";
} else {
$dinfo .= ".";
}
$res =& $db->query("INSERT INTO changelog SET log_record=NOW(), log_title='$title', log_desc='$dinfo'");
$go .= "?mode=".$mode."&action=0";
break;
case '2':
// Правка имеющейся версии дистрибутива
$versname = mysql_real_escape_string($_POST["versNam"]);
$versnumb = mysql_real_escape_string($_POST["versNum"]);
$verscode = mysql_real_escape_string($_POST["versCN"]);
$distname = abs(intval($_POST["distName"]));
$versID = abs(intval($_POST["versID"]));
$res =& $db->query("UPDATE version SET dist_id='$distname', vname='$versname', version='$versnumb', vcodename='$verscode' WHERE version_id='$versID'");
$go .= "?mode=".$mode."&action=0";
break;
case '3':
// Удаление существующей версии дистрибутива
$versID = abs(intval($_POST["versID"]));
$res =& $db->query("SELECT * FROM version v JOIN distribution d ON v.dist_id=d.dist_id WHERE v.version_id='$versID'");
$res->fetchInto($log, DB_FETCHMODE_ASSOC);
$res =& $db->query("DELETE FROM version WHERE version_id='$versID'");
$res =& $db->query("DELETE FROM ver2rep WHERE ver_id='$versID'");
// ChangeLog recording
$title = "Удалена поддержка ".$log["distname"]." ".$log["version"];
$dinfo = "Из Ant удалена поддержка версии ".$log["version"]."{CNAME} дистрибутива ".$log["distname"].".";
if ($log["vname"]!="") {
$dinfo = str_replace("{CNAME}","(“".$log["vname"]."”)",$dinfo);
} else {
$dinfo = str_replace("{CNAME}","",$dinfo);
}
$res =& $db->query("INSERT INTO changelog SET log_record=NOW(), log_title='$title', log_desc='$dinfo'");
$go .= "?mode=".$mode."&action=0";
break;
}
case '3':
switch ($act) {
case '0':
break;
case '1':
// Добавление нового источника
$origin = mysql_real_escape_string($_POST["origin"]);
$res =& $db->query("INSERT INTO origin SET origin='$origin'");
$go .= "?mode=".$mode."&action=0";
break;
case '2':
// Правка существующего источника
$origin = mysql_real_escape_string($_POST["origin"]);
$id = abs(intval($_POST["originID"]));
$res =& $db->query("UPDATE origin SET origin='$origin' WHERE origin_id='$id'");
$go .= "?mode=$mode&action=0";
break;
case '3':
// Удаление существующего источника
$id = abs(intval($_POST["originID"]));
$res =& $db->query("DELETE FROM rep2orig WHERE origin_id='$id'");
$res =& $db->query("DELETE FROM origin WHERE origin_id='$id'");
$go .= "?mode=".$mode."&action=0";
break;
}
break;
case '4':
switch ($act) {
case '0':
break;
case '1':
break;
case '2':
// Добавление нового репозитория
$versID = abs(intval($_POST["vers"]));
$repname = mysql_real_escape_string($_POST["repName"]);
$repinfo = mysql_real_escape_string($_POST["repInfo"]);
$repsche = abs(intval($_POST["scheme"]));
$reptype = abs(intval($_POST["rtype"]));
$reproot = abs(intval($_POST["rootFolder"]));
$res =& $db->query("INSERT INTO repository SET repname='$repname', repdescribe='$repinfo', scheme_id='$repsche', rtype_id='$reptype', root_id='$reproot'");
$res =& $db->query("SELECT rep_id FROM repository ORDER BY rep_id DESC LIMIT 1");
$res->fetchInto($rep, DB_FETCHMODE_ASSOC);
$rep_id = $rep["rep_id"];
$res =& $db->query("INSERT INTO ver2rep SET ver_id='$versID', rep_id='$rep_id'");
for ($i=0;$i<count($_POST["sect"]);$i++) {
$res =& $db->query("INSERT INTO sect2rep SET sect_id='".$_POST["sect"][$i]."', rep_id='$rep_id'");
}
$go .= "?mode=".$mode."&action=0";
break;
case '3':
// Правка репозитория
$repID = abs(intval($_POST["rep"]));
$repname = mysql_real_escape_string($_POST["repName"]);
$repinfo = mysql_real_escape_string($_POST["repInfo"]);
$repsche = abs(intval($_POST["scheme"]));
$reptype = abs(intval($_POST["rtype"]));
$reproot = abs(intval($_POST["rootFolder"]));
$res =& $db->query("UPDATE repository SET repname='$repname', repdescribe='$repinfo', scheme_id='$repsche', rtype_id='$reptype', root_id='$reproot' WHERE rep_id='$repID'");
$res =& $db->query("DELETE FROM sect2rep WHERE rep_id='$repID'");
for ($i=0;$i<count($_POST["sect"]);$i++) {
$res =& $db->query("INSERT INTO sect2rep SET sect_id='".$_POST["sect"][$i]."', rep_id='$repID'");
}
$go .= "?mode=".$mode."&action=0";
break;
case '4':
// Удаление репозитория
$repID = abs(intval($_POST["rep"]));
$res =& $db->query("DELETE FROM repository WHERE rep_id='$repID'");
$res =& $db->query("DELETE FROM sect2rep WHERE rep_id='$repID'");
$res =& $db->query("DELETE FROM ver2rep WHERE rep_id='$repID'");
$go .= "?mode=".$mode."&action=0";
break;
}
break;
case '5':
switch ($act) {
case '0':
break;
case '1':
// Создание секции
$sectname = mysql_real_escape_string($_POST["sectName"]);
$sectinfo = mysql_real_escape_string($_POST["sectInfo"]);
$req =& $db->query("INSERT INTO section SET sectname='$sectname', sectinfo='$sectinfo'");
$req =& $db->query("SELECT sect_id FROM section ORDER BY sect_id DESC LIMIT 1");
$req->fetchInto($sect, DB_FETCHMODE_ASSOC);
for($i=0;$i<count($_POST["dist"]);$i++) {
$req =& $db->query("INSERT INTO sect2dist SET dist_id='".$_POST["dist"][$i]."', sect_id='".$sect["sect_id"]."'");
}
$go .= "?mode=".$mode."&act=0";
break;
case '2':
// Правка секции
$sectID = abs(intval($_POST["sectID"]));
$sectname = mysql_real_escape_string($_POST["sectName"]);
$sectinfo = mysql_real_escape_string($_POST["sectInfo"]);
$req =& $db->query("UPDATE section SET sectname='$sectname', sectinfo='$sectinfo' WHERE sect_id='$sectID'");
$req =& $db->query("DELETE FROM sect2dist WHERE sect_id='$sectID'");
for($i=0;$i<count($_POST["dist"]);$i++) {
$req =& $db->query("INSERT INTO sect2dist SET dist_id='".$_POST["dist"][$i]."', sect_id='".$sectID."'");
}
$go .= "?mode=".$mode."&action=0";
break;
case '3':
// Удаление секции
$sectID = abs(intval($_POST["sectID"]));
$req =& $db->query("DELETE FROM section WHERE sect_id='$sectID'");
$req =& $db->query("DELETE FROM sect2dist WHERE sect_id='$sectID'");
$req =& $db->query("DELETE FROM sect2rep WHERE sect_id='$sectID'");
$go .= "?mode=".$mode."&action=0";
break;
}
break;
case '6':
switch ($act) {
case '0':
break;
case '1':
// Добавление новой схемы
$scheme = mysql_real_escape_string($_POST["scheme"]);
$req =& $db->query("INSERT INTO scheme SET scheme='$scheme'");
$go .= "?mode=".$mode."&act=0";
break;
case '2':
// Правка схемы
$schemeID = abs(intval($_POST["schemeID"]));
$scheme = mysql_real_escape_string($_POST["scheme"]);
$req =& $db->query("UPDATE scheme SET scheme='$scheme' WHERE scheme_id='$schemeID'");
$go .= "?mode=".$mode."&act=0";
break;
case '3':
// Удаление схемы
$schemeID = abs(intval($_POST["schemeID"]));
$req =& $db->query("DELETE FROM scheme WHERE scheme_id='$schemeID'");
$go .= "?mode=".$mode."&act=0";
break;
}
break;
case '21':
switch ($act) {
case '0':
break;
case '1':
// Добавление интерфейса
$ifname = mysql_real_escape_string($_POST["ifname"]);
$ifinfo = mysql_real_escape_string($_POST["ifinfo"]);
$ifname = str_replace(".php","",$ifname);
$req =& $db->query("INSERT INTO interfaces SET interface='$ifname', interfaceinfo='$ifinfo'");
break;
case '2':
// Правка интерфейса
$ifname = mysql_real_escape_string($_POST["ifname"]);
$ifinfo = mysql_real_escape_string($_POST["ifinfo"]);
$if = abs(intval($_POST["if"]));
$ifname = str_replace(".php","",$ifname);
$req =& $db->query("UPDATE interfaces SET interface='$ifname', interfaceinfo='$ifinfo' WHERE if_id='$if'");
break;
case '3':
// Удаление интерфейса
$if = abs(intval($_POST["if"]));
$req =& $db->query("DELETE FROM interfaces WHERE if_id='$if'");
break;
}
break;
/*-------------------------------------------------------------------------------------------------------*/
/* case '7':
switch ($act) {
case '0':
break;
case '1':
// Добавление нового типа репозитория
$rtype = mysql_real_escape_string($_POST["rtype"]);
$req =& $db->query("INSERT INTO rtype SET rtype='$rtype'");
$go .= "?mode=7&act=0";
break;
case '2':
// Правка существующего типа репозитория
$rtypeID = abs(intval($_POST["rtypeID"]));
$rtype = mysql_real_escape_string($_POST["rtype"]);
$req =& $db->query("UPDATE rtype SET rtype='$rtype' WHERE rtype_id='$rtypeID'");
$go .= "?mode=7&act=0";
break;
case '3':
// Удаление типа репозитория
$rtypeID = abs(intval($_POST["rtypeID"]));
$req =& $db->query("DELETE FROM rtype WHERE rtype_id='$rtypeID'");
$go .= "?mode=7&act=0";
break;
}
break;
case '8':
switch ($act) {
case '0':
break;
case '1':
// Создание корневой папки репозиториев
$root = mysql_real_escape_string($_POST["rootFolder"]);
$req =& $db->query("INSERT INTO root SET root_folder='$root'");
$go .= "?mode=10&act=0";
break;
case '2':
// Редактирование корневой папки репозиториев
$root_id = abs(intval($_POST["rootID"]));
$root_fd = mysql_real_escape_string($_POST["rootFolder"]);
$req =& $db->query("UPDATE root SET root_folder='$root_fd' WHERE root_id='$root_id'");
$go .= "?mode=10&act=0";
break;
case '3':
// Удаление корневой папки репозиториев
$root_id = abs(intval($_POST["rootID"]));
$req =& $db->query("DELETE FROM root WHERE root_id='$root_id'");
$go .= "?mode=10&act=0";
break;
}
break;
case '13':
switch ($act) {
case '0':
break;
case '1':
// Добавление новой настройки Ant
$option = mysql_real_escape_string($_POST["setoption"]);
$value = mysql_real_escape_string($_POST["setvalue"]);
$req =& $db->query("INSERT INTO settings SET opt='$option', optvalue='$value'");
break;
case '2':
// Правка настройки Ant
$optID = abs(intval($_POST["optID"]));
$option = mysql_real_escape_string($_POST["setoption"]);
$value = mysql_real_escape_string($_POST["setvalue"]);
$req =& $db->query("UPDATE settings SET opt='$option', optvalue='$value' WHERE opt_id='$optID'");
break;
case '3':
// Удаление настройки
$optID = abs(intval($_POST["optID"]));
$req =& $db->query("DELETE FROM settings WHERE opt_id='$optID'");
break;
}
break;
case '14':
switch ($act) {
case '0':
break;
case '1':
// Смена пароля
// $OID = abs(intval($_POST["OID"]));
$oldpass = mysql_real_escape_string($_POST["oldPW"]);
$newpass1 = mysql_real_escape_string($_POST["newPW1"]);
$newpass2 = mysql_real_escape_string($_POST["newPW2"]);
$errpwd = 0;
$spass = md5($newpass1."ANT");
$soldpass = md5($oldpass."ANT");
if ($soldpass != $_COOKIE[$CookiePasswd]) {
$go .= "?error=1";
$errpwd = 1;
}
if ($newpass1 != $newpass2) {
$go .= "?error=2";
$errpwd = 2;
}
if ($errpwd==0) {
// fix: Для многопользовательского варианта придется запрос переписать
$req =& $db->query("UPDATE owner SET passwd='$spass' WHERE login='admin'");
}
break;
}
break;*/
}
header("Location: $go\n\n");
?>