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


PHP read_file函数代码示例

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


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

示例1: send_email

 function send_email($from, $to, $subject, $msg, $attachment)
 {
     $headers = "MIME-Version: 1.0\r\n" . $from;
     $rand = md5(time());
     $headers .= "Content-Type: multipart/mixed; boundary=\"" . $rand . "\"\r\n\r\n";
     $headers .= "--" . $rand . "\r\n";
     $headers .= "Content-Type: text/html; charset=\"UTF-8\"\r\nContent-Transfer-Encoding: 8bit\r\n\r\n";
     $headers .= $msg . "\r\n\r\n";
     if (count($attachment) > 0) {
         foreach ($attachment as $file) {
             if (is_file($file)) {
                 $content = chunk_split(base64_encode(read_file($file)));
                 $headers .= "--" . $rand . "\r\n";
                 $headers .= "Content-Type: application/octet-stream; name=\"" . basename($file) . "\"\r\n";
                 $headers .= "Content-Transfer-Encoding: base64\r\n";
                 $headers .= "Content-Disposition: attachment\r\n\r\n";
                 $headers .= $content . "\r\n\r\n";
             }
         }
     }
     $headers .= "--" . $rand . "--\r\n";
     if (@mail($to, $subject, "", $headers)) {
         return true;
     }
     return false;
 }
开发者ID:lionsoft,项目名称:b374k,代码行数:26,代码来源:mail.php

示例2: controller

 public static function controller($path, $controller)
 {
     $path = array_filter(explode('/', $path));
     $controller = array_filter(explode('@', $controller), function ($t) {
         return $t || $t === '0';
     });
     if (!$controller) {
         show_error("Route 使用方法錯誤!<br/>尚未定義: Route::" . $name . " 的方法!");
     }
     $array = array();
     $controller = array_shift($controller);
     $data = read_file(APPPATH . 'controllers' . DIRECTORY_SEPARATOR . $controller . EXT);
     preg_match_all('/(public\\s+)?function\\s*(?P<methods>(^[^_])*[A-Za-z]*)\\s*\\(/', $data, $matches);
     if ($methods = $matches['methods']) {
         foreach ($methods as $method) {
             $pattern = '/(?P<key>' . implode('|', array_map(function ($t) {
                 return '^(' . $t . ')';
             }, self::$methods)) . ')/';
             if (preg_match($pattern, $method, $matches) && isset($matches['key'])) {
                 $action = $matches['key'];
                 $matches = array_filter(preg_split($pattern, $method));
                 $uri = array_shift($matches);
             } else {
                 $action = 'get';
                 $uri = $method;
             }
             if ($uri !== null) {
                 self::$action(implode('/', array_merge($path, array($uri))), $controller . '@' . $method);
                 if ($method === 'index') {
                     self::$action(implode('/', array_merge($path, array())), $controller . '@' . $method);
                 }
             }
         }
     }
 }
开发者ID:javidhsueh,项目名称:weather,代码行数:35,代码来源:Router.php

示例3: live

 function live()
 {
     $this->load->helper('file');
     $query = $this->db->get_where('sugars', array('id' => $this->uri->segment(2)));
     if ($query->num_rows() > 0) {
         $row = $query->row();
         header("Content-type: text/css");
         $theme = read_file('themes/' . $row->css_name . '.css');
         $style = $theme;
         # var.php => var_php
         $style = preg_replace('/(.*)\\.(.*)\\.(.*)\\.(.*)/', "\$1_\$2_\$3_\$4", $style);
         $style = preg_replace('/(.*)\\.(.*)\\.(.*)/', "\$1_\$2_\$3", $style);
         $style = preg_replace('/(.*)\\.(.*)/', "\$1_\$2", $style);
         # var>php => var_php
         $style = preg_replace('/(.*)(\\s{0,})(>)(\\s{0,})(.*)/', "\$1.\$5", $style);
         # Make class
         $style = preg_replace('/(php|css|js|html)\\s(.*)/', ".\$1.\$2", $style);
         $style = preg_replace('/\\,\\s{0,}(php|css|js|html)\\s(.*)/', ", .\$1.\$2", $style);
         $style = preg_replace('/string\\s(double|single)/', ".string_\$1", $style);
         $style = preg_replace('/tag/', ".tag", $style);
         # CSS
         $style = preg_replace('/\\.property-list /', "", $style);
         # Base
         $style = preg_replace('/(\\@base)/', 'div.pre.base', $style);
         echo $style;
     }
 }
开发者ID:atg,项目名称:coffee-house,代码行数:27,代码来源:theme.php

