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


PHP file函数代码示例

本文整理汇总了PHP中file函数的典型用法代码示例。如果您正苦于以下问题:PHP file函数的具体用法?PHP file怎么用?PHP file使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: onls

 function onls()
 {
     $logdir = UC_ROOT . 'data/logs/';
     $dir = opendir($logdir);
     $logs = $loglist = array();
     while ($entry = readdir($dir)) {
         if (is_file($logdir . $entry) && strpos($entry, '.php') !== FALSE) {
             $logs = array_merge($logs, file($logdir . $entry));
         }
     }
     closedir($dir);
     $logs = array_reverse($logs);
     foreach ($logs as $k => $v) {
         if (count($v = explode("\t", $v)) > 1) {
             $v[3] = $this->date($v[3]);
             $v[4] = $this->lang[$v[4]];
             $loglist[$k] = $v;
         }
     }
     $page = max(1, intval($_GET['page']));
     $start = ($page - 1) * UC_PPP;
     $num = count($loglist);
     $multipage = $this->page($num, UC_PPP, $page, 'admin.php?m=log&a=ls');
     $loglist = array_slice($loglist, $start, UC_PPP);
     $this->view->assign('loglist', $loglist);
     $this->view->assign('multipage', $multipage);
     $this->view->display('admin_log');
 }
开发者ID:tang86,项目名称:discuz-utf8,代码行数:28,代码来源:log.php

示例2: ajoutLieu

function ajoutLieu()
{
    require 'connect.php';
    $requete = $bdd->query("SELECT \n\t\t\t\t\t\t\t\tVILID\n\t\t\t\t\t\t\tFROM\n\t\t\t\t\t\t\t\tcommune");
    $villes = $requete->fetchAll();
    $requete->closeCursor();
    $requete = $bdd->prepare("SELECT \n\t\t\t\t\t\t\t\tLIEUID\n\t\t\t\t\t\t\tFROM\n\t\t\t\t\t\t\t\tLIEU\n\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\tLIEUID=:lieuId\n\t\t\t\t\t\t\t\tAND\n\t\t\t\t\t\t\t\tVILID=:ville\n\t\t\t\t\t\t\t\tAND\n\t\t\t\t\t\t\t\tLIEUNOM=:nom");
    $requeteSeconde = $bdd->prepare("INSERT INTO LIEU\n\t\t\t\t\t\t\t\t\t\t(LIEUID,\n\t\t\t\t\t\t\t\t\t\tVILID,\n\t\t\t\t\t\t\t\t\t\tLIEUNOM,\n\t\t\t\t\t\t\t\t\t\tLIEUCOORDGPS)\n\t\t\t\t\t\t\t\t\tVALUES\n\t\t\t\t\t\t\t\t\t\t(:lieuId,\n\t\t\t\t\t\t\t\t\t\t:ville,\n\t\t\t\t\t\t\t\t\t\t:nom,\n\t\t\t\t\t\t\t\t\t\t:gps)");
    for ($i = 0; $i < 100; $i++) {
        echo $lieuId = $i;
        echo $ville = $villes[rand(0, sizeof($villes) - 1)]['VILID'];
        $lieuT = file('./generateurLieu.txt');
        $lieu = array(trim($lieuT[rand(0, 93)]), trim($lieuT[rand(0, 93)]));
        $lieu = implode("-", $lieu);
        echo $nom = $lieu;
        echo $gps = rand(0, 5000);
        echo "<br />";
        $requete->execute(array("ville" => $ville, "nom" => $nom));
        if ($requete->fetch() == false) {
            $requeteSeconde->execute(array("lieuId" => $lieuId, "ville" => $ville, "nom" => $nom, "gps" => $gps));
        } else {
            $i--;
        }
    }
    $requete->closeCursor();
    $requeteSeconde->closeCursor();
}
开发者ID:ploufppe,项目名称:ppe,代码行数:27,代码来源:generateurLieuAB.php

示例3: get_lvm_iscsi_deployment_image_rootdevice_identifier

