function getDirectoryTree($outerDir, $basepath)
{
    $dirs = array_diff(scandir($outerDir), array(".", ".."));
    $dir_array = array();
    foreach ($dirs as $d) {
        $dir_array[] = is_dir($outerDir . "/" . $d) ? getDirectoryTree($outerDir . "/" . $d, $filters) : ($dir_array[] = $basepath . $d);
    }
    return $dir_array;
}
예제 #2
0
function getDirectoryTree($outerDir, $depth)
{
    global $result_dirs;
    global $refd_dirs;
    global $pos_dirs;
    global $pattern;
    global $no_pattern;
    $dirs = array_diff(scandir($outerDir), array(".", ".."));
    foreach ($dirs as $d) {
        if (substr($d, -1) != "~") {
            $id = "{$outerDir}/{$d}";
            if (is_dir($id)) {
                $b64od = $depth == 0 ? "#" : base64_encode($outerDir);
                $refd_dirs[$b64od] = 1;
                $b64d = base64_encode($id);
                $pos_dirs[$b64d] = count($result_dirs);
                array_push($result_dirs, array("id" => $b64d, "parent" => $b64od, "text" => "<b>{$d}</b>"));
                getDirectoryTree($id, $depth + 1);
            } else {
                if ($no_pattern || preg_match($pattern, $d)) {
                    $stat = stat($outerDir . "/" . $d);
                    $sz = $stat['size'];
                    $sx = 'b';
                    if ($sz > 1024) {
                        $sz /= 1024;
                        $sx = "Kb";
                        if ($sz > 1024) {
                            $sz /= 1024;
                            $sx = "Mb";
                            if ($sz >= 1024) {
                                $sz /= 1024;
                                $sx = "Gb";
                                if ($sz >= 1024) {
                                    $sz /= 1024;
                                    $sx = "Tb";
                                    if ($sz >= 1024) {
                                        $sz /= 1024;
                                        $sx = "Pb";
                                    }
                                }
                            }
                        }
                        $sz = round($sz, 2);
                    }
                    $ss = "<b>{$d}</b> | <i>{$sz}{$sx}</i> | " . date("Y M d H:i:s T", $stat['mtime']) . " ";
                    $b64od = $depth == 0 ? "#" : base64_encode($outerDir);
                    $refd_dirs[$b64od] = 1;
                    array_push($result_dirs, array("id" => base64_encode($id), "parent" => $b64od, "text" => $ss));
                }
            }
        }
    }
}
예제 #3
0
function getDirectoryTree($outerDir, &$files = array())
{
    $dirs = array_diff(scandir($outerDir), array(".", ".."));
    foreach ($dirs as $d) {
        if (is_dir($outerDir . "/" . $d)) {
            getDirectoryTree($outerDir . '/' . $d, $files);
        } else {
            if (preg_match('/^[\\d]+.rrd$/', $d)) {
                array_push($files, preg_replace('/\\/+/', '/', $outerDir . '/' . $d));
            }
        }
    }
    return $files;
}
예제 #4
0
 private final function load_modules()
 {
     $module_directories = getDirectoryTree($this->path);
     foreach ($module_directories as $module_name) {
         $module_path = $this->path . '/' . $module_name . '/class.deployment_' . $module_name . '.php';
         if (file_exists($module_path)) {
             require_once $module_path;
             // Load module
             $this->modules[$module_name] = new $module_name();
             if (is_subclass_of($this->modules[$module_name], 'NConf_Deployment_Modules')) {
                 NConf_DEBUG::set("{$module_name} loaded", 'DEBUG', 'Module');
                 $this->modules[$module_name]->name = $module_name;
             } else {
                 NConf_DEBUG::set("{$module_name} FAILED", 'ERROR', 'Module');
                 echo "<br>Failed loading modul {$module_name}";
             }
         }
     }
 }
예제 #5
0
<?php

#
# load and configure modules
#
$modules_dir = getDirectoryTree('include/modules');
foreach ($modules_dir as $module) {
    $module_config = 'include/modules/' . $module . '/init.php';
    if (file_exists($module_config)) {
        require_once $module_config;
        message($debug, "Initialized module: {$module_config}");
    } else {
        message($error, "FAILED to initialize module: {$module_config}");
    }
}
예제 #6
0
파일: source.php 프로젝트: aikianapa/aiki
function getDirectoryTree($outerDir, $x, $exclude = array())
{
    $dirs = array_diff(scandir($outerDir), array(".", ".."));
    $dir_array = array();
    foreach ($dirs as $d) {
        if (!in_array($d, $exclude)) {
            if (is_dir($outerDir . "/" . $d)) {
                $dir_array[$d] = getDirectoryTree($outerDir . "/" . $d, $x);
            } else {
                preg_match("/{$x}/", $d, $tmp);
                if (isset($tmp[0])) {
                    $dir_array[$d] = $d;
                }
            }
        }
    }
    return $dir_array;
}
function SyncMultipleImages($ShowMessages, $LastTimeRun, $db, $db_oc, $oc_tableprefix, $EmailText = '')
{
    if ($EmailText != '') {
        $EmailText = $EmailText . "Sync Multiple Images" . "\n" . PrintTimeInformation($db);
    }
    if ($ShowMessages) {
        echo '<p class="page_title_text" align="center"><strong>' . _('Synchronize multiple images per item') . '</strong></p>';
        echo '<div>';
        echo '<table class="selection">';
        $TableHeader = '<tr>
							<th>' . _('webERP Code') . '</th>
							<th>' . _('File') . '</th>
						</tr>';
        echo $TableHeader;
    }
    $SQLTruncate = "TRUNCATE " . $oc_tableprefix . "product_image";
    $resultSQLTruncate = DB_query_oc($SQLTruncate);
    $k = 0;
    //row colour counter
    $i = 0;
    // get all images in part_pics folder (ideally should be OpenCart images folder...)
    $imagefiles = getDirectoryTree($_SESSION['part_pics_dir'], 'jpg');
    foreach ($imagefiles as $file) {
        $multipleimage = 1;
        $exist_multiple = TRUE;
        while ($multipleimage <= 5) {
            $suffix = "." . $multipleimage;
            if (strpos($file, $suffix) > 0) {
                // GET stockid from filename
                $StockId = substr($file, 0, strpos($file, $suffix));
                // get Opencart productid
                $ProductId = GetOpenCartProductId($StockId, $db_oc, $oc_tableprefix);
                if ($ProductId > 0) {
                    // insert info about multiple images
                    $sqlInsert = "INSERT INTO " . $oc_tableprefix . "product_image\r\n\t\t\t\t\t\t\t\t\t(product_id,\r\n\t\t\t\t\t\t\t\t\timage,\r\n\t\t\t\t\t\t\t\t\tsort_order)\r\n\t\t\t\t\t\t\t\tVALUES\r\n\t\t\t\t\t\t\t\t\t('" . $ProductId . "',\r\n\t\t\t\t\t\t\t\t\t'" . PATH_OPENCART_IMAGES . $file . "',\r\n\t\t\t\t\t\t\t\t\t'" . $multipleimage . "')";
                    $resultInsert = DB_query_oc($sqlInsert, $InsertErrMsg, $DbgMsg, true);
                    if ($ShowMessages) {
                        $k = StartEvenOrOddRow($k);
                        printf('<td>%s</td>
								<td>%s</td>
								</tr>', $StockId, $file);
                    }
                    $i++;
                }
            }
            $multipleimage++;
        }
    }
    if ($ShowMessages) {
        echo '</table>
				</div>
				</form>';
        prnMsg(locale_number_format($i, 0) . ' ' . _('Multiple Images Synchronized'), 'success');
    }
    if ($EmailText != '') {
        $EmailText = $EmailText . locale_number_format($i, 0) . ' ' . _('Multiple Images Synchronized') . "\n\n";
    }
    return $EmailText;
}