function GetList() { $arFiles = array(); $vf = new CFileCheckerLog(); if ($handle = @opendir($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules")) { while (($file = readdir($handle)) !== false) { if ($file == "." || $file == "..") { continue; } if (!Is_File($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/" . $file)) { continue; } if (SubStr($file, 0, StrLen("serverfilelog-")) != "serverfilelog-") { continue; } if (SubStr($file, -4) != ".dat") { continue; } if (SubStr($file, -8) === "_tmp.dat") { continue; } $ts = SubStr($file, StrLen("serverfilelog-")); $ts = SubStr($ts, 0, -4); if (IntVal($ts) <= 0) { continue; } $vf->__GetDescriptionList($ts); if ($vf->GetDescriptionTs() > 0) { $arFiles[] = array("TIMESTAMP_X" => $vf->GetDescriptionTs(), "REGION" => $vf->GetDescriptionRegion(), "EXTENTIONS" => $vf->GetDescriptionCollectedExtensions(), "LOG" => "", "FILE" => $file); } } closedir($handle); } return $arFiles; }
function Load_TextDomain() { $this->text_domain = get_class($this); $lang_file = DirName(__FILE__) . '/donate_' . get_locale() . '.mo'; if (Is_File($lang_file)) { load_textdomain($this->text_domain, $lang_file); } }
function get_files($directory) { $arr_file = (array) Glob($directory . '{,.}*', GLOB_BRACE); $sort_order = array(); foreach ($arr_file as $index => $file) { $path = RealPath($file); if (!Is_File($path)) { unset($arr_file[$index]); } else { $arr_file[$index] = $path; $sort_order[$index] = StrToLower($file); } } Array_Multisort($sort_order, $arr_file); return $arr_file; }
static function addOptionBox($title, $include_file, $column = 'main', $state = 'opened') { # Check the input if (!Is_File($include_file)) { return False; } if (empty($title)) { $title = ' '; } # Column (can be 'side' or 'main') if ($column != '' && $column != Null && $column != 'main') { $column = 'side'; } else { $column = 'main'; } # State (can be 'opened' or 'closed') if ($state != '' && $state != Null && $state != 'opened') { $state = 'closed'; } else { $state = 'opened'; } # Add a new box self::$arr_option_box[$column][] = (object) array('title' => $title, 'file' => $include_file, 'state' => $state); }
function getTree($source, $recursive = 0, $mask = '') { $res = array(); $orig_mask = $mask; if (!$mask) { $mask = '*'; } $mask = preg_quote($mask); $mask = str_replace('\\*', '.*?', $mask); $mask = '^' . $mask . '$'; if (!Is_Dir($source)) { return 0; // incorrect source path } if ($dir = @opendir($source)) { while (($file = readdir($dir)) !== false) { if (Is_Dir($source . "/" . $file) && $file != '.' && $file != '..' && $recursive) { $res2 = $this->getTree($source . "/" . $file, $recursive, $orig_mask); foreach ($res2 as $k => $v) { $res[$k] = $v; } } elseif (Is_File($source . "/" . $file) && preg_match('/' . $mask . '/', $file)) { $res[$source . "/" . $file] = array('FILENAME' => $file, 'SIZE' => filesize($source . "/" . $file), 'MTIME' => filemtime($source . "/" . $file)); } } closedir($dir); } return $res; }
function getFilesTree($destination, $sort = 'name') { if (substr($destination, -1) == '/' || substr($destination, -1) == '\\') { $destination = substr($destination, 0, strlen($destination) - 1); } $res = array(); if (!Is_Dir($destination)) { return $res; } if ($dir = @opendir($destination)) { while (($file = readdir($dir)) !== false) { if (Is_Dir($destination . "/" . $file) && $file != '.' && $file != '..') { $tmp = getFilesTree($destination . "/" . $file); if (is_array($tmp)) { foreach ($tmp as $elem) { $res[] = $elem; } } } elseif (Is_File($destination . "/" . $file)) { $res[] = $destination . "/" . $file; } } closedir($dir); } if ($sort == 'name') { sort($res, SORT_STRING); } return $res; }
<?php /* Plugin Name: Fancy Gallery Description: Will bring your galleries as valid XHTML blocks on screen and associate linked images with Fancybox. Plugin URI: http://dennishoppe.de/wordpress-plugins/fancy-gallery Version: 1.3.8 Author: Dennis Hoppe Author URI: http://DennisHoppe.de */ // Please think about a donation if (Is_File(DirName(__FILE__) . '/donate.php')) { include DirName(__FILE__) . '/donate.php'; } if (!Class_Exists('wp_plugin_fancy_gallery')) { class wp_plugin_fancy_gallery { var $base_url; var $text_domain; function __construct() { // Read base $this->base_url = get_bloginfo('wpurl') . '/' . Str_Replace("\\", '/', SubStr(RealPath(DirName(__FILE__)), Strlen(ABSPATH))); // Get ready to translate $this->Load_TextDomain(); // Set Hooks if (Is_Admin()) { Add_Action('admin_menu', array($this, 'add_options_page')); Add_Action('admin_head', array($this, 'print_admin_header')); } else { Add_Action('wp_head', array($this, 'print_header'));
function copyTree($source, $destination, $over=0) { $res=1; if (!Is_Dir($source)) { return 0; // incorrect source path } if (!Is_Dir($destination)) { if (!mkdir($destination, 0777)) { return 0; // cannot create destination path } } if ($dir = @opendir($source)) { while (($file = readdir($dir)) !== false) { if (Is_Dir($source."/".$file) && ($file!='.') && ($file!='..')) { $res=copyTree($source."/".$file, $destination."/".$file, $over); } elseif (Is_File($source."/".$file) && (!file_exists($destination."/".$file) || $over)) { $res=copy($source."/".$file, $destination."/".$file); } } closedir($dir); } return $res; }
function Print_Gallery_Meta_Box($post, $box) { $include_file = $this->arr_meta_box[$box['args']]['include_file']; if (Is_File($include_file)) { include $include_file; } }
/** * FrontEnd * * Module frontend * * @access public */ function usual(&$out) { $terminals=SQLSelect("SELECT * FROM terminals WHERE CANPLAY=1 ORDER BY TITLE"); $total=count($terminals); for($i=0;$i<$total;$i++) { //if ($terminals[$i]['NAME']==$session->data['PLAY_TERMINAL']) { // $terminals[$i]['SELECTED']=1; // $out['TERMINAL_TITLE']=$terminals[$i]['TITLE']; //} } $out['TERMINALS']=$terminals; $out['TERMINALS_TOTAL']=count($terminals); if ($this->mode=='play') { //echo $this->owner->popup; global $showplayer; $this->showplayer=1; if ($this->showplayer) { $showplayer=1; } if ($showplayer) { $this->showplayer=1; $out['SHOWPLAYER']=1; } global $terminal_id; $out['TERMINAL_ID']=$terminal_id; } global $collection_id; if ($this->collection_id) { $collection_id=$this->collection_id; } $this->collection_id=$collection_id; $out['COLLECTIONS']=SQLSelect("SELECT * FROM collections ORDER BY TITLE"); if (count($out['COLLECTIONS'])==1) { $collection_id=$out['COLLECTIONS'][0]['ID']; $this->collection_id=$collection_id; $out['COLLECTIONS_TOTAL']=1; } if ($collection_id) { $collection=SQLSelectOne("SELECT * FROM collections WHERE ID='".(int)$collection_id."'"); $path=($collection['PATH']);//addslashes $out['COLLECTION_ID']=$collection['ID']; } else { return; } //$this->getConfig(); //$path=$this->config['PATH']; // echo $path; // global $folder; if ($this->folder) { $folder=base64_decode($this->folder); } else { $this->folder=base64_encode($folder); } $favorites=SQLSelect("SELECT * FROM media_favorites WHERE 1 ORDER BY ID DESC"); if ($favorites) { $total=count($favorites); for($i=0;$i<$total;$i++) { $favorites[$i]['PATH']=urlencode(utf2win($favorites[$i]['PATH'])); } $out['FAVORITES']=$favorites; } $folder=str_replace('././', './', $folder); $path=str_replace('././', './', $path); $act_dir=$path.$folder; $out['MEDIA_PATH']=win2utf($path); $out['CURRENT_DIR']=win2utf('./'.$folder); $out['CURRENT_DIR']=str_replace('././', './', $out['CURRENT_DIR']); $out['CURRENT_DIR_TITLE']=$folder; $tmp=explode('/', $out['CURRENT_DIR']); $total=count($tmp); if ($total>0) { $spath='.'; for($i=0;$i<$total;$i++) { $tmp_rec=array(); $tmp_rec['TITLE']=$tmp[$i]; $spath.='/'.$tmp_rec['TITLE']; $spath=str_replace('././', './', $spath); $tmp_rec['PATH']=urlencode(utf2win($spath).'/'); if ($tmp_rec['TITLE']=='.') { $tmp_rec['TITLE']='Home'; } $out['HISTORY'][]=$tmp_rec; //echo $tmp_rec['PATH']."<br>"; } $out['CURRENT_DIR_TITLE']=($out['HISTORY'][$total-3]['TITLE'].'/'.$out['HISTORY'][$total-2]['TITLE']); } $out['CURRENT_DIR_TITLE_HTML']=urlencode($out['CURRENT_DIR_TITLE']); $out['CURRENT_DIR_HTML']=urlencode('./'.($folder)); $tmp=SQLSelectOne("SELECT ID FROM media_favorites WHERE LIST_ID='".(int)$list_id."' AND COLLECTION_ID='".$collection['ID']."' AND PATH LIKE '".DBSafe($out['CURRENT_DIR'])."'"); if ($tmp['ID']) { $out['FAVORITE']=1; } global $file; if ($file) { $out['FILE']=win2utf($file); $out['BASEFILE']=win2utf(basename($file)); $file=str_replace('/', '\\\\', $file); $out['FULLFILE']=win2utf(addslashes($path).$file); $out['FULLFILE_S']=str_replace('\\\\', '\\', $out['FULLFILE']); } if (preg_match('/foto/is', $act_dir) || preg_match('/photo/is', $act_dir)) { $out['LIST_MODE']='foto'; } $descriptions=$this->getDescriptions($act_dir); global $media_ajax; if ($media_ajax) { global $op; global $list_id; global $title; global $dir; header ("HTTP/1.0: 200 OK\n"); header ('Content-Type: text/html; charset=utf-8'); $tmp_path=$dir; if ($op=='favorite_add') { $rec=array(); $rec['TITLE']=$title; $rec['PATH']=$tmp_path; $rec['LIST_ID']=(int)$list_id; $rec['COLLECTION_ID']=$collection_id; SQLInsert('media_favorites', $rec); echo "OK"; } if ($op=='favorite_remove') { SQLExec("DELETE FROM media_favorites WHERE LIST_ID='".(int)$list_id."' AND COLLECTION_ID='".$collection['ID']."' AND PATH LIKE '".DBSafe($tmp_path)."'"); echo "OK"; } exit; } function sort_files($a, $b) { return strcmp(strtoupper($a["TITLE"]), strtoupper($b["TITLE"])); } $dirs=array(); //$act_dir='\\\\home\\media\\'; //echo $act_dir; $d=openDir($act_dir); //exit; if ($d) { while ($file=readDir($d)) { if (($file==".") || ($file=="..")) { continue; } if (Is_Dir($act_dir.$file)) { $rec=array(); $rec['TITLE']=$file; $rec['TITLE_SHORT']=$rec['TITLE']; if (strlen($rec['TITLE_SHORT'])>50) { $rec['TITLE_SHORT']=substr($rec['TITLE_SHORT'], 0, 50).'...'; } $rec['TITLE']=win2utf($rec['TITLE']); $rec['TITLE_SHORT']=win2utf($rec['TITLE_SHORT']); if (IsSet($descriptions[$file])) { $rec['DESCR']=$descriptions[$file]; } $rec['PATH']=urlencode(($folder.$file)).'/'; $rec['REAL_PATH']=$dir.$file; $rec['ID']=md5($rec['REAL_PATH']); $dirs[]=$rec; } } closeDir($d); } //$dirs=mysort_array($dirs, "TITLE"); usort($dirs, 'sort_files'); //print_r($dirs); if (count($dirs)>0) $out['DIRS']=$dirs; @$d=openDir($act_dir); if ($d) { $cover=$this->getCover($act_dir); if ($cover) { $out['COVER']=$cover; $out['COVER_PATH']=urlencode(str_replace('\\\\', '\\', $act_dir).$cover); } $files=array(); while ($file=readDir($d)) { if (($file==".") || ($file=="..") || ($file=="Descript.ion")) { continue; } if (Is_File($act_dir.$file)) { $rec=array(); $rec['TITLE']=$file; if (IsSet($descriptions[$file])) { $rec['DESCR']=$descriptions[$file]; } if (strlen($rec['TITLE'])>50) { $rec['TITLE_SHORT']=substr($rec['TITLE'], 0, 50)."..."; } else { $rec['TITLE_SHORT']=$rec['TITLE']; } $rec['TITLE']=win2utf($rec['TITLE']); $rec['TITLE_SHORT']=win2utf($rec['TITLE_SHORT']); $rec['REAL_PATH']=($folder.$file); $rec['PATH']=urlencode($folder.$file); $rec['FULL_PATH']=urlencode(str_replace('\\\\', '\\', $act_dir).$file); $size=filesize($act_dir.$file); $total_size+=$size; if ($size>1024) { if ($size>1024*1024) { $size=(((int)(($size/1024/1024)*10))/10)." Mb"; } else { $size=(int)($size/1024)." Kb"; } } else { $size.=" b"; } $rec['SIZE']=$size; $rec['ID']=md5($rec['PATH']); $files[]=$rec; } } closeDir($d); } //$files=mysort_array($files, "TITLE"); usort($files, 'sort_files'); if (count($files)>0) { $total=count($files); $out['TOTAL_FILES']=$total; for($i=0;$i<$total;$i++) { if (preg_match('/\.jpg$/is', $files[$i]['PATH'])) { $files[$i]['IS_FOTO']=1; } if (($i+1)%4==0) { $files[$i]['NEWROW']=1; } } $out['FILES']=$files; } $out['TOTAL_DIRS']=count($dirs); if ($total_size>1024) { if ($total_size>1024*1024) { $total_size=(((int)(($total_size/1024/1024)*10))/10)." Mb"; } else { $total_size=(int)($total_size/1024)." Kb"; } } else { $total_size.=" b"; } $out['TOTAL_SIZE']=$total_size; }
/** * removeTree * * remove directory tree * * @access public */ function removeTree($destination) { $res = 1; if (!Is_Dir($destination)) { return 0; // cannot create destination path } if ($dir = @opendir($destination)) { while (($file = readdir($dir)) !== false) { if (Is_Dir($destination . "/" . $file) && $file != '.' && $file != '..') { $res = $this->removeTree($destination . "/" . $file); } elseif (Is_File($destination . "/" . $file)) { $res = unlink($destination . "/" . $file); } } closedir($dir); $res = rmdir($destination); } return $res; }
function files($parameters="") { global $REQUEST_URI; global $out; global $mode; $dir=str_replace('\\\'', "'", $_SERVER['REQUEST_URI']); $dir=preg_replace("/^\/.*?\//", "./", $dir); $dir=preg_replace("/\?.*?$/", "", $dir); $dir=urldecode($dir); //echo utf2win($dir); //exit; $paths=split("/", $dir); $old=""; $history=array(); foreach($paths as $v) { if ($v=="") continue; if ($v==".") continue; $rec=array(); $rec['TITLE']=$v; $rec['PATH']=$old."$v/"; $old.="$v/"; $history[]=$rec; } $out['HISTORY']=$history; $out['CURRENT_DIR_TITLE']=($dir); $out['CURRENT_DIR']=urlencode($dir); $act_dir=INIT_DIR."$dir"; if (@$mode=="descr") { global $file; global $new_descr; global $REMOTE_ADDR; global $can_edit; if (strpos($can_edit, $REMOTE_ADDR)>0) setDescription($act_dir, $file, $new_descr); $mode=""; header("Location:?\n\n"); exit; } $descriptions=getDescriptions($act_dir); $d=openDir($act_dir); $dirs=array(); while ($file=readDir($d)) { if (($file==".") || ($file=="..")) { continue; } if (Is_Dir($act_dir.$file)) { $rec=array(); $rec['TITLE']=$file; $rec['TITLE_SHORT']=$rec['TITLE']; if (strlen($rec['TITLE_SHORT'])>30) { $rec['TITLE_SHORT']=substr($rec['TITLE_SHORT'], 0, 30).'...'; } if (IsSet($descriptions[$file])) { $rec['DESCR']=$descriptions[$file]; } $rec['PATH']=urlencode("$file").'/'; $rec['REAL_PATH']=$dir.$file; $dirs[]=$rec; } } closeDir($d); $dirs=mysort_array($dirs, "TITLE"); if (count($dirs)>0) $out['DIRS']=$dirs; $d=openDir($act_dir); $files=array(); while ($file=readDir($d)) { if (($file==".") || ($file=="..") || ($file=="Descript.ion")) { continue; } if (Is_File($act_dir.$file)) { $rec=array(); $rec['TITLE']=$file; if (IsSet($descriptions[$file])) { $rec['DESCR']=$descriptions[$file]; } if (strlen($rec['TITLE'])>30) { $rec['TITLE_SHORT']=substr($rec['TITLE'], 0, 30)."..."; } else { $rec['TITLE_SHORT']=$rec['TITLE']; } $rec['PATH']="$file"; $size=filesize($act_dir.$file); $total_size+=$size; if ($size>1024) { if ($size>1024*1024) { $size=(((int)(($size/1024/1024)*10))/10)." Mb"; } else { $size=(int)($size/1024)." Kb"; } } else { $size.=" b"; } $rec['SIZE']=$size; $files[]=$rec; } } closeDir($d); $files=mysort_array($files, "TITLE"); if (count($files)>0) $out['FILES']=$files; $out['TOTAL_FILES']=count($files); $out['TOTAL_DIRS']=count($dirs); if ($total_size>1024) { if ($total_size>1024*1024) { $total_size=(((int)(($total_size/1024/1024)*10))/10)." Mb"; } else { $total_size=(int)($total_size/1024)." Kb"; } } else { $total_size.=" b"; } $out['TOTAL_SIZE']=$total_size; }
public function Render_Gallery($template_file) { # Uses template filter $template_file = Apply_Filters('fancy_gallery_template', $template_file); # If there is no valid template file we bail out if (!Is_File($template_file)) { $template_file = $this->Get_Default_Template(); } # Load template Ob_Start(); include $template_file; $code = Ob_Get_Clean(); # Strip Whitespaces $code = PReg_Replace('/\\s+/', ' ', $code); $code = Str_Replace('> <', '><', $code); $code = Trim($code); # Return return $code; }
function IO_Files($Path, &$Result = array()) { /******************************************************************************/ $__args_types = array('string', 'array'); #------------------------------------------------------------------------------- $__args__ = Func_Get_Args(); eval(FUNCTION_INIT); /******************************************************************************/ $Files = IO_Scan($Path); if (Is_Error($Files)) { return ERROR | @Trigger_Error('[IO_Files]: не удалось получить содержимое папки'); } #------------------------------------------------------------------------------- foreach ($Files as $File) { #------------------------------------------------------------------------------- $File = SPrintF('%s/%s', $Path, $File); #------------------------------------------------------------------------------- if (Is_Dir($File)) { #------------------------------------------------------------------------------- if (Is_Error(IO_Files($File, $Result))) { return ERROR | @Trigger_Error('[IO_Files]: не удалось осуществить рекурсивный вызов'); } #------------------------------------------------------------------------------- } else { #------------------------------------------------------------------------------- if (Is_File($File)) { $Result[] = $File; } #------------------------------------------------------------------------------- } #------------------------------------------------------------------------------- } #------------------------------------------------------------------------------- return $Result; #------------------------------------------------------------------------------- }
/** * Lit le fichier passé en paramètre et retourne son contenu * * @param string $file le chemin d'accès complet au fichier (inclu le nom du fichier) * @access private * @return string $date le contenu du fichier * @exception bool false * @since 1.0 */ function getFile($file) { if (!Is_File($file)) { return false; } $fp = @fopen($file, 'r'); $data = @fread($fp, filesize($file)); @fclose($fp); return $data; }
public function Add_Option_Box($title, $include_file, $column = 'main', $state = 'opened') { # Check the input if (!Is_File($include_file)) { return False; } if ($title == '') { $title = ' '; } # Column (can be 'side' or 'main') if ($column != '' && $column != Null && $column != 'main') { $column = 'side'; } else { $column = 'main'; } # State (can be 'opened' or 'closed') if ($state != '' && $state != Null && $state != 'opened') { $state = 'closed'; } else { $state = 'opened'; } # Add a new box $this->arr_option_box[$column][] = array('title' => $title, 'file' => $include_file, 'state' => $state); }
<?php // Send Header Mime type Header('Content-Type: text/javascript'); // Load WordPress $wp_load = 'wp-load.php'; while (!Is_File('wp-load.php')) { if (Is_Dir('../')) { ChDir('../'); } else { die('Could not find WordPress.'); } } include_once 'wp-load.php'; // Is the class ready? if (!Class_exists('wp_plugin_fancy_gallery')) { die('Could not find the Fancy Gallery Plugin.'); } /* * I use an anonymous function because we are in the global NameSpace. * You can access the "Load_Setting" function of the the plugin class via: * * $setting = $load_setting($key, $default) * */ $load_setting = Create_Function('$key, $default = False', 'return call_user_func(Array(\'wp_plugin_fancy_gallery\', \'load_setting\'), $key, $default);'); // Set image extensions $arr_type = array('jpg', 'jpeg', 'png', 'gif', 'bmp', 'wbmp', 'ico'); ?> jQuery(function(){
function copyFiles($source, $destination, $over = 0, $patterns = 0) { $res = 1; if (!Is_Dir($source)) { return 0; // cannot create destination path } if (!Is_Dir($destination)) { if (!mkdir($destination)) { return 0; // cannot create destination path } } if ($dir = @opendir($source)) { while (($file = readdir($dir)) !== false) { if (Is_Dir($source . "/" . $file) && $file != '.' && $file != '..') { //$res=$this->copyTree($source."/".$file, $destination."/".$file, $over, $patterns); } elseif (Is_File($source . "/" . $file) && (!file_exists($destination . "/" . $file) || $over)) { if (!is_array($patterns)) { $ok_to_copy = 1; } else { $ok_to_copy = 0; $total = count($patterns); for ($i = 0; $i < $total; $i++) { if (preg_match('/' . $patterns[$i] . '/is', $file)) { $ok_to_copy = 1; } } } if ($ok_to_copy) { $res = copy($source . "/" . $file, $destination . "/" . $file); } } } closedir($dir); } return $res; }
function prepare_cache_file() { // Prepare Cache file if (!Is_Dir($this->cache_dir_path) && !Is_File($this->cache_dir_path) && Is_Writable(DirName($this->cache_dir_path))) { MkDir($this->cache_dir_path); ChMod($this->cache_dir_path, 0755); } if (Is_Dir($this->cache_dir_path) && Is_Writable($this->cache_dir_path)) { Touch($this->cache_file_path); } }