function hiddenVerify($strVal, $strOpts)
{
    //---------------------------------------------------------------------
    //
    //---------------------------------------------------------------------
    global $gbShowHiddenVerifyError;
    $CI =& get_instance();
    $gbShowHiddenVerifyError = true;
    $aOpts = explode(',', $strOpts);
    $strVerificationModule = trim($aOpts[0]);
    $strVModEntryPoint = trim($aOpts[1]);
    // does the file exist?
    $strFullFN = './application/helpers/custom_verification/' . $strVerificationModule;
    $fArray = get_file_info($strFullFN);
    if ($fArray === false) {
        $CI->form_validation->set_message('hiddenVerify', 'Unable to find custom validation file! Please check with your system administrator.');
        return false;
    }
    // extract the helper name, then load helper
    $strHelperName = substr($strVerificationModule, 0, strlen($strVerificationModule) - 11);
    $CI->load->helper('custom_verification/' . $strHelperName);
    // does the entry point exist?
    if (!is_callable($strVModEntryPoint)) {
        $CI->form_validation->set_message('hiddenVerify', 'Unable to find the entry point for custom validation file! Please check with your system administrator.');
        return false;
    }
    $gbShowHiddenVerifyError = false;
    return call_user_func($strVModEntryPoint);
}
示例#2
0
 /**
  *	checks if site is installed... and configured... if not redirects to install script
  */
 function _check_installation()
 {
     // if there is no site_config.php it's not installed
     $this->load->helper('file');
     $info = get_file_info(APPPATH . "config/site_config.php");
     if ($info === false) {
         redirect('/install', 'location');
     }
 }
示例#3
0
 function fileInfo($path, $output)
 {
     $CI =& get_instance();
     $CI->load->helper('file');
     $item = get_file_info($path, array($output));
     foreach ($item as $ritem) {
         return $ritem;
     }
 }
示例#4
0
 function Install()
 {
     parent::Controller();
     $this->load->helper('file');
     $info = get_file_info(APPPATH . "config/site_config.php");
     if ($info !== false) {
         // daca site-ul este deja instalat iesim de aici...
         redirect('/home', 'location');
     }
 }
示例#5
0
 private function _test_get_file_info($vals)
 {
     $content = 'Jack and Jill went up the mountain to fight a billy goat.';
     $last_modified = time() - 86400;
     $file = vfsStream::newFile('my_file.txt', 0777)->withContent($content)->lastModified($last_modified)->at($this->_test_dir);
     $ret_values = array('name' => 'my_file.txt', 'server_path' => 'vfs://my_file.txt', 'size' => 57, 'date' => $last_modified, 'readable' => TRUE, 'writable' => TRUE, 'executable' => TRUE, 'fileperms' => 33279);
     $info = get_file_info(vfsStream::url('my_file.txt'), $vals);
     foreach ($info as $k => $v) {
         $this->assertEquals($ret_values[$k], $v);
     }
 }
 function updateDBConfigFile($strDBName, $strDBHost, $strUserName, $strPWord)
 {
     //---------------------------------------------------------------------
     //
     //---------------------------------------------------------------------
     $strDBConfigFN = set_realpath('.') . 'application/config/database.php';
     $fInfo = get_file_info($strDBConfigFN);
     if ($fInfo === false) {
         $this->bError = true;
         $this->strErrMsg = 'Can not find the database configuration file ' . $strDBConfigFN . '<br>';
         return;
     }
     $strDBConfig = '<?php' . "\n" . '/* ----------------------------' . "\n" . '  Database configuration entries updated on ' . date('Y-m-d H:i:s') . ' for the ' . "\n" . '  Delightful Labor installation. ' . "\n\n" . '  Updates can be found at the bottom of this file.' . "\n" . ' ----------------------------*/' . "\n" . "?>" . read_file($strDBConfigFN) . "\n\n" . '/* ----------------------------' . "\n" . '  Delightful Labor database settings. ' . "\n" . ' ----------------------------*/' . "\n" . "\$db['default']['hostname'] = '{$strDBHost}';\n" . "\$db['default']['username'] = '******';\n" . "\$db['default']['password'] = '******';\n" . "\$db['default']['database'] = '{$strDBName}';\n";
     write_file($strDBConfigFN, $strDBConfig);
 }
