Ejemplo n.º 1
0
function processBlogSettingsForm()
{
    global $manager;
    $upload_path = $_POST['upload_path'];
    $upload_url = "http://" . str_replace("http://", "", $_POST['upload_url']);
    $old_uploadpath = $_POST['old_uploadpath'];
    // Prepare path and url...
    if (strrchr($upload_path, "/") != "/") {
        $upload_path .= "/";
    }
    if (strrchr($upload_url, "/") != "/") {
        $upload_url .= "/";
    }
    if ($upload_path != $old_uploadpath) {
        // Need to move files then...
        dircopy($old_uploadpath, $upload_path);
        rmdirr($old_uploadpath);
    }
    $manager->clerk->updateSetting("blog_path", array($upload_path, $upload_url, ""));
    $thumbWidth = empty($_POST['thumbWidth']) ? 0 : $_POST['thumbWidth'];
    $thumbHeight = empty($_POST['thumbHeight']) ? 0 : $_POST['thumbHeight'];
    $intelliScaling = $_POST['intelligentScaling'];
    $manager->clerk->updateSetting("blog_thumbnail", array($thumbWidth, $thumbHeight, ""));
    $manager->clerk->updateSetting("blog_intelliscaling", array($intelliScaling, "", ""));
    $manager->message(1, false, "Settings updated!");
}
Ejemplo n.º 2
0
function dircopy($path, $dest)
{
    if (is_dir($path)) {
        @mkdir($dest);
        $objects = scandir($path);
        if (sizeof($objects) > 0) {
            foreach ($objects as $file) {
                if ($file == "." || $file == "..") {
                    continue;
                }
                // go on
                if (is_dir($path . DS . $file)) {
                    dircopy($path . DS . $file, $dest . DS . $file);
                } else {
                    copy($path . DS . $file, $dest . DS . $file);
                }
            }
        }
        return true;
    } elseif (is_file($path)) {
        return copy($path, $dest);
    } else {
        return false;
    }
}
Ejemplo n.º 3
0
 /**
  *	This method is called via AJAX
  */
 function index($database, $code_template)
 {
     $data_path = array();
     $data_path['code_template'] = $code_template;
     $data_path['app_dir'] = $database;
     $this->idb->connect($database);
     $manifest = json_decode(file_get_contents('templates' . DS . $code_template . DS . 'manifest.json'), TRUE);
     $path_output = $manifest['output_directory'] . DS . $database;
     // Load the folder model
     $this->load->model('folder_model');
     // Get the folder permissions
     $folder_info = $this->folder_model->check_permissions($manifest['output_directory']);
     // Validate the folder permissions
     if ($folder_info['is_writeable'] == true) {
         $tables = $this->db->list_tables();
         $path_templates = 'templates';
         /**
          *	Create input / output paths for the model_iscaffold.
          */
         foreach ($manifest['working_directories'] as $dir) {
             if (is_array($dir)) {
                 list($source, $target) = $dir;
                 $data_path['input_' . $dir[0]] = $path_templates . DS . $code_template . DS . $manifest['working_root_directory'] . DS . $source . DS;
                 $data_path['output_' . $dir[0]] = $path_output . DS . $manifest['working_root_directory'] . DS . $target . DS;
             } else {
                 $data_path['input_' . $dir] = $path_templates . DS . $code_template . DS . $manifest['working_root_directory'] . DS . $dir . DS;
                 $data_path['output_' . $dir] = $path_output . DS . $manifest['working_root_directory'] . DS . $dir . DS;
             }
         }
         /**
          *	 Nuke the output directory if neccessery
          */
         if ($manifest['dump_output_directory'] === TRUE) {
             delete_files($path_output, TRUE);
         }
         @mkdir($path_output, 0777);
         /**
          *	Copdy additional resources
          */
         foreach ($manifest['copy_directories'] as $dir) {
             dircopy($dir, $path_output);
         }
         /**
          *	This is wehere the code generation is invoked
          *	Each table is processed here
          */
         foreach ($tables as $table) {
             if ($table !== 'sf_config') {
                 $this->model_iscaffold->Process_Table($table, $data_path, $code_template, $manifest);
             }
         }
         echo '{ "result": "success" }';
     } else {
         echo '{ "result": "error", "message": "There was a problem generating your application, ther output directory <strong>(' . $manifest['output_directory'] . ')</strong> is not writable." }';
     }
 }
