コード例 #1
0
ファイル: adminUzivatele.php プロジェクト: klofac/combros
        }
        //pridat skupiny
        $sql = "SELECT * FROM skupiny\n              WHERE stav != 'none' AND id NOT IN (" . implode($uzivatelovy_skupiny, ",") . ")\n              ORDER BY nazev";
        $rs = $sqlEngine->query($sql);
        if (SQLEngine::getRowCount($rs) > 0) {
            $TM->assignBlockVars('uzivatel.edit.pridat', $actionHere, 2);
            foreach (SQLEngine::getRows($rs) as $skupina) {
                unset($T_data);
                $T_data["id"] = $skupina["id"];
                $T_data["nazev"] = $skupina["nazev"];
                $TM->assignBlockVars('uzivatel.edit.pridat.kategorie', $T_data, 3);
            }
            $sql = "SELECT * FROM kanaly";
            $rs = $sqlEngine->query($sql);
            $nastavenyKanal = false;
            foreach (SQLEngine::getRows($rs) as $kanal) {
                unset($T_data);
                $T_data["id"] = $kanal["id"];
                $T_data["nazev"] = $kanal["nazev"];
                if ($kanal["nazev"] == "email" && $u["email"] != "" || $kanal["nazev"] == "sms" && $u["sms"] != "") {
                    $nastavenyKanal = true;
                    $TM->assignBlockVars('uzivatel.edit.pridat.kanal', $T_data, 3);
                }
            }
            if (!$nastavenyKanal) {
                $TM->assignBlockVars('uzivatel.edit.pridat', array("kategorieAddDisable" => "disabled=\"disabled\""), 3);
            }
        }
    }
} else {
    $TM->assignBlockVars('uzivatel.vyberUzivatele', array(), 1);
コード例 #2
0
ファイル: adminReminder.php プロジェクト: klofac/combros
require_once "../lib/log-1.11.4/Log.php";
$conf["log"]["logfile"] = $conf["tmpDir"] . $conf["separator"] . $_SERVER["SERVER_NAME"] . ".log";
//uroven logu, ktera se bude ukladat
//PEAR_LOG_EMERG, PEAR_LOG_ALERT, PEAR_LOG_CRIT, PEAR_LOG_ERR,
//PEAR_LOG_WARNING, PEAR_LOG_NOTICE, PEAR_LOG_INFO, PEAR_LOG_DEBUG
$conf["log"]["level"] = PEAR_LOG_DEBUG;
//druh handleru (mail,file,console,firebug,display,error_log,null,mdb2,syslog,sql)
$conf["log"]["handler"] = "file";
//rozsirujici konfigurace handleru
$conf["log"]["conf"] = array("timeFormat" => "%Y-%m-%d %H:%M:%S", "lineFormat" => "%{timestamp} [%{priority}] %{message}", "buffering" => true);
//konec logu
session_start();
//inicializace db
foreach ($conf["sqlconn"] as $server => $db) {
    try {
        $sqlEngine = new SQLEngine();
        $sqlEngine->setSlaveConnection($db["dbhost"], $db["dbuser"], $db["dbpass"], $db["dbname"]);
        $adminDataQuery = "SELECT * FROM spravce_info";
        $rs = $sqlEngine->query($adminDataQuery);
        $conf["spravce_info"] = SQLEngine::getFirstRow($rs);
        $pocetDnu = 7;
        $rozdil = 60 * 60 * 24 * $pocetDnu;
        $selMsg = "SELECT TIMESTAMPDIFF(DAY, vlozeno, NOW()) as naposledyVlozeno\n           FROM zpravy\n           INNER JOIN spravce_admini ON spravce_admini.id = zpravy.vytvoril\n           WHERE TIMESTAMPDIFF(DAY, vlozeno, NOW()) >= 7";
        $rs = $sqlEngine->query($selMsg);
        if (SQLEngine::getRowCount($rs) > 0) {
            $pocetDnu = SQLEngine::getFirstRow($rs);
            $pocetDnu = $pocetDnu["naposledyVlozeno"];
            echo $server . ": " . $pocetDnu . " > " . $conf["spravce_info"]["spravceEmail"] . "<br />";
            $mail = new PHPMailer();
            $mail->From = $conf["spravce_info"]["odesilatelEmail"];
            $mail->FromName = $conf["spravce_info"]["odesilatelName"];
コード例 #3
0
ファイル: publicMessages.php プロジェクト: klofac/combros
            $T_data["stav"] = "Bude rozeslano: " . date("d.m.Y H:i", $zprava["odeslatPo"]);
            break;
        case "PROGRESS":
            $T_data["stav"] = "Probíhá rozesílání";
            break;
        case "DONE":
            $T_data["stav"] = "Zpráva rozeslána";
            break;
    }
    // zobrazujeme jen nadpis, nebudeme obycejne uzivatele informovat o vnitrnich stavech
    $T_data["stav"] = "Kategorie";
    $T_data["menu"] = $menu;
    $TM->assignBlockVars('msg', $T_data);
    $query = "SELECT idSkupiny, skupiny.stav FROM zpravy_skupiny\n            INNER JOIN skupiny ON skupiny.id = zpravy_skupiny.idSkupiny\n            WHERE zpravy_skupiny.idZpravy = " . $zprava["id"];
    $qSkupiny = $sqlEngine->query($query);
    foreach (SQLEngine::getRows($qSkupiny) as $sk) {
        unset($T_data_skupiny);
        if ($sk["stav"] == "public") {
            $T_data_skupiny["filterSkupinaURL"] = getUrl("publicMessages", array("skupina" => $sk["idSkupiny"]));
        } else {
            $T_data_skupiny["filterSkupinaURL"] = "javascript: alert('Nejde nastavit filter na privátní skupinu')";
        }
        $T_data_skupiny["nazev"] = $skupiny[$sk["idSkupiny"]];
        $TM->assignBlockVars('msg.skupiny', $T_data_skupiny, 1);
    }
    $vypsanychZprav++;
    if ($vypsanychZprav >= $vypsatZprav) {
        break;
    }
}
if ($vypsanychZprav == 0) {
コード例 #4
0
ファイル: bgWorker.php プロジェクト: klofac/combros
             $out["result_text"] = SQLEngine::getErrorText($rs);
             unset($_SESSION["bgWorker"]["authCode"]);
             $_SESSION["user"]["email"] = $_REQUEST["email"];
             $script .= "alert('Zadaný kód byl úspěšně ověřen, děkujeme. " . $out["result_text"] . "');parent.location.href='" . getUrl("userDetail", array("s" => $_REQUEST["svalue"])) . "';";
         } else {
             // kod neni zadan v poradku
             $script = "alert('Zadaný kód není správný');";
         }
         break;
     case 'checkAuthCodesms':
         // overime zda auth kod je ;
         if ($_SESSION["bgWorker"]["authCode"] == $_REQUEST["authcodesms"]) {
             // bezpecnostni zdrzeni kvuli robotum
             sleep(2);
             //inicializace db
             $sqlEngine2 = new SQLEngine($conf["sqlconn"][$_REQUEST["svalue"]]["dbhost"], $conf["sqlconn"][$_REQUEST["svalue"]]["dbuser"], $conf["sqlconn"][$_REQUEST["svalue"]]["dbpass"], $conf["sqlconn"][$_REQUEST["svalue"]]["dbname"]);
             $sql2 = "UPDATE uzivatele SET sms=? WHERE id=?";
             $rs = $sqlEngine2->query($sql2, array($_REQUEST["sms"], $_SESSION["user"]["id"]));
             $out["result"] = SQLEngine::getErrorCode($rs);
             $out["result_text"] = SQLEngine::getErrorText($rs);
             unset($_SESSION["bgWorker"]["authCode"]);
             $_SESSION["user"]["email"] = $_REQUEST["email"];
             $script = "alert('Zadaný kód byl úspěšně ověřen, děkujeme. " . $out["result_text"] . "');parent.location.href='" . getUrl("userDetail", array()) . "';";
         } else {
             // kod neni zadan v poradku
             $script = "alert('Zadaný kód není správný');";
         }
         break;
     default:
         break;
 }
コード例 #5
0
ファイル: sablonyZprav.php プロジェクト: klofac/combros
 function vypis($bazarId = 0, $nazevSablony = "", $order_by = "nazev", $order_type = "DESC")
 {
     $where = "";
     if ($nazevSablony != "") {
         $where .= " AND nazev='" . $nazevSablony . "'";
     }
     //nacti defaultni sablony - bazarId=0
     $sql = "SELECT sablony_zprav.* FROM sablony_zprav WHERE 1=1 and bazarId=0 " . $where . " order by " . $order_by . " " . $order_type;
     $rs = $this->db2->query($sql);
     foreach (SQLEngine::getRows($rs) as $row) {
         //$row["body_html"]=str_replace('\"','"',$row["body_html"]);
         $out[$row["nazev"]] = $row;
     }
     //pridej zbytek filtru
     if ($bazarId != 0 and $bazarId != "") {
         $where .= " AND bazarId=" . $bazarId;
     }
     //ted nacti a prepis aktualnim zaznamem
     $sql = "SELECT sablony_zprav.* FROM sablony_zprav  WHERE 1=1 " . $where;
     $rs = $this->db2->query($sql);
     foreach (SQLEngine::getRows($rs) as $row) {
         //$row["body_html"]=str_replace('\"','"',$row["body_html"]);
         $out[$row["nazev"]] = $row;
     }
     return $out;
 }
コード例 #6
0
ファイル: adminLogin.php プロジェクト: klofac/combros
<?php

adminLoginValidate(false);
// controler, odchyceni vstupu
if ($_REQUEST["login"] != "" && $_REQUEST["heslo"] != "") {
    // zavolame backend na overeni pristupu
    // kontrola zda neni uzivatel se stejnym loginem j*z registrovan
    $sql = "SELECT * FROM spravce_admini WHERE login=? AND heslo=SUBSTRING(MD5(?), 1, 20)";
    $rs = $sqlEngine->query($sql, array($_REQUEST["login"], $_REQUEST["heslo"]));
    $admin = SQLEngine::getFirstRow($rs);
    if ($admin["id"] > 0) {
        // pokud je overeni ok, naplnime session, jinak vratime zpravu ze prihlaseni nebylo uspesne
        $_SESSION["admin"] = $admin;
        //tady bude redirect na userDetail
        header('location: ' . getUrl("adminSeznamZprav", array()));
        exit;
    } else {
        $chyba = "Login nebo heslo nebylo zadáno správně";
    }
}
// promyslet jak udelat prenaseni hesla bezpecnejsi pomoci jednorazoveho hesla nebo predanim klice kterym JS MD5 zahesuje pred odeslanim heslo, heslo by bylo ulozene v session a vygeneruje se vzdy pri vytvoreni formulare nove
// vybereme hlavni sablonu
$T->setFile('modulX', 'srcTpl/admin.htm');
// polozky menu
include_once 'moduly/menuAdmin.php';
// nastartujeme lokalni sablonu
$TM = new MyTemplate();
$TM->setFile('modulY', 'srcTpl/adminLogin_modul.htm');
if (isset($chyba)) {
    unset($T_data);
    $T_data['textChyby'] = $chyba;
コード例 #7
0
ファイル: adminNovaZprava.php プロジェクト: klofac/combros
$TM = new MyTemplate();
$TM->setFile('modulY', 'srcTpl/adminNovaZprava_modul.htm');
// ukazeme prefix a zmensime o to mozny pocet znaku zpravy SMS
$prefixSMS = $conf["spravce_info"]["subjectPrefix"] . ":";
//vypis seznamu skupiny
$TM->assignVars("actionHere", $_SERVER["REQUEST_URI"]);
$TM->assignVars("obsahEmailu", isset($_REQUEST["obsah"]) ? $_REQUEST["obsah"] : "");
$TM->assignVars("obsahSMS", isset($_REQUEST["obsahSMS"]) ? $_REQUEST["obsahSMS"] : "");
$TM->assignVars("zbyvaZnakuSms", 160 - strlen($prefixSMS));
$TM->assignVars("prefixSMS", $prefixSMS);
$TM->assignVars("datumOdeslat", isset($_REQUEST["odeslatPo"]) ? $_REQUEST["odeslatPo"] : date("Y-m-d H:i"));
$sql = "SELECT * FROM skupiny WHERE stav != 'none' ORDER BY stav, nazev";
$rs = $sqlEngine->query($sql);
$predchozi_stav = "";
$skupiny_popis = array('public' => "Veřejné", 'private' => "Soukromé");
foreach (SQLEngine::getRows($rs) as $skupina) {
    unset($T_data);
    if ($predchozi_stav == "" || $predchozi_stav != $skupina["stav"]) {
        $predchozi_stav = $skupina["stav"];
        $T_data["stav"] = $skupiny_popis[$skupina["stav"]];
        $TM->assignBlockVars('skupiny', $T_data);
    }
    $T_data["id"] = $skupina["id"];
    $T_data["nazev"] = $skupina["nazev"];
    $T_data["selected"] = isset($_REQUEST["skupina"][$skupina["id"]]) ? "selected=\"selected\"" : "";
    $TM->assignBlockVars('skupiny.radek', $T_data, 1);
}
if (isset($chyba)) {
    unset($T_data);
    $T_data['textChyby'] = $chyba;
    $TM->assignBlockVars('ERROR', $T_data);
コード例 #8
0
ファイル: adminSkupiny.php プロジェクト: klofac/combros
foreach (SQLEngine::getRows($rs) as $skupina) {
    unset($T_data);
    if ($predchozi_stav == "" || $predchozi_stav != $skupina["stav"]) {
        $T_data["hlavickaKanaly"] = $hlavickaKanaly;
        $predchozi_stav = $skupina["stav"];
        $T_data["stav"] = $skupiny_popis[$skupina["stav"]];
        $TM->assignBlockVars('skupinySetup.stav', $T_data, 1);
    }
    $T_data["id"] = $skupina["id"];
    $T_data["nazev"] = $skupina["nazev"];
    $T_data[$skupina["stav"] . "Check"] = "selected=\"selected\"";
    $TM->assignBlockVars('skupinySetup.stav.radek', $T_data, 2);
    //ceny kanalu
    $skupinyKanaly = "SELECT * FROM skupiny_kanaly WHERE idSkupina = ?";
    $rs_skupinyKanaly = $sqlEngine->query($skupinyKanaly, array($skupina["id"]));
    foreach (SQLEngine::getRows($rs_skupinyKanaly) as $k) {
        //if(!is_int($k["idKanal"])) continue;
        $idKanal = $k["idKanal"];
        $kanalySeznam[$idKanal]["skupCena"] = $k["cenaZaZpravu"] / 100;
    }
    foreach ($kanalySeznam as $id => $k) {
        unset($T_data);
        $T_data["idSkupiny"] = $skupina["id"];
        $T_data["cena"] = $kanalySeznam[$id]["skupCena"];
        $T_data["idKanalu"] = $id;
        $TM->assignBlockVars('skupinySetup.stav.radek.cenaKanaly', $T_data, 3);
        $kanalySeznam[$id]["skupCena"] = 0;
    }
}
if (isset($chyba)) {
    unset($T_data);
コード例 #9
0
ファイル: uzivatel.php プロジェクト: klofac/combros
 /**
  * funkce pro vypis feedbacku
  * @param <type> $filtr filtr=array(
  *    hodnoceny_id   -  id hodnoceneho uzivatele
  *     hodnotici_id   -  id hodnoticiho uzivatele
  *      )
  * @return <type> \
  */
 function feedbackVypis($filtr)
 {
     $sql = "select hodnotil_id,concat(uzivatel.jmeno,' ',uzivatel.prijmeni) as hodnotil_nazev,popis,uzivatel_feedback.hodnoceni,uzivatel_feedback.cas from uzivatel_feedback left join uzivatel ON uzivatel.id=hodnotil_id  where hodnoceny_id='" . $filtr["hodnoceny_id"] . "' order by cas desc";
     $rs = $this->db2->query($sql);
     return SQLEngine::getRows($rs);
 }
コード例 #10
0
ファイル: adminDetail.php プロジェクト: klofac/combros
    $T_data['idSkupiny'] = $row["id"];
    if ($row["idSkupina"] == 0) {
        $nastaveno = -1;
    } else {
        $nastaveno = 0;
    }
    $is_email_ok ? $T_data['disable_email'] = "" : ($T_data['disable_email'] = "disabled");
    $T_data['option_email'] = get_option($nastaveno, $kanaly[1]);
    $is_sms_ok ? $T_data['disable_sms'] = "" : ($T_data['disable_sms'] = "disabled");
    $T_data['option_sms'] = get_option(-1);
    $TM->assignBlockVars('table_A.row_A', $T_data, 1);
}
// nacteme skupiny dostupne jen po schvaleni spravce
$sql = "SELECT usk.*,sk.* FROM uzivatele_skupiny AS usk LEFT JOIN skupiny AS sk ON sk.id = usk.idSkupina WHERE usk.idUzivatel = ? AND sk.stav = 'private'";
$rs = $sqlEngine->query($sql, array(2));
$rows = SQLEngine::getRows($rs);
foreach ($rows as $row) {
    unset($T_data);
    $T_data['skupina_nazev'] = $row["nazev"];
    $is_email_ok ? $T_data['disable_email'] = "" : ($T_data['disable_email'] = "disabled");
    $T_data['option_email'] = get_option(array(-1, 0));
    $is_sms_ok ? $T_data['disable_sms'] = "" : ($T_data['disable_sms'] = "disabled");
    $T_data['option_sms'] = get_option(array(-1));
    $TM->assignBlockVars('table_B.row_B', $T_data, 1);
}
//if (!$is_sms_ok)  $chyba = "Doplňte prosím svoje SMS číslo";
if (!$is_email_ok) {
    $chyba = "Nastavte svoji platnou emailovou adresu, jinak nebudou dostupné žádné volby pro nastavení";
}
if (isset($chyba)) {
    unset($T_data);
コード例 #11
0
ファイル: userDetail.php プロジェクト: klofac/combros
    foreach ($vybranyKanal as $i => $v) {
        $vybranyKanal[$i] = -1;
    }
}
// nacteme skupiny dostupne jen po schvaleni spravce
$sql = "SELECT * FROM skupiny \n      WHERE stav = 'private'";
$rs = $sqlEngine->query($sql);
foreach (SQLEngine::getRows($rs) as $row) {
    unset($T_data);
    //seznam vybranych kanalu
    $rs_viceKanalu = $sqlEngine->query("SELECT * FROM uzivatele_skupiny WHERE idUzivatel = ? && idSkupina = ?", array($_SESSION["user"]["id"], $row["id"]));
    // muzeme zobrazit jen ty co jsou prideleny spravcem, uzivatel si VIP sam vybrat nemuze
    if (SQLEngine::getRowCount($rs_viceKanalu) == 0) {
        continue;
    }
    foreach (SQLEngine::getRows($rs_viceKanalu) as $kanal) {
        $vybranyKanal[$kanal["kanal"]] = 0;
    }
    $T_data['skupina_nazev'] = $row["nazev"];
    $T_data['idSkupiny'] = $row["id"];
    $is_email_ok ? $T_data['disable_email'] = "" : ($T_data['disable_email'] = "disabled");
    $T_data['option_email'] = get_option($vybranyKanal[0], $cenaKanal[$row["id"]][0]);
    // zatim je defaultne uzivateli zakazano nastavovat SMS, pouze admin
    // ($is_sms_ok ? $T_data['disable_sms'] = "" : $T_data['disable_sms'] = "disabled");
    $T_data['disable_sms'] = "disabled";
    $T_data['option_sms'] = get_option($vybranyKanal[1], $cenaKanal[$row["id"]][1]);
    $TM->assignBlockVars('table_B.row_B', $T_data, 1);
    foreach ($vybranyKanal as $i => $v) {
        $vybranyKanal[$i] = -1;
    }
}
コード例 #12
0
ファイル: userZmenaHesla.php プロジェクト: klofac/combros
<?php

if ($_REQUEST["stare"] != "" && $_REQUEST["nove"] != "" && $_REQUEST["kontrola"] != "") {
    if ($_REQUEST["nove"] == $_REQUEST["kontrola"]) {
        if (substr(md5($_REQUEST["stare"]), 0, 12) == $_SESSION["user"]["heslo"]) {
            $query = "UPDATE uzivatele SET heslo = SUBSTRING(MD5(?), 1, 12) WHERE id = ?";
            $update = $sqlEngine->query($query, array($_REQUEST["nove"], $_SESSION["user"]["id"]));
            if (SQLEngine::isError($update)) {
                $chyba = "Oops něco se porouchalo";
            } else {
                $chyba = "Heslo bylo změněno";
                $_SESSION["user"]["heslo"] = substr(md5($_REQUEST["nove"]), 0, 12);
            }
        } else {
            $chyba = "Špatně vyplněno staré heslo";
        }
    } else {
        $chyba = "Nové heslo se neshoduje s kontrolou";
    }
}
// vybereme hlavni sablonu
$T->setFile('modulX', 'srcTpl/user.htm');
// polozky menu
include_once 'moduly/menuUser.php';
// nastartujeme lokalni sablonu
$TM = new MyTemplate();
$TM->setFile('modulY', 'srcTpl/userZmenaHesla_modul.htm');
if (isset($chyba)) {
    unset($T_data);
    $T_data['textChyby'] = $chyba;
    $TM->assignBlockVars('ERROR', $T_data);
コード例 #13
0
ファイル: index.php プロジェクト: klofac/combros
    unset($modul);
}
// nepodorovany modul
// tady musi byt bezpecnostni kontrola, jestli promenna $modul obsahuje platny nazev templatu z adresare srcTpl, kdyz ne, tak unset($modul)
if (!isset($modul)) {
    //tady bude redirect na userDetail
    header('location: ' . getUrl("userLogin", array()));
    exit;
}
//zjistime zda je pro domenu vubec definovana DB
if (!isset($conf["sqlconn"][$_REQUEST["s"]])) {
    die($conf["version"] . "<BR><BR>  Litujeme, ale pro -" . $_REQUEST["s"] . "- neni sluzba povolena. <BR><BR>  Vice informaci naleznete na <A HREF=\"http://www.combros.info\">www.combros.info</A>");
}
//echo $_SERVER["PHP_SELF"];
//inicializace db
$sqlEngine = new SQLEngine($conf["sqlconn"][$_REQUEST["s"]]["dbhost"], $conf["sqlconn"][$_REQUEST["s"]]["dbuser"], $conf["sqlconn"][$_REQUEST["s"]]["dbpass"], $conf["sqlconn"][$_REQUEST["s"]]["dbname"]);
// nacteme dalsi konfiguraci z DB
$sql = "SELECT * FROM spravce_info";
$rs = $sqlEngine->query($sql);
$conf["spravce_info"] = SQLEngine::getFirstRow($rs);
$conf['lng'] = $conf["spravce_info"]["contentLanguage"];
/*
foreach (SQLEngine::getRows($rs) as $radek) {
    $out["uzivatel"]["doprava"][$radek['poradi']]["nazev"] = $radek["nazev"];
    $out["uzivatel"]["doprava"][$radek['poradi']]["cena"]  = $radek["cena"];
}
*/
// controller zavola zobrazovac, ktery nacte template
$T = new MyTemplate();
require 'moduly/' . $modul . '.php';
// hlavicka
コード例 #14
0
ファイル: userNew.php プロジェクト: klofac/combros
 $sql = "SELECT * FROM uzivatele WHERE login=?";
 $rs = $sqlEngine->query($sql, array($_REQUEST["login"]));
 $uzivatel = SQLEngine::getFirstRow($rs);
 // pokud takovy login neexistuje
 if (!isset($uzivatel["login"])) {
     // pokus o zalozeni noveho uzivatele
     $sql = "INSERT INTO uzivatele SET login=?, heslo=SUBSTRING(MD5(?), 1, 12), stav='active',naposledyPrihlasen=NOW(), poznamka=?";
     $rs = $sqlEngine->query($sql, array($_REQUEST["login"], $_REQUEST["heslo"], $_REQUEST["zprava"]));
     $out["result"] = SQLEngine::getErrorCode($rs);
     $out["result_text"] = SQLEngine::getErrorText($rs);
     if ($out["result"] + 0 == 0) {
         // naplnime session jako by byl prihlasen
         // kontrola zda neni uzivatel se stejnym loginem j*z registrovan
         $sql = "SELECT * FROM uzivatele WHERE login=? AND heslo=SUBSTRING(MD5(?), 1, 12)";
         $rs = $sqlEngine->query($sql, array($_REQUEST["login"], $_REQUEST["heslo"]));
         $uzivatel = SQLEngine::getFirstRow($rs);
         if ($uzivatel["id"] > 0) {
             // pokud je overeni ok, naplnime session, jinak vratime zpravu ze prihlaseni nebylo uspesne
             $_SESSION["user"] = $uzivatel;
             // redirect na userDetail
             header('location: ' . getUrl("userDetail", array()));
             exit;
         } else {
             $chyba = "Uživatele se nepodařilo založit";
         }
     } else {
         $chyba = $out["result_text"];
     }
 } else {
     $chyba = "Vybrany login je již registrován jiným uživatelem, zvolte jiný login";
 }
コード例 #15
0
ファイル: SQLEngine.php プロジェクト: klofac/combros
 /**
  * slouzi pro nakesovani odpovedi dotazu typu SELECT pokud nekolik modulu na strance vola backend se stejnymi parametry
  * soucasne promazava cache po stanovenem limitu a umoznuje sdileni odpovedi vice aplikacnimi servery
  * @param string $query SQL dotaz SELECT ktery se ma vykonat
  * @param string $Benchmarked je-li vyplneno, bude zalogovan banchmark test do err_log a text bude pouzit jako identifikator ve vypisu logu
  * @param int $maxold pocet minut jak muze byt vysledek stary, jinak dojde k jeho aktualizaci (default 0) 0=cache off
  * @return array $out["rows"] ... radky s vysledky s omezenim limit, $out["count"] ... pocet nalezenych vysedku bez omezeni limitu
  */
 public function query($query, $params = array(), $benchMarked = "", $maxOld = 0)
 {
     if (!is_array($params)) {
         $params = array($params);
     }
     $time_start = microtime(true);
     $isCache = $maxOld > 0 && !$this->isUpdate($query);
     $actualPDO = $this->getPDO($query, $isCache);
     $connectionInfo = $actualPDO === $this->pdoMaster ? $this->masterHost . "/" . $this->masterDBName . " (master)" : ($connectionInfo = $this->slaveHost . "/" . $this->slaveDBName . " (slave)");
     if ($isCache) {
         // vypocteme id dotazu pro cache
         $checksum = sprintf("%u\n", crc32($query . print_r_log($params)));
         // zjistime zda uz takovy dotaz neprobehl a zda neni po expiraci
         $stmt = $actualPDO->prepare("SELECT *,TIMESTAMPDIFF(MINUTE,created,NOW()) AS oldmin FROM cache_sql WHERE sql_hash=?");
         $stmt->execute(array($checksum));
         $cache = $stmt->fetch();
         $isCache = $stmt->rowCount() > 0 && $cache['oldmin'] < $maxOld;
     }
     //znovu se ptam na stejnou podminku, protoze se mohla mezitim zmenit
     if ($isCache) {
         $out = unserialize($cache['result']);
     } else {
         // neprobehl nebo vyexpiroval - provedeme dotaz a vysledek ulozime do cache
         $stmt = $actualPDO->prepare($query);
         $stmt->setFetchMode(PDO::FETCH_ASSOC);
         $success = $stmt->execute($params);
         $errorInfo = $stmt->errorInfo();
         $out['errorCode'] = $errorInfo[0];
         $out['errorText'] = $errorInfo[2];
         $out["rows"] = $stmt->fetchAll();
         $out["lastInsertId"] = $actualPDO->lastInsertId();
         $out["affectedRows"] = $stmt->rowCount();
         if (!SQLEngine::isError($out)) {
             $out['errorText'] = "";
             $rs1 = $actualPDO->query("SELECT FOUND_ROWS() as pocet")->fetch();
             $out['count'] = $rs1['pocet'];
             //pokud nezafunguje found_rows a vrati 0-1 radku, tak pro jistotu si vezmu pocet z vracenych radku
             if ($out['count'] + 0 < 2) {
                 $out['count'] = count($out["rows"]);
             }
         } else {
             logmsg("SQLERROR:" . self::getErrorCode($out) . ":" . self::getErrorText($out) . "\n" . $query . "\n" . print_r_log($params), PEAR_LOG_CRIT);
         }
         if ($maxOld > 0) {
             // ulozime vysledek do cache pokud nepresahuje limitni delku mediumtext 2^24
             $serial = serialize($out);
             if (strlen($serial) < pow(2, 24) && strlen($serial) > 0) {
                 $sql = "REPLACE cache_sql SET sql_hash=?, result=?";
                 $stmt = $actualPDO->prepare($sql);
                 $stmt->execute(array($checksum, $serial));
             }
         }
     }
     $time_end = microtime(true);
     $time = $time_end - $time_start;
     global $conf;
     if ($conf["enableProfiler"]) {
         $stmt = $actualPDO->prepare("select count(*) as pocet from inzerat");
         $stmt->setFetchMode(PDO::FETCH_ASSOC);
         $success = $stmt->execute(array());
         $rs1 = $stmt->fetch();
         $profilerInsert = "INSERT INTO profiler_data (request_id, request_uri, startSql, stopSql, query, params, pocetInzeratu, callStack) VALUES (?, ?, ?, ?, ?, ?, ?, ?);";
         $e = new Exception();
         $profileParams = array($_SERVER["REQUEST_TIME"], $_SERVER["REQUEST_URI"], $time_start, $time_end, $query, serialize($params), $rs1["pocet"], $e->getTraceAsString());
         $stmt = $this->getPDOMaster()->prepare($profilerInsert);
         $stmt->execute($profileParams);
     }
     logmsg("BENCHMARK {$benchMarked} STOP for connection " . $connectionInfo . " " . round($time, 3) . "\n" . print_r_log($query) . "\n" . print_r_log($params), PEAR_LOG_DEBUG);
     return $out;
 }
コード例 #16
0
ファイル: sender.php プロジェクト: klofac/combros
//uroven logu, ktera se bude ukladat
//PEAR_LOG_EMERG, PEAR_LOG_ALERT, PEAR_LOG_CRIT, PEAR_LOG_ERR,
//PEAR_LOG_WARNING, PEAR_LOG_NOTICE, PEAR_LOG_INFO, PEAR_LOG_DEBUG
$conf["log"]["level"] = PEAR_LOG_DEBUG;
//druh handleru (mail,file,console,firebug,display,error_log,null,mdb2,syslog,sql)
$conf["log"]["handler"] = "file";
//rozsirujici konfigurace handleru
$conf["log"]["conf"] = array("timeFormat" => "%Y-%m-%d %H:%M:%S", "lineFormat" => "%{timestamp} [%{priority}] %{message}", "buffering" => true);
//konec logu
foreach ($conf["sqlconn"] as $zakaznik => $zakaznikSQLConf) {
    // zpracujeme jen ty databaze co jsou v configu povoleny
    if ($zakaznikSQLConf["enableSendMessage"] != "Y") {
        continue;
    }
    // byla nalezena db kterou se mame zabyvat, startujeme
    $sqlEngine = new SQLEngine($conf["sqlconn"][$zakaznik]["dbhost"], $conf["sqlconn"][$zakaznik]["dbuser"], $conf["sqlconn"][$zakaznik]["dbpass"], $conf["sqlconn"][$zakaznik]["dbname"]);
    // zjistime zda je na DB zamek jine instance sender.php
    $sql = "SELECT * FROM scriptLockLog WHERE scriptName = ? AND dbName = ? AND finishTime IS NULL";
    $rs = $sqlEngine->query($sql, array("sender.php", $conf["sqlconn"][$zakaznik]["dbname"]));
    // zamek uz je tak prejdeme na dalsi DB
    if (SQLEngine::getRowCount($rs) > 0) {
        continue;
    }
    // neni zamek, vytvorime ho a muzeme zacit
    $sql = "INSERT INTO scriptLockLog SET scriptName = ? , dbName = ? , startTime = NOW()";
    $rs = $sqlEngine->query($sql, array("sender.php", $conf["sqlconn"][$zakaznik]["dbname"]));
    $sql = "SELECT * FROM spravce_info";
    $rs = $sqlEngine->query($sql);
    unset($conf["spravce_info"]);
    $conf["spravce_info"] = SQLEngine::getFirstRow($rs);
    //vytvoreni seznamu zprav a prirareni je k uzivatelum, kategoriim, kanalum