Example #1
0
function errorHandler($iErrCode, $sErrMsg, $sFile, $iLine, $aContext)
{
    // Fatalt?
    if ($iErrCode = E_USER_ERROR) {
        // TODO: Gör till EN, enda skillnad die() om ERROR
        // Logga och dö
        $sMsg = time() . ": " . $sFile . ": " . $iLine . ": " . $sErrMsg;
        error_log($sMsg, 3, FATAL_ERRORLOG);
        die("A fatal error has occured.<BR>Errormessage: " . $sErrMsg . "<BR>Please contact the sysadmin and give the following code: " . time());
    } elseif ($aContext['this']) {
        // Felet inträffade i en klass, skicka vidare till klassens felhanterare
        // Men tryck först in felmeddelanden
        $oConfig &= Configuration::createInstance();
        $iCodeLen = strspn($sErrMsg, "1234567890");
        $sErrMsg = substr_replace($sErrMsg, $oConfig->getErrorMsg($iErrNo = substr($sErrMsg, 0, $iCodeLen)), 0, $iCodeLen);
        $sErrMsg .= " (" . $iErrNo . ")";
        $aContext['this']->errorHandler($iErrNo, $sErrMsg);
    } else {
        // Skriv ut felet lite fint
        // TODO: Koda
        // TODO: Anropa loggobjekt
    }
    // Returnera
    return NULL;
}
Example #2
0
function fixDateFormat($iTimestamp, $iVersion = 1)
{
    if (!$iTimestamp) {
        return "";
    }
    $oConfiguration =& Configuration::createInstance();
    $iRest = time() % 86400;
    if (($iTime = time()) - $iTimestamp < $iRest) {
        return date($oConfiguration->getCustomValue("DateFormatToday" . $iVersion), $iTimestamp);
    } elseif ($iTime - $iTimestamp < $iRest + 86400) {
        return date($oConfiguration->getCustomValue("DateFormatYesterday" . $iVersion), $iTimestamp);
    } else {
        return date($oConfiguration->getCustomValue("DateFormat" . $iVersion), $iTimestamp);
    }
}
Example #3
0
function validUser()
{
    // Kolla grejer
    if (isset($_SESSION['oUser']) and $_SESSION['iValidUntil'] > time() and $_SESSION['sIP'] == $_SERVER['REMOTE_ADDR']) {
        // Inloggad användare
        // Konfigurationsobjekt
        $oConfiguration =& Configuration::createInstance();
        // Uppdatera validitet
        $_SESSION['iValidUntil'] = time() + $oConfiguration->getCustomValue("ValidTime") * 60;
        // Returnera
        return TRUE;
    } else {
        // Ej inloggad
        return FALSE;
    }
}
Example #4
0
 function open()
 {
     // Konfigurationsobjekt
     $oConfig =& Configuration::createInstance();
     // Anslut
     if (!($this->rMySQL = mysql_connect($oConfig->getMysqlHost(), $oConfig->getMysqlUser(), $oConfig->getMysqlPass()))) {
         trigger_error(mysql_error(), E_USER_WARNING);
         return FALSE;
     }
     // V?lj databas
     if (!mysql_select_db($oConfig->getMysqlDb(), $this->rMySQL)) {
         trigger_error(mysql_error($this->rMySQL), E_USER_WARNING);
         return FALSE;
     }
     // Returnera
     return TRUE;
 }
Example #5
0
<?php

// RegisterUser.php
// Skriven av Eli Kaufman för Daft
// Copyright Daft 2003 under GPL
// This file is part of PHPDaft.
// PHPDaft is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
// PHPDaft 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 General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with PHPDaft; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
// Visa var filerna finns
ini_set("include_path", "/home/daft/konferens/");
// Inkludera filer
require "Classes/class_Configuration.php";
require "Classes/yapter.php";
$oConfiguration =& Configuration::createInstance();
// Template
$oTemplate = new Template("/home/daft/Templates/RegisterUser.tpl");
$oTemplate->set("Title", $oConfiguration->getCustomValue("Title"));
// Tryck ut
$oTemplate->parse();
$oTemplate->spit();
Example #6
0
 function createPasswordAndSend()
 {
     // Konfiguration
     $oConfiguration =& Configuration::createInstance();
     // Templat
     $oTemplate = new Template(TEMPLATE_PATH);
     $oTemplate->setParseMode(TRUE);
     // Skapa password
     $this->setPassword($sPassword = randStr($oConfiguration->getCustomValue("PasswordLen")));
     // Definiera
     $oTemplate->set("UserName", $this->sName);
     $oTemplate->set("Password", $sPassword);
     // Hämta output
     $oTemplate->parse();
     $sData = $oTemplate->getContents();
     // Maila
     if (!mail($this->sEmail, $oConfiguration->getCustomValue("MailSubject"), $sData, "From: " . $oConfiguration->getCustomValue("MailFrom") . " <*****@*****.**>")) {
         trigger_error("41", E_USER_WARNING);
         return FALSE;
     }
     // Returnera
     return TRUE;
 }