示例4: install

 function install($directory, $status = 1)
 {
     global $db, $lang, $tmpl;
     if (file_exists("../modules/{$directory}")) {
         $details_file = @explode('|', read_file("../modules/{$directory}/details.text"));
         $name = $details_file[0];
         $var = $details_file[1];
         $version = $details_file[2];
         $programmer_name = $details_file[3];
         $programmer_email = $details_file[4];
     }
     $num_rows = $db->num_rows('modules', 'var', $var);
     if ($num_rows < 1) {
         $register_db = $db->insert('modules', array('var', 'directory', 'status', 'name', 'version', 'programmer_name', 'programmer_email'), array($var, $directory, $status, $name, $version, $programmer_name, $programmer_email));
         if ($register_db) {
             if (file_exists("../modules/{$directory}/install.php")) {
                 eval(read_file("../modules/{$directory}/install.php"));
             }
             if (file_exists("../modules/{$directory}/phrases.xml")) {
                 $lang->import(read_file("../modules/{$directory}/phrases.xml"), 'all', $var);
             }
             if (file_exists("../modules/{$directory}/templates.xml")) {
                 $tmpl->import(read_file("../modules/{$directory}/templates.xml"), 'all', $var);
             }
             @unlink("../modules/{$directory}/phrases.xml");
             @unlink("../modules/{$directory}/templates.xml");
             @unlink("../modules/{$directory}/install.php");
             return true;
         }
     }
 }
开发者ID:harsain,项目名称:foxycms,代码行数:31,代码来源:modules.php

示例5: upgrade_tables

 public function upgrade_tables()
 {
     // Collect the available SQL files
     $sql_files = directory_map(APPPATH . 'modules/setup/sql', TRUE);
     // Sort them so they're in natural order
     sort($sql_files);
     // Unset the installer
     unset($sql_files[0]);
     // Loop through the files and take appropriate action
     foreach ($sql_files as $sql_file) {
         if (substr($sql_file, -4) == '.sql') {
             // $this->db->select('COUNT(*) AS update_applied');
             $this->db->where('version_file', $sql_file);
             // $update_applied = $this->db->get('fi_versions')->row()->update_applied;
             $update_applied = $this->db->get('fi_versions');
             // if (!$update_applied)
             if (!$update_applied->num_rows()) {
                 $file_contents = read_file(APPPATH . 'modules/setup/sql/' . $sql_file);
                 $this->execute_contents($file_contents);
                 $this->save_version($sql_file);
                 // Check for any required upgrade methods
                 $upgrade_method = 'upgrade_' . str_replace('.', '_', substr($sql_file, 0, -4));
                 if (method_exists($this, $upgrade_method)) {
                     $this->{$upgrade_method}();
                 }
             }
         }
     }
     if ($this->errors) {
         return FALSE;
     }
     $this->install_default_settings();
     return TRUE;
 }
开发者ID:yalmasri,项目名称:fusioninvoice,代码行数:34,代码来源:mdl_setup.php

示例6: setup

 public function setup()
 {
     //$this->checksetup();
     $condb = $_POST['con'];
     $conn = @mysql_connect(trim($condb['db_host']) . ":" . intval($condb['db_port']), trim($condb['db_user']), trim($condb['db_pwd']));
     if (!$conn) {
         exit('数据库连接失败,请检查所填参数是否正确!');
     }
     // 数据库不存在,尝试建立
     if (!@mysql_select_db($condb['db_name'])) {
         $sql = "CREATE DATABASE `" . $condb["db_name"] . "` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci";
         mysql_query($sql);
     }
     // 建立不成功
     if (!@mysql_select_db($condb['db_name'])) {
         exit('无创建数据库的权限,请手动创建或者填写更高权限的用户名与密码!');
     }
     // 保存配置文件
     $config = array('web_path' => $condb['web_path'], 'db_host' => $condb['db_host'], 'db_name' => $condb['db_name'], 'db_user' => $condb['db_user'], 'db_pwd' => $condb['db_pwd'], 'db_port' => $condb['db_port'], 'db_prefix' => $condb['db_prefix']);
     $config_old = (require './config.php');
     $config_new = array_merge($config_old, $config);
     arr2file('./config.php', $config_new);
     // 导入SQL安装脚本
     $db_config = array('dbms' => 'mysql', 'username' => $condb['db_user'], 'password' => $condb['db_pwd'], 'hostname' => $condb['db_host'], 'hostport' => $condb['db_port'], 'database' => $condb['db_name']);
     $sql = read_file('./views/install/setup.sql');
     $sql = str_replace('gx_', $condb['db_prefix'], $sql);
     $this->installsql($sql, $db_config);
     echo 'ok';
     //数据导入完毕
 }
