public function testDeleteLoop()
 {
     $path = $this->path;
     global $delete_file_array;
     delete_loop($path);
     $files = get_recursive_file_list($path);
     $this->assertEquals(sizeof($delete_file_array), sizeof($files));
     $this->assertEquals(array_slice($delete_file_array, 0, 5), array_slice($files, 0, 5));
 }
예제 #2
0
파일: checksum.php 프로젝트: rasomu/chuza
function generate_checksum_file(&$report)
{
    global $gCms;
    $config =& $gCms->GetConfig();
    $output = '';
    $excludes = array('^\\.svn', '^CVS$', '^\\#.*\\#$', '~$', '\\.bak$', '^uploads$', '^tmp$', '^captchas$');
    $tmp = get_recursive_file_list($config['root_path'], $excludes);
    if (count($tmp) <= 1) {
        $report = lang('error_retrieving_file_list');
        return false;
    }
    foreach ($tmp as $file) {
        if (is_dir($file)) {
            continue;
        }
        $md5sum = md5_file($file);
        $file = str_replace($config['root_path'], '', $file);
        $output .= "{$md5sum}--:--{$file}\n";
    }
    $handlers = ob_list_handlers();
    for ($cnt = 0; $cnt < sizeof($handlers); $cnt++) {
        ob_end_clean();
    }
    header('Pragma: public');
    header('Expires: 0');
    header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
    header('Cache-Control: private', false);
    header('Content-Description: File Transfer');
    header('Content-Type: text/plain');
    header("Content-Disposition: attachment; filename=\"checksum.dat\"");
    header('Content-Transfer-Encoding: binary');
    header('Content-Length: ' . strlen($output));
    echo $output;
    exit;
}
예제 #3
0
}
if (!$this->CheckPermission('Modify Files')) {
    exit;
}
$config = $gCms->GetConfig();
$this->smarty->assign('currentpath', $this->Lang("currentpath"));
$this->smarty->assign('path', $path);
$this->smarty->assign('dirformstart', $this->CreateFormStart($id, 'newdir', $returnid));
$this->smarty->assign('hiddenpath', $this->CreateInputHidden($id, "path", $path));
$this->smarty->assign('newdirnametext', $this->Lang("newdirname"));
$this->smarty->assign('newdirnameinput', $this->CreateInputText($id, "newdirname", "", 40, 255));
$this->smarty->assign('dirsubmit', $this->CreateInputSubmit($id, "go", $this->Lang("ok"), "", ""));
$this->smarty->assign('dirformend', $this->CreateFormEnd());
$this->smarty->assign('formstart', $this->CreateFormStart($id, 'filesform', $returnid));
// get the dirs from uploadspath
$filerec = get_recursive_file_list($config['uploads_path'], array(), -1, 'DIRS');
//$dirlist[$this->Lang('selecttargetdir')] = '-';
foreach ($filerec as $key => $value) {
    $value1 = str_replace($config['root_path'], '', $value);
    //prevent current dir from showing up
    if ($value1 == $path . "/") {
        continue;
    }
    //Check for hidden files
    $dirs = explode("/", $value1);
    $hidden = false;
    foreach ($dirs as $dir) {
        if (substr($dir, 0, 1) == ".") {
            $hidden = true;
            break;
        }
예제 #4
0
/**
 * Return an array containing a list of files in a directory
 * performs a recursive search
 *
 * @internal
 * @param  string    Start Path.
 * @param  array     Array of regular expressions indicating files to exclude.
 * @param  int       How deep to browse (-1=unlimited)
 * @param  string    "FULL"|"DIRS"|"FILES"
 * @param  d         for internal use only
 * @return  array
**/
function get_recursive_file_list($path, $excludes, $maxdepth = -1, $mode = "FULL", $d = 0)
{
    if (substr($path, strlen($path) - 1) != '/') {
        $path .= '/';
    }
    $dirlist = array();
    if ($mode != "FILES") {
        $dirlist[] = $path;
    }
    if ($handle = opendir($path)) {
        while (false !== ($file = readdir($handle))) {
            if ($file == '.' || $file == '..') {
                continue;
            }
            if (filespec_is_excluded($file, $excludes)) {
                continue;
            }
            $file = $path . $file;
            if (!@is_dir($file)) {
                if ($mode != "DIRS") {
                    $dirlist[] = $file;
                }
            } elseif ($d >= 0 && ($d < $maxdepth || $maxdepth < 0)) {
                $result = get_recursive_file_list($file . '/', $excludes, $maxdepth, $mode, $d + 1);
                $dirlist = array_merge($dirlist, $result);
            }
        }
        closedir($handle);
    }
    if ($d == 0) {
        natcasesort($dirlist);
    }
    return $dirlist;
}
    @mkdir($xerte_toolkits_site->root_file_path . $xerte_toolkits_site->module_path . "xerte/templates/" . $folder . "/");
    @mkdir($xerte_toolkits_site->root_file_path . $xerte_toolkits_site->module_path . "xerte/templates/" . $folder . "/media/");
    @chmod($xerte_toolkits_site->root_file_path . $xerte_toolkits_site->module_path . "xerte/parent_templates/" . $folder . "/", 0777);
    @chmod($xerte_toolkits_site->root_file_path . $xerte_toolkits_site->module_path . "xerte/parent_templates/" . $folder . "/common/", 0777);
    @chmod($xerte_toolkits_site->root_file_path . $xerte_toolkits_site->module_path . "xerte/parent_templates/" . $folder . "/thumbs/", 0777);
    @chmod($xerte_toolkits_site->root_file_path . $xerte_toolkits_site->module_path . "xerte/parent_templates/" . $folder . "/models/", 0777);
    @chmod($xerte_toolkits_site->root_file_path . $xerte_toolkits_site->module_path . "xerte/templates/" . $folder . "/", 0777);
    @chmod($xerte_toolkits_site->root_file_path . $xerte_toolkits_site->module_path . "xerte/templates/" . $folder . "/media/", 0777);
    @chmod($xerte_toolkits_site->root_file_path . $xerte_toolkits_site->module_path . "xerte/parent_templates/", $parent);
    @chmod($xerte_toolkits_site->root_file_path . $xerte_toolkits_site->module_path . "xerte/templates/", $templates);
}
$xerte_module_path = $xerte_toolkits_site->root_file_path . DIRECTORY_SEPARATOR . $xerte_toolkits_site->module_path;
foreach (array('media', 'thumbs', 'common', 'models') as $toplevel) {
    // Get all files in the temp (exploded zip's) import $toplevel dir.
    $toplevel_src_path = $temp_dir . DIRECTORY_SEPARATOR . $folder . DIRECTORY_SEPARATOR . $toplevel;
    $files_to_move = get_recursive_file_list($toplevel_src_path);
    // Move them to the xerte/templates/$folder/$toplevel dir.
    $destination = $xerte_module_path . "xerte/templates/" . $folder . "/{$toplevel}/";
    // 'media' is the odd one out in going to parent_templates, the rest just go to templates.
    if ($toplevel == "media") {
        $destination = $xerte_module_path . "xerte/parent_templates/" . $folder . "/{$toplevel}/";
    }
    foreach ($files_to_move as $file) {
        @rename($file, $destination . $file);
    }
    // Now remove all the (media|thumbs|common|models) files.
    recursive_delete($toplevel_src_path, true);
}
$template_src = $temp_dir . DIRECTORY_SEPARATOR . $folder . DIRECTORY_SEPARATOR;
rename($template_src . "template.rlt", $xerte_module_path . "xerte/parent_templates/" . $folder . "/" . $folder . ".rlt");
rename($template_src . "template.xml", $xerte_module_path . "xerte/templates/" . $folder . "/data.xml");
 /**
  * Creates an xml data package from the module directory.
  *
  * @param mixed $modinstance The instance of the module object
  * @param string $message Reference to a string which will be filled with the message 
  *                        created by the run of the method
  * @param integer $filecount Reference to an interger which will be filled with the 
  *                           total # of files in the package
  * @return string an XML string comprising the module and its files
  */
 function CreateXMLPackage(&$modinstance, &$message, &$filecount)
 {
     // get a file list
     $filecount = 0;
     $dir = dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . "modules" . DIRECTORY_SEPARATOR . $modinstance->GetName();
     $files = get_recursive_file_list($dir, $this->xml_exclude_files);
     $xmltxt = '<?xml version="1.0" encoding="ISO-8859-1"?>';
     $xmltxt .= $this->xmldtd . "\n";
     $xmltxt .= "<module>\n";
     $xmltxt .= "\t<dtdversion>" . MODULE_DTD_VERSION . "</dtdversion>\n";
     $xmltxt .= "\t<name>" . $modinstance->GetName() . "</name>\n";
     $xmltxt .= "\t<version>" . $modinstance->GetVersion() . "</version>\n";
     $xmltxt .= "  <mincmsversion>" . $modinstance->MinimumCMSVersion() . "</mincmsversion>\n";
     $xmltxt .= "\t<help><![CDATA[" . base64_encode($modinstance->GetHelpPage()) . "]]></help>\n";
     $xmltxt .= "\t<about><![CDATA[" . base64_encode($modinstance->GetAbout()) . "]]></about>\n";
     $desc = $modinstance->GetAdminDescription();
     if ($desc != '') {
         $xmltxt .= "\t<description><![CDATA[" . $desc . "]]></description>\n";
     }
     $depends = $modinstance->GetDependencies();
     foreach ($depends as $key => $val) {
         $xmltxt .= "\t<requires>\n";
         $xmltxt .= "\t  <requiredname>{$key}</requiredname>\n";
         $xmltxt .= "\t  <requiredversion>{$val}</requiredversion>\n";
         $xmltxt .= "\t</requires>\n";
     }
     foreach ($files as $file) {
         // strip off the beginning
         if (substr($file, 0, strlen($dir)) == $dir) {
             $file = substr($file, strlen($dir));
         }
         if ($file == '') {
             continue;
         }
         $xmltxt .= "\t<file>\n";
         $filespec = $dir . DIRECTORY_SEPARATOR . $file;
         $xmltxt .= "\t  <filename>{$file}</filename>\n";
         if (@is_dir($filespec)) {
             $xmltxt .= "\t  <isdir>1</isdir>\n";
         } else {
             $xmltxt .= "\t  <isdir>0</isdir>\n";
             $data = base64_encode(file_get_contents($filespec));
             $xmltxt .= "\t  <data><![CDATA[" . $data . "]]></data>\n";
         }
         $xmltxt .= "\t</file>\n";
         ++$filecount;
     }
     $xmltxt .= "</module>\n";
     $message = 'XML package of ' . strlen($xmltxt) . ' bytes created for ' . $modinstance->GetName();
     $message .= ' including ' . $filecount . ' files';
     return $xmltxt;
 }
예제 #7
0
/**
 * 
 * Function copy loop
 * This function checks http security settings
 * @param string path = the path we are copying
 * @version 1.0
 * @author Patrick Lockley
 */
function copy_loop($path)
{
    global $copy_file_array;
    $copy_file_array = get_recursive_file_list($path);
    return $copy_file_array;
}