function get_lvm_iscsi_deployment_image_rootdevice_identifier($lvm_iscsi_storage_id)
{
    global $OPENQRM_SERVER_BASE_DIR;
    global $OPENQRM_ADMIN;
    global $event;
    // place for the storage stat files
    $StorageDir = $_SERVER["DOCUMENT_ROOT"] . '/openqrm/base/plugins/lvm-storage/storage';
    $rootdevice_identifier_array = array();
    $storage = new storage();
    $storage->get_instance_by_id($lvm_iscsi_storage_id);
    $storage_resource = new resource();
    $storage_resource->get_instance_by_id($storage->resource_id);
    $storage_resource_id = $storage_resource->id;
    $ident_file = "{$StorageDir}/{$storage_resource_id}.lv.lvm-iscsi-deployment.ident";
    if (file_exists($ident_file)) {
        unlink($ident_file);
    }
    // send command
    $resource_command = "{$OPENQRM_SERVER_BASE_DIR}/openqrm/plugins/lvm-storage/bin/openqrm-lvm-storage post_identifier -t lvm-iscsi-deployment -u {$OPENQRM_ADMIN->name} -p {$OPENQRM_ADMIN->password}";
    $storage_resource->send_command($storage_resource->ip, $resource_command);
    if (!lvm_iscsi_deployment_wait_for_identfile($ident_file)) {
        $event->log("get_image_rootdevice_identifier", $_SERVER['REQUEST_TIME'], 2, "image.lvm-iscsi-deployment", "Timeout while requesting image identifier from storage id {$storage->id}", "", "", 0, 0, 0);
        return;
    }
    $fcontent = file($ident_file);
    foreach ($fcontent as $lun_info) {
        $tpos = strpos($lun_info, ",");
        $timage_name = trim(substr($lun_info, 0, $tpos));
        $troot_device = trim(substr($lun_info, $tpos + 1));
        $rootdevice_identifier_array[] = array("value" => "{$troot_device}", "label" => "{$timage_name}");
    }
    return $rootdevice_identifier_array;
}
开发者ID:kelubo,项目名称:OpenQRM,代码行数:33,代码来源:image.lvm-iscsi-deployment.php

示例4: installLanguage2

 function installLanguage2($f, $l, $m)
 {
     global $php;
     $patt = '/^([A-Z0-9_]+)[\\s]{0,}=[\\s]{0,}[\'"](.*)[\'"];$/';
     foreach (file($f) as $item) {
         $item = trim($item);
         if ($item != '') {
             if (preg_match($patt, $item, $match)) {
                 if (isset($php[$match[1]])) {
                     $php[$match[1]][$l] = addslashes($match[2]);
                 } else {
                     $save = array();
                     if (preg_match('/^[0-9]+$/', $value)) {
                         $save['type'] = 'int';
                     } else {
                         $save['type'] = 'text';
                     }
                     $save['key'] = $match[1];
                     $save['owner'] = $m;
                     $save[$l] = addslashes($match[2]);
                     $save['js'] = 1;
                     $php[$match[1]] = $save;
                 }
             }
         }
     }
 }
开发者ID:phannack,项目名称:GCMS,代码行数:27,代码来源:langtool.php

示例5: sendMessage

function sendMessage($phoneTo, $textMessage)
{
    $user = "noreplypw606";
    $password = "pw10606jo";
    $api_id = "3356658";
    $baseurl = "http://api.clickatell.com";
    $text = urlencode($textMessage);
    $to = $phoneTo;
    // auth call
    $url = "{$baseurl}/http/auth?user={$user}&password={$password}&api_id={$api_id}";
    // do auth call
    $ret = file($url);
    // explode our response. return string is on first line of the data returned
    $sess = explode(":", $ret[0]);
    if ($sess[0] == "OK") {
        $sess_id = trim($sess[1]);
        // remove any whitespace
        $url = "{$baseurl}/http/sendmsg?session_id={$sess_id}&to={$to}&text={$text}";
        // do sendmsg call
        $ret = file($url);
        $send = explode(":", $ret[0]);
        if ($send[0] == "ID") {
            // echo "success\nmessage ID: ". $send[1];
            return true;
        } else {
            // echo "send message failed";
            return false;
        }
    } else {
        // echo "Authentication failure: ". $ret[0];
        return false;
    }
}
开发者ID:ricain59,项目名称:fortaff,代码行数:33,代码来源:mobile.php

