public static function registerController()
 {
     $controllerPathPostFix = "_Controller.class.php";
     $length = strlen($controllerPathPostFix);
     $exclude_list = array(".", "..", "example.txt");
     $filesInDir = array_diff(scandir(self::$settings["classpaths"]["controller_classes"]), $exclude_list);
     foreach ($filesInDir as $filename) {
         self::$controller[strtolower(substr($filename, 0, -$length))] = substr($filename, 0, -strlen(".class.php"));
     }
     ErrorReporter::logVarExport('Registry::$controller => controllers registered', self::$controller);
 }
 public static function autoload($className)
 {
     foreach (self::$class_paths as $key => $classPath) {
         $filePath = $classPath . $className . ".class.php";
         if (file_exists($filePath)) {
             include_once $filePath;
             ErrorReporter::logMessage("ClassLoader::autoload(" . $className . ") => " . $classPath . $className . ".class.php loaded");
             return;
         }
     }
     ErrorReporter::logMessage("ClassLoader::autoload(" . $className . ") => " . $className . " not found");
     die('Couldnt find class: <strong>' . $className . '</strong> !');
 }
    public function showPage(Request $request)
    {
        // creating MainPage and modifing header information
        $page = MainPage::create();
        $page->getLayoutElem("header")->addHeaderElem('<link rel="stylesheet" type="text/css" href="' . Registry::$settings['config']['CSS_PATH'] . 'products_view_layout.css">');
        $page->getLayoutElem("header")->addHeaderElem('
        <script type="text/javascript">
                 var edi_feld_focused = false;
                 var basket = new Basket();
                 document.onkeydown = function(e){
                     var evt = e ? e:event;
                     var keyCode = evt.keyCode;
                     if(keyCode == 13 && edi_feld_focused){
                         search();
                     }
                 };
                function search(){
                    //alert(document.getElementById("search_string").value);
                     var url ="products?search="+document.getElementById("search_string").value;
                     window.location.href = url;
                }
                function addToBasket(productid){
                 var oldCookie = document.cookie;
                 document.cookie = oldCookie+""

                }
                function Basket(){
                    this.items = {};

                }
                Basket.prototype.addItem = function(itemID){
                    if(this.items[itemID] == undefined){
                        this.items[itemID] = 1;

                    }else{
                       var tmp = this.items[itemID];
                       this.items[itemID] = tmp+1;

                    }
                };
                Basket.prototype.removeItem = function(itemID){
                    if(!this.items[itemID] == undefined){
                       var tmp = this.items[itemID];
                       this.items[itemID] = tmp-1;

                    }
                };
         </script>');
        // deciding which content to build
        // this $request->get doesnt mean get, its the PHP $_GET which is wraped in Request class
        ErrorReporter::logVarExport(__CLASS__ . "::showPage(request) => request get export", $request->get);
        ErrorReporter::logVarExport(__CLASS__ . "::showPage(request) => request post export", $request->post);
        $search_string = $request->get["search"];
        $basketItem = $request->get["itemID"];
        if (!empty($basketItem)) {
            if (empty($_SESSION["basket"])) {
                $_SESSION["basket"] = array();
            }
            $itemID = mysql_real_escape_string($basketItem);
            $count = $_SESSION["basket"][$itemID];
            if (!empty($count)) {
                $_SESSION["basket"][$itemID] = $count + 1;
            } else {
                $_SESSION["basket"][$itemID] = 1;
            }
        }
        if (!empty($search_string)) {
            // fetch sql data
            //            var_dump(mysql_real_escape_string($search_string));
            $resultSet = TeileMapperImpl::make()->getListOfTeileByBezeichnung(mysql_real_escape_string($search_string));
            if (count($resultSet) == 1) {
                MonitorEntry::updateEntry($resultSet[0]->getBezeichnung);
            }
            $prev_search = "search=" . $search_string . "&";
        } else {
            // fetch sql data
            //            $resultSet = TeileMapperImpl::make()->getAlleProdukte();
            $resultSet = TeileMapperImpl::make()->getProdukte();
        }
        // fetch view and apply data to view
        $page->setContentView(Products_View::create());
        $page->getLayoutElem("contentview")->applyData(array("products" => $resultSet, "prev_search" => $prev_search));
        // show view
        $page->showPage($page->layoutElementMap);
    }
    public function showPage(Request $request)
    {
        // creating MainPage and modifing header information
        $page = MainPage::create();
        $page->getLayoutElem("header")->addHeaderElem('<link rel="stylesheet" type="text/css" href="' . Registry::$settings['config']['CSS_PATH'] . 'adminpanel_view_layout.css">');
        $page->getLayoutElem("header")->addHeaderElem('
        <script type="text/javascript">
               var old_color = "white";
               function highlight_row($divElem){
                    if(old_color == "white") old_color = $divElem.style.backgroundColor;
                    $divElem.style.backgroundColor = "#FFF2D5";
               }

               function unhighlight_row($divElem){
                    $divElem.style.backgroundColor = old_color;
               }

               function stueckListeVonAnfordern(){
                    var produkt = document.getElementById("stueckliste_produkt").value;
                    window.location.href = "adminpanel?stuecklisteVon="+produkt;
               }

               function teil_hinzufuegen(){
                        var bezeichnung,preis,kategorie,wirdAngeboten,bild,beschreibung;
                        bezeichnung = document.getElementById("teil_bezeichnung").value;
                        preis = document.getElementById("teil_preis").value;
                        kategorie = document.getElementById("teil_typ").value;
                        wirdAngeboten = document.getElementById("teil_angeboten").value;
                        bild = document.getElementById("teil_bild").value;
                        beschreibung = document.getElementById("teil_beschreibung").value;
                        window.location.href = "adminpanel?teil_bezeichnung="+bezeichnung+
                                               "&teil_preis="+preis+
                                               "&teil_typ="+kategorie+
                                               "&teil_angeboten="+wirdAngeboten+
                                               "&teil_bild="+bild+
                                               "&teil_beschreibung="+beschreibung;
               }

               /*
               *          <input type="text" id="struktur_otnr" value="OTNR">
                        <input type="text" id="struktur_utnr" value="UTNR">
                        <input type="text" id="struktur_menge" value="Menge">
                        <button onclick="javascript:struktur_hinzufuegen()">Eintragen</button>*/
               function struktur_hinzufuegen(){
                     var otnr,utnr,menge;
                        otnr = document.getElementById("struktur_otnr").value;
                        utnr = document.getElementById("struktur_utnr").value;
                        menge = document.getElementById("struktur_menge").value;

                         window.location.href = "adminpanel?struktur_otnr="+otnr+
                                               "&struktur_utnr="+utnr+
                                               "&struktur_menge="+menge;

               }

               function berechnen(){

                    var glaettungsfaktor = parseFloat(document.getElementById("glaettungsfaktor").value);
                    var monat = document.getElementById("monat").value;
                    var jahr = document.getElementById("jahr").value;
                    var teilName = document.getElementById("teilname").value;

                     window.location.href = "adminpanel?monat="+monat+
                                             "&jahr="+jahr+
                                             "&teilname="+teilName+
                                             "&faktor="+glaettungsfaktor;

               }

               function kunde_hinzufuegen(){
//                                       <input type="text" id="kunde_Name" value="Name">
//                        <input type="text" id="kunde_Vorname" value="Vorname">
//                        <input type="text" id="kunde_eMail" value="eMail">
                    var name,vorname,email;
                    name = document.getElementById("kunde_Name").value;
                    vorname = document.getElementById("kunde_Vorname").value;
                    email = document.getElementById("kunde_eMail").value;

                    window.location.href = "adminpanel?kunde_Name="+name+
                                               "&kunde_Vorname="+vorname+
                                               "&kunde_eMail="+email;

               }

       </script>');
        // deciding which content to build
        // this $request->get doesnt mean get, its the PHP $_GET which is wraped in Request class
        ErrorReporter::logVarExport(__CLASS__ . "::showPage(request) => request get export", $request->get);
        ErrorReporter::logVarExport(__CLASS__ . "::showPage(request) => request post export", $request->post);
        $stuecklisteProdukt = $request->get["stuecklisteVon"];
        $teil_bezeichnung = $request->get["teil_bezeichnung"];
        $teil_preis = $request->get["teil_preis"];
        $teil_typ = $request->get["teil_typ"];
        $teil_angeboten = $request->get["teil_angeboten"];
        $teil_bild = $request->get["teil_bild"];
        $teil_beschreibung = $request->get["teil_beschreibung"];
        $struktur_otnr = $request->get["struktur_otnr"];
        $struktur_utnr = $request->get["struktur_utnr"];
        $struktur_menge = $request->get["struktur_menge"];
        $kunde_name = $request->get["kunde_Name"];
        $kunde_vorname = $request->get["kunde_Vorname"];
        $kunde_email = $request->get["kunde_eMail"];
        if (isset($teil_bezeichnung) && isset($teil_preis) && isset($teil_typ) && isset($teil_angeboten) && isset($teil_beschreibung)) {
            TeileMapperImpl::make()->teilErstellen($teil_bezeichnung, $teil_preis, $teil_typ, $teil_angeboten, "application/view/images/" . $teil_bild, $teil_beschreibung);
        }
        if (isset($struktur_otnr) && isset($struktur_utnr) && isset($struktur_menge)) {
            StrukturMapperImpl::make()->strukturAnlegen($struktur_otnr, $struktur_utnr, $struktur_menge);
        }
        if (isset($kunde_name) && isset($kunde_vorname) && isset($kunde_email)) {
            KundeMapperImpl::make()->kundeHinzufuegen($kunde_name, $kunde_vorname, $kunde_email);
        }
        //testdaten initialisieren
        if (isset($stuecklisteProdukt)) {
            StrukturMapperImpl::make()->getAlleStrukturen();
            //listeVonTeilen und ListeVonStrukturen wird in getAlleStrukuren erzeugt
            Stueckliste::bestimmeOberUndUnterteile(Stueckliste::$listeVonTeilen, Stueckliste::$listeVonStrukturen);
            //          Stueckliste::stueckliste_test();
            $stuecklisteProdukt = Stueckliste::getProdukt($stuecklisteProdukt);
            //AuftragsVerfolgung::teilHinzufuegen($stuecklisteProdukt,200,AuftragsVerfolgung::getTimestamp(5,12,2012));
        }
        //        $abc_analyse_result = ABC_Analyse::abc_analyse_test();
        $abc_analyse_result = ABC_Analyse::analyse(ABC_Analyse::convertToABC_ADT(TeileMapperImpl::make()->getAlleTeile()));
        //var_dump(BestellungMapperImpl::make()->getBestellungenByKundenID(1));
        $bedarfs_daten = AuftragsVerfolgung::getAlleBedarfe();
        $bedarfsableitungs_daten = AuftragsVerfolgung::getAlleBedarfsAbleitungen();
        $faktor = $request->get["faktor"];
        $monat = $request->get["monat"];
        $jahr = $request->get["jahr"];
        $teilname = $request->get["teilname"];
        if (isset($teilname) and isset($jahr) and isset($monat) and isset($faktor)) {
            $bedarfsanalyse_ergebnis = PrimaerbedarfsAnalyse::calcZukuenftigenBedarf($teilname, $monat, $jahr, $faktor);
        } else {
            $bedarfsanalyse_ergebnis = " ";
            $teilname = "Aircar";
            $monat = "12";
            $jahr = "2012";
            $faktor = "0.20";
        }
        //        PrimaerbedarfsAnalyse::primaerbedarfstest();
        // fetch view and apply data to view
        $page->setContentView(AdminPanel_View::create());
        $page->getLayoutElem("contentview")->applyData(array("stueckliste_produkt" => $stuecklisteProdukt, "abc_analyse_array" => $abc_analyse_result, "bedarfs_daten" => $bedarfs_daten, "bedarfsableitungs_daten" => $bedarfsableitungs_daten, "bedarfsanalyse_ergebnis" => $bedarfsanalyse_ergebnis, "bedarfsanalyse_teilname" => $teilname, "bedarfsanalyse_monat" => $monat, "bedarfsanalyse_jahr" => $jahr, "bedarfsanalyse_faktor" => $faktor));
        // show view
        $page->showPage($page->layoutElementMap);
    }
Exemplo n.º 5
0
                    $error_level = 0;
                    break;
                case E_WARNING:
                case E_USER_WARNING:
                    $error_level = 1;
                    break;
                case E_NOTICE:
                case E_USER_NOTICE:
                    $error_level = 2;
                    break;
                    $error_level = 0;
                default:
                    $error_level = 0;
                    break;
            }
            if (isset($app)) {
                $app->onError($error_level, $errstr, $errfile, $errline);
                $parsed = true;
            } else {
                $parsed = false;
            }
        }
        return $parsed;
    }
    function init()
    {
        $old_error_handler = set_error_handler(array("ErrorReporter", "handler"));
    }
}
ErrorReporter::init();
    public function showPage(Request $request)
    {
        // creating MainPage and modifing header information
        $page = MainPage::create();
        $page->getLayoutElem("header")->addHeaderElem('<link rel="stylesheet" type="text/css" href="' . Registry::$settings['config']['CSS_PATH'] . 'basketoverview_view_layout.css">');
        $page->getLayoutElem("header")->addHeaderElem('<script type="text/javascript">
            function removeItems(itemID,oldCount){
                var count_field = document.getElementById("product_"+itemID+"_count");
                var currentCount = count_field.value;
                if(currentCount >= 0 && currentCount < oldCount){
                    if(confirm("Sie sind dabei "+(oldCount-currentCount)+" Artikel von diesem Artikel entfernen")){
                          window.location.href = "basketoverview?itemID="+itemID+"&count="+currentCount;
                    }else{

                    }
                }else{
                    if(currentCount == oldCount){
                        alert("Zum entfernen die neue Menge die Sie behalten wollen eintragen.")
                    }
                    count_field.value=oldCount;
                }
            }

            function bestellen(){
                var day = document.getElementById("day").value;
                var month = document.getElementById("month").value;
                var year = document.getElementById("year").value;
                var gesamtpreis = document.getElementById("gesamtpreis").innerHTML;
                if(confirm("Sie sind dabei ihre Bestellung im Wert von "+gesamtpreis+" abzuschicken, bestätigen Sie dies bitte!")){
                   window.location.href = "basketoverview?bestellen=1&day="+day+"&month="+month+"&year="+year;
                }
            }

        </script>');
        // deciding which content to build
        // this $request->get doesnt mean get, its the PHP $_GET which is wraped in Request class
        ErrorReporter::logVarExport(__CLASS__ . "::showPage(request) => request get export", $request->get);
        ErrorReporter::logVarExport(__CLASS__ . "::showPage(request) => request post export", $request->post);
        $basketItem = $request->get["itemID"];
        $count = $request->get["count"];
        if (isset($basketItem) && isset($count)) {
            $basketItem = mysql_real_escape_string($basketItem);
            $count = mysql_real_escape_string($count);
            if ($_SESSION["basket"][$basketItem] > $count) {
                if (!($count <= 0)) {
                    $_SESSION["basket"][$basketItem] = $count;
                } else {
                    $_SESSION["basket"] = array_diff_key($_SESSION["basket"], array($basketItem => $count));
                }
            }
        }
        $products = array();
        if (isset($_SESSION["basket"])) {
            foreach ($_SESSION["basket"] as $productID => $count) {
                array_push($products, TeileMapperImpl::make()->getTeileById($productID));
            }
        }
        $month = $request->get["month"];
        $day = $request->get["day"];
        $year = $request->get["year"];
        if (isset($request->get["bestellen"]) and isset($month) and isset($day) and isset($year)) {
            StrukturMapperImpl::make()->getAlleStrukturen();
            //listeVonTeilen und ListeVonStrukturen wird in getAlleStrukuren erzeugt
            Stueckliste::bestimmeOberUndUnterteile(Stueckliste::$listeVonTeilen, Stueckliste::$listeVonStrukturen);
            //          Stueckliste::stueckliste_test();
            $lieferdatum = AuftragsVerfolgung::getTimestamp($day, $month, $year);
            foreach ($products as $product) {
                $teil = Stueckliste::getProdukt($product->getBezeichnung());
                AuftragsVerfolgung::teilHinzufuegen($teil, $_SESSION["basket"][$teil->id()], $lieferdatum);
            }
            $_SESSION["basket"] = array();
            $products = array();
        }
        // fetch view and apply data to view
        $page->setContentView(BasketOverview_View::create());
        $page->getLayoutElem("contentview")->applyData(array("basket" => $_SESSION['basket'], "products" => $products));
        // show view
        $page->showPage($page->layoutElementMap);
    }
Exemplo n.º 7
0
<?php

/* bootstrap */
/* Error Reporting: */
error_reporting(E_ALL & ~E_NOTICE);
define("BASE_PATH", dirname(realpath(__FILE__)) . "\\");
define("APP_PATH", BASE_PATH . "application\\");
require_once APP_PATH . "config.php";
define("PATH", $_CONFIG['path']);
require_once APP_PATH . "registry.php";
require_once APP_PATH . "classloader.php";
// adding class directorys
ClassLoader::setClassPaths($__CLASSPATHS);
// binding ClassLoader
spl_autoload_register(array('ClassLoader', 'autoload'));
// linking settings to registry
Registry::$settings['config'] =& $__CONFIG;
Registry::$settings['classpaths'] =& $__CLASSPATHS;
Registry::$settings['database'] =& $__DATABASE;
ErrorReporter::logPageRequest();
session_start();
//starting main Application
$app = Application::start();
//include(APP_PATH . "view/phtml/default_view.phtml");
<?php

class ErrorReporter
{
    const POST_URL = "url";
    const POST_MESSAGE = "msg";
    const LOG_URL = "error.log";
    private $url = "";
    private $message = "";
    public function init()
    {
        $this->checkPOST();
    }
    private function checkPOST()
    {
        $this->url = stripcslashes($_POST[ErrorReporter::POST_URL]);
        $this->message = stripcslashes($_POST[ErrorReporter::POST_MESSAGE]);
        $date = new DateTime();
        $dateString = $date->format('Y-m-d H:i:s');
        if (isset($this->url) && isset($this->url)) {
            $file = fopen(ErrorReporter::LOG_URL, "a");
            fwrite($file, $dateString . " " . $this->message . "\n");
            fclose($file);
            echo "complete";
        } else {
            echo "error";
        }
    }
}
$errorReporter = new ErrorReporter();
$errorReporter->init();