示例#7
0
function ada_foto($file)
{
    $CI =& get_instance();
    $CI->load->helper('file');
    $cek_foto = get_file_info('./assets/img/foto_conto/' . $file);
    if (!$cek_foto) {
        return FALSE;
    } else {
        if (empty($file)) {
            return FALSE;
        } else {
            return TRUE;
        }
    }
}
 /**
  * Open each files, compile a list of functions within
  * @param string $folder
  * @param array $array_of_filenames
  * @param $new_array
  */
 private function list_functions_in_files($folder, $array_of_filenames, &$new_array)
 {
     $this->load->helper('file');
     foreach ($array_of_filenames as $key => $filename) {
         if (is_array($filename)) {
             $this->list_functions_in_files($folder . $key . '/', $filename, $new_array);
         } else {
             if (!in_array($filename, $this->file_exclude)) {
                 $file_content = read_file('./' . $folder . $filename);
                 $new_array[] = array('filename' => $filename, 'info' => get_file_info('./' . $folder . $filename), 'functions' => $this->discover_functions_in_content($file_content));
             }
         }
     }
     return $new_array;
 }
 function propriedades_arquivos($arquivo, $complemento = '')
 {
     $ci =& get_instance();
     if (!file_exists($arquivo)) {
         return $dadosImagem['localizacao'] = false;
     } else {
         $arquivoDados = explode('/', $arquivo);
         $extension = substr(strrchr($arquivo, '.'), 1);
         if ($extension != null) {
             $ci->load->helper('file');
             $mime = get_mime_by_extension($arquivo);
             if ($mime != false) {
                 $mime2 = explode('/', get_mime_by_extension($arquivo));
             } else {
                 $mime2[0] = "desconhecido";
                 $mime2[1] = "desconhecido";
             }
         } else {
             $mime2[0] = "desconhecido";
             $mime2[1] = "desconhecido";
             $mime = null;
         }
     }
     $ci->load->helper('file');
     $size = get_file_info($arquivo, array('name', 'server_path', 'size', 'date', 'readable', 'writable', 'executable', 'fileperms'));
     $dadosImagem = array();
     foreach ($size as $k => $v) {
         $dadosImagem[$complemento . $k] = $v;
     }
     $dadosImagem[$complemento . 'localizacao'] = true;
     $dadosImagem[$complemento . 'mime'] = $mime;
     $dadosImagem[$complemento . 'mimeTipo'] = isset($mime2[0]) ? $mime2[0] : '';
     $dadosImagem[$complemento . 'mimeSub'] = isset($mime2[1]) ? $mime2[1] : '';
     $dadosImagem[$complemento . 'arquivo_formatado'] = renomear_arquivos($arquivoDados[count($arquivoDados) - 1]);
     $dadosImagem[$complemento . 'date_formatado'] = date('Y-m-d H:i:s', $size['date']);
     if ($mime2[0] == 'image') {
         $propriedades = getimagesize($arquivo);
         $dadosImagem[$complemento . 'largura'] = $propriedades[0];
         $dadosImagem[$complemento . 'altura'] = $propriedades[1];
     } else {
         $dadosImagem[$complemento . 'largura'] = null;
         $dadosImagem[$complemento . 'altura'] = null;
     }
     return $dadosImagem;
 }
示例#10
0
文件: Html.php 项目: k-site/k-cms
 /** 생성자 */
 function __construct()
 {
     parent::__construct();
     $this->load->helper('file');
     $pos = strpos($this->input->server('PHP_SELF'), '/index.php') + 1;
     $html_root = substr($this->input->server('PHP_SELF'), 0, $pos) . 'html';
     $domain = str_replace('www.', '', $this->input->server('SERVER_NAME'));
     // 도메인으로 등록여부를 체크...
     // $query = $this->db->query("SELECT * FROM k_site WHERE domain='{$domain}'");
     // print_r($query->row());
     // 화면 설정 파일 인클루드...
     $config_file = get_file_info(rtrim(getenv("DOCUMENT_ROOT"), '/') . $html_root . '/view/' . $domain . '/config.php');
     if ($config_file) {
         require_once $config_file['server_path'];
         $this->html = $html;
         $this->html['root'] = $html_root;
     }
 }
示例#11
0
文件: playlist.php 项目: RiJo/m3uer
function save($root, $path, $data)
{
    $playlist_file_info = get_file_info($path);
    // Reference: http://stackoverflow.com/questions/689185/json-decode-returns-null-php
    if (get_magic_quotes_gpc()) {
        // Remove PHP magic quotes
        $data = stripslashes($data);
    }
    $data = json_decode($data, true);
    if ($data == null) {
        die('Playlist could not be saved: Could not parse json data');
    }
    $handle = @fopen($playlist_file_info['path'], 'w') or die('Playlist could not be saved: Could not open file for writing');
    fwrite($handle, playlist_header() . LINE_BREAK);
    fwrite($handle, implode("\n", playlist_contents($playlist_file_info['path'], $data)));
    fclose($handle);
    echo 'Playlist saved successfully';
}
示例#12
0
 private function getFileSize($id, $fn)
 {
     $this->load->helper('file');
     $r = "0 KB";
     $fp = $this->filepath . $id . DIRECTORY_SEPARATOR . $fn;
     $fileinfo = get_file_info($fp);
     if ($fileinfo) {
         if (isset($fileinfo["size"])) {
             $unit = " KB";
             $size = $fileinfo["size"] / 1024;
             if ($size >= 1024) {
                 $size = $size / 1024;
                 $unit = " MB";
             }
             $r = round($size, 2) . $unit;
         }
     }
     return $r;
 }