示例6: __construct

 function __construct($file, $firstLine = true)
 {
     $this->file = $file;
     $this->db = array();
     $this->dbBackup = array();
     $this->firstLine = $firstLine;
     if (file_exists($file)) {
         // Read JSON file.
         $lines = file($file);
         // Remove the first line, the first line is for security reasons.
         if ($firstLine) {
             unset($lines[0]);
         }
         // Regenerate the JSON file.
         $implode = implode($lines);
         // Unserialize, JSON to Array.
         $array = $this->unserialize($implode);
         if (empty($array)) {
             Log::set(__METHOD__ . LOG_SEP . 'Invalid JSON file: ' . $file . ', cannot be decoded. Check the file content.');
         } else {
             $this->db = $array;
             $this->dbBackup = $array;
         }
     } else {
         Log::set(__METHOD__ . LOG_SEP . 'File ' . $file . ' does not exists');
     }
 }
开发者ID:clstrfcuk,项目名称:bludit,代码行数:27,代码来源:dbjson.class.php

示例7: tplsadmin_copy_templates_f2db

function tplsadmin_copy_templates_f2db($tplset_to, $whr_append = '1')
{
    global $db;
    // get tplsource
    $result = $db->query("SELECT * FROM " . $db->prefix("tplfile") . "  WHERE tpl_tplset='default' AND ({$whr_append})");
    while ($row = $db->fetchArray($result)) {
        $basefilepath = tplsadmin_get_basefilepath($row['tpl_module'], $row['tpl_type'], $row['tpl_file']);
        $tpl_source = rtrim(implode("", file($basefilepath)));
        $lastmodified = filemtime($basefilepath);
        $drs = $db->query("SELECT tpl_id FROM " . $db->prefix("tplfile") . " WHERE tpl_tplset='" . addslashes($tplset_to) . "' AND ({$whr_append}) AND tpl_file='" . addslashes($row['tpl_file']) . "' AND tpl_refid='" . addslashes($row['tpl_refid']) . "'");
        if (!$db->getRowsNum($drs)) {
            // INSERT mode
            $sql = "INSERT INTO " . $db->prefix("tplfile") . " SET tpl_refid='" . addslashes($row['tpl_refid']) . "',tpl_desc='" . addslashes($row['tpl_desc']) . "',tpl_lastmodified='" . addslashes($lastmodified) . "',tpl_type='" . addslashes($row['tpl_type']) . "',tpl_tplset='" . addslashes($tplset_to) . "',tpl_file='" . addslashes($row['tpl_file']) . "',tpl_module='" . addslashes($row['tpl_module']) . "'";
            $db->query($sql);
            $tpl_id = $db->getInsertId();
            $db->query("INSERT INTO " . $db->prefix("tplsource") . " SET tpl_id='{$tpl_id}', tpl_source='" . addslashes($tpl_source) . "'");
            altsys_template_touch($tpl_id);
        } else {
            while (list($tpl_id) = $db->fetchRow($drs)) {
                // UPDATE mode
                $db->query("UPDATE " . $db->prefix("tplfile") . " SET tpl_lastmodified='" . addslashes($lastmodified) . "' WHERE tpl_id='{$tpl_id}'");
                $db->query("UPDATE " . $db->prefix("tplsource") . " SET tpl_source='" . addslashes($tpl_source) . "' WHERE tpl_id='{$tpl_id}'");
                altsys_template_touch($tpl_id);
            }
        }
    }
}
开发者ID:BackupTheBerlios,项目名称:peakxoops-svn,代码行数:27,代码来源:tpls_functions.php