Ejemplo n.º 4
0
function processPrefsForm()
{
    global $manager;
    $username = $_POST['username'];
    $name = $_POST['display_name'];
    $password = $_POST['password'];
    $passwordConf = $_POST['password_conf'];
    $email = $_POST['email'];
    $siteName = $_POST['site_name'];
    $siteUrl = $_POST['site_url'];
    $cleanUrls = $_POST['clean_urls'];
    $cache_path = $_POST['cache_path'];
    $cache_url = $_POST['cache_url'];
    $old_cache_path = $_POST['old_cache_path'];
    // User wants to change their password
    if (!empty($_POST['password']) && !empty($_POST['password_conf'])) {
        if ($_POST['password'] != $_POST['password_conf']) {
            $manager->message(0, false, "Password do not match! Please re-confirm.");
        } elseif (strlen($_POST['password']) < 6 || strlen($_POST['password_conf']) < 6) {
            $manager->message(0, false, "Password must be at least 6 characters long!");
        } else {
            //hash password securely
            if ($manager->clerk->query_edit("users", "password= '******'", "WHERE id= '" . $manager->guard->user('USER_ID') . "'")) {
                $manager->message(1, false, "Password changed!");
            } else {
                $manager->message(0, true, "Could not save your Settings!");
            }
        }
    }
    $personal = $manager->clerk->query_edit("users", "username= '******', display_name= '{$name}', email= '{$email}'", "WHERE id= '" . $manager->guard->user('USER_ID') . "'");
    $manager->clerk->updateSetting("site", array($siteName, $siteUrl));
    if (strrchr($cache_path, "/") != "/") {
        $cache_path .= "/";
    }
    if (strrchr($cache_url, "/") != "/") {
        $cache_url .= "/";
    }
    if ($cache_path != $old_cache_path) {
        // Need to move files then...
        dircopy($old_cache_path, $cache_path);
        rmdirr($old_cache_path);
    }
    $manager->clerk->updateSetting("clean_urls", array($cleanUrls));
    $manager->clerk->updateSetting("cache_path", array($cache_path, $cache_url));
    if ($personal) {
        $manager->message(1, false, "Settings saved!");
    } else {
        $manager->message(0, true, "Could not save your Settings!");
    }
}
Ejemplo n.º 5
0
function processProjectSettingsForm()
{
    global $manager;
    $upload_path = $_POST['upload_path'];
    $upload_url = "http://" . str_replace("http://", "", $_POST['upload_url']);
    $old_uploadpath = $_POST['old_uploadpath'];
    // Prepare path and url...
    if (strrchr($upload_path, "/") != "/") {
        $upload_path .= "/";
    }
    if (strrchr($upload_url, "/") != "/") {
        $upload_url .= "/";
    }
    if ($upload_path != $old_uploadpath) {
        // Need to move files then...
        dircopy($old_uploadpath, $upload_path);
        rmdirr($old_uploadpath);
    }
    $manager->clerk->updateSetting("projects_path", array($upload_path, $upload_url, ""));
    $projThumbWidth = empty($_POST['projThumbWidth']) ? 0 : $_POST['projThumbWidth'];
    $projThumbHeight = empty($_POST['projThumbHeight']) ? 0 : $_POST['projThumbHeight'];
    $fileThumbWidth = empty($_POST['fileThumbWidth']) ? 0 : $_POST['fileThumbWidth'];
    $fileThumbHeight = empty($_POST['fileThumbHeight']) ? 0 : $_POST['fileThumbHeight'];
    $intelliScaling = empty($_POST['image_intelligentScaling']) ? 0 : $_POST['image_intelligentScaling'];
    $hideSections = (int) $_POST['hideSections'];
    $hideFileInfo = (int) $_POST['hideFileInfo'];
    $resizeProjThumb = (int) $_POST['resizeProjThumb'];
    $manager->clerk->updateSetting("projects_thumbnailIntelliScaling", array($_POST['projects_thumbnailIntelliScaling']));
    $manager->clerk->updateSetting("projects_fullsizeimg", array($_POST['fullsizeimg_width'] . "x" . $_POST['fullsizeimg_height'], $_POST['fullsizeimg_intelli'], $_POST['fullsizeimg_do_scale']));
    $nav_opts = serialize(array('prev' => $_POST['prev'], 'divider' => $_POST['divider'], 'next' => $_POST['next'], 'of' => $_POST['of'], 'nav_pos' => $_POST['slideshow_nav_pos'], 'fx' => $_POST['slideshow_fx']));
    $manager->clerk->updateSetting("slideshow_opts", array($nav_opts));
    $updates = array('projThumb' => array("data1= '{$projThumbWidth}', data2= '{$projThumbHeight}'", "WHERE name= 'projects_thumbnail'"), 'fileThumb' => array("data1= '{$fileThumbWidth}', data2= '{$fileThumbHeight}'", "WHERE name= 'projects_filethumbnail'"), 'projects_intelliscaling' => array("data1= '{$intelliScaling}'", "WHERE name= 'projects_intelliscaling'"), 'hideSections' => array("data1= '{$hideSections}'", "WHERE name= 'projects_hideSections'"), 'hideFileInfo' => array("data1= '{$hideFileInfo}'", "WHERE name= 'projects_hideFileInfo'"), 'resizeProjThumb' => array("data1= '{$resizeProjThumb}'", "WHERE name= 'resizeProjThumb'"));
    $ok = true;
    foreach ($updates as $update) {
        if (!$manager->clerk->query_edit("global_settings", $update[0], $update[1])) {
            $ok = false;
        }
    }
    if ($ok) {
        $manager->message(1, false, "Settings updated!");
    } else {
        $manager->message(0, true, "Could not update all settings!");
    }
}
Ejemplo n.º 6
0
function dircopy($source, $target)
{
    $permissions = fileperms($source);
    if (is_dir($source)) {
        @mkdir($target);
        $d = dir($source);
        while (FALSE !== ($entry = $d->read())) {
            if ($entry == '.' || $entry == '..') {
                continue;
            }
            $Entry = $source . '/' . $entry;
            if (is_dir($Entry)) {
                dircopy($Entry, $target . '/' . $entry);
                continue;
            }
            copy($Entry, $target . '/' . $entry);
            chmod($target . '/' . $entry, $permissions);
        }
        $d->close();
    } else {
        copy($source, $target);
    }
    chmod($target, $permissions);
}
Ejemplo n.º 7
0
/**
 * Copy a complete directory
 *
 * @param  string	$srcdir		Source directory
 * @param  string	$dstdir		Destination directory
 * @return int		Number of copied files
 */
function dircopy($srcdir, $dstdir, $verbose = false)
{
    $num = 0;
    if (!is_dir($dstdir) && !shouldIgnore($dstdir)) {
        mkdir($dstdir);
    }
    if ($curdir = opendir($srcdir)) {
        while ($file = readdir($curdir)) {
            if ($file != '.' && $file != '..') {
                $srcfile = $srcdir . '\\' . $file;
                $dstfile = $dstdir . '\\' . $file;
                if (is_file($srcfile) && !shouldIgnore($srcfile)) {
                    if (is_file($dstfile)) {
                        $ow = filemtime($srcfile) - filemtime($dstfile);
                    } else {
                        $ow = 1;
                    }
                    if ($ow > 0) {
                        if ($verbose) {
                            echo "Copying '{$srcfile}' to '{$dstfile}'...";
                        }
                        if (copy($srcfile, $dstfile)) {
                            touch($dstfile, filemtime($srcfile));
                            $num++;
                            if ($verbose) {
                                echo "OK\n";
                            }
                        } else {
                            echo "Error: File '{$srcfile}' could not be copied!\n";
                        }
                    }
                } else {
                    if (is_dir($srcfile) && !shouldIgnore($srcfile)) {
                        $num += dircopy($srcfile, $dstfile, $verbose);
                    }
                }
            }
        }
        closedir($curdir);
    }
    return $num;
}
Ejemplo n.º 8
0
 $returnText .= '<h2>Gestione Package di "' . $collection_short . '"</h2>';
 //
 // CREATE PACKAGE
 if ($isCreatePackage) {
     if ($package_short != '') {
         if (!in_array($package_ext, $EXTENSION_PACKAGE)) {
             $resultMsg .= '<span class="error">ERRORE: estensione "' . $package_ext . '" non riconosciuta!</span><br />';
         } else {
             $package_short = explode('_', $package_short);
             $package_short = strtoupper($package_short[0] . $package_ext);
             getPackageList($collectionPath, &$packageList, true);
             $package_id = strtolower(normalize($package_short));
             if (array_search($package_id, $packageList['package_id']) === FALSE) {
                 $packageTemplate = DCTL_SETTINGS_TEMPLATES_PACKAGE;
                 $packagePath = $collectionPath . $package_id . SYS_PATH_SEP;
                 dircopy($packageTemplate, $packagePath);
                 $idx = 0;
                 $idx = sprintf("%03d", $idx + 1);
                 $from = $packagePath . DCTL_PACKAGE_BODY;
                 $to = $packagePath . str_ireplace('$', $idx, DCTL_PACKAGE_BODY);
                 rename($from, $to);
                 $header = $packagePath . DCTL_FILE_HEADER;
                 if (is_file($header)) {
                     $contents = cleanUpIndentation(file_get_contents($header));
                     $contents = str_ireplace('package_id ""', 'package_id "' . $package_id . '"', $contents);
                     $contents = str_ireplace('package_short ""', 'package_short "' . $package_short . '"', $contents);
                     if (file_put_contents($header, forceUTF8($contents, $header)) !== FALSE) {
                         @chmod($header, CHMOD);
                         getPackageList($collectionPath, &$packageList, true);
                         $prosecute = array_search($package_short, $packageList['package_short']) !== FALSE;
                         if ($prosecute) {
Ejemplo n.º 9
0
function dircopy($srcdir, $dstdir, &$files = array())
{
    if (!is_dir($dstdir)) {
        mkdir($dstdir, CHMOD);
    }
    @chmod($dstdir, CHMOD);
    $handle = opendir($srcdir);
    while ($entry = readdir($handle)) {
        if (substr($entry, 0, 1) != '.') {
            $fullsrc = $srcdir . SYS_PATH_SEP . $entry;
            $fulldst = $dstdir . SYS_PATH_SEP . $entry;
            if (is_dir($fullsrc)) {
                if (!is_dir($fulldst)) {
                    mkdir($fulldst, CHMOD);
                }
                @chmod($fulldst, CHMOD);
                dircopy($fullsrc, $fulldst, &$files);
            } else {
                if (is_file($fullsrc)) {
                    copy($fullsrc, $fulldst);
                    @chmod($fulldst, CHMOD);
                }
                $files[] = $entry;
            }
        }
    }
    @chmod($dstdir, CHMOD);
}
Ejemplo n.º 10
0
<?php

OpenLibrary('misc.library');
dircopy($this->basedir . '/var/adodb/', MODULE_PATH . 'adodb/adodb/');
Ejemplo n.º 11
0
 if ($_POST['demo_install'] == 'true') {
     $zc_install->fileExists('sql/current/demo_data.php', ERROR_TEXT_DEMO_SQL_NOTEXIST, ERROR_CODE_DEMO_SQL_NOTEXIST);
 }
 if ($zc_install->error == false) {
     if ($_POST['demo_install'] == 'true') {
         require 'sql/current/demo_data.php';
         foreach ($extra_sqls as $extra_sql) {
             if (!$db->Execute($extra_sql)) {
                 $zc_install->error = true;
             }
         }
         //        db_executeSql('sql/current/demo_data.sql', DB_DATABASE, DB_PREFIX);
         // copy the demo image files to company directory
         $source_dir = DIR_FS_ADMIN . 'themes/default/images/demo';
         $dest_dir = DIR_FS_ADMIN . 'my_files/' . $_SESSION['company'] . '/inventory/images/demo';
         dircopy($source_dir, $dest_dir);
     }
     $db->updateConfigureValue('COMPANY_ID', $store_id);
     $db->updateConfigureValue('COMPANY_NAME', $store_name);
     $db->updateConfigureValue('COMPANY_ADDRESS1', $store_address1);
     $db->updateConfigureValue('COMPANY_ADDRESS2', $store_address2);
     $db->updateConfigureValue('COMPANY_CITY_TOWN', $store_city_town);
     $db->updateConfigureValue('COMPANY_ZONE', $store_zone);
     $db->updateConfigureValue('COMPANY_POSTAL_CODE', $store_postal_code);
     $db->updateConfigureValue('COMPANY_COUNTRY', $store_country);
     $db->updateConfigureValue('COMPANY_EMAIL', $store_email);
     $db->updateConfigureValue('COMPANY_WEBSITE', $store_website);
     $db->updateConfigureValue('COMPANY_TELEPHONE1', $store_telephone1);
     $db->updateConfigureValue('COMPANY_TELEPHONE2', $store_telephone2);
     $db->updateConfigureValue('COMPANY_FAX', $store_fax);
     $db->updateConfigureValue('DEFAULT_CURRENCY', $store_default_currency);
Ejemplo n.º 12
0
global $flutter_domain;
if (!(is_user_logged_in() && current_user_can(FLUTTER_CAPABILITY_MODULES))) {
    die(__('Athentication failed!', $flutter_domain));
}
require_once 'RCCWP_CustomWriteModule.php';
require_once 'RCCWP_CustomWritePanel.php';
require_once 'RCCWP_Application.php';
require_once 'RCCWP_CustomWritePanel.php';
$moduleID = (int) $_REQUEST['custom-write-module-id'];
$module = RCCWP_CustomWriteModule::Get($moduleID);
if (isset($_POST["write_panels"])) {
    //$write_panels = json_decode(stripslashes($_POST["write_panels"]));
    $modulePath = FLUTTER_MODULES_DIR . $module->name . DIRECTORY_SEPARATOR;
    $tmpPath = sys_get_temp_dir() . DIRECTORY_SEPARATOR;
    // Copy dir to tmp folder
    dircopy($modulePath, $tmpPath . $module->name);
    $moduleTmpPath = "{$tmpPath}{$module->name}";
    chmod_R($moduleTmpPath, 0777);
    // Export write panels
    //check if arrary the write modules is empty
    if ($_POST["write_panels"] != NULL) {
        $write_panels = split(",", $_POST["write_panels"]);
        foreach ($write_panels as $panelID) {
            $writePanel = RCCWP_CustomWritePanel::Get($panelID);
            $exportedFilename = $moduleTmpPath . DIRECTORY_SEPARATOR . '_' . $writePanel->name . '.pnl';
            RCCWP_CustomWritePanel::Export($panelID, $exportedFilename);
        }
    }
    // Export duplicates and description
    $moduleInfoFilename = $moduleTmpPath . DIRECTORY_SEPARATOR . 'module_info.exp';
    $moduleInfo_exported_data['duplicates'] = RCCWP_ModuleDuplicate::GetCustomModulesDuplicates($moduleID);
Ejemplo n.º 13
0
function dircopy($srcdir, $dstdir, $verbose = false)
{
    $num = 0;
    if (!is_dir($dstdir)) {
        mkdir($dstdir);
    }
    if ($curdir = opendir($srcdir)) {
        while ($file = readdir($curdir)) {
            if ($file != '.' && $file != '..') {
                $srcfile = $srcdir . DS . $file;
                $dstfile = $dstdir . DS . $file;
                if (is_file($srcfile)) {
                    if (is_file($dstfile)) {
                        $ow = filemtime($srcfile) - filemtime($dstfile);
                    } else {
                        $ow = 1;
                    }
                    if ($ow > 0) {
                        if ($verbose) {
                            $tmpstr = _KUNENA_COPY_FILE;
                            $tmpstr = str_replace('%src%', $srcfile, $tmpstr);
                            $tmpstr = str_replace('%dst%', $dstfile, $tmpstr);
                            echo $tmpstr;
                        }
                        if (copy($srcfile, $dstfile)) {
                            touch($dstfile, filemtime($srcfile));
                            $num++;
                            if ($verbose) {
                                echo _KUNENA_COPY_OK;
                            }
                        } else {
                            echo "" . _KUNENA_DIRCOPERR . " '{$srcfile}' " . _KUNENA_DIRCOPERR1 . "";
                        }
                    }
                } else {
                    if (is_dir($srcfile)) {
                        $num += dircopy($srcfile, $dstfile, $verbose);
                    }
                }
            }
        }
        closedir($curdir);
    }
    return $num;
}
Ejemplo n.º 14
0
<?php

OpenLibrary('misc.library');
recremovedir(CGI_PATH . 'htmlarea/');
dircopy($this->basedir . '/www/cgi/htmlarea/', CGI_PATH . 'htmlarea/');
Ejemplo n.º 15
0
 /**
  * Copy this album to the location specified by $newfolder, copying all
  * metadata, subalbums, and subalbums' metadata with it.
  * @param $newfolder string the folder to copy to, including the name of the current folder (possibly renamed).
  * @return boolean true on success and false on failure.
  *
  */
 function copyAlbum($newfolder)
 {
     // First, ensure the new base directory exists.
     $oldfolder = $this->name;
     $dest = getAlbumFolder() . '/' . UTF8ToFilesystem($newfolder);
     // Check to see if the destination directory already exists
     if (file_exists($dest)) {
         // Disallow moving an album over an existing one.
         return false;
     }
     if (substr($newfolder, count($oldfolder)) == $oldfolder) {
         // Disallow copying to a subfolder of the current folder (infinite loop).
         return false;
     }
     if ($this->isDynamic()) {
         if (@copy($this->localpath, $dest)) {
             $oldf = mysql_real_escape_string($oldfolder);
             $sql = "SELECT * FROM " . prefix('albums') . " WHERE `id` = '" . $this->getAlbumID() . "'";
             $subrow = query_single_row($sql);
             $success = $this->replicateDBRow($subrow, $oldfolder, $newfolder, true);
             return $success;
         } else {
             return false;
         }
     } else {
         if (mkdir_recursive(dirname($dest)) === TRUE) {
             // Make the move (rename).
             $num = dircopy($this->localpath, $dest);
             // Get the subalbums.
             $oldf = mysql_real_escape_string($oldfolder);
             $sql = "SELECT * FROM " . prefix('albums') . " WHERE folder LIKE '{$oldf}%'";
             $result = query_full_array($sql);
             $allsuccess = true;
             foreach ($result as $subrow) {
                 $success = $this->replicateDBRow($subrow, $oldfolder, $newfolder, $subrow['folder'] == $oldfolder);
                 if (!($success == true && mysql_affected_rows() == 1)) {
                     $allsuccess = false;
                 }
             }
             return $allsuccess;
         }
     }
     return false;
 }
Ejemplo n.º 16
0
 function dircopy($src, $dest, $folder_permission = 0755, $file_permission = 0644)
 {
     $res = false;
     $src = str_replace('\\', '/', $src);
     $src = str_replace('//', '/', $src);
     $dest = str_replace('\\', '/', $dest);
     $dest = str_replace('//', '/', $dest);
     //file copy
     if (is_file($src)) {
         if (is_dir($dest)) {
             if ($dest[strlen($dest) - 1] != '/') {
                 $__dest = $dest . "/";
             }
             $__dest .= basename($src);
         } else {
             $__dest = $dest;
         }
         $res = copy($src, $__dest);
         chmod($__dest, $file_permission);
     } elseif (is_dir($src)) {
         if (!is_dir($dest)) {
             directory_make($dest, $folder_permission);
             chmod($dest, $folder_permission);
         }
         if ($src[strlen($src) - 1] != '/') {
             $__src = $src . '/';
         } else {
             $__src = $src;
         }
         if ($dest[strlen($dest) - 1] != '/') {
             $__dest = $dest . '/';
         } else {
             $__dest = $dest;
         }
         $res = true;
         $handle = opendir($src);
         while ($file = readdir($handle)) {
             if ($file != '.' && $file != '..') {
                 $res = dircopy($__src . $file, $__dest . $file, $folder_permission, $file_permission);
             }
         }
         closedir($handle);
     } else {
         $res = false;
     }
     return $res;
 }
Ejemplo n.º 17
0
function publish_SendToXDB($exist, $collName, $packName, $partName, &$operationsPublish)
{
    global $EXTENSION_PACKAGE;
    // INIT
    $toPublish = array();
    // PREPARA FOLDERS
    $component = $collName;
    if ($packName != '') {
        $component .= SYS_PATH_SEP . $packName;
    }
    $operationsPublish .= '&gt; avvio la preparazione dei dati per "' . $component . ':<br />';
    hardFlush(&$operationsPublish);
    $prosecute = TRUE;
    if (!is_dir(DCTL_PUBLISH)) {
        if (mkdir(DCTL_PUBLISH, CHMOD)) {
            $operationsPublish .= '&gt; creo cartella ' . DCTL_PUBLISH . '...<br />';
        } else {
            $operationsPublish .= '<span class="error">impossibile creare la cartella "' . DCTL_PUBLISH . '"!</span><br />';
            $prosecute = FALSE;
        }
    }
    @chmod(DCTL_PUBLISH, CHMOD);
    $operationsPublish .= '&gt; avvio la preparazione dei file in "' . DCTL_PUBLISH . '":<br />';
    hardFlush(&$operationsPublish);
    if ($prosecute) {
        // COPIA I DTD
        dircopy(DCTL_SETTINGS_DTD, DCTL_PUBLISH);
        $operationsPublish .= '&#160;&#160;- copio "' . DCTL_DTD . '"...<br />';
        hardFlush(&$operationsPublish);
        // COPIA GLI ADD-ONS
        dircopy(DCTL_SETTINGS_ADDONS, DCTL_PUBLISH);
        $operationsPublish .= '&#160;&#160;- copio "' . DCTL_ADDONS . '"...<br />';
        hardFlush(&$operationsPublish);
        // AGGIORNA IL CATALOGO.XML
        $operationsPublish .= '&#160;&#160;- verifico il catalogo dei "' . DCTL_DTD . '":<br />';
        hardFlush(&$operationsPublish);
        $dtd_catalog = XMLDB_CATALOG;
        try {
            if (isset($xml_dom)) {
                unset($xml_dom);
            }
            $xml_dom = new DOMDocument('1.0', 'UTF-8');
            $xml_dom->preserveWhiteSpace = false;
            forceUTF8($dtd_catalog);
            $xml_dom->load($dtd_catalog, DCTL_XML_LOADER);
        } catch (Exception $e) {
            $operationsPublish .= '<span class="error">impossibile caricare XML "' . $entry . '"... {' . $e . '}</span><br />';
            $prosecute = FALSE;
        }
        if ($prosecute) {
            $upd = FALSE;
            $dtds_needed = array();
            $handle = opendir(DCTL_SETTINGS_DTD);
            while ($entry = readdir($handle)) {
                if (substr($entry, 0, 1) != '.') {
                    $srcx = filemtime(DCTL_SETTINGS_DTD . $entry);
                    $tgtx = false || @filemtime(XMLDB_ENTITIES . SYS_PATH_SEP . $entry);
                    if ($srcx > $tgtx) {
                        $upd = TRUE;
                    }
                }
            }
            dircopy(DCTL_SETTINGS_DTD, XMLDB_ENTITIES, &$dtds_needed);
            $operationsPublish .= '&#160;&#160;- copio da "' . DCTL_SETTINGS_DTD . '" a "' . XMLDB_ENTITIES . '"...<br />';
            hardFlush(&$operationsPublish);
            $dtds_present = $xml_dom->getElementsByTagName('system');
            foreach ($dtds_present as $dtd_present) {
                $dtd_chk = $dtd_present->getAttribute('systemId');
                $dtd_key = array_search($dtd_chk, $dtds_needed);
                if ($dtd_key !== FALSE) {
                    $dtds_needed[$dtd_key] = '';
                }
            }
            foreach ($dtds_needed as $dtd_needed) {
                if ($dtd_needed != '') {
                    $node = $xml_dom->createElement('system');
                    $dtd_root = $xml_dom->getElementsByTagName('catalog')->item(0);
                    $newnode = $dtd_root->appendChild($node);
                    $newnode->setAttribute('systemId', $dtd_needed);
                    $newnode->setAttribute('uri', 'entities' . SYS_PATH_SEP . $dtd_needed);
                    $operationsPublish .= '&gt; aggiungo ' . $dtd_needed . '...<br />';
                    hardFlush(&$operationsPublish);
                    $upd = TRUE;
                }
            }
            if ($upd == TRUE) {
                $xml_dom->save($dtd_catalog);
                $operationsPublish .= '<span class="error">Aggiornamento non eseguito per modifiche necessarie al database.</span><br />';
                $operationsPublish .= '<span class="error">IMPORTANTE: riavviare exist per proseguire correttamente (aggiornato "catalog.xml")!</span><br />';
                $prosecute = FALSE;
            }
            if ($prosecute) {
                // PREPARA XML #1
                $xsl_path = DCTL_COMMODORO_XSLT . 'tei_publisher_1.xsl';
                if (!is_file($xsl_path)) {
                    $operationsPublish .= '<span class="error">impossibile trovare XSLT "' . $xsl_path . '"!</span><br />';
                    $prosecute = FALSE;
                } else {
                    try {
                        if (isset($xsl_dom)) {
                            unset($xsl_dom);
                        }
                        $xsl_dom = new DOMDocument('1.0', 'UTF-8');
                        $xsl_dom->preserveWhiteSpace = false;
                        forceUTF8($xsl_path);
                        $xsl_dom->load($xsl_path, DCTL_XML_LOADER);
                    } catch (Exception $e) {
                        $operationsPublish .= '<span class="error">impossibile caricare XSLT "' . $xsl_path . '"... {' . $e . '}</span><br />';
                        $prosecute = FALSE;
                    }
                    if ($prosecute) {
                        $operationsPublish .= '&gt; carico XSLT "' . $xsl_path . '"...<br />';
                        hardFlush(&$operationsPublish);
                        try {
                            if (isset($xsl_proc)) {
                                unset($xsl_proc);
                            }
                            $xsl_proc = new XSLTProcessor();
                            $xsl_proc->registerPHPFunctions();
                            $xsl_proc->importStyleSheet($xsl_dom);
                            // attach the xsl rules
                        } catch (Exception $e) {
                            $operationsPublish .= '<span class="error">impossibile inizializzare il processore XSL... {' . $e . '}</span><br />';
                            $prosecute = FALSE;
                        }
                        if ($prosecute) {
                            $operationsPublish .= '&gt; trasformo i file XML (#1):<br />';
                            $prosecute = publish_recurseContents(DCTL_PROJECT_PATH . $collName, $collName, $packName, $xsl_proc, &$operationsPublish, &$toPublish);
                        }
                        if ($prosecute) {
                            // PREPARA XML #2
                            $xsl_path = DCTL_COMMODORO_XSLT . 'tei_publisher_2.xsl';
                            if (!is_file($xsl_path)) {
                                $operationsPublish .= '<span class="error">impossibile trovare XSLT "' . $xsl_path . '"!</span><br />';
                                $prosecute = FALSE;
                            } else {
                                try {
                                    if (isset($xsl_dom)) {
                                        unset($xsl_dom);
                                    }
                                    $xsl_dom = new DOMDocument('1.0', 'UTF-8');
                                    $xsl_dom->preserveWhiteSpace = false;
                                    forceUTF8($xsl_path);
                                    $xsl_dom->load($xsl_path, DCTL_XML_LOADER);
                                } catch (Exception $e) {
                                    $operationsPublish .= '<span class="error">impossibile caricare XSLT "' . $xsl_path . '"... {' . $e . '}</span><br />';
                                    $prosecute = FALSE;
                                }
                                if ($prosecute) {
                                    $operationsPublish .= '&gt; carico XSLT "' . $xsl_path . '"...<br />';
                                    hardFlush(&$operationsPublish);
                                    try {
                                        if (isset($xsl_proc)) {
                                            unset($xsl_proc);
                                        }
                                        $xsl_proc = new XSLTProcessor();
                                        $xsl_proc->registerPHPFunctions();
                                        $xsl_proc->importStyleSheet($xsl_dom);
                                        // attach the xsl rules
                                    } catch (Exception $e) {
                                        $operationsPublish .= '<span class="error">impossibile inizializzare il processore XSL... {' . $e . '}</span><br />';
                                        $prosecute = FALSE;
                                    }
                                    if ($prosecute) {
                                        $operationsPublish .= '&gt; trasformo i file XML :: ID/NUM (#2):<br />';
                                        hardFlush(&$operationsPublish);
                                        foreach ($toPublish as $fullsrc) {
                                            $prosecute = true;
                                            $fulldst = $fullsrc;
                                            $entry = basename($fulldst);
                                            if (in_array(substr($entry, -8, 4), $EXTENSION_PACKAGE) !== FALSE) {
                                                $operationsPublish .= '&#160;- trasformazione XSLT per XML "' . $entry . '":';
                                                try {
                                                    if (isset($xml_dom)) {
                                                        unset($xml_dom);
                                                    }
                                                    $xml_dom = new DOMDocument('1.0', 'UTF-8');
                                                    $xsl_dom->preserveWhiteSpace = false;
                                                    forceUTF8($fullsrc);
                                                    $xml_dom->load($fullsrc, DCTL_XML_LOADER);
                                                } catch (Exception $e) {
                                                    $operationsPublish .= '<span class="error">impossibile caricare XML "' . $entry . '"... {' . $e . '}</span><br />';
                                                    $prosecute = FALSE;
                                                }
                                                if ($prosecute) {
                                                    $operationsPublish .= '&#160;aggiorno...';
                                                    try {
                                                        $text = $xsl_proc->transformToXML($xml_dom);
                                                    } catch (Exception $e) {
                                                        $operationsPublish .= '<span class="error">impossibile trasformare XML "' . $entry . '"... {' . $e . '}</span><br />';
                                                        $prosecute = FALSE;
                                                    }
                                                    if ($prosecute) {
                                                        $operationsPublish .= '&#160;scrivo XML...';
                                                        $text = str_ireplace('xmlns=""', '', $text);
                                                        try {
                                                            $fd = fopen($fulldst, "wb");
                                                            $out = fwrite($fd, forceUTF8($text));
                                                            fclose($fd);
                                                            @chmod($fulldst, CHMOD);
                                                            $operationsPublish .= '&#160;ok<br/>';
                                                        } catch (Exception $e) {
                                                            $operationsPublish .= '<span class="error">impossibile riscrivere XML "' . $entry . '"... {' . $e . '}</span><br />';
                                                            $prosecute = FALSE;
                                                        }
                                                        hardFlush(&$operationsPublish);
                                                    }
                                                }
                                            }
                                        }
                                    }
                                    if ($prosecute) {
                                        // PREPARA XML #3
                                        // 3) carico i file XML e li trasformo
                                        $xsl_path = DCTL_COMMODORO_XSLT . 'tei_publisher_3.xsl';
                                        if (!is_file($xsl_path)) {
                                            $operationsPublish .= '<span class="error">impossibile trovare XSLT "' . $xsl_path . '"!</span><br />';
                                            $prosecute = FALSE;
                                        }
                                        if ($prosecute) {
                                            try {
                                                if (isset($xsl_dom)) {
                                                    unset($xsl_dom);
                                                }
                                                $xsl_dom = new DOMDocument('1.0', 'UTF-8');
                                                $xsl_dom->preserveWhiteSpace = false;
                                                forceUTF8($xsl_path);
                                                $xsl_dom->load($xsl_path, DCTL_XML_LOADER);
                                            } catch (Exception $e) {
                                                $operationsPublish .= '<span class="error">impossibile caricare XSLT "' . $xsl_path . '"... {' . $e . '}</span><br />';
                                                $prosecute = FALSE;
                                            }
                                            if ($prosecute) {
                                                $operationsPublish .= '&gt; carico XSLT "' . $xsl_path . '"...<br />';
                                                hardFlush(&$operationsPublish);
                                                try {
                                                    if (isset($xsl_proc)) {
                                                        unset($xsl_proc);
                                                    }
                                                    $xsl_proc = new XSLTProcessor();
                                                    $xsl_proc->registerPHPFunctions();
                                                    $xsl_proc->importStyleSheet($xsl_dom);
                                                    // attach the xsl rules
                                                } catch (Exception $e) {
                                                    $operationsPublish .= '<span class="error">impossibile inizializzare il processore XSL... {' . $e . '}</span><br />';
                                                    $prosecute = FALSE;
                                                }
                                                if ($prosecute) {
                                                    $operationsPublish .= '&gt; trasformo i file XML :: LABEL/NAME/TOPIC (#3):<br />';
                                                    hardFlush(&$operationsPublish);
                                                    global $mysql_dbName;
                                                    global $mysql_dbIconclass;
                                                    try {
                                                        $mysql_dbName = dctl_sql_connect(DCTL_DB_NAME);
                                                    } catch (Exception $e) {
                                                        die('<span class="wctl_error">[DB] ' . $e . '</span>');
                                                    }
                                                    try {
                                                        $mysql_dbIconclass = dctl_sql_connect(DCTL_DB_ICONCLASS);
                                                    } catch (Exception $e) {
                                                        die('<span class="wctl_error">[DB] ' . $e . '</span>');
                                                    }
                                                    foreach ($toPublish as $fullsrc) {
                                                        $prosecute = true;
                                                        $fulldst = $fullsrc;
                                                        $entry = basename($fulldst);
                                                        if (in_array(substr($entry, -8, 4), $EXTENSION_PACKAGE) !== FALSE) {
                                                            $operationsPublish .= '&#160;- trasformazione XSLT per XML "' . $entry . '":';
                                                            try {
                                                                if (isset($xml_dom)) {
                                                                    unset($xml_dom);
                                                                }
                                                                $xml_dom = new DOMDocument('1.0', 'UTF-8');
                                                                $xml_dom->preserveWhiteSpace = false;
                                                                forceUTF8($fullsrc);
                                                                $xml_dom->load($fullsrc, DCTL_XML_LOADER);
                                                            } catch (Exception $e) {
                                                                $operationsPublish .= '<span class="error">impossibile caricare XML "' . $entry . '"... {' . $e . '}</span><br />';
                                                                $prosecute = FALSE;
                                                            }
                                                            if ($prosecute) {
                                                                $operationsPublish .= '&#160;aggiorno...';
                                                                if ($mysql_dbName && $mysql_dbIconclass) {
                                                                    try {
                                                                        // the two parameters (collection and package) are needed for key_items, they will
                                                                        // be used by the function *get_n_from_xml_id*, which is called from xslt
                                                                        $xsl_proc->setParameter('', 'collection', $collName);
                                                                        // if $packName is empty, we need to do some ugly hack on the
                                                                        if ($packName == '') {
                                                                            $package = substr($entry, strpos($entry, $collName . '-') + strlen($collName . '-'), strrpos($entry, '.') - strlen($entry));
                                                                        } else {
                                                                            $package = $packName;
                                                                        }
                                                                        $xsl_proc->setParameter('', 'package', $package);
                                                                        $text = $xsl_proc->transformToXML($xml_dom);
                                                                    } catch (Exception $e) {
                                                                        $operationsPublish .= '<span class="error">impossibile trasformare XML "' . $entry . '"... {' . $e . '}</span><br />';
                                                                        $prosecute = FALSE;
                                                                    }
                                                                    if ($prosecute) {
                                                                        $operationsPublish .= '&#160;scrivo XML...';
                                                                        $text = str_ireplace('xmlns=""', '', $text);
                                                                        try {
                                                                            $fd = fopen($fulldst, "wb");
                                                                            $out = fwrite($fd, forceUTF8($text, $fulldst));
                                                                            fclose($fd);
                                                                            @chmod($fulldst, CHMOD);
                                                                            $operationsPublish .= 'ok<br/>';
                                                                        } catch (Exception $e) {
                                                                            $operationsPublish .= '<span class="error">impossibile riscrivere XML "' . $entry . '"... {' . $e . '}</span><br />';
                                                                            $prosecute = FALSE;
                                                                        }
                                                                        hardFlush(&$operationsPublish);
                                                                    }
                                                                } else {
                                                                    $operationsPublish .= '<span class="error">impossibile connettersi a MySQL...</span><br />';
                                                                    $prosecute = FALSE;
                                                                }
                                                            }
                                                        }
                                                    }
                                                    mysql_close($mysql_dbName);
                                                    mysql_close($mysql_dbIconclass);
                                                    if ($prosecute) {
                                                        // PREPARA XMLDB
                                                        $operationsPublish .= '&gt; connessione al database "exist":<br />';
                                                        hardFlush(&$operationsPublish);
                                                        if (!$exist) {
                                                            $operationsPublish .= '<span class="error">impossibile connettersi al database "exist"... {' . $e . '}</span><br />';
                                                            $prosecute = FALSE;
                                                        }
                                                        if ($prosecute) {
                                                            $baseDB = XMLDB_PATH_BASE;
                                                            $result = $exist->createCollection($baseDB) != FALSE or dump($exist->getError());
                                                            if (!$result) {
                                                                $operationsPublish .= '<span class="error">impossibile creare la Collection base "' . $baseDB . '"!</span><br />';
                                                                $prosecute = FALSE;
                                                            }
                                                            if ($prosecute) {
                                                                // 1) creo la collezione in exist
                                                                $operationsPublish .= '&#160;&#160;- aggiorno la Collection "' . $collName . '":<br />';
                                                                hardFlush(&$operationsPublish);
                                                                if ($packName == '') {
                                                                    $exist->removeCollection($baseDB . $collName);
                                                                    $operationsPublish .= '&#160;&#160;- ripulisco la Collection "' . $collName . '"...<br />';
                                                                }
                                                                $result = $exist->createCollection($baseDB . $collName) != FALSE or dump($exist->getError());
                                                                if (!$result) {
                                                                    $operationsPublish .= '<span class="error">impossibile creare la Collection "' . $collName . '"!</span><br />';
                                                                    $prosecute = FALSE;
                                                                }
                                                                $operationsPublish .= '&gt; pubblico i dati nel database...<br />';
                                                                hardFlush(&$operationsPublish);
                                                                foreach ($toPublish as $fullsrc) {
                                                                    $prosecute = true;
                                                                    $fulldst = $fullsrc;
                                                                    $entry = basename($fulldst);
                                                                    // 3) pubblico nella collezione di exist
                                                                    $operationsPublish .= '&#160;&#160;- pubblico "' . $entry . '"...';
                                                                    $pathTo = $baseDB . $collName . DB_PATH_SEP . $entry;
                                                                    $result = $exist->uploadResource($pathTo, $fulldst) !== FALSE or dump($exist->getError());
                                                                    if (!$result) {
                                                                        $operationsPublish .= '<span class="error">impossibile pubblicare XML "' . $entry . '"!</span><br />';
                                                                        $prosecute = FALSE;
                                                                    } else {
                                                                        $operationsPublish .= '&#160;ok<br />';
                                                                        $prosecute = TRUE;
                                                                    }
                                                                    hardFlush(&$operationsPublish);
                                                                }
                                                                if ($prosecute) {
                                                                    $fullsrc = DCTL_PROJECT_PATH . $collName . SYS_PATH_SEP . DCTL_MEDIA;
                                                                    if (true) {
                                                                        $prosecute = publish_recurseMedia($fullsrc, DCTL_PUBLISH_MEDIA, &$operationsPublish);
                                                                    } else {
                                                                        if (!COPY_MEDIA) {
                                                                            $operationsPublish .= '<br /><span class="error">RI-ABILITA COPIA DEI MEDIA...';
                                                                        } else {
                                                                            // COPIA MEDIA
                                                                            $operationsPublish .= '&#160;&#160;- copio "' . $fullsrc . '"...<br />';
                                                                            hardFlush(&$operationsPublish);
                                                                            dircopy($fullsrc, DCTL_PUBLISH_MEDIA);
                                                                        }
                                                                    }
                                                                    $operationsPublish .= '<br /><span class="ok">Pubblicazione per "' . $collName;
                                                                    if ($packName != '') {
                                                                        $operationsPublish .= SYS_PATH_SEP . $packName;
                                                                    }
                                                                    $operationsPublish .= '" effettuata con successo.</span><br /><br />';
                                                                } else {
                                                                    $operationsPublish .= '<br /><span class="error">Errori nella pubblicazione per "' . $component . '"!</span><br /><br />';
                                                                }
                                                                hardFlush(&$operationsPublish);
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    return TRUE && $prosecute;
}
Ejemplo n.º 18
0
ob_start();
if (version_compare(PHP_VERSION, "5.1.3", "<")) {
    exit("Chyrp requires PHP 5.1.3 or greater. Installation cannot continue.");
}
$open = opendir(".");
$numbers = array(0);
while (false !== ($list = readdir($open))) {
    preg_match("/([0-9]+)/", $list, $number);
    if (!isset($number[1])) {
        continue;
    }
    $numbers[] = $number[1];
}
closedir($open);
$num = "demo" . (max($numbers) + 1);
dircopy("__stock", $num);
$open_timestamp = fopen("./" . $num . "/CREATED_AT", "w");
fwrite($open_timestamp, time());
fclose($open_timestamp);
function dircopy($src_dir, $dst_dir, $verbose = false, $use_cached_dir_trees = false)
{
    static $cached_src_dir;
    static $src_tree;
    static $dst_tree;
    $num = 0;
    if (($slash = substr($src_dir, -1)) == "\\" || $slash == "/") {
        $src_dir = substr($src_dir, 0, strlen($src_dir) - 1);
    }
    if (($slash = substr($dst_dir, -1)) == "\\" || $slash == "/") {
        $dst_dir = substr($dst_dir, 0, strlen($dst_dir) - 1);
    }
Ejemplo n.º 19
0
function dircopy($source, $destination, $child = 1)
{
    if (!is_dir($source)) {
        return false;
    }
    mmkdir($destination);
    $handle = dir($source);
    while ($entry = $handle->read()) {
        if ($entry != "." && $entry != "..") {
            if (is_dir($source . "/" . $entry)) {
                dircopy($source . "/" . $entry, $destination . "/" . $entry, $child);
            } else {
                copy($source . "/" . $entry, $destination . "/" . $entry);
            }
        }
    }
    return true;
}
Ejemplo n.º 20
0
function DirCopy($srcdir, $dstdir, $verbose)
{
    global $arrHttp, $msgstr;
    $num = 0;
    if (!is_dir($dstdir)) {
        mkdir($dstdir);
    }
    if ($curdir = opendir($srcdir)) {
        while ($file = readdir($curdir)) {
            if ($file != '.' && $file != '..') {
                $srcfile = $srcdir . "/" . $file;
                $dstfile = $dstdir . "/" . str_replace($arrHttp["base_sel"], $arrHttp["nombre"], $file);
                $ext = substr($file, strlen($file) - 4, 4);
                if (is_file($srcfile)) {
                    if (is_file($dstfile)) {
                        $ow = filemtime($srcfile) - filemtime($dstfile);
                    } else {
                        $ow = 1;
                    }
                    if ($ow > 0) {
                        if ($verbose) {
                            echo " ({$srcfile}) --> ({$dstfile}) ...<br>";
                        }
                        if (copy($srcfile, $dstfile)) {
                            touch($dstfile, filemtime($srcfile));
                            $num++;
                            if ($verbose) {
                                echo "OK<br>\n";
                            }
                        } else {
                            echo $msgstr["warning"] . "! " . $msgstr["nocopyfile"] . " " . $srcfile . "<br>\n";
                        }
                    }
                } else {
                    if (is_dir($srcfile)) {
                        $num += dircopy($srcfile, $dstfile, $verbose);
                    }
                }
            }
        }
        closedir($curdir);
    }
    return $num;
}
Ejemplo n.º 21
0
* @package Kunena
*
* @Copyright (C) 2008 - 2009 Kunena Team All rights reserved
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
* @link http://www.kunena.com
*
* Based on FireBoard Component
* @Copyright (C) 2006 - 2007 Best Of Joomla All rights reserved
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
* @link http://www.bestofjoomla.com
*
* JoomlaBoard converter
*
**/
defined('_JEXEC') or die('Restricted access');
//copy the attachments to Kunena directory
dircopy(KUNENA_ROOT_PATH . DS . "components/com_joomlaboard/uploaded", KUNENA_PATH_UPLOADED . DS, false);
dircopy(KUNENA_ROOT_PATH . DS . "components/com_joomlaboard/avatars", KUNENA_PATH_UPLOADED . DS . "avatars", false);
$kunena_db =& JFactory::getDBO();
$kunena_db->setQuery("update #__fb_attachments set filelocation = replace(filelocation,'com_joomlaboard','com_kunena');");
$kunena_db->query();
$kunena_db->setQuery("update #__fb_attachments set filelocation = replace(filelocation,'" . KUNENA_PATH . DS . "uploaded','/images/fbfiles');");
if ($kunena_db->query()) {
    //    echo "<img src='images/tick.png' align='absmiddle'>"._KUNENA_UP_ATT_10."<br />";
}
$kunena_db->setQuery("update #__fb_messages_text set message = replace(message,'/components/com_kunena/uploaded','/images/fbfiles');");
if ($kunena_db->query()) {
    //    echo "<img src='images/tick.png' align='absmiddle'>"._KUNENA_UP_ATT_10_MSG."<br />";
}
// As a last step we recount all forum stats
CKunenaTools::reCountBoards();
Ejemplo n.º 22
0
/**
 * Copies a directory recursively
 * @param string $srcdir the source directory.
 * @param string $dstdir the destination directory.
 * @return the total number of files copied.
 */
function dircopy($srcdir, $dstdir)
{
    $num = 0;
    if (!is_dir($dstdir)) {
        mkdir($dstdir);
    }
    if ($curdir = opendir($srcdir)) {
        while ($file = readdir($curdir)) {
            if ($file != '.' && $file != '..') {
                $srcfile = $srcdir . '/' . $file;
                $dstfile = $dstdir . '/' . $file;
                if (is_file($srcfile)) {
                    if (is_file($dstfile)) {
                        $ow = filemtime($srcfile) - filemtime($dstfile);
                    } else {
                        $ow = 1;
                    }
                    if ($ow > 0) {
                        if (copy($srcfile, $dstfile)) {
                            touch($dstfile, filemtime($srcfile));
                            $num++;
                        }
                    }
                } else {
                    if (is_dir($srcfile)) {
                        $num += dircopy($srcfile, $dstfile);
                    }
                }
            }
        }
        closedir($curdir);
    }
    return $num;
}
Ejemplo n.º 23
0
 /**
  * Add translation definition
  *
  * @access public
  * @return string
  */
 public function upload_language()
 {
     $this->load->library('currencies');
     $this->load->helper('directory');
     $error = FALSE;
     $feedback = array();
     //the cache directory in the store front
     $front_cache_path = @realpath(ROOTPATH . 'local/cache');
     //create the writable language directory in the cache directory
     if (!@is_dir($front_cache_path . '/language')) {
         if (!@mkdir($front_cache_path . '/language', 0777)) {
             $error = TRUE;
         }
     }
     //create a temporary directory to store the uploaded zip file
     $temp_langauge_path = $front_cache_path . '/language/' . time();
     if ($error === FALSE && @mkdir($temp_langauge_path)) {
         //upload the zip file and extract it, put the language files into temporary directory
         $config = array('upload_path' => $temp_langauge_path, 'allowed_types' => 'zip');
         $this->load->library('upload', $config);
         if ($this->upload->do_upload('file')) {
             $this->load->library('pclzip', $this->upload->data('full_path'));
             if ($this->pclzip->extract(PCLZIP_OPT_PATH, $temp_langauge_path) == 0) {
                 $error = TRUE;
                 $feedback[] = lang('ms_error_wrong_zip_file_format');
             }
         } else {
             //upload failed
             $error = TRUE;
             $feedback[] = $this->upload->display_errors();
         }
     } else {
         //create the temporary language directory failed
         $error = TRUE;
         $feedback[] = sprintf(lang('ms_error_creating_directory_failed'), $front_cache_path);
     }
     if ($error === FALSE) {
         //scan the temporary directory to get the language files
         $this->load->library('directory_listing');
         $this->directory_listing->set_directory($temp_langauge_path);
         $this->directory_listing->set_include_directories(TRUE);
         $this->directory_listing->set_include_files(FALSE);
         $files = $this->directory_listing->get_files();
         $code = NULL;
         foreach ($files as $file) {
             if (@is_dir($temp_langauge_path . '/' . $file['name']) && is_dir($temp_langauge_path . '/' . $file['name'] . '/admin')) {
                 $code = $file['name'];
                 break;
             }
         }
         //copy the uploaded languages files into install, store front and admin panel
         if ($code !== NULL) {
             dircopy($temp_langauge_path . '/' . $code . "/language", @realpath(ROOTPATH . 'system/tomatocart/language'));
             dircopy($temp_langauge_path . '/' . $code . "/admin/language", APPPATH . 'language');
             dircopy($temp_langauge_path . '/' . $code . "/install/language", @realpath(ROOTPATH . 'install/applications/language'));
             @unlink($temp_langauge_path);
         } else {
             $error = TRUE;
             $feedback[] = lang('ms_error_wrong_language_package');
         }
     }
     if ($error === FALSE) {
         //import the language definitons into database
         if ($this->lang_model->import($code, 'replace')) {
             $response = array('success' => TRUE, 'feedback' => lang('ms_success_action_performed'));
         } else {
             $response = array('success' => FALSE, 'feedback' => lang('ms_error_action_not_performed'));
         }
     } else {
         $response = array('success' => FALSE, 'feedback' => $osC_Language->get('ms_error_action_not_performed') . "<br />" . implode("<br />", $feedback));
     }
     $this->output->set_output(json_encode($response));
 }
Ejemplo n.º 24
0
<?php

OpenLibrary('misc.library');
recremovedir(MODULE_PATH . 'ezpdflib/fonts');
dircopy($this->basedir . '/extras/fonts/', MODULE_PATH . 'ezpdflib/fonts/');
Ejemplo n.º 25
0
function install_build_dirs($company, $include_demo = false)
{
    global $messageStack;
    if (!file_exists(DIR_FS_MY_FILES . 'backups')) {
        $status = mkdir(DIR_FS_MY_FILES . 'backups');
    }
    if (!$status) {
        $messageStack->add('Cannot create directory (' . DIR_FS_MY_FILES . 'backups' . ') check your permissions.', 'error');
        return false;
    }
    install_blank_webpage(DIR_FS_MY_FILES . 'backups/index.html');
    // protect backups directory from spiders
    if (!file_exists(DIR_FS_MY_FILES . $company)) {
        mkdir(DIR_FS_MY_FILES . $company);
    }
    install_blank_webpage(DIR_FS_MY_FILES . $company . '/index.html');
    // protect company directory from spiders
    if (!file_exists(DIR_FS_MY_FILES . $company . '/images')) {
        mkdir(DIR_FS_MY_FILES . $company . '/images');
    }
    if (!file_exists(DIR_FS_MY_FILES . $company . '/inventory')) {
        mkdir(DIR_FS_MY_FILES . $company . '/inventory');
    }
    if (!file_exists(DIR_FS_MY_FILES . $company . '/inventory/images')) {
        mkdir(DIR_FS_MY_FILES . $company . '/inventory/images');
    }
    if (!file_exists(DIR_FS_MY_FILES . $company . '/shipping')) {
        mkdir(DIR_FS_MY_FILES . $company . '/shipping');
    }
    if (!file_exists(DIR_FS_MY_FILES . $company . '/temp')) {
        mkdir(DIR_FS_MY_FILES . $company . '/temp');
    }
    @chmod(DIR_FS_MY_FILES . $company . '/temp', 0777);
    // needed for db access
    // now copy some startup files
    $source = DIR_FS_MY_FILES . '../themes/default/images/phreebooks_logo.jpg';
    // default logo for forms
    $dest = DIR_FS_MY_FILES . $company . '/images/phreebooks_logo.jpg';
    copy($source, $dest);
    if ($include_demo) {
        // now copy the demo image files
        $source_dir = DIR_FS_MY_FILES . '../themes/default/images/demo';
        $dest_dir = DIR_FS_MY_FILES . $company . '/inventory/images/demo';
        dircopy($source_dir, $dest_dir);
    }
    return true;
}