示例#13
0
 public function test()
 {
     //$this->load->helper('file');
     //返回和index.php在同一个目录下的test.txt文件的内容,使用的是原生的php函数
     echo file_get_contents('test.txt');
     $this->load->helper('file');
     $data = 'Some file data<br/>';
     //write_file方法会覆盖文件中已有的内容
     if (!write_file('test.txt', $data)) {
         echo 'Unable to write the file<br/>';
     } else {
         echo 'File written!<br/>';
     }
     //		if (delete_files('zcyytest/')) {
     //			echo '删除成功!<br/>';
     //		} else {
     //			echo '删除失败!<br/>';
     //		}
     //连这个目录下的文件夹一起删除
     //		if (delete_files('zcyytest/', TRUE)) {
     //			echo '删除成功!<br/>';
     //		} else {
     //			echo '删除失败!<br/>';
     //		}
     echo APPPATH . '<br/>';
     $controllers = get_filenames(APPPATH . '../' . 'zcyytest/');
     print_r($controllers);
     echo '<br/>';
     $models_info = get_dir_file_info(APPPATH . '../' . 'zcyytest/');
     print_r($models_info);
     echo '<br/>';
     print_r(get_file_info(APPPATH . '../' . 'zcyytest/1.txt'));
     echo '<br/>';
     //将文件权限的数字格式(例如 fileperms() 函数的返回值)转换为标准的符号格式。
     echo symbolic_permissions(fileperms('test.txt'));
     echo '<br/>';
     //将文件权限的数字格式(例如 fileperms() 函数的返回值)转换为三个字符的八进制表示格式。
     echo octal_permissions(fileperms('test.txt'));
     echo '<br/>';
 }
示例#14
0
 public function index()
 {
     $this->Purview_model->checkPurview($this->tablefunc);
     $folder = $this->input->post('folder');
     if (!$folder) {
         $folder = $this->defaultfolder;
     }
     $listarr = directory_map($folder, 1);
     $folderlist = array();
     $phplist = array();
     $csslist = array();
     $jslist = array();
     foreach ($listarr as $list) {
         $thispath = $folder . '/' . $list;
         $newlist = get_file_info($thispath);
         $newlist['permissions'] = octal_permissions(fileperms($thispath));
         $newlist['name'] = $list;
         if (is_dir($thispath)) {
             $folderlist[] = $newlist;
         } else {
             $newlist['size'] = byte_format($newlist['size']);
             $ext = get_suffix($thispath);
             switch ($ext) {
                 case 'php':
                     $phplist[] = $newlist;
                     break;
                 case 'css':
                     $csslist[] = $newlist;
                     break;
                 case 'js':
                     $jslist[] = $newlist;
                     break;
                 default:
                     break;
             }
         }
     }
     $res = array('tpl' => 'list', 'tablefunc' => $this->tablefunc, 'folderlist' => $folderlist, 'phplist' => $phplist, 'csslist' => $csslist, 'jslist' => $jslist, 'defaultfolder' => $this->defaultfolder, 'folder' => $folder);
     $this->load->view($this->tablefunc, $res);
 }