示例8: generate

 public function generate($fname, $gender)
 {
     $this->maintemplate = file_get_contents('Template/NCLNameCaseRuTest.main');
     $this->testtemplate = file_get_contents('Template/NCLNameCaseRuTest' . $fname . $gender . '.test');
     $this->resultArr = file('Names/' . $gender . '_full_result.txt');
     $this->count = 0;
     if ($gender == 'boy') {
         $this->gender = 1;
     } else {
         $this->gender = 2;
     }
     //foreach ($this->resultArr as $key=>$value)
     //{
     //$this->gender=$key+1;
     foreach ($this->resultArr as $id => $name) {
         $tmpnames = explode("#", trim(str_replace('ё', 'е', $name)));
         $firstRes = array();
         $secondRes = array();
         $fatherRes = array();
         $c = count($tmpnames);
         for ($i = 0; $i < $c; $i++) {
             $cur = explode(" ", trim($tmpnames[$i]));
             $firstRes[] = trim($cur[1]);
             $secondRes[] = trim($cur[0]);
             $fatherRes[] = trim($cur[2]);
         }
         $this->generateTest($firstRes, $secondRes, $fatherRes);
     }
     //}
     $res = str_replace('{% tests %}', $this->tests, $this->maintemplate);
     $res = str_replace('{% name %}', $fname, $res);
     file_put_contents('../Library/NCLNameCaseRuTest' . $fname . $gender . '.php', $res);
 }
开发者ID:klearvue,项目名称:namecaselib,代码行数:33,代码来源:NCLNameCaseRuTest.generator.php

示例9: loadfont

 function loadfont($fontfile)
 {
     $this->fontFile = file($fontfile);
     if (!$this->fontFile) {
         die("Couldnt open fontfile {$fontfile}\n");
     }
     $hp = explode(" ", $this->fontFile[0]);
     // get header
     $this->signature = substr($hp[0], 0, strlen($hp[0]) - 1);
     $this->hardblank = substr($hp[0], strlen($hp[0]) - 1, 1);
     $this->height = $hp[1];
     $this->baseline = $hp[2];
     $this->maxLenght = $hp[3];
     $this->oldLayout = $hp[4];
     $this->commentLines = $hp[5] + 1;
     if (isset($hp[6])) {
         $this->printDirection = $hp[6];
     }
     if (isset($hp[7])) {
         $this->fullLayout = $hp[7];
     }
     if (isset($hp[8])) {
         $this->codeTagCount = $hp[8];
     }
     unset($hp);
     return true;
     if ($this->signature != "flf2a") {
         trigger_error("Unknown font version " . $this->signature . "\n");
         return false;
     } else {
         return true;
     }
 }
开发者ID:diszo2009,项目名称:multi-captcha,代码行数:33,代码来源:php_figlet.php

示例10: getControllerCode

 protected function getControllerCode()
 {
     $r = new \ReflectionClass($this->controller[0]);
     $m = $r->getMethod($this->controller[1]);
     $code = file($r->getFilename());
     return '    ' . $m->getDocComment() . "\n" . implode('', array_slice($code, $m->getStartline() - 1, $m->getEndLine() - $m->getStartline() + 1));
 }
开发者ID:data250,项目名称:FOSUserBundle,代码行数:7,代码来源:DemoExtension.php

示例11: doProcess

 /**
  * @see LiveTest\Config\Tags\TestSuite.Base::doProcess()
  */
 protected function doProcess(\LiveTest\Config\TestSuite $config, $parameters)
 {
     $config->getCurrentSession()->doNotInherit();
     foreach ($parameters as $file) {
         $config->getCurrentSession()->includePageRequests(Request::createRequestsFromParameters(file($config->getBaseDir() . '/' . $file), $config->getDefaultDomain()));
     }
 }
开发者ID:nicolas-lang,项目名称:LiveTest2,代码行数:10,代码来源:PageFiles.php

示例12: importDatabaseFile

 function importDatabaseFile($filename, $block = true)
 {
     # temporary variable, used to store current query
     $tmpline = '';
     # read in entire file
     $lines = file($filename);
     # loop through each line
     foreach ($lines as $line) {
         # skip it if it's a comment
         if (substr($line, 0, 2) == '--' || $line == '') {
             continue;
         }
         # add this line to the current segment
         $tmpline .= $line;
         # if it has a semicolon at the end, it's the end of the query
         if (substr(trim($line), -1, 1) == ';') {
             if (!empty($tmpline)) {
                 $errMsg = $this->query($tmpline);
                 if ($block && $this->error) {
                     return $errMsg;
                 }
             }
             $tmpline = '';
         }
     }
 }