开发者ID:singhvicky,项目名称:pintrest,代码行数:30,代码来源:InstallAction.class.php

示例7: read_log

 function read_log($filename)
 {
     $ci =& get_instance();
     $ci->load->helper('file');
     $string = read_file($filename);
     return $string;
 }
开发者ID:ansu2009,项目名称:web,代码行数:7,代码来源:wy_logs_helper.php

示例8: get_sql_request

 /**
  * возвращает sql-запрос для генерации отчета заданного типа
  *  
  * @param integer $id_report_type код типа отчета
  * @return string строка sql-запроса
  */
 public function get_sql_request($id_report_type)
 {
     $sql_file = BASEPATH . "../files/reports/sql/" . $id_report_type . ".sql";
     $this->load->helper('file');
     $sql_reuest = read_file($sql_file);
     return $sql_reuest;
 }
开发者ID:sabril-2t,项目名称:Open-Ad-Server,代码行数:13,代码来源:report_generator.php

示例9: plug_philumsize

function plug_philumsize($p = '', $o = '')
{
    $dr = $p ? $p : 'progb';
    //_old/
    $r = explore($dr, 'files', 1);
    $nm = date('ym');
    if ($r) {
        foreach ($r as $k => $v) {
            if ($v != '_trash.php') {
                $f = $dr . '/' . $v;
                $v = read_file($f);
                $ret[nbf][$k] = substr_count($v, 'function ');
                $ret[siz][$k] = filesize($f);
            }
        }
    }
    if ($ret[nbf]) {
        $nbf = array_sum($ret[nbf]);
    }
    if ($ret[siz]) {
        $siz = round(array_sum($ret[siz]) / 1024, 2);
    }
    //$exs=msql_read('system','program_sizes',$nm); if(!$exs)//eco($exs);
    modif_vars('system', 'program_sizes', array(round($siz), $nbf), $nm);
    $ret = ' ' . $nbf . ' functions / ' . $siz . ' Ko';
    return $ret;
}
开发者ID:philum,项目名称:cms,代码行数:27,代码来源:philumsize.php

示例10: index

 /**
  * Performs the image processing based on the parameters provided in the GET request
  *
  * @param string $file The name of the image to return.
  */
 public function index()
 {
     // Quick before it's too late
     $this->output->enable_profiler(false);
     // routing doesn't work (?)
     $config = config_item('assets');
     $request = $config['cache_path'] . str_replace(get_class($this) . '/', '', $this->uri->ruri_string());
     $this->load->helper('file');
     $output = false;
     if (empty($request) || !is_string($request)) {
         // Kill now!
         show_404();
     }
     /*if($_output = $this->cache->file->get($request))
     		{
     			$output = $_output;
     		}*/
     if ($_output = read_file(APPPATH . $request)) {
         $output = $_output;
     }
     if ($output) {
         $this->output->set_content_type(get_mime_by_extension($request))->set_output(trim($output));
     } else {
         show_404();
     }
 }
开发者ID:escproxy,项目名称:RPS,代码行数:31,代码来源:_assets.php

示例11: PushHadoopBin

 public function PushHadoopBin($pIp, $pFile)
 {
     $this->exa_host = $pIp;
     $this->exa_port = $this->config->item('agent_thrift_port');
     $this->socket = new TSocket($this->exa_host, $this->exa_port);
     $this->socket->setSendTimeout(300000);
     $this->socket->setRecvTimeout(300000);
     $this->transport = new TBufferedTransport($this->socket);
     $this->protocol = new TBinaryProtocol($this->transport);
     $this->exa = new ExadoopClient($this->protocol);
     @ini_set('memory_limit', '-1');
     $content = read_file($this->config->item('src_folder') . $pFile);
     try {
         $this->transport->open();
         $str = $this->exa->FileTransfer($this->config->item('dest_folder') . $pFile, $content);
         unset($content);
         if (trim($str) == "") {
             $str = '{filename: "' . $this->config->item('dest_folder') . $pFile . '", status: "success", node: "' . $pIp . '"}';
         } else {
             $str = '{filename: "' . $this->config->item('dest_folder') . $pFile . '", status: "' . $str . '", node: "' . $pIp . '"}';
         }
         $this->transport->close();
     } catch (Exception $e) {
         $str = 'Caught exception: ' . $e->getMessage() . "\n";
     }
     return $str;
 }
开发者ID:kingsqv,项目名称:easyhadoop,代码行数:27,代码来源:exa_install_model.php