示例#15
0
function clean_temp($mode = 'day', $max = 1)
{
    $CI =& get_instance();
    $CI->load->helper('directory');
    $CI->load->helper('file');
    //$directory = '/var/www/temp/';
    $directory = TEMPPATH;
    $files = directory_map($directory);
    $now = time();
    $files_to_take[] = 'picture.jpg';
    $files_to_take[] = 'fab_ui_safety.json';
    $files_to_take[] = 'instagram_feed.json';
    $files_to_take[] = 'instagram_hash.json';
    $files_to_take[] = 'twitter.json';
    $files_to_take[] = 'faq.json';
    $files_to_take[] = 'macro_response';
    $files_to_take[] = 'macro_trace';
    $files_to_take[] = 'macro_status.json';
    foreach ($files as $file) {
        $file_date = get_file_info($directory . $file, 'date')['date'];
        $diff = $now - $file_date;
        $diff_min = $diff / 60;
        $diff_hour = $diff_min / 60;
        $diff_days = $diff_hour / 24;
        switch ($mode) {
            case 'min':
                $remove = $diff_min > $max;
                break;
            case 'hour':
                $remove = $diff_hour > $max;
                break;
            case 'day':
                $remove = $diff_days > $max;
                break;
        }
        if ($remove && !in_array($file, $files_to_take)) {
            unlink($directory . $file);
        }
    }
}
示例#16
0
 /**
  * @brief 下载文件,默认在 UPLOAD 文件夹下
  *
  * @param string $file
  * @param string $path 设定路径,默认为false
  *
  * @return 
  */
 public function download($file, $path = false)
 {
     if ($file) {
         if ($path) {
             $file = $path . $file;
         } else {
             $file = UPLOAD_PATH . $file;
         }
     } else {
         return false;
     }
     if (!file_exists($file)) {
         return false;
     }
     if (!function_exists('get_mime_by_extension')) {
         $CI =& get_instance();
         $CI->load->helper('file');
     }
     if ($type = get_mime_by_extension($file)) {
         $file_info = get_file_info($file);
         // ob_start();
         // ini_set('memory_limit','1200M');
         // set_time_limit(900);
         // // required for IE, otherwise Content-disposition is ignored
         // if(ini_get('zlib.output_compression'))
         //     ini_set('zlib.output_compression', 'Off');
         header("Content-Type:" . $type);
         header('Content-Disposition:attachment;filename=' . $file_info['name']);
         header('Content-Transfer-Encodeing: binary');
         header('Content-Length:' . $file_info['size']);
         // ob_clean();
         // flush();
         readfile($file);
         exit;
     } else {
         log_message('debug', 'class download: can\'t find the file type');
         return false;
     }
 }
示例#17
0
 /**
  * Takes a given path and prints the content in json format.
  */
 public static function get_content($app, $path)
 {
     $path = __DIR__ . '/../data/' . $path;
     $path = rtrim($path, '/');
     require_once __DIR__ . '/helper.php';
     // get dir content
     $files = array();
     $folders = array();
     list_dir($path, $files, $folders);
     $files = array_merge($folders, $files);
     // get info
     foreach ($files as $k => $v) {
         $i = get_file_info($v['path'], array('name', 'size', 'date', 'fileperms'));
         if ($v['folder']) {
             $files[$k] = array('name' => $i['name'], 'size' => '---', 'date' => date('Y-m-d H:i:s', $i['date']), 'perm' => unix_perm_string($i['fileperms']), 'folder' => True);
         } else {
             $files[$k] = array('name' => $i['name'], 'size' => human_filesize($i['size']), 'date' => date('Y-m-d H:i:s', $i['date']), 'perm' => unix_perm_string($i['fileperms']), 'folder' => False);
         }
         $files[$k]['link'] = str_replace(__DIR__ . '/../data/', '', $v['path']);
     }
     return json_encode(array('status' => 'ok', 'files' => $files));
 }
示例#18
0
 public function _form_vars($id = NULL, $fields = NULL, $log_to_recent = TRUE, $display_normal_submit_cancel = TRUE)
 {
     $vars = parent::_form_vars($id, $fields, $log_to_recent, $display_normal_submit_cancel);
     $saved = $vars['data'];
     $import_view = FALSE;
     $warning_window = '';
     if (!empty($saved['name'])) {
         $view_twin = APPPATH . 'views/_blocks/' . $saved['name'] . EXT;
         if (file_exists($view_twin)) {
             $this->load->helper('file');
             $view_twin_info = get_file_info($view_twin);
             if (!empty($saved)) {
                 $tz = date('T');
                 if ($view_twin_info['date'] > strtotime($saved['last_modified'] . ' ' . $tz) or $saved['last_modified'] == $saved['date_added'] and !$this->input->get('uploaded')) {
                     $warning_window = lang('blocks_updated_view', $view_twin);
                 }
             }
         }
     }
     $vars['warning_window'] = $warning_window;
     return $vars;
 }
示例#19
0
 function import_view()
 {
     $out = 'error';
     if ($this->input->post('id')) {
         $block_data = $this->model->find_by_key($this->input->post('id'), 'array');
         $this->load->helper('file');
         $view_twin = APPPATH . 'views/_blocks/' . $block_data['name'] . EXT;
         if (file_exists($view_twin)) {
             $view_twin_info = get_file_info($view_twin);
             $tz = date('T');
             if ($view_twin_info['date'] > strtotime($block_data['last_modified'] . ' ' . $tz) or $block_data['last_modified'] == $block_data['date_added']) {
                 // must have content in order to not return error
                 $out = file_get_contents($view_twin);
                 // replace PHP tags with template tags... comments are replaced because of xss_clean()
                 if ($this->sanitize_input) {
                     $out = php_to_template_syntax($out);
                 }
             }
         }
     }
     $this->output->set_output($out);
 }