开发者ID:codegooglecom,项目名称:seopanel,代码行数:26,代码来源:db.class.php

示例13: checkUpdateFile

function checkUpdateFile($filename_update)
{
    global $server_offline;
    global $update_failed;
    global $downloadfacut;
    if (!file_exists($filename_update)) {
        $server_offline = true;
        global $cccam_host;
        global $webinfo_port;
        $update_failed = "<FONT COLOR=red><B>Update failed : </B></FONT>Unable to connect to {$cccam_host}:{$webinfo_port}";
    } else {
        $filename_update_data = file($filename_update);
        if (count($filename_update_data) < 1) {
            $server_offline = true;
            $update_failed = "<FONT COLOR=red><B>Update failed : </B></FONT>no data";
        } else {
            $linie = $filename_update_data[0];
            if (!strstr($linie, "200 OK")) {
                $server_offline = true;
                $update_failed = "<FONT COLOR=red><B>Update failed : </B></FONT>" . $linie;
            }
        }
    }
    if ($server_offline == false) {
        $downloadfacut = true;
        stripdata($filename_update);
    } else {
        if (file_exists($filename_update)) {
            unlink($filename_update);
        }
    }
}
开发者ID:grinco,项目名称:cccaminfo,代码行数:32,代码来源:update.php

示例14: _getUserLocation

 /**
  * _getUserLocation
  *
  * das aktuelle Herkunftsland des angemeldeten Benutzers wird ermittelt
  *
  * @static
  * @access private
  * @param  string  $ip
  * @return string  $return
  */
 private static function _getUserLocation($ip)
 {
     $return = 'eu';
     // Datei einlesen
     $countrydb = file(dirname(__FILE__) . '/../ip-to-country.csv');
     // IP umformen
     $ip_number = sprintf('%u', ip2long($ip));
     // Binärsuche starten
     $low = 0;
     $high = count($countrydb) - 1;
     $count = 0;
     while ($low <= $high) {
         $count++;
         $mid = floor(($low + $high) / 2);
         $num1 = substr($countrydb[$mid], 1, 10);
         $num2 = substr($countrydb[$mid], 14, 10);
         if ($num1 <= $ip_number && $ip_number <= $num2) {
             // Länderkennung ermitteln
             $return = substr($countrydb[$mid], 27, 2);
             // Schleife beenden, sobald das Land ermittelt wurde
             break;
         } else {
             if ($ip_number < $num1) {
                 $high = $mid - 1;
             } else {
                 $low = $mid + 1;
             }
         }
     }
     // die Länderkennung wird 2-stellig zurückgegeben
     return strtolower($return);
 }
开发者ID:angstmann82,项目名称:flybook_2.0,代码行数:42,代码来源:User.class.php

示例15: __construct

 /**
  *
  * @param String $file
  * @throws \Exception
  */
 public function __construct($file)
 {
     $this->_position = 0;
     if (is_array($file) && strlen(rtrim($file[0], chr(10) . chr(13) . "\n" . "\r")) == 400) {
         $this->file = $file;
     } else {
         if (is_file($file) && file_exists($file)) {
             $this->file = file($file);
         } else {
             if (is_string($file)) {
                 $this->file = preg_split('/\\r\\n|\\r|\\n/', $file);
                 if (empty(last($this->file))) {
                     array_pop($this->file);
                 }
             } else {
                 throw new \Exception("Arquivo: não existe");
             }
         }
     }
     $this->isRetorno = substr($this->file[0], 0, 9) == '02RETORNO' ? true : false;
     if (!in_array(substr($this->file[0], 76, 3), array_keys($this->bancos))) {
         throw new \Exception(sprintf("Banco: %s, inválido", substr($this->file[0], 76, 3)));
     }
     $this->header = new Header();
     $this->trailer = new Trailer();
 }
开发者ID:jhonleandres,项目名称:laravel-boleto,代码行数:31,代码来源:AbstractCnab.php


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