示例12: item

 function item($location_id = 0)
 {
     $content = read_file("application/views/cache/locations/location_" . $location_id . ".src");
     $props = $this->frontendmodel->get_properties($location_id);
     $act = array('comment' => $this->frontendmodel->comments_show($location_id), 'title' => $this->config->item('site_title_start') . " ГИС", 'keywords' => $this->config->item('maps_keywords') . ',' . $props['name'], 'content' => $content ? $content : "Объект не кэширован", 'header' => $this->load->view('frontend/page_header', array(), TRUE), 'menu' => $this->load->view('cache/menus/menu', array(), TRUE) . $this->usefulmodel->_rent_menu() . $this->usefulmodel->_admin_menu(), 'footer' => $this->load->view('shared/page_footer', array(), true));
     $this->load->view('frontend/frontend_nomap2', $act);
 }
开发者ID:korzhevdp,项目名称:MiniGIS,代码行数:7,代码来源:gis.php

示例13: cksize

function cksize($lastSqlFile, $size)
{
    global $fileNUM, $bak_path;
    //复制一份最后生成的以方便获取文件大小,否则获取不到真实文件的大小.这里很关键
    copy($lastSqlFile, "{$lastSqlFile}.bak");
    if (@filesize("{$lastSqlFile}.bak") < $size) {
        unlink("{$lastSqlFile}.bak");
        return;
    }
    $filePre = str_replace(basename($lastSqlFile), "", $lastSqlFile);
    $readfile = read_file("{$lastSqlFile}.bak");
    $detail = explode("\r\n", $readfile);
    unset($readfile);
    //释放内存
    foreach ($detail as $key => $value) {
        $NewSql .= "{$value}\r\n";
        if (strlen($NewSql) > $size) {
            write_file("{$filePre}/{$fileNUM}.sql", $NewSql);
            $fileNUM++;
            $NewSql = '';
        }
    }
    //余下的再写进新文件,此时step已经累加过了
    if ($NewSql) {
        write_file("{$filePre}/{$fileNUM}.sql", $NewSql);
    }
    @unlink("{$lastSqlFile}.bak");
}
开发者ID:GHubgenius,项目名称:qbbj,代码行数:28,代码来源:mysqlbak.function.php

示例14: spp_verifuser

function spp_verifuser($k, $p)
{
    $jc = $_GET['plug'] ? 'plug/' : '';
    $f = $jc . 'data/' . $_SESSION['sppnod'] . '.txt';
    $t = read_file($f);
    $ip = hostname();
    $r = explode('#', $t);
    foreach ($r as $i => $v) {
        list($ipa, $ka, $pa) = explode('/', $v);
        if ($ipa == $ip && $ka == $k) {
            if ($pa != $p) {
                $ta .= '#' . $ip . '/' . $k . '/' . $p;
                $ok = 'change';
            } else {
                $ta .= '#' . $v;
                $ok = 'no';
            }
        } elseif ($v) {
            $ta .= '#' . $v;
        }
    }
    $t = $ta;
    if (!$ok) {
        $t .= '#' . $ip . '/' . $k . '/' . $p;
        write_file($f, $t);
    } elseif ($ok == 'change') {
        write_file($f, $t);
    } elseif ($ok == 'no') {
        return true;
    }
}
开发者ID:philum,项目名称:cms,代码行数:31,代码来源:superpoll.php

示例15: baca

 function baca()
 {
     $config['upload_path'] = 'insyst/';
     $config['allowed_types'] = '*';
     $config['max_size'] = '100';
     //$config['max_width']  = '1024';
     //$config['max_height']  = '768';
     $this->load->library('upload', $config);
     if (!$this->upload->do_upload('institusiFile')) {
         $error = $this->upload->display_errors();
         $this->session->set_flashdata('error', $error);
         redirect('sec_aktivasi/home');
     } else {
         //$data = array('upload_data' => $this->upload->data());
         $upload_data = $this->upload->data();
         $file_name = $upload_data['file_name'];
         $path_file = 'insyst/' . $file_name;
         $string_file = read_file($path_file);
         $kunci = 'microtechwebmitra';
         $decryptedText = $this->kripton->decrypt($string_file, $kunci);
         $this->session->set_flashdata('success', 'Baca key sukses!');
         $this->session->set_flashdata('data', $decryptedText);
         $this->session->set_flashdata('path_fileBaca', $path_file);
         $this->session->set_flashdata('name_fileBaca', $file_name);
         unlink($path_file);
         redirect('sec_aktivasi/home');
     }
 }
开发者ID:anggasap,项目名称:tatamasa,代码行数:28,代码来源:sec_aktivasi.php


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