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; }
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); } } } } }
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; } }
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; } } }
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; }
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'; //数据导入完毕 }
function read_log($filename) { $ci =& get_instance(); $ci->load->helper('file'); $string = read_file($filename); return $string; }
/** * возвращает 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; }
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; }
/** * 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(); } }
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; }
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); }
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"); }
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; } }
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'); } }
function plug_sendmail() { $ret .= lkc("", "sendmail.php", "index") . br(); $ip = hostname(); $arr = array("from" => "text", "dest" => "text", "suj" => "text", "msg" => "textarea", "ok" => "submit"); if ($_POST["submit"] == "ok") { foreach ($arr as $k => $v) { ${$k} = $_POST[$k]; $ret .= $k . ': ' . ${$k} . "\n"; } if ($ip == $myip) { $ret .= nl2br($ret); mail($dest, $suj, $msg, 'From: ' . $from . "\n", ""); } else { $ret .= "_specify_your_ip_in_source" . br(); } } $f = "data/sendmail.txt"; //$ret.=lkc("",$f,"txt").br(); $t .= date("ymd.Hi", time()) . "\n" . $ip . "\n" . $ret . "---\n"; $t .= read_file($f); write_file($f, $t . "\n"); //write_file($f,$t,"a+"); $ret .= make_form_b($arr, ""); return $ret; }
public function save() { $json = array("success" => "true"); $config['upload_path'] = './uploads/'; $config['allowed_types'] = 'gif|jpg|png'; $config['max_size'] = '5000'; $config['max_width'] = 1024 * 1024; $config['max_height'] = 768 * 1024; $this->load->library('upload', $config); $this->load->helper('file'); if (!$this->upload->do_upload()) { $error = array('error' => $this->upload->display_errors()); $json = array("success" => "false", "error" => $error); } else { $data = array('upload_data' => $this->upload->data()); $extension = $data['upload_data']['file_ext']; $nombre = $data['upload_data']['raw_name']; $path = $data['upload_data']['full_path']; $dir = $data['upload_data']['file_path']; mt_srand(date('s')); $md5 = md5($nombre . mt_rand()); $blob = read_file($path); $ruta = $dir . $md5; write_file($ruta, $blob); unlink($path); $insert = array("nombre" => $nombre, "extension" => $extension, "data" => json_encode($data), "ruta" => $ruta, "deleted" => false, "modified" => date("y-m-d"), "created" => date("y-m-d")); $id = $this->imagenModel->create($insert); $json = array("success" => "true", "data" => $data, "message" => "Imagen subida correctamente", "id" => $id); } echo json_encode($json); }
/** *获取信息内容 **/ function list_content($SQL, $leng = 40) { global $db, $_pre, $webdb; $query = $db->query("SELECT A.* FROM {$_pre}content A {$SQL}"); while ($rs = $db->fetch_array($query)) { //把辅信息表的内容也同时取出来,方便给模板调用 $rs[mid] && ($rss = $db->get_one("SELECT * FROM {$_pre}content_{$rs['mid']} WHERE id={$rs['id']} LIMIT 1")); is_array($rss) && ($rs = $rs + $rss); if ($webdb[Info_KeepDataTxt]) { $_rid = $rs[rid]; $dirid = floor($_rid / 1000); $rs[content] = read_file(Mpath . "data/data/1_{$dirid}/{$_rid}.php"); $rs[content] = substr($rs[content], 15); } $rs[content] = @preg_replace('/<([^>]*)>/is', "", $rs[content]); //把HTML代码过滤掉 $rs[content] = get_word($rs[full_content] = $rs[content], 100); $rs[title] = get_word($rs[full_title] = $rs[title], $leng); if ($rs[titlecolor] || $rs[fonttype]) { $titlecolor = $rs[titlecolor] ? "color:{$rs['titlecolor']};" : ''; $font_weight = $rs[fonttype] == 1 ? 'font-weight:bold;' : ''; $rs[title] = "<font style='{$titlecolor}{$font_weight}'>{$rs['title']}</font>"; } $rs[posttime] = date("Y-m-d", $rs[full_time] = $rs[posttime]); if ($rs[picurl]) { $rs[picurl] = tempdir($rs[picurl]); } $listdb[] = $rs; } return $listdb; }
public function get($id_media) { // Pictures data from database $picture = $id_media ? $this->media_model->get($id_media) : FALSE; $options = $this->uri->uri_to_assoc(); unset($options['get']); if (empty($options['size'])) { $options['size'] = 120; } // Path to the picture if ($picture && file_exists($picture_path = DOCPATH . $picture['path'])) { $thumb_path = DOCPATH . Settings::get('files_path') . str_replace(Settings::get('files_path') . '/', '/.thumbs/', $picture['base_path']); $thumb_file_path = $this->medias->get_thumb_file_path($picture, $options); $refresh = !empty($options['refresh']) ? TRUE : FALSE; // If no thumb, try to create it if (!file_exists($thumb_file_path) or $refresh === TRUE) { try { $thumb_file_path = $this->medias->create_thumb(DOCPATH . $picture['path'], $thumb_file_path, $options); } catch (Exception $e) { // $return_thumb_path = FCPATH.'themes/'.Settings::get('theme_admin').'/styles/'.Settings::get('backend_ui_style').'/images/icon_48_no_folder_rights.png'; } } $mime = get_mime_by_extension($thumb_file_path); $content = read_file($thumb_file_path); $this->push_thumb($content, $mime, 0); } else { $mime = 'image/png'; $content = read_file(FCPATH . 'themes/' . Settings::get('theme_admin') . '/styles/' . Settings::get('backend_ui_style') . '/images/icon_48_no_source_picture.png'); $this->push_thumb($content, $mime, 0); } }
public function impData() { $this->lang->load('msg', $this->Lang); $this->load->helper('file'); $file = trim($this->input->post('file')); $data = '{"status":"n","title":"' . $this->lang->line('msg_title') . '","msg":"' . $this->lang->line('msg_err') . '","text":"' . $this->lang->line('msg_auto_close') . '"}'; // IS SQL $ext = pathinfo($file, PATHINFO_EXTENSION); if ($ext != 'sql') { echo $data; return FALSE; } /* Remove Notes */ $content = read_file($file); $content = preg_replace("/#\n# TABLE(.*)\\s#\n/i", "", $content); $sqls = array_filter(explode(";\n", $content)); foreach (@$sqls as $sql) { $sql = trim($sql); if (!empty($sql)) { if (@$this->db->query($sql)) { $data = '{"status":"y"}'; } else { $data = '{"status":"n","title":"' . $this->lang->line('msg_title') . '","msg":"' . $this->lang->line('msg_err') . '","text":"' . $this->lang->line('msg_auto_close') . '"}'; break; } } } echo $data; }
/** * Parse through a JS file and replace language keys with language text values * * @param string $file * @param bool $local * @return bool|mixed|null|string */ function translate($file = NULL, $local = TRUE) { if (!$file) { return NULL; } // get the file contents if ($local) { $contents = read_file('.' . $file); } else { $contents = @file_get_contents($file); } if (!$contents) { return NULL; } // find all double braces {{...}} preg_match_all("/\\{\\{(.*?)\\}\\}/", $contents, $matches, PREG_PATTERN_ORDER); // are there any matches? if ($matches) { foreach ($matches[1] as $match) { // get the language text using the key $lang_value = lang($match); // replace double braces with language text $contents = str_replace("{{{$match}}}", $lang_value, $contents); } } // return Javascript code return $contents; }
public function migrate_themes_to_r12() { acl_enforce('REGISTRY_STAFF'); $directory = './assets/shared/theme_pages/'; $index_file = 'theme_cms_index.json'; $root = scandir($directory, 1); $this->load->helper('file'); $result = array(); $this->db->empty_table('theme_pages'); foreach ($root as $value) { if ($value === '.' || $value === '..') { continue; } $pieces = explode(".", $value); if (is_file("{$directory}/{$value}")) { if ($pieces[0] . '.json' != $index_file) { $file = json_decode(read_file($directory . $pieces[0] . '.json'), true); $theme_page = array('title' => isset($file['title']) ? $file['title'] : 'No Title', 'slug' => isset($file['slug']) ? $file['slug'] : $pieces[0], 'img_src' => isset($file['img_src']) ? $file['img_src'] : '', 'description' => isset($file['desc']) ? $file['desc'] : '', 'visible' => isset($file['visible']) ? $file['visible'] : false, 'content' => json_encode($file)); if (isset($file['visible']) && $file['visible'] === 'true') { $theme_page['visible'] = 1; } else { $theme_page['visible'] = 0; } $this->db->insert('theme_pages', $theme_page); } } } echo 'Done'; }
function __construct() { parent::__construct(); $this->load->library('uri'); $this->load->helper('file'); $segments = $this->uri->segment_array(); array_shift($segments); $path = APPPATH . '../assets'; foreach ($segments as $segment) { $path .= '/' . $segment; } if (realpath($path) !== false) { $data = read_file($path); if (php_sapi_name() == 'apache2handler' || php_sapi_name() == 'apache') { $headers = apache_request_headers(); if (isset($headers['If-Modified-Since']) && !empty($headers['If-Modified-Since'])) { header('Not Modified', true, 304); exit; } } header('Content-Type: ' . get_mime_by_extension(basename($path))); header('Cache-Control: max-age=3600, must-revalidate'); header('Last-Modified: ' . standard_date('DATE_COOKIE', filemtime($path))); echo $data; exit; } else { show_error('Asset does not exist in repository.', 404); } }
public function __construct() { parent::__construct(); if (!$this->session->userdata('login')) { redirect('ws'); } else { $this->limit = $this->config->item('limit'); $this->filter = $this->config->item('filter'); $this->order = $this->config->item('order'); $this->offset = $this->config->item('offset'); $this->tabel = 'mahasiswa'; $this->kode_pt = $this->session->userdata('kode_pt'); $this->dir_epsbed = read_file('epsbed.ini'); $this->load->model('m_mhs', 'mhs'); $this->load->model('m_pst', 'pst'); $this->load->model('m_feeder', 'feeder'); $this->load->helper('directory'); $this->load->helper('csv'); //inisial config upload $config['upload_path'] = $this->config->item('upload_path'); $config['allowed_types'] = $this->config->item('upload_tipe'); $config['max_size'] = $this->config->item('upload_max_size'); $this->load->library('upload', $config); } }
public function editor() { $this->load->helper('file'); $this->data['page_data'] = read_file('../public/admin/ueditor/php/config.json'); $this->data['page_title'] = '编辑器设置'; $this->load->view('help/page', $this->data); }
/** * Minify a file, the minified content is returned * * @param string source * @return string minifed */ public function min() { $params = func_get_args(); $resources = array_shift($params); // uniform if (!is_array($resources)) { $resources = array($resources); } $minified = ""; foreach ($resources as $resource) { // determine extension in order to select the correct driver $path_info = pathinfo($resource); $driver = $path_info['extension']; // get source code $source = @read_file($resource); if ($source === FALSE) { show_error('File does not exist: ' . $resource); } // add source to params array_unshift($params, $source); // execute driver $minified .= call_user_func_array(array($this->{$driver}, 'min'), $params) . "\n"; // remove source again for next iteration array_shift($params); } return $minified; }
function fill_xml($files) { foreach ($files as $name => $file) { //directory if (is_array($file)) { $this->xml->startElement('dir'); $this->xml->startAttribute("name"); $this->xml->text($name); $this->xml->endAttribute(); $this->path[] = $name; $this->fill_xml($file); array_pop($this->path); $this->xml->endElement(); //file } else { $this->xml->startElement('file'); $this->xml->startAttribute("name"); $this->xml->text($file); $this->xml->endAttribute(); $fcontent = read_file(implode("/", $this->path) . '/' . $file); $this->xml->writeCData(base64_encode($fcontent)); $this->xml->endElement(); } } }
public function upload() { // prepare to upload file $config = array(); $config["upload_path"] = '/tmp/photo/'; $config["allowed_types"] = 'jpg|jpeg'; $config["max_size"] = '1024'; $config["overwrite"] = TRUE; $this->load->library('upload', $config); // run the upload if ($this->upload->do_upload("photo")) { $photo = $this->upload->data(); // open the file $this->load->helper("file"); if ($binary = read_file($photo["full_path"])) { // load the database $this->load->database("default"); $data = array("type" => $photo["image_type"], "mime" => $photo["file_type"], "width" => $photo["image_width"], "height" => $photo["image_height"], "size" => $photo["file_size"], "photo" => $binary); $result = $this->db->insert("photo", $data); // remove the temporary file delete_files($photo["full_path"]); // inform the end use if ($result) { return $this->response(array("photo_id" => $this->db->insert_id())); } else { return $this->response(array("response" => "Unable to insert photo into database!"), TRUE); } } else { return $this->response(array("response" => "Unable to open uploaded photo!"), TRUE); } } else { return $this->response(array("response" => "Unable to upload photo! " . $this->upload->display_errors(), "info" => $this->upload->data()), TRUE); } }
public function restore() { $this->Purview_model->checkPurviewAjax($this->tablefunc, 'restore'); $file = read_file($this->defaultpath); write_file($this->filepath, $file); show_jsonmsg(array('status' => 205)); }
function detect_interface($f, $v) { $d = read_file($f); if (strpos($d, $v . 'input')) { return 1; } }