示例#20
0
文件: api.php 项目: hoogle/ttt
 function getDirectoryFiles($path, $sortby = "name", $sign = "+")
 {
     $path = rtrim($path, "/") . "/";
     $this->load->helper("directory");
     $this->load->helper("file");
     $dir_ary = directory_map($path, TRUE);
     $file_attr_arr = array('name', 'size', 'date', 'mtime', 'type', 'mime', 'md5');
     $files_arr = array();
     foreach ($dir_ary as $file) {
         $tmp_arr = get_file_info($path . $file, $file_attr_arr);
         $addmd5 = $sortby == "mime" ? "_{$tmp_arr['md5']}" : "";
         $files_arr[$tmp_arr[$sortby] . $addmd5] = get_file_info($path . $file, $file_attr_arr);
     }
     if ($sign == "-") {
         krsort($files_arr);
     } else {
         ksort($files_arr);
     }
     foreach ($files_arr as $f_arr) {
         $ordered_arr[] = $f_arr;
     }
     return $ordered_arr;
 }
示例#21
0
 function get($id = false)
 {
     if ($id === false) {
         redirect('forms');
     }
     $this->load->helper('download');
     $this->load->helper('file');
     // Check if the file exists
     $result = $this->db->get_where('forms', array('fid' => $id));
     if ($result->num_rows() == 0) {
         $this->data['main_content'] .= $this->load->view('download_missing', $this->data, true);
         $this->load->view('default', $this->data);
     } else {
         $file = $result->row_array();
         $path = 'assets/documents/' . $file['link'];
         $finfo = get_file_info($path);
         $ext = end(explode(".", $finfo["name"]));
         // Make the file name should be safely stored in the db
         $name = "{$file["name"]}.{$ext}";
         $data = read_file($path);
         force_download($name, $data);
     }
 }
/**
 * Gets the directory file info.
 *
 * @access	public
 * @param 	string
 * @param 	boolean
 * @param 	boolean
 * @return	array
 */
