当前位置: 首页>>代码示例>>PHP>>正文


PHP DataSource::createInstance方法代码示例

本文整理汇总了PHP中DataSource::createInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP DataSource::createInstance方法的具体用法?PHP DataSource::createInstance怎么用?PHP DataSource::createInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DataSource的用法示例。


在下文中一共展示了DataSource::createInstance方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: Stier

#spNsvN
require "Html.php";
require "Stier.php";
require "lib/SiteContext.php";
require "lib/UsersArea/Utils.php";
//Stier og options
$stier = new Stier();
//Henter variable udefra
$ind = Html::setPostOrGetVars($HTTP_POST_VARS, $HTTP_GET_VARS);
if (isset($ind['brugernavn'])) {
    $username = $ind['brugernavn'];
} else {
    $username = '';
}
//Load the data source
$datafil = DataSource::createInstance($username, $stier);
$datafil->hentFil();
//Instantierer klassen med standardkode
$lib = new Html($ind, $datafil);
$siteContext = new SiteContext($lib, $stier, $ind, 'da');
$lib->setSiteContext($siteContext);
$lib->setStier($stier);
//spIsvN
$svar = explode(",,", $datafil->getLine(43));
$spoer = explode("::", $datafil->getLine(41));
$svaret = $ind['svaret'];
//Must we receive anwsers from this site?
$problemer = '';
if (!$lib->countVisit(getenv('HTTP_REFERER'), $datafil->getLine(111))) {
    $problemer .= "Sidens ejer har angivet, at der ikke m registreres statistikker eller svar fra andre sider end en rkke angivne sider, og denne side er ikke en af dem. Derfor er dette svar <em>ikke</em> registreret.<br>Sidens ejer kan inkludere denne side ({$ENV}{'HTTP_REFERER'}) i de tilladte sider, ved at logge ind p brugeromrdet p <a href=\"{$options}{'ZSHomePage'}\">{$options}{'ZSHomePage'}c</a> og g til siden &quot;Indstillinger&quot;, hvorp der kan opgives en rkke sider hvorfra der m registreres statistikker og svar.";
}
开发者ID:simonmikkelsen,项目名称:zipstat,代码行数:31,代码来源:pollAnswer.php

