Хранилища Subversion ant

Редакция

Редакция 533 | Редакция 535 | К новейшей редакции | Авторство | Сравнить с предыдущей | Последнее изменение | Открыть журнал | RSS

<?php

/**
 *  
 *  Codename: ant-ng - generator of sources.list for Debian and
 *  distributives, based on Debian
 *  http://alex-w.org.ru/p/antng/
 *
 *  Copyright (c) 2009 Alexander Wolf
 *  Dual licensed under the MIT and GNU LGPL licenses.
 *  http://alex-w.org.ru/p/antng/license
 *
 */


require_once dirname(__FILE__)."/init.php";

$mode = $_POST["mode"];

switch ($mode) {
    case 'authorize':
        $r = $core->checkSign($_POST["word"]);
        header("Location: ".$r["Location"]."\n\n");
        break;
    case 'distributive-add':
        // Добавление нового дистрибутива
        $DName  = $secure->checkStr($_POST["dname"],1);
        $DUA    = $secure->checkStr($_POST["dua"],1);
        $DType  = $secure->checkInt($_POST["dtype"]);
        $DLogo  = 0;

        if ($_FILES["distlogo"]["type"]!=0) {
            $folder   = $picture.$DUA."-orig.png";
            $folderN  = $picture.$DUA.".png";
            $folderEM = $picture.$DUA."-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);
                $DLogo = 1;
            }
        }

        $r = $core->addDistribution($DName, $DType, $DUA, $DLogo);
        if ($r["ERR"]==0) {
            header("Location: ".$manager."\n\n");
        } else {
            echo $r["ERRINFO"];
        }

        break;
    case 'distributive-edit':
        // Редактирование информации о дистрибутиве
        $ID     = $secure->checkInt($_POST["distID"]);
        $DName  = $secure->checkStr($_POST["dname"],1);
        $DUA    = $secure->checkStr($_POST["dua"],1);
        $DType  = $secure->checkInt($_POST["dtype"]);
        $DLogo  = 0;

        echo "D:".$_FILES["distlogo"]["type"];
        if ($_FILES["distlogo"]["type"]!="") {
            $folder   = $picture.$DUA."-orig.png";
            $folderN  = $picture.$DUA.".png";
            $folderEM = $picture.$DUA."-em.png";

            // debug on
            echo " F:".$folder;

            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);
                $DLogo = 1;
            }
        }

        $r = $core->updateDistribution($ID, $DName, $DType, $DUA, $DLogo);
        if ($r["ERR"]==0) {
            //header("Location: ".$manager."\n\n");
        } else {
            echo $r["ERRINFO"];
        }

        break;
    case 'distributive-delete':
        // Удаление информации о дистрибутиве
        $ID     = $secure->checkInt($_POST["distID"]);

        $r = $core->dropDistribution($ID);
        if ($r["ERR"]==0) {
            header("Location: ".$manager."\n\n");
        } else {
            echo $r["ERRINFO"];
        }

        break;
    case 'version-add':
        // Добавление новой версии дистрибутива
        $DistID = $secure->checkInt($_POST["distname"]);
        $VName  = $secure->checkStr($_POST["vname"],1);
        $VNmbr  = $secure->checkStr($_POST["version"],1);
        $VCNme  = $secure->checkStr($_POST["vcodename"],1);

        $r = $core->addDistVersion($DistID, $VNmbr, $VName, $VCNme);
        if ($r["ERR"]==0) {
            header("Location: ".$manager."\n\n");
        } else {
            echo $r["ERRINFO"];
        }

        break;
    case 'version-edit':
        // Редактирование версии дистрибутива
        $versID = $secure->checkInt($_POST["versionID"]);
        $VName  = $secure->checkStr($_POST["vname"],1);
        $VNmbr  = $secure->checkStr($_POST["version"],1);
        $VCNme  = $secure->checkStr($_POST["vcodename"],1);

        $r = $core->updateDistVersion($versID, $VNmbr, $VName, $VCNme);
        if ($r["ERR"]==0) {
            header("Location: ".$manager."\n\n");
        } else {
            echo $r["ERRINFO"];
        }

        break;
    case 'version-delete':
        // Удаление версии дистрибутива
        $versID = $secure->checkInt($_POST["versionID"]);

        $r = $core->dropDistVersion($versID);
        if ($r["ERR"]==0) {
            header("Location: ".$manager."\n\n");
        } else {
            echo $r["ERRINFO"];
        }

        break;
    case 'section-add':
        // Добавление новой секции
        $SName  = $secure->checkStr($_POST["sname"],1);
        $SInfo  = $secure->checkStr($_POST["sinfo"],1);

        $r = $core->addSection($SName, $SInfo);
        if ($r["ERR"]==0) {
            header("Location: ".$manager."\n\n");
        } else {
            echo $r["ERRINFO"];
        }

        break;
    case 'section-edit':
        // Редактирование информации о секции
        $sectID = $secure->checkInt($_POST["sectionID"]);
        $SName  = $secure->checkStr($_POST["sname"],1);
        $SInfo  = $secure->checkStr($_POST["sinfo"],1);

        $r = $core->updateSection($sectID, $SName, $SInfo);
        if ($r["ERR"]==0) {
            header("Location: ".$manager."\n\n");
        } else {
            echo $r["ERRINFO"];
        }

        break;
    case 'section-delete':
        // Удаление информации о секции
        $sectID = $secure->checkInt($_POST["sectionID"]);

        $r = $core->dropSection($sectID);
        if ($r["ERR"]==0) {
            header("Location: ".$manager."\n\n");
        } else {
            echo $r["ERRINFO"];
        }

        break;
}

?>