function get_dir_file_info($source_dir, $top_level_only = TRUE, $include_path = FALSE, $_recursion = FALSE)
{
    static $_filedata = array();
    static $orig_directory;
    if (!isset($orig_directory)) {
        $orig_directory = $source_dir;
    }
    $relative_path = $source_dir;
    if ($fp = @opendir($source_dir)) {
        // reset the array and make sure $source_dir has a trailing slash on the initial call
        if ($_recursion === FALSE) {
            $_filedata = array();
            $source_dir = str_replace("\\", "/", rtrim(realpath($source_dir), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR);
        }
        while (FALSE !== ($file = readdir($fp))) {
            if (@is_dir($source_dir . $file) && strncmp($file, '.', 1) !== 0 and $top_level_only === FALSE) {
                get_dir_file_info($source_dir . $file . DIRECTORY_SEPARATOR, $top_level_only, $include_path, TRUE);
            } elseif (strncmp($file, '.', 1) !== 0) {
                $fileinfo = get_file_info($source_dir . $file);
                $file_prefix = $include_path ? substr($source_dir, strlen($orig_directory) - 1) : $source_dir;
                if (!empty($file_prefix)) {
                    $file = $file_prefix . "/" . $file;
                    $file = str_replace(array("//", "\\/"), array("/", "/"), $file);
                    // replace double slash
                    if (substr($file, 0, 1) == '/') {
                        $file = substr($file, 1);
                    }
                }
                $_filedata[$file] = $fileinfo;
                $_filedata[$file]['relative_path'] = $relative_path;
            }
        }
        return $_filedata;
    } else {
        return FALSE;
    }
}
示例#23
0
 public function del()
 {
     $filename = $this->input->get('filename');
     if (!$filename) {
         $filename = $this->input->post('filename');
         if (!$filename) {
             $this->outJson(-1);
         }
     }
     if (is_string($filename)) {
         $filename = array($filename);
     }
     $noauth = array();
     foreach ($filename as $k => $v) {
         $file = get_file_info($this->path . $v);
         if ($file) {
             $auth = octal_permissions(fileperms($this->path . $v));
             $number = substr($auth, -1);
             if ($number != 7) {
                 $noauth[] = $v;
             } else {
                 if (is_file($file['server_path'])) {
                     unlink($file['server_path']);
                 }
                 if (is_dir($file['server_path'])) {
                     rmdir($file['server_path']);
                 }
             }
         }
     }
     if (!$noauth) {
         $this->outJson(0);
     } else {
         $this->outJson(1, '', implode(',', $noauth) . '没有权限删除!');
     }
 }
示例#24
0
文件: design.php 项目: rmdort/adiee
 /**
  * Sync data from files
  *
  * Update database to match current template files
  *
  * @access	public
  * @return	void
  */
 function sync_run()
 {
     if (!$this->cp->allowed_group('can_access_design')) {
         show_error($this->lang->line('unauthorized_access'));
     }
     $message = '';
     if ($this->config->item('save_tmpl_files') != 'y' or $this->config->item('tmpl_file_basepath') == '') {
         $this->functions->redirect(BASE . AMP . 'C=design' . AMP . 'M=sync_templates');
     }
     if (!$this->cp->allowed_group('can_admin_templates')) {
         show_error($this->lang->line('unauthorized_access'));
     }
     if (!($confirmed = $this->input->get_post('confirm')) or $confirmed != 'confirm') {
         $this->functions->redirect(BASE . AMP . 'C=design' . AMP . 'M=sync_templates');
     }
     if (!$this->input->post('toggle') or !is_array($this->input->post('toggle'))) {
         $this->functions->redirect(BASE . AMP . 'C=design' . AMP . 'M=sync_templates');
     }
     $damned = array();
     $create_files = array();
     foreach ($_POST['toggle'] as $key => $val) {
         if (strncmp($val, 'cf-', 3) == 0) {
             $create_files[] = substr($val, 3);
             $damned[] = substr($val, 3);
         } else {
             $damned[] = $val;
         }
     }
     $save_result = FALSE;
     // If we need to create files, we do it now.
     if (count($create_files) > 0) {
         $this->db->select(array('group_name', 'template_name', 'template_type', 'template_id', 'edit_date', 'template_data'));
         $this->db->join('template_groups', 'template_groups.group_id = templates.group_id');
         $this->db->where('templates.site_id', $this->config->item('site_id'));
         $this->db->where('save_template_file', 'y');
         $this->db->where_in('template_id', $create_files);
         $this->db->order_by('group_name, template_name', 'ASC');
         $query = $this->db->get('templates');
         if ($query->num_rows() > 0) {
             foreach ($query->result() as $row) {
                 $tdata = array('site_short_name' => $this->config->item('site_short_name'), 'template_id' => $row->template_id, 'template_group' => $row->group_name, 'template_name' => $row->template_name, 'template_type' => $row->template_type, 'template_data' => $row->template_data, 'edit_date' => $this->localize->now, 'last_author_id' => $this->session->userdata['member_id']);
                 $save_result = $this->update_template_file($tdata);
                 if ($save_result == FALSE) {
                     show_error($this->lang->line('template_not_saved'));
                 }
             }
         }
         //  Annoying.  This would cut down on overhead and eliminate need to include these in the following processing.
         //  UPDATE exp_templates SET edit_date = $this->localize->now WHERE template_id IN ($create_files)
     }
     $this->load->library('api');
     $this->api->instantiate('template_structure');
     $this->load->helper('file');
     $this->db->select(array('group_name', 'templates.group_id', 'template_name', 'template_type', 'template_id', 'edit_date'));
     $this->db->join('template_groups', 'template_groups.group_id = templates.group_id');
     $this->db->where('templates.site_id', $this->config->item('site_id'));
     $this->db->where('save_template_file', 'y');
     $this->db->where_in('template_id', $damned);
     $this->db->order_by('group_name, template_name', 'ASC');
     $query = $this->db->get('templates');
     $existing = array();
     if ($query->num_rows() > 0) {
         foreach ($query->result() as $row) {
             // Skip groups they do not have access to
             if (!$this->_template_access_privs(array('group_id' => $row->group_id))) {
                 continue;
             }
             $existing[$row->group_name . '.group'][$row->template_name . $this->api_template_structure->file_extensions($row->template_type)] = array($row->group_id, $row->template_id, $row->edit_date, $row->template_name, $row->template_type);
         }
     }
     $query->free_result();
     $basepath = $this->config->slash_item('tmpl_file_basepath');
     $basepath .= '/' . $this->config->item('site_short_name');
     $this->load->helper('directory');
     $files = directory_map($basepath, 0, 1);
     $save_revisions = $this->config->item('save_tmpl_revisions');
     $maxrev = $this->config->item('max_tmpl_revisions');
     if ($files !== FALSE) {
         foreach ($files as $group => $templates) {
             if (substr($group, -6) != '.group') {
                 continue;
             }
             $group_name = substr($group, 0, -6);
             // remove .group
             // update existing templates
             foreach ($templates as $template) {
                 if (is_array($template)) {
                     continue;
                 }
                 if (isset($existing[$group][$template])) {
                     $edit_date = $existing[$group][$template]['2'];
                     $file_date = get_file_info($basepath . '/' . $group . '/' . $template);
                     if ($file_date !== FALSE && $file_date['date'] < $edit_date) {
                         continue;
                     }
                     $contents = file_get_contents($basepath . '/' . $group . '/' . $template);
                     if ($contents !== FALSE) {
                         $data = array('group_id' => $existing[$group][$template]['0'], 'template_name' => $existing[$group][$template]['3'], 'template_type' => $existing[$group][$template]['4'], 'template_data' => $contents, 'edit_date' => $this->localize->now, 'save_template_file' => 'y', 'last_author_id' => $this->session->userdata['member_id'], 'site_id' => $this->config->item('site_id'));
                         $this->db->where('template_id', $existing[$group][$template]['1']);
                         $this->db->update('templates', $data);
                         // Revision tracking
                         if ($save_revisions == 'y') {
                             $data = array('item_id' => $existing[$group][$template]['1'], 'item_table' => 'exp_templates', 'item_field' => 'template_data', 'item_data' => $contents, 'item_date' => $this->localize->now, 'item_author_id' => $this->session->userdata['member_id']);
                             $this->db->insert('revision_tracker', $data);
                             // Cull revisions
                             if ($maxrev != '' and is_numeric($maxrev) and $maxrev > 0) {
                                 $this->db->select('tracker_id');
                                 $this->db->where('item_id', $existing[$group][$template]['1']);
                                 $this->db->where('item_table', 'exp_templates');
                                 $this->db->where('item_field', 'template_data');
                                 $this->db->order_by("tracker_id", "desc");
                                 $res = $this->db->get('revision_tracker');
                                 if ($res->num_rows() > 0 and $res->num_rows() > $maxrev) {
                                     $flag = '';
                                     $ct = 1;
                                     foreach ($res->result_array() as $row) {
                                         if ($ct >= $maxrev) {
                                             $flag = $row['tracker_id'];
                                             break;
                                         }
                                         $ct++;
                                     }
                                     if ($flag != '') {
                                         $this->db->where('tracker_id <', $flag);
                                         $this->db->where('item_id', $existing[$group][$template]['1']);
                                         $this->db->where('item_table', 'exp_templates');
                                         $this->db->where('item_field', 'template_data');
                                         $this->db->delete('revision_tracker');
                                     }
                                 }
                             }
                         }
                     }
                     unset($existing[$group][$template]);
                 }
             }
         }
     }
     $this->functions->clear_caching('all');
     $message = $this->lang->line('sync_completed');
     $this->session->set_flashdata('message_success', $message);
     $this->functions->redirect(BASE . AMP . 'C=design' . AMP . 'M=sync_templates');
 }
示例#25
0
 function get_dir_file_info($source_dir, $include_path = FALSE, $_recursion = FALSE)
 {
     static $_filedata = array();
     $relative_path = $source_dir;
     if ($fp = @opendir($source_dir)) {
         // reset the array and make sure $source_dir has a trailing slash on the initial call
         if ($_recursion === FALSE) {
             $_filedata = array();
             $source_dir = rtrim(realpath($source_dir), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
         }
         while (FALSE !== ($file = readdir($fp))) {
             if (@is_dir($source_dir . $file) && strncmp($file, '.', 1) !== 0) {
                 get_dir_file_info($source_dir . $file . DIRECTORY_SEPARATOR, $include_path, TRUE);
             } elseif (strncmp($file, '.', 1) !== 0) {
                 $_filedata[$file] = get_file_info($source_dir . $file);
                 $_filedata[$file]['relative_path'] = $relative_path;
             }
         }
         return $_filedata;
     } else {
         return FALSE;
     }
 }
示例#26
0
 /**
  * Gets File Metadata- may move to db
  *
  * @param	string	$file_path	The full path to the file to check
  * @return	array
  */
 function get_file_sizes($file_path)
 {
     ee()->load->helper('file');
     $filedata = array('height' => '', 'width' => '');
     $filedata['is_image'] = $this->is_viewable_image($file_path);
     if ($filedata['is_image'] && function_exists('getimagesize')) {
         $D = @getimagesize($file_path);
         $filedata['height'] = $D['1'];
         $filedata['width'] = $D['0'];
     }
     $s = get_file_info($file_path, array('size'));
     $filedata['size'] = $s ? $s['size'] : FALSE;
     return $filedata;
 }
示例#27
0
 /**
  * Get Directory File Information
  *
  * Reads the specified directory and builds an array containing the filenames,
  * filesize, dates, and permissions
  *
  * Any sub-folders contained within the specified path are read as well.
  *
  * @param	string	path to source
  * @param	bool	Look only at the top level directory specified?
  * @param	bool	internal variable to determine recursion status - do not use in calls
  * @return	array
  */
 function get_dir_file_info($source_dir, $top_level_only = TRUE, $_recursion = FALSE)
 {
     static $_filedata = array();
     $relative_path = $source_dir;
     if ($fp = @opendir($source_dir)) {
         // reset the array and make sure $source_dir has a trailing slash on the initial call
         if ($_recursion === FALSE) {
             $_filedata = array();
             $source_dir = rtrim(realpath($source_dir), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
         }
         // foreach (scandir($source_dir, 1) as $file) // In addition to being PHP5+, scandir() is simply not as fast
         while (FALSE !== ($file = readdir($fp))) {
             if (@is_dir($source_dir . $file) && $file[0] !== '.' && $top_level_only === FALSE) {
                 get_dir_file_info($source_dir . $file . DIRECTORY_SEPARATOR, $top_level_only, TRUE);
             } elseif ($file[0] !== '.') {
                 $_filedata[$file] = get_file_info($source_dir . $file);
                 $_filedata[$file]['relative_path'] = $relative_path;
             }
         }
         closedir($fp);
         return $_filedata;
     }
     return FALSE;
 }
 /**
  * Returns an array of information about a particular asset file
  *
  * @access	public
  * @param	string	An asset file
  * @return	array
  */
 public function find_by_key($file)
 {
     $file = $this->get_file($file);
     $CI =& get_instance();
     $assets_folder = WEB_ROOT . $CI->config->item('assets_path');
     // normalize file path
     $file = trim(str_replace($assets_folder, '', $file), '/');
     $asset_path = $assets_folder . $file;
     $asset_path = str_replace('/', DIRECTORY_SEPARATOR, $asset_path);
     // for windows
     return get_file_info($asset_path);
 }
示例#29
0
function thumb($imagem = NULL, $width = 100, $height = 75, $geratag = TRUE, $pasta = 'uploads')
{
    $CI =& get_instance();
    $CI->load->helper('file');
    $caminho = './medias/images/' . $pasta . '/thumbs/';
    $thumb = $height . 'x' . $width . '_' . $imagem;
    $thumbinfo = get_file_info($caminho . $thumb);
    if ($thumbinfo != FALSE) {
        $retorno = base_url($caminho . $thumb);
    } else {
        $CI->load->library('image_lib');
        $config['image_library'] = 'gd2';
        $config['source_image'] = './medias/images/' . $pasta . '/' . $imagem;
        $config['new_image'] = $caminho . $thumb;
        $config['maintain_ratio'] = TRUE;
        $config['width'] = $width;
        $config['height'] = $height;
        $CI->image_lib->initialize($config);
        if ($CI->image_lib->resize()) {
            $CI->image_lib->clear();
            $retorno = base_url($caminho . $thumb);
        } else {
            $retorno = FALSE;
        }
    }
    if ($geratag && $retorno != FALSE) {
        $retorno = '<img src="' . $retorno . '" alt="">';
    }
    return $retorno;
}
示例#30
0
 function check_user($user_name)
 {
     $CI =& get_instance();
     /* User validation */
     $ini_file = $CI->config->item('config_path') . "users/" . $user_name . ".ini";
     /* Check if user ini file exists */
     if (!get_file_info($ini_file)) {
         $CI->messages->add('User does not exists.', 'error');
         return FALSE;
     }
     /* Parsing user ini file */
     $user_data = parse_ini_file($ini_file);
     if (!$user_data) {
         $CI->messages->add('Invalid user file.', 'error');
         return FALSE;
     }
     if (!isset($user_data['username'])) {
         $CI->messages->add('Username missing from user file.', 'error');
         return FALSE;
     }
     if (!isset($user_data['password'])) {
         $CI->messages->add('Password missing from user file.', 'error');
         return FALSE;
     }
     if (!isset($user_data['status'])) {
         $CI->messages->add('Status missing from user file.', 'error');
         return FALSE;
     }
     if (!isset($user_data['role'])) {
         $CI->messages->add('Role missing from user file. Defaulting to "guest" role.', 'error');
         $user_data['role'] = 'guest';
     }
     if (!isset($user_data['accounts'])) {
         $CI->messages->add('Accounts missing from user file.', 'error');
     }
     return $user_data;
 }