示例2: Logger

    }
    //Log the visit
    $timeAdjusted = Html::getTimeAdjusted(NULL, $stier);
    $logger = new Logger($stier);
    $logger->logVisit($timeAdjusted, isset($ind['ssto']) ? $ind['ssto'] : '', isset($ind['referer']) ? $ind['referer'] : '', isset($ind['colors']) ? $ind['colors'] : '', isset($ind['java']) ? $ind['java'] : '', isset($ind['taelnr']) ? $ind['taelnr'] : '', isset($ind['taelnavn']) ? $ind['taelnavn'] : '', isset($ind['js']) ? $ind['js'] : '', getenv('HTTP_USER_AGENT'), getenv('REMOTE_ADDR'), getenv('HTTP_ACCEPT_LANGUAGE'), getenv('HTTP_REFERER'), $username, '');
}
//End if is log mode enabled
//Set the engine to NULL, so we can see if it has not been created.
$engine = NULL;
if ($stier->getOption('processMode') !== 0) {
    require_once "Mstat.php";
    require_once "lib/ZipStatEngine.php";
    require_once "lib/SiteContext.php";
    require_once "lib/Localizer.php";
    //Loads the data file
    $datafil = DataSource::createInstance($ind['brugernavn'], $stier);
    $res = $datafil->hentFil();
    //Handle errors:
    $errors = new Errors();
    //Was the datafile fetched successfully
    if ($res === -2) {
        //Temporarely instance for error handling
        //'da' is danish, currently the only user interface language.
        $siteContext = new ShortSiteContext($stier, $ind, 'da');
        $errors->addError(new Error(2, sprintf($siteContext->getLocale('errDamagedDatasource'), $stier->getOption('name_of_service'))));
    } elseif (!$res or $res === 0) {
        //Temporarely instance for error handling
        $siteContext = new ShortSiteContext($stier, $ind, 'da');
        $errors->addError(new Error(2, sprintf($siteContext->getLocale('errDatasourceInaccessible'), $stier->getOption('name_of_service'))));
    }
    $lib = new Html($ind, $datafil);
开发者ID:simonmikkelsen,项目名称:zipstat,代码行数:31,代码来源:zipstat.php

示例3: Stier

<?php

require "Html.php";
require "Stier.php";
require "lib/SiteContext.php";
require "lib/Localizer.php";
$options = new Stier();
//Fetches parameters for the script.
$in = Html::setPostOrGetVars($HTTP_POST_VARS, $HTTP_GET_VARS);
//Validates the username.
$datafile = DataSource::createInstance($in['brugernavn'], $options);
//Creates the standard library.
$lib = new Html($in, $datafile);
//Instantiates the SiteContext-objecet.
$siteContext = new SiteContext($lib, $options, $in, 'da');
//Fetches the users data.
$res = $datafile->hentFil();
$lib->setSiteContext($siteContext);
$lib->setStier($options);
//Sets the code lib in the site context.
$siteContext->setCodeLib($lib);
if ($res === -2) {
    $errMsg .= "Din datafil er desvrre blevet beskadiet, og der kan derfor ikke registreres statistikker. Kontakt " . $options->getOption('name_of_service') . "'s administrator via e-mail-adressen nederst p siden.";
} elseif (!$res) {
    $errMsg .= "Datafilen kunne hentes. Enten er det et problem p " . $options->getOption('name_of_service') . " eller ogs har du skrevet det forkerte brugernavn - det kan indeholder tegn der ikke er tilladt - prv at generere den obligatoriske kode igen.";
}
if (strlen($errMsg) !== 0) {
    $errMsg = $lib->problemer($errMsg);
    include "view.php";
    $site = new HtmlSite($siteContext, "Fejl");
    $site->addHtml($errMsg);
开发者ID:simonmikkelsen,项目名称:zipstat,代码行数:31,代码来源:clickCounter.php

示例4: validateStartPage

 /**
  * Validates the start page and returns the result as an Errors object.
  */
 function validateStartPage()
 {
     $errors = new Errors();
     $in = $this->siteContext->getHTTP_VARS();
     $lib = $this->siteContext->getCodeLib();
     if (!isset($in['navn']) or strlen($in['navn']) === 0) {
         $errors->addError(new Error(2, $this->siteContext->getLocale('regErrorNoName')));
     }
     if (!isset($in['e-mail']) or strlen($in['e-mail']) === 0 or !$lib->okmail($in['e-mail'])) {
         $errors->addError(new Error(2, $this->siteContext->getLocale('regErrorBadEmail')));
     }
     if (!isset($in['url']) or strlen($in['url']) === 0 or !$lib->okurl($in['url'])) {
         $errors->addError(new Error(2, $this->siteContext->getLocale('regErrorBadUrl')));
     }
     if (!isset($in['titel']) or strlen($in['titel']) === 0) {
         $errors->addError(new Error(2, $this->siteContext->getLocale('regErrorNoTitle')));
     }
     if (!isset($in['brugernavn']) or strlen($in['brugernavn']) === 0 or !Datafil::isUsernameValid($in['brugernavn'])) {
         $errors->addError(new Error(2, $this->siteContext->getLocale('regBadUsername')));
     } else {
         $datasource = DataSource::createInstance($in['brugernavn'], $this->siteContext->getOptions());
         if ($datasource->userExists()) {
             $errors->addError(new Error(2, $this->siteContext->getLocale('regTakenUsername')));
         }
     }
     if (!isset($in['pwd1']) or strlen($in['pwd1']) === 0 or !isset($in['pwd2']) or strlen($in['pwd2']) === 0 or $in['pwd1'] !== $in['pwd2']) {
         $errors->addError(new Error(2, $this->siteContext->getLocale('regBadPassword')));
     }
     return $errors;
 }
开发者ID:simonmikkelsen,项目名称:zipstat,代码行数:33,代码来源:register.php

示例5: Stier

#2-E-mail
#&3-URL
#&4-Tittel
#&5-Startdato
#6-Password
#Variable
require "lib/SiteGenerator/SiteGenerator.php";
require "lib/SiteContext.php";
require "Stier.php";
require "Html.php";
require "view.php";
//Program
$stier = new Stier();
$ind = Html::setPostOrGetVars($HTTP_POST_VARS, $HTTP_GET_VARS);
//Tjekker brugernavnet
$datafil = DataSource::createInstance($ind['username'], $stier);
$res = $datafil->hentFil();
$lib = new Html($ind, $res);
$siteContext = new SiteContext($lib, $stier, $ind, 'da');
if (!isset($ind['type'])) {
    if (isset($ind['username'])) {
        $username = $ind['username'];
    } else {
        $username = "";
    }
    $side = new HtmlSite($siteContext, "Glemt kodeord");
    $html = "<div class=forside>\n";
    $html .= "\t<form action='" . htmlentities(getenv("SCRIPT_NAME")) . "' method='POST'>\n";
    $html .= "\t\t<p><label>Brugernavn <input type='text' name='username' value='" . htmlentities($username) . "'/></label></p>\n";
    $html .= "\t\t<p><input type='submit' value='Send kodeord' /></p>\n";
    $html .= "\t\t<input type='hidden' name='type' value='mailpwd' />\n";
开发者ID:simonmikkelsen,项目名称:zipstat,代码行数:31,代码来源:mailpwd.php

示例6: Stier

<?php

//52 - IP adr to ignore
//53 - redirect adress
require "Html.php";
require "Stier.php";
require "lib/SiteContext.php";
require "lib/UsersArea/Utils.php";
$stier = new Stier();
$datafil = DataSource::createInstance($_SERVER['QUERY_STRING'], $stier);
$res = $datafil->hentFil();
$problemer = '';
//No problems so far
if ($res === -2) {
    $problemer .= "Din datafil er desvrre blevet beskadiet, og der kan derfor ikke registreres statistikker. Kontakt " . $stier->getOption('name_of_service') . "'s administrator via e-mail-adressen nederst p siden.";
} elseif (!$res) {
    $problemer .= "Datafilen kunne hentes. Enten er det et problem p " . $stier->getOption('name_of_service') . " eller ogs har du skrevet det forkerte brugernavn - det kan indeholder tegn der ikke er tilladt - prv at generere den obligatoriske kode igen.";
}
$lib = new Html($ind, $datafil);
$lib->setStier($stier);
$lib->outputNoCacheHeaders();
if (strlen($problemer) === 0) {
    $datafil->setLine(52, getenv('REMOTE_ADDR'));
    $datafil->gemFil();
    $url = trim($datafil->getLine(53));
    if (strlen($url) > 0) {
        if (strpos(strtolower($url), 'http://') !== 0) {
            $url = "http://" . $url;
        }
        header('Location: ' . $url);
    } else {
开发者ID:simonmikkelsen,项目名称:zipstat,代码行数:31,代码来源:ignore.php

示例7: doProcess

 /**
  * Processes the log using the processor set using setProcessor().
  */
 function doProcess()
 {
     $processIntoEach = $this->options->getOption('processIntoEach') !== 0;
     $processAllIntoOne = $this->options->getOption('processAllInOne') !== 0;
     //Stores the sources to process for each iteration.
     $processSources = array();
     //Gives the index in above where the user source is/should be located
     //If "All into one" is enabled it should be 1, else 0
     $userSourceIndex = 0;
     if ($processIntoEach) {
         //Cache to store "into each" sources in
         $datasources = array();
     }
     if ($processAllIntoOne) {
         $allUsername = $this->options->getOption('processAllInOneUsername');
         $allDatasource = DataSource::createInstance($allUsername, $this->options);
         $allDatasource->hentFil();
         $processSources[0] =& $allDatasource;
         $userSourceIndex = 1;
     }
     $this->logDatasource->openForProcessing();
     while (($record = $this->logDatasource->nextRecord()) !== NULL) {
         //Retrive and parse the log data
         $record = substr($record, 1, -1);
         //The @ is there so we don't get 13 warnings about undefined vars.
         @(list($username, $time, $url, $referer, $ipAddr, $lang, $useragent, $screen_res, $colors, $javasupport, $jsSupport, $visitorId, $counterNo, $counterName) = explode("\"\"", $record));
         //Is a data source for the user loaded
         if (isset($username) and strlen($username) > 0) {
             if (!isset($datasources[$username])) {
                 $userSource = DataSource::createInstance($username, $this->options);
                 $userSource->hentFil();
                 $datasources[$username] =& $userSource;
                 $processSources[$userSourceIndex] =& $userSource;
             } else {
                 $processSources[$userSourceIndex] =& $datasources[$username];
             }
         } else {
             unset($processSources[$userSourceIndex]);
             $processSources[$userSourceIndex] = NULL;
         }
         //Do the processing
         for ($i = 0; $i < count($processSources); $i++) {
             if ($processSources[$i] === NULL) {
                 continue;
             }
             //Set the data source to use
             $this->processor->setDataSource($processSources[$i]);
             //And do the processing
             $this->processor->process($time, $screen_res, $referer, $colors, $javasupport, $counterNo, $counterName, $jsSupport, $useragent, $ipAddr, $lang, $url);
         }
         //End foreach
     }
     //End while
     $this->logDatasource->closeSource();
     if ($processAllIntoOne) {
         $processSources[0]->gemFil();
     }
     //Close the user data sources.
     if ($processIntoEach) {
         foreach ($datasources as $key => $source) {
             if ($source === NULL) {
                 continue;
             }
             $source->gemFil();
         }
     }
 }
开发者ID:simonmikkelsen,项目名称:zipstat,代码行数:70,代码来源:Logger.php


注:本文中的DataSource::createInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。