示例#1
0
文件: step4.php 项目: NejcZdovc/sumo2
function copyFiles($src, $dst)
{
    $dir = opendir($src);
    if (!is_dir($dst)) {
        mkdir($dst, PER_FOLDER) or die("Mkdir problem: " . $dst);
    }
    while (false !== ($file = readdir($dir))) {
        if ($file != '.' && $file != '..') {
            if (is_dir($src . '/' . $file)) {
                copyFiles($src . '/' . $file, $dst . '/' . $file);
                chmodAll($dst . '/' . $file, PER_FILE);
            } else {
                copy($src . '/' . $file, $dst . '/' . $file) or die("Copy problem: " . $src . '/' . $file . "  ->  " . $dst . '/' . $file);
                chmodAll($dst . '/' . $file, PER_FILE);
            }
        }
    }
    closedir($dir);
}
示例#2
0
 public function UnZip()
 {
     global $lang;
     if (!isset($_SESSION['valArray'])) {
         $this->getValues();
     }
     $error = array();
     $zip = new ZipArchive();
     if ($zip->open('../temp/update/' . $_SESSION['valArray'] . '.zip') === TRUE) {
         if (is_dir('../temp/update/' . $_SESSION['valArray'] . '/')) {
             recursive_remove_directory('../temp/update/' . $_SESSION['valArray'] . '/');
         }
         mkdir('../temp/update/' . $_SESSION['valArray'] . '/', PER_FOLDER);
         chmod('../temp/update/' . $_SESSION['valArray'] . '/', PER_FOLDER);
         $zip->extractTo('../temp/update/' . $_SESSION['valArray'] . '/');
         if (!$zip->close()) {
             array_push($error, $lang->MOD_134 . "<br/>");
         } else {
             chmodAll('../temp/update/' . $_SESSION['valArray'] . '/');
         }
     } else {
         array_push($error, $lang->MOD_135 . " " . $_SESSION['valArray'] . ".zip<br/>");
     }
     if (count($error) == 0) {
         return "yes";
     } else {
         return $error;
     }
 }
示例#3
0
 } else {
     if ($db->filter('type') == 'addt') {
         $name = $db->filter('name');
         $number = $db->filter('number');
         $newname = strtolower(str_replace(' ', '_', $name));
         if (!file_exists('../../templates/' . $user->domainName . '/' . $newname)) {
             mkdir('../../templates/' . $user->domainName . '/' . $newname, PER_FOLDER);
             chmod('../../templates/' . $user->domainName . '/' . $newname, PER_FOLDER);
         }
         $zip = new ZipArchive();
         if ($zip->open('../temp/' . $number . '.zip') === TRUE) {
             $zip->extractTo('../../templates/' . $user->domainName . '/' . $newname . '/');
             if ($zip->close()) {
                 unlink('../temp/' . $number . '.zip');
                 $files = scandir('../../templates/' . $user->domainName . '/' . $newname . '/');
                 chmodAll('../../templates/' . $user->domainName . '/' . $newname . '/');
                 foreach ($files as &$value) {
                     if (is_dir('../../templates/' . $user->domainName . '/' . $newname . '/' . $value) && ($value == "images" || $value == "img")) {
                         setImages('../../templates/' . $user->domainName . '/' . $newname . '/' . $value . '/', $number);
                         recursive_remove_directory('../../templates/' . $user->domainName . '/' . $newname . '/' . $value);
                     }
                 }
                 $db->query('INSERT INTO cms_template (name,folder, domain) VALUES ("' . $name . '", "' . $newname . '", "' . $user->domain . '")');
                 echo 'ok';
             }
         }
         exit;
     } else {
         if ($db->filter('type') == 'addlb') {
             $name = $db->filter('name');
             $number = $db->filter('number');
示例#4
0
     $delete .= ' AND ids.domainID!="' . $domain . '"';
 }
 $qD = $db->query('SELECT def.moduleName, domain.name, ids.ID FROM cms_modules_def as def LEFT JOIN cms_domains_ids as ids ON def.ID=ids.elementID LEFT JOIN cms_domains as domain ON ids.domainID=domain.ID WHERE def.ID="' . $id . '" AND ids.type="mod" ' . $delete . '');
 while ($rD = $db->fetch($qD)) {
     $db->query("DELETE FROM cms_domains_ids WHERE elementID='" . $id . "' AND type='mod'");
     recursive_remove_directory('../../modules/' . $rD['name'] . '/' . $rD['moduleName'] . '/');
 }
 //Add
 $moduleData = $db->get($db->query('SELECT moduleName FROM cms_modules_def WHERE ID="' . $id . '"'));
 foreach ($domains as $domain) {
     $qA = $db->rows($db->query('SELECT ID FROM cms_domains_ids WHERE domainID="' . $domain . '" AND elementID="' . $id . '" AND type="mod" '));
     if ($qA == 0) {
         $nameD = $db->get($db->query('SELECT name FROM cms_domains WHERE ID="' . $domain . '"'));
         if (!is_dir('../../modules/' . $nameD['name'] . '/' . $moduleData['moduleName'] . '')) {
             copyFiles('../../modules/default/' . $moduleData['moduleName'] . '/', '../../modules/' . $nameD['name'] . '/' . $moduleData['moduleName'] . '/');
             chmodAll('../../modules/' . $nameD['name'] . '/' . $moduleData['moduleName'] . '/');
         }
         $files = scandir('../../modules/default/images/');
         foreach ($files as $file) {
             if (strlen($file) > 2) {
                 if (!is_file('../../modules/' . $nameD['name'] . '/images/' . $file)) {
                     copy('../../modules/default/images/' . $file, '../../modules/' . $nameD['name'] . '/images/' . $file);
                     chmod('../../modules/' . $nameD['name'] . '/images/' . $file, PER_FILE);
                 }
             }
         }
         $db->query("INSERT INTO cms_domains_ids (elementID,domainID,type) VALUES ('" . $id . "','" . $domain . "','" . $db->filter('ver') . "')");
     }
 }
 echo 'ok';
 exit;