Exemple #1
0
function calendarUpdate()
{
    try {
        //update module name
        \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "modules` SET `name` = 'Calendar' WHERE `id` = 21");
        //update navigation url
        \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "backend_areas` SET `uri` = 'index.php?cmd=Calendar' WHERE `area_id` = 16");
        //Insert component entry
        \Cx\Lib\UpdateUtil::sql("INSERT INTO `" . DBPREFIX . "component` (`id`, `name`, `type`) VALUES ('21', 'Calendar', 'module')");
        //update module name for frontend pages
        \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "content_page` SET `module` = 'Calendar' WHERE `module` = 'calendar'");
        //following queries for changing the path from images/calendar into images/Calendar
        \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "module_calendar_event` SET `pic` = REPLACE(`pic`, 'images/calendar', 'images/Calendar'),\n                                                                                    `attach` = REPLACE(`attach`, 'images/calendar', 'images/Calendar'),\n                                                                                    `place_map` = REPLACE(`place_map`, 'images/calendar', 'images/Calendar')\n                                                                                     WHERE `pic` LIKE ('" . ASCMS_PATH_OFFSET . "/images/calendar%') ");
    } catch (\Cx\Lib\UpdateException $e) {
        return "Error: {$e->sql}";
    }
    $sourcePath = ASCMS_DOCUMENT_ROOT . '/images/calendar';
    $targetPath = ASCMS_DOCUMENT_ROOT . '/images/Calendar';
    try {
        if (file_exists($sourcePath) && !file_exists($targetPath)) {
            \Cx\Lib\FileSystem\FileSystem::makeWritable($sourcePath);
            if (!\Cx\Lib\FileSystem\FileSystem::move($sourcePath, $targetPath)) {
                return 'Failed to Moved the files from ' . $sourcePath . ' to ' . $targetPath . '.<br>';
            }
        }
    } catch (\Cx\Lib\FileSystem\FileSystemException $e) {
        return $e->getMessage();
    }
    return 'Calendar Component Updated Successfully';
}
Exemple #2
0
function downloadsUpdate()
{
    try {
        //update module name
        \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "modules` SET `name` = 'Downloads' WHERE `id` = 53");
        //update navigation url
        \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "backend_areas` SET `uri` = 'index.php?cmd=Downloads' WHERE `area_id` = 132");
        //Insert component entry
        \Cx\Lib\UpdateUtil::sql("INSERT INTO `" . DBPREFIX . "component` (`id`, `name`, `type`) VALUES ('53', 'Downloads', 'module')");
        //update module name for frontend pages
        \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "content_page` SET `module` = 'Downloads' WHERE `module` = 'downloads'");
        //following queries for changing the path from images/downloads into images/Downloads
        \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "module_downloads_download`\n                                        SET `image` = REPLACE(`image`, 'images/downloads', 'images/Downloads')\n                                        WHERE `image` LIKE ('" . ASCMS_PATH_OFFSET . "/images/downloads%')");
        \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "module_downloads_category`\n                                        SET `image` = REPLACE(`image`, 'images/downloads', 'images/Downloads')\n                                        WHERE `image` LIKE ('" . ASCMS_PATH_OFFSET . "/images/downloads%')");
        \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "module_downloads_download_locale`\n                                        SET `source` = REPLACE(`source`, 'images/downloads', 'images/Downloads')\n                                        WHERE `source` LIKE ('" . ASCMS_PATH_OFFSET . "/images/downloads%')");
    } catch (\Cx\Lib\UpdateException $e) {
        return "Error: {$e->sql}";
    }
    $sourcePath = ASCMS_DOCUMENT_ROOT . '/images/downloads';
    $targetPath = ASCMS_DOCUMENT_ROOT . '/images/Downloads';
    try {
        if (file_exists($sourcePath) && !file_exists($targetPath)) {
            \Cx\Lib\FileSystem\FileSystem::makeWritable($sourcePath);
            if (!\Cx\Lib\FileSystem\FileSystem::move($sourcePath, $targetPath)) {
                return 'Failed to Moved the files from ' . $sourcePath . ' to ' . $targetPath . '.<br>';
            }
        }
    } catch (\Cx\Lib\FileSystem\FileSystemException $e) {
        return $e->getMessage();
    }
    return 'Downloads Updated successfully';
}
Exemple #3
0
function galleryUpdate()
{
    try {
        //update module name
        \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "modules` SET `name` = 'Gallery' WHERE `id` = 3");
        //update navigation url
        \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "backend_areas` SET `uri` = 'index.php?cmd=Gallery' WHERE `area_id` = 12");
        //Insert component entry
        \Cx\Lib\UpdateUtil::sql("INSERT INTO `" . DBPREFIX . "component` (`id`, `name`, `type`) VALUES ('3', 'Gallery', 'module')");
        //update module name for frontend pages
        \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "content_page` SET `module` = 'Gallery' WHERE `module` = 'gallery'");
    } catch (\Cx\Lib\UpdateException $e) {
        return "Error: {$e->sql}";
    }
    $sourcePath = ASCMS_DOCUMENT_ROOT . '/images/gallery';
    $targetPath = ASCMS_DOCUMENT_ROOT . '/images/Gallery';
    try {
        if (file_exists($sourcePath) && !file_exists($targetPath)) {
            \Cx\Lib\FileSystem\FileSystem::makeWritable($sourcePath);
            if (!\Cx\Lib\FileSystem\FileSystem::move($sourcePath, $targetPath)) {
                return 'Failed to Moved the files from ' . $sourcePath . ' to ' . $targetPath . '.<br>';
            }
        }
    } catch (\Cx\Lib\FileSystem\FileSystemException $e) {
        return $e->getMessage();
    }
    return 'Gallery Component Updated Successfully';
}
Exemple #4
0
function forumUpdates()
{
    //Update the database changes
    try {
        //update module name
        \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "modules` SET `name` = 'Forum' WHERE `id` = 20");
        //update navigation url
        \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "backend_areas` SET `uri` = 'index.php?cmd=Forum' WHERE `area_id` = 106");
        //Insert component entry
        \Cx\Lib\UpdateUtil::sql("INSERT INTO `" . DBPREFIX . "component` (`id`, `name`, `type`) VALUES ('20', 'Forum', 'module')");
        //update module name for frontend pages
        \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "content_page` SET `module` = 'Forum' WHERE `module` = 'forum'");
    } catch (\Cx\Lib\UpdateException $e) {
        return "Error: {$e->sql}";
    }
    //Update script for moving the folder
    $sourcePath = ASCMS_DOCUMENT_ROOT . '/media/forum';
    $destinationPath = ASCMS_DOCUMENT_ROOT . '/media/Forum';
    try {
        if (file_exists($sourcePath) && !file_exists($destinationPath)) {
            \Cx\Lib\FileSystem\FileSystem::makeWritable($sourcePath);
            if (!\Cx\Lib\FileSystem\FileSystem::move($sourcePath, $destinationPath)) {
                return 'Failed to move the folder from ' . $sourcePath . ' to ' . $destinationPath . '.';
            }
        }
    } catch (\Cx\Lib\FileSystem\FileSystemException $e) {
        return $e->getMessage();
    }
    return 'Forum updated successfully.';
}
Exemple #5
0
function fileSharingUpdate()
{
    try {
        //update module name
        \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "modules` SET `name` = 'FileSharing' WHERE `id` = 68");
        //update navigation url
        \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "backend_areas` SET `uri` = 'index.php?cmd=media&amp;archive=FileSharing' WHERE `area_id` = 187");
        //Insert component entry
        \Cx\Lib\UpdateUtil::sql("INSERT INTO `" . DBPREFIX . "component` (`id`, `name`, `type`) VALUES ('68', 'FileSharing', 'module')");
        //update module name for frontend pages
        \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "content_page` SET `module` = 'FileSharing' WHERE `module` = 'filesharing'");
        //update section
        \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "core_setting` SET `section` = 'FileSharing',`value` = 'on' WHERE\n                `section` = 'filesharing' AND `name` = 'permission' AND `group` = 'config'");
    } catch (\Cx\Lib\UpdateException $e) {
        return "Error: {$e->sql}";
    }
    $sourcePath = ASCMS_DOCUMENT_ROOT . '/media/filesharing';
    $targetPath = ASCMS_DOCUMENT_ROOT . '/media/FileSharing';
    try {
        if (file_exists($sourcePath) && !file_exists($targetPath)) {
            \Cx\Lib\FileSystem\FileSystem::makeWritable($sourcePath);
            if (!\Cx\Lib\FileSystem\FileSystem::move($sourcePath, $targetPath)) {
                return 'Failed to Moved the files from ' . $sourcePath . ' to ' . $targetPath . '.<br>';
            }
        }
    } catch (\Cx\Lib\FileSystem\FileSystemException $e) {
        return $e->getMessage();
    }
    return 'FileSharing updated successfully';
}
Exemple #6
0
function marketUpdates()
{
    //Update the database changes
    try {
        //update module name
        \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "modules` SET `name` = 'Market' WHERE `id` = 33");
        //update navigation url
        \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "backend_areas` SET `uri` = 'index.php?cmd=Market' WHERE `area_id` = 98");
        //Insert component entry
        \Cx\Lib\UpdateUtil::sql("INSERT INTO `" . DBPREFIX . "component` (`id`, `name`, `type`) VALUES ('33', 'Market', 'module')");
        //update module name for frontend pages
        \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "content_page` SET `module` = 'Market' WHERE `module` = 'market'");
    } catch (\Cx\Lib\UpdateException $e) {
        return "Error: {$e->sql}";
    }
    //Update script for moving the folder
    $marketMediaPath = ASCMS_DOCUMENT_ROOT . '/media';
    try {
        if (file_exists($marketMediaPath . '/market') && !file_exists($marketMediaPath . '/Market')) {
            \Cx\Lib\FileSystem\FileSystem::makeWritable($marketMediaPath . '/market');
            if (!\Cx\Lib\FileSystem\FileSystem::move($marketMediaPath . '/market', $marketMediaPath . '/Market')) {
                return 'Failed to move the folder from ' . $marketMediaPath . '/market to ' . $marketMediaPath . '/Market.';
            }
        }
    } catch (\Cx\Lib\FileSystem\FileSystemException $e) {
        return $e->getMessage();
    }
    return 'Market updated successfully.';
}
Exemple #7
0
function accessUpdates()
{
    //Update the database changes
    try {
        //update module name
        \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "modules` SET `name` = 'Access' WHERE `id` = 23");
        //update navigation url
        \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "backend_areas` SET `uri` = 'index.php?cmd=Access', `module_id` = '23' WHERE `area_id` = 18");
        \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "backend_areas` SET `uri` = 'index.php?cmd=Access' WHERE `area_id` = 208");
        //Insert component entry
        \Cx\Lib\UpdateUtil::sql("INSERT INTO `" . DBPREFIX . "component` (`id`, `name`, `type`) VALUES ('23', 'Access', 'core_module')");
        //update module name for frontend pages
        \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "content_page` SET `module` = 'Access' WHERE `module` = 'access'");
        //update module name for crm core settings
        \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "core_setting` SET `section` = 'Access' WHERE `section` = 'access' AND `name` = 'providers' AND `group` = 'sociallogin'");
    } catch (\Cx\Lib\UpdateException $e) {
        return "Error: {$e->sql}";
    }
    //Update script for moving the folder
    $accessImgPath = ASCMS_DOCUMENT_ROOT . '/images';
    try {
        if (file_exists($accessImgPath . '/access') && !file_exists($accessImgPath . '/Access')) {
            \Cx\Lib\FileSystem\FileSystem::makeWritable($accessImgPath . '/access');
            if (!\Cx\Lib\FileSystem\FileSystem::move($accessImgPath . '/access', $accessImgPath . '/Access')) {
                return 'Failed to move the folder from ' . $accessImgPath . '/access to ' . $accessImgPath . '/Access.';
            }
        }
    } catch (\Cx\Lib\FileSystem\FileSystemException $e) {
        return $e->getMessage();
    }
    return 'Access updated successfully.';
}
Exemple #8
0
function _podcastUpdate()
{
    global $objDatabase, $_ARRAYLANG, $objUpdate, $_CONFIG;
    //move podcast images directory
    $path = ASCMS_DOCUMENT_ROOT . '/images';
    $oldImagesPath = '/content/podcast';
    $newImagesPath = '/podcast';
    if ($objUpdate->_isNewerVersion($_CONFIG['coreCmsVersion'], '1.2.1')) {
        if (!file_exists($path . $newImagesPath) && file_exists($path . $oldImagesPath)) {
            \Cx\Lib\FileSystem\FileSystem::makeWritable($path . $oldImagesPath);
            if (!\Cx\Lib\FileSystem\FileSystem::copy_folder($path . $oldImagesPath, $path . $newImagesPath)) {
                setUpdateMsg(sprintf($_ARRAYLANG['TXT_UNABLE_TO_MOVE_DIRECTORY'], $path . $oldImagesPath, $path . $newImagesPath));
                return false;
            }
        }
        \Cx\Lib\FileSystem\FileSystem::makeWritable($path . $newImagesPath);
        \Cx\Lib\FileSystem\FileSystem::makeWritable($path . $newImagesPath . '/youtube_thumbnails');
        //change thumbnail paths
        $query = "UPDATE `" . DBPREFIX . "module_podcast_medium` SET `thumbnail` = REPLACE(`thumbnail`, '/images/content/podcast/', '/images/podcast/')";
        if ($objDatabase->Execute($query) === false) {
            return _databaseError($query, $objDatabase->ErrorMsg());
        }
    }
    //set new default settings
    $query = "UPDATE `" . DBPREFIX . "module_podcast_settings` SET `setvalue` = '50' WHERE `setname` = 'thumb_max_size' AND `setvalue` = ''";
    if ($objDatabase->Execute($query) === false) {
        return _databaseError($query, $objDatabase->ErrorMsg());
    }
    $query = "UPDATE `" . DBPREFIX . "module_podcast_settings` SET `setvalue` = '85' WHERE `setname` = 'thumb_max_size_homecontent' AND `setvalue` = ''";
    if ($objDatabase->Execute($query) === false) {
        return _databaseError($query, $objDatabase->ErrorMsg());
    }
    // only update if installed version is at least a version 2.0.0
    // older versions < 2.0 have a complete other structure of the content page and must therefore completely be reinstalled
    if (!$objUpdate->_isNewerVersion($_CONFIG['coreCmsVersion'], '2.0.0')) {
        try {
            // migrate content page to version 3.0.1
            $search = array('/(.*)/ms');
            $callback = function ($matches) {
                $content = $matches[1];
                if (empty($content)) {
                    return $content;
                }
                // add missing placeholder {PODCAST_JAVASCRIPT}
                if (strpos($content, '{PODCAST_JAVASCRIPT}') === false) {
                    $content .= "\n{PODCAST_JAVASCRIPT}";
                }
                // add missing placeholder {PODCAST_PAGING}
                if (strpos($content, '{PODCAST_PAGING}') === false) {
                    $content = preg_replace('/(\\s+)(<!--\\s+END\\s+podcast_media\\s+-->)/ms', '$1$2$1<div class="noMedium">$1    {PODCAST_PAGING}$1</div>', $content);
                }
                return $content;
            };
            \Cx\Lib\UpdateUtil::migrateContentPageUsingRegexCallback(array('module' => 'podcast'), $search, $callback, array('content'), '3.0.1');
        } catch (\Cx\Lib\UpdateException $e) {
            return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
        }
    }
    return true;
}
Exemple #9
0
function ecardUpdates()
{
    //Update database changes
    try {
        //update module name
        \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "modules` SET `name` = 'Ecard' WHERE `id` = 49");
        //update navigation url
        \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "backend_areas` SET `uri` = 'index.php?cmd=Ecard' WHERE `area_id` = 130");
        //Insert component entry
        \Cx\Lib\UpdateUtil::sql("INSERT INTO `" . DBPREFIX . "component` (`id`, `name`, `type`) VALUES ('49', 'Ecard', 'module')");
        //update module name for frontend pages
        \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "content_page` SET `module` = 'Ecard' WHERE `module` = 'ecard'");
    } catch (\Cx\Lib\UpdateException $e) {
        return "Error: {$e->sql}";
    }
    //Update script for moving the folders
    $imgModulesfolderPath = ASCMS_DOCUMENT_ROOT . '/images/modules/ecard';
    $mediafolderPath = ASCMS_DOCUMENT_ROOT . '/media/Ecard';
    try {
        if (!file_exists($mediafolderPath)) {
            \Cx\Lib\FileSystem\FileSystem::make_folder($mediafolderPath);
            \Cx\Lib\FileSystem\FileSystem::makeWritable($mediafolderPath);
        }
        //move the folder from '/images/modules/ecard/ecards_optimized' to '/media/Ecard/ecards_optimized'
        if (file_exists($imgModulesfolderPath . '/ecards_optimized') && !file_exists($mediafolderPath . '/ecards_optimized')) {
            \Cx\Lib\FileSystem\FileSystem::makeWritable($imgModulesfolderPath . '/ecards_optimized');
            if (!\Cx\Lib\FileSystem\FileSystem::move($imgModulesfolderPath . '/ecards_optimized', $mediafolderPath . '/ecards_optimized')) {
                return 'Failed to Move the folders from ' . $imgModulesfolderPath . '/ecards_optimized to ' . $mediafolderPath . '/ecards_optimized.';
            }
        }
        //move the folder from '/images/modules/ecard/send_ecards' to '/media/Ecard/send_ecards'
        if (file_exists($imgModulesfolderPath . '/send_ecards') && !file_exists($mediafolderPath . '/send_ecards')) {
            \Cx\Lib\FileSystem\FileSystem::makeWritable($imgModulesfolderPath . '/send_ecards');
            if (!\Cx\Lib\FileSystem\FileSystem::move($imgModulesfolderPath . '/send_ecards', $mediafolderPath . '/send_ecards')) {
                return 'Failed to Move the folders from ' . $imgModulesfolderPath . '/send_ecards to ' . $mediafolderPath . '/send_ecards.';
            }
        }
        //move the folder from '/images/modules/ecard/thumbnails' to '/media/Ecard/thumbnails'
        if (file_exists($imgModulesfolderPath . '/thumbnails') && !file_exists($mediafolderPath . '/thumbnails')) {
            \Cx\Lib\FileSystem\FileSystem::makeWritable($imgModulesfolderPath . '/thumbnails');
            if (!\Cx\Lib\FileSystem\FileSystem::move($imgModulesfolderPath . '/thumbnails', $mediafolderPath . '/thumbnails')) {
                return 'Failed to Move the folders from ' . $imgModulesfolderPath . '/thumbnails to ' . $mediafolderPath . '/thumbnails.';
            }
        }
        return 'Successfully updated.';
    } catch (\Cx\Lib\FileSystem\FileSystemException $e) {
        return $e->getMessage();
    }
}
Exemple #10
0
 protected function initContrexxCaching()
 {
     global $_CONFIG;
     // in case the request's origin is from a mobile devie
     // and this is the first request (the InitCMS object wasn't yet
     // able to determine of the mobile device wishes to be served
     // with the system's mobile view), we shall deactivate the caching system
     if (\InitCMS::_is_mobile_phone() && !\InitCMS::_is_tablet() && !isset($_REQUEST['smallscreen'])) {
         $this->boolIsEnabled = false;
         return;
     }
     if ($_CONFIG['cacheEnabled'] == 'off') {
         $this->boolIsEnabled = false;
         return;
     }
     if (isset($_REQUEST['caching']) && $_REQUEST['caching'] == '0') {
         $this->boolIsEnabled = false;
         return;
     }
     // TODO: Reimplement - see #1205
     /*if ($this->isException()) {
           $this->boolIsEnabled = false;
           return;
       }*/
     $this->boolIsEnabled = true;
     // check the cache directory
     if (!is_dir(ASCMS_CACHE_PATH)) {
         \Cx\Lib\FileSystem\FileSystem::make_folder(ASCMS_CACHE_PATH);
     }
     if (!is_writable(ASCMS_CACHE_PATH)) {
         \Cx\Lib\FileSystem\FileSystem::makeWritable(ASCMS_CACHE_PATH);
     }
     $this->strCachePath = ASCMS_CACHE_PATH . '/';
     $this->intCachingTime = intval($_CONFIG['cacheExpiration']);
     // Use data of $_GET and $_POST to uniquely identify a request.
     // Important: You must not use $_REQUEST instead. $_REQUEST also contains
     //            the data of $_COOKIE. Whereas the cookie information might
     //            change in each request, which might break the caching-
     //            system.
     $request = array_merge_recursive($_GET, $_POST);
     ksort($request);
     $this->arrPageContent = array('url' => $_SERVER['REQUEST_URI'], 'request' => $request);
     $this->strCacheFilename = md5(serialize($this->arrPageContent));
 }
Exemple #11
0
function _ecardUpdate()
{
    global $objDatabase, $_ARRAYLANG, $_CORELANG;
    try {
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_ecard_ecards', array('code' => array('type' => 'VARCHAR(35)', 'notnull' => true, 'default' => '', 'primary' => true), 'date' => array('type' => 'INT(10)', 'notnull' => true, 'default' => 0, 'unsigned' => true), 'TTL' => array('type' => 'INT(10)', 'notnull' => true, 'default' => 0, 'unsigned' => true), 'salutation' => array('type' => 'VARCHAR(100)', 'notnull' => true, 'default' => ''), 'senderName' => array('type' => 'VARCHAR(100)', 'notnull' => true, 'default' => ''), 'senderEmail' => array('type' => 'VARCHAR(100)', 'notnull' => true, 'default' => ''), 'recipientName' => array('type' => 'VARCHAR(100)', 'notnull' => true, 'default' => ''), 'recipientEmail' => array('type' => 'VARCHAR(100)', 'notnull' => true, 'default' => ''), 'message' => array('type' => 'TEXT', 'notnull' => true)));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_ecard_settings', array('setting_name' => array('type' => 'VARCHAR(100)', 'notnull' => true, 'default' => '', 'primary' => true), 'setting_value' => array('type' => 'TEXT', 'notnull' => true, 'default' => 0)));
    } catch (\Cx\Lib\UpdateException $e) {
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    $ins_tpl = "\n        INSERT INTO " . DBPREFIX . "module_ecard_settings (setting_name, setting_value)\n        VALUES ('%s', '%s')\n        ON DUPLICATE KEY UPDATE `setting_name` = `setting_name`\n    ";
    $insert_values = array(array('maxCharacters', '100'), array('maxLines', '50'), array('motive_0', 'Bild_001.jpg'), array('motive_1', 'Bild_002.jpg'), array('motive_2', ''), array('motive_3', ''), array('motive_4', ''), array('motive_5', ''), array('motive_6', ''), array('motive_7', ''), array('motive_8', ''), array('maxHeight', '300'), array('validdays', '30'), array('maxWidth', '300'), array('maxHeightThumb', '80'), array('maxWidthThumb', '80'), array('subject', 'Sie haben eine E-Card erhalten!'), array('emailText', "[[ECARD_SENDER_NAME]] hat Ihnen eine E-Card geschickt.<br />\n Sie können diese während den nächsten [[ECARD_VALID_DAYS]] Tagen unter [[ECARD_URL]] abrufen."));
    foreach ($insert_values as $setting) {
        $query = sprintf($ins_tpl, addslashes($setting[0]), addslashes($setting[1]));
        if (!$objDatabase->Execute($query)) {
            return _databaseError($query, $objDatabase->ErrorMsg());
        }
    }
    /*     * **********************************************
     * BUGFIX:	Set write access to the image dir   *
     * ********************************************** */
    $arrImagePaths = array(array(ASCMS_DOCUMENT_ROOT . '/images/modules/ecard', ASCMS_PATH_OFFSET . '/images/modules/ecard'), array(ASCMS_ECARD_OPTIMIZED_PATH, ASCMS_ECARD_OPTIMIZED_WEB_PATH), array(ASCMS_ECARD_SEND_ECARDS_PATH, ASCMS_ECARD_SEND_ECARDS_WEB_PATH), array(ASCMS_ECARD_THUMBNAIL_PATH, ASCMS_ECARD_THUMBNAIL_WEB_PATH));
    foreach ($arrImagePaths as $arrImagePath) {
        if (\Cx\Lib\FileSystem\FileSystem::makeWritable($arrImagePath[0])) {
            if ($mediaDir = @opendir($arrImagePath[0])) {
                while ($file = readdir($mediaDir)) {
                    if ($file != '.' && $file != '..') {
                        if (!\Cx\Lib\FileSystem\FileSystem::makeWritable($arrImagePath[0] . '/' . $file)) {
                            setUpdateMsg(sprintf($_ARRAYLANG['TXT_SET_WRITE_PERMISSON_TO_FILE'], $arrImagePath[0] . '/' . $file, $_CORELANG['TXT_UPDATE_TRY_AGAIN']), 'msg');
                            return false;
                        }
                    }
                }
            } else {
                setUpdateMsg(sprintf($_ARRAYLANG['TXT_SET_WRITE_PERMISSON_TO_DIR_AND_CONTENT'], $arrImagePath[0] . '/', $_CORELANG['TXT_UPDATE_TRY_AGAIN']), 'msg');
                return false;
            }
        } else {
            setUpdateMsg(sprintf($_ARRAYLANG['TXT_SET_WRITE_PERMISSON_TO_DIR_AND_CONTENT'], $arrImagePath[0] . '/', $_CORELANG['TXT_UPDATE_TRY_AGAIN']), 'msg');
            return false;
        }
    }
    return true;
}
Exemple #12
0
function crmUpdates()
{
    //Update the database changes
    try {
        //update module name
        \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "modules` SET `name` = 'Crm' WHERE `id` = 69");
        //update navigation url
        \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "backend_areas` SET `uri` = 'index.php?cmd=Crm&act=customers' WHERE `area_id` = 191");
        \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "backend_areas` SET `uri` = 'index.php?cmd=Crm&act=task' WHERE `area_id` = 192");
        \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "backend_areas` SET `uri` = 'index.php?cmd=Crm&act=deals' WHERE `area_id` = 193");
        \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "backend_areas` SET `uri` = 'index.php?cmd=Crm&act=settings' WHERE `area_id` = 195");
        //Insert component entry
        \Cx\Lib\UpdateUtil::sql("INSERT INTO `" . DBPREFIX . "component` (`id`, `name`, `type`) VALUES ('69', 'Crm', 'module')");
        //update module name for email templates
        \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "core_mail_template` SET `section` = 'Crm' WHERE `section` = 'crm'");
        \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "core_text` SET `section` = 'Crm' WHERE `section` = 'crm'");
        //update module name for crm core settings
        \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "core_setting` SET `section` = 'Crm' WHERE `section` = 'crm'");
    } catch (\Cx\Lib\UpdateException $e) {
        return "Error: {$e->sql}";
    }
    //Update script for moving the folder
    $crmImgPath = ASCMS_DOCUMENT_ROOT . '/images';
    $crmMediaPath = ASCMS_DOCUMENT_ROOT . '/media';
    try {
        if (file_exists($crmImgPath . '/crm') && !file_exists($crmImgPath . '/Crm')) {
            \Cx\Lib\FileSystem\FileSystem::makeWritable($crmImgPath . '/crm');
            if (!\Cx\Lib\FileSystem\FileSystem::move($crmImgPath . '/crm', $crmImgPath . '/Crm')) {
                return 'Failed to move the folder from ' . $crmImgPath . '/crm to ' . $crmImgPath . '/Crm.';
            }
        }
        if (file_exists($crmMediaPath . '/crm') && !file_exists($crmMediaPath . '/Crm')) {
            \Cx\Lib\FileSystem\FileSystem::makeWritable($crmMediaPath . '/crm');
            if (!\Cx\Lib\FileSystem\FileSystem::move($crmMediaPath . '/crm', $crmMediaPath . '/Crm')) {
                return 'Failed to move the folder from ' . $crmMediaPath . '/crm to ' . $crmMediaPath . '/Crm.';
            }
        }
    } catch (\Cx\Lib\FileSystem\FileSystemException $e) {
        return $e->getMessage();
    }
    return 'Crm updated successfully.';
}
Exemple #13
0
function shopUpdates()
{
    //Update the database changes
    try {
        //update module name
        \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "modules` SET `name` = 'Shop' WHERE `id` = 16");
        //update navigation url
        \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "backend_areas` SET `uri` = 'index.php?cmd=Shop' WHERE `area_id` = 13");
        //Insert component entry
        \Cx\Lib\UpdateUtil::sql("INSERT INTO `" . DBPREFIX . "component` (`id`, `name`, `type`) VALUES ('16', 'Shop', 'module')");
        //update module name for frontend pages
        \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "content_page` SET `module` = 'Shop' WHERE `module` = 'shop'");
        //update module name for crm core settings
        \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "core_setting` SET `section` = 'Shop' WHERE `section` = 'shop'");
        //update module name for email templates
        \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "core_mail_template` SET `section` = 'Shop' WHERE `section` = 'shop'");
        \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "core_text` SET `section` = 'Shop' WHERE `section` = 'shop'");
    } catch (\Cx\Lib\UpdateException $e) {
        return "Error: {$e->sql}";
    }
    //Update script for moving the folder
    $shopImgPath = ASCMS_DOCUMENT_ROOT . '/images';
    $shopMediaPath = ASCMS_DOCUMENT_ROOT . '/media';
    try {
        if (file_exists($shopImgPath . '/shop') && !file_exists($shopImgPath . '/Shop')) {
            \Cx\Lib\FileSystem\FileSystem::makeWritable($shopImgPath . '/shop');
            if (!\Cx\Lib\FileSystem\FileSystem::move($shopImgPath . '/shop', $shopImgPath . '/Shop')) {
                return 'Failed to move the folder from ' . $shopImgPath . '/shop to ' . $shopImgPath . '/Shop.';
            }
        }
        if (file_exists($shopMediaPath . '/shop') && !file_exists($shopMediaPath . '/Shop')) {
            \Cx\Lib\FileSystem\FileSystem::makeWritable($shopMediaPath . '/shop');
            if (!\Cx\Lib\FileSystem\FileSystem::move($shopMediaPath . '/shop', $shopMediaPath . '/Shop')) {
                return 'Failed to move the folder from ' . $shopMediaPath . '/shop to ' . $shopMediaPath . '/Shop.';
            }
        }
    } catch (\Cx\Lib\FileSystem\FileSystemException $e) {
        return $e->getMessage();
    }
    return 'Shop updated successfully.';
}
Exemple #14
0
function mediaDirUpdate()
{
    try {
        //update module name
        \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "modules` SET `name` = 'MediaDir' WHERE `id` = 60");
        //update navigation url
        \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "backend_areas` SET `uri` = 'index.php?cmd=MediaDir' WHERE `area_id` = 153");
        //Insert component entry
        \Cx\Lib\UpdateUtil::sql("INSERT INTO `" . DBPREFIX . "component` (`id`, `name`, `type`) VALUES ('60', 'MediaDir', 'module')");
        //update module name for frontend pages
        \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "content_page` SET `module` = 'MediaDir' WHERE `module` = 'mediadir'");
        //update class name
        \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "module_mediadir_inputfield_types` SET `name` = 'linkGroup' WHERE `name` = 'link_group'");
        \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "module_mediadir_inputfield_types` SET `name` = 'googleMap' WHERE `name` = 'google_map'");
        \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "module_mediadir_inputfield_types` SET `name` = 'addStep' WHERE `name` = 'add_step'");
        \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "module_mediadir_inputfield_types` SET `name` = 'fieldGroup' WHERE `name` = 'field_group'");
        \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "module_mediadir_inputfield_types` SET `name` = 'productAttributes' WHERE `name` = 'product_attributes'");
        \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "module_mediadir_inputfield_types` SET `name` = 'googleWeather' WHERE `name` = 'google_weather'");
        //following queries for changing the path from images/mediadir into images/MediaDir
        \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "module_mediadir_categories` \n                                        SET `picture` = REPLACE(`picture`, 'images/mediadir', 'images/MediaDir')\n                                        WHERE `picture` LIKE ('" . ASCMS_PATH_OFFSET . "/images/mediadir%')");
        \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "module_mediadir_forms` \n                                        SET `picture` = REPLACE(`picture`, 'images/mediadir', 'images/MediaDir')\n                                        WHERE `picture` LIKE ('" . ASCMS_PATH_OFFSET . "/images/mediadir%')");
        \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "module_mediadir_levels` \n                                        SET `picture` = REPLACE(`picture`, 'images/mediadir', 'images/MediaDir')\n                                        WHERE `picture` LIKE ('" . ASCMS_PATH_OFFSET . "/images/mediadir%')");
        \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "module_mediadir_rel_entry_inputfields` \n                                        SET `value` = REPLACE(`value`, 'images/mediadir', 'images/MediaDir')\n                                        WHERE `value` LIKE ('" . ASCMS_PATH_OFFSET . "/images/mediadir%')");
        \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "module_mediadir_rel_entry_inputfields_clean1` \n                                        SET `value` = REPLACE(`value`, 'images/mediadir', 'images/MediaDir')\n                                        WHERE `value` LIKE ('" . ASCMS_PATH_OFFSET . "/images/mediadir%')");
    } catch (\Cx\Lib\UpdateException $e) {
        return "Error: {$e->sql}";
    }
    $sourcePath = ASCMS_DOCUMENT_ROOT . '/images/mediadir';
    $targetPath = ASCMS_DOCUMENT_ROOT . '/images/MediaDir';
    try {
        if (file_exists($sourcePath) && !file_exists($targetPath)) {
            \Cx\Lib\FileSystem\FileSystem::makeWritable($sourcePath);
            if (!\Cx\Lib\FileSystem\FileSystem::move($sourcePath, $targetPath)) {
                return 'Failed to Moved the files from ' . $sourcePath . ' to ' . $targetPath . '.<br>';
            }
        }
    } catch (\Cx\Lib\FileSystem\FileSystemException $e) {
        return $e->getMessage();
    }
    return 'Media Directory Updated Successfully';
}
Exemple #15
0
function blogUpdates()
{
    //Update the database changes
    try {
        //update module name
        \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "modules` SET `name` = 'Blog' WHERE `id` = 47");
        //update navigation url
        \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "backend_areas` SET `uri` = 'index.php?cmd=Blog' WHERE `area_id` = 119");
        \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "backend_areas` SET `uri` = 'index.php?cmd=Blog&act=manageEntry' WHERE `area_id` = 120");
        \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "backend_areas` SET `uri` = 'index.php?cmd=Blog&act=addEntry' WHERE `area_id` = 121");
        \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "backend_areas` SET `uri` = 'index.php?cmd=Blog&act=manageCategory' WHERE `area_id` = 122");
        \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "backend_areas` SET `uri` = 'index.php?cmd=Blog&act=addCategory' WHERE `area_id` = 123");
        \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "backend_areas` SET `uri` = 'index.php?cmd=Blog&act=settings' WHERE `area_id` = 124");
        \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "backend_areas` SET `uri` = 'index.php?cmd=Blog&act=networks' WHERE `area_id` = 125");
        //Insert component entry
        \Cx\Lib\UpdateUtil::sql("INSERT INTO `" . DBPREFIX . "component` (`id`, `name`, `type`) VALUES ('47', 'Blog', 'module')");
        //update module name for frontend pages
        \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "content_page` SET `module` = 'Blog' WHERE `module` = 'blog'");
        //following queries for changing the path from images/blog into images/Blog
        \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "module_blog_messages_lang` \n                                        SET `image` = REPLACE(`image`, 'images/blog', 'images/Blog')\n                                        WHERE `image` LIKE ('" . ASCMS_PATH_OFFSET . "/images/blog%')");
        \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "module_blog_networks` \n                                        SET `icon` = REPLACE(`icon`, 'images/blog', 'images/Blog')\n                                        WHERE `icon` LIKE ('" . ASCMS_PATH_OFFSET . "/images/blog%')");
    } catch (\Cx\Lib\UpdateException $e) {
        return "Error: {$e->sql}";
    }
    //Update script for moving the folder
    $blogImgPath = ASCMS_DOCUMENT_ROOT . '/images';
    try {
        if (file_exists($blogImgPath . '/blog') && !file_exists($blogImgPath . '/Blog')) {
            \Cx\Lib\FileSystem\FileSystem::makeWritable($blogImgPath . '/blog');
            if (!\Cx\Lib\FileSystem\FileSystem::move($blogImgPath . '/blog', $blogImgPath . '/Blog')) {
                return 'Failed to move the folder from ' . $blogImgPath . '/blog to ' . $blogImgPath . '/Blog.';
            }
        }
    } catch (\Cx\Lib\FileSystem\FileSystemException $e) {
        return $e->getMessage();
    }
    return 'Blog updated successfully.';
}
Exemple #16
0
function podcastUpdate()
{
    try {
        // Update module name
        \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "modules` SET `name` = 'Podcast' WHERE `id` = 35");
        // Update navigation url value
        \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "backend_areas` SET `uri` = 'index.php?cmd=Podcast' WHERE `area_id` = 93");
        // Insert entry for component
        \Cx\Lib\UpdateUtil::sql("INSERT INTO `" . DBPREFIX . "component` (`id`, `name`, `type`) VALUES ('35', 'Podcast', 'module')");
        // Update module name for frontend pages
        \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "content_page` SET `module` = 'Podcast' WHERE `module` = 'podcast'");
        // Update the thumbnail path from images/podcast into images/Podcast
        \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "module_podcast_medium`\n                                        SET `thumbnail` = REPLACE(`thumbnail`, 'images/podcast', 'images/Podcast')\n                                        WHERE `thumbnail` LIKE ('" . ASCMS_PATH_OFFSET . "/images/podcast%')");
    } catch (\Cx\Lib\UpdateException $e) {
        return "Error: {$e->sql}";
    }
    //Update script for moving the folder
    $imgPath = ASCMS_DOCUMENT_ROOT . '/images';
    $mediaPath = ASCMS_DOCUMENT_ROOT . '/media';
    try {
        if (file_exists($imgPath . '/podcast') && !file_exists($imgPath . '/Podcast')) {
            \Cx\Lib\FileSystem\FileSystem::makeWritable($imgPath . '/podcast');
            if (!\Cx\Lib\FileSystem\FileSystem::move($imgPath . '/podcast', $imgPath . '/Podcast')) {
                return 'Failed to move the folder from ' . $imgPath . '/podcast to ' . $imgPath . '/Podcast.';
            }
        }
        if (file_exists($mediaPath . '/podcast') && !file_exists($mediaPath . '/Podcast')) {
            \Cx\Lib\FileSystem\FileSystem::makeWritable($mediaPath . '/podcast');
            if (!\Cx\Lib\FileSystem\FileSystem::move($mediaPath . '/podcast', $mediaPath . '/Podcast')) {
                return 'Failed to move the folder from ' . $mediaPath . '/podcast to ' . $mediaPath . '/Podcast.';
            }
        }
    } catch (\Cx\Lib\FileSystem\FileSystemException $e) {
        return $e->getMessage();
    }
    return 'Podcast Component database updated successfully';
}
Exemple #17
0
function _memberdirUpdate()
{
    global $objDatabase, $_ARRAYLANG, $_CORELANG;
    try {
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_memberdir_directories', array('dirid' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'parentdir' => array('type' => 'INT(11)', 'notnull' => true, 'default' => '0'), 'active' => array('type' => 'SET(\'1\',\'0\')', 'notnull' => true, 'default' => '1'), 'name' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => ''), 'description' => array('type' => 'TEXT'), 'displaymode' => array('type' => 'SET(\'0\',\'1\',\'2\')', 'notnull' => true, 'default' => '0'), 'sort' => array('type' => 'INT(11)', 'notnull' => true, 'default' => '1'), 'pic1' => array('type' => 'SET(\'1\',\'0\')', 'notnull' => true, 'default' => '0'), 'pic2' => array('type' => 'SET(\'1\',\'0\')', 'notnull' => true, 'default' => '0'), 'lang_id' => array('type' => 'INT(2)', 'unsigned' => true, 'notnull' => true, 'default' => '1')), array('memberdir_dir' => array('fields' => array('name', 'description'), 'type' => 'FULLTEXT')));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_memberdir_name', array('field' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'dirid' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'name' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => ''), 'active' => array('type' => 'SET(\'0\',\'1\')', 'notnull' => true, 'default' => ''), 'lang_id' => array('type' => 'INT(2)', 'unsigned' => true, 'notnull' => true, 'default' => '1')));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_memberdir_settings', array('setid' => array('type' => 'INT(4)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'setname' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => ''), 'setvalue' => array('type' => 'TEXT'), 'lang_id' => array('type' => 'INT(2)', 'unsigned' => true, 'notnull' => true, 'default' => '1')));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_memberdir_values', array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'dirid' => array('type' => 'INT(14)', 'notnull' => true, 'default' => '0'), 'pic1' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => ''), 'pic2' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => ''), '0' => array('type' => 'SMALLINT(5)', 'notnull' => true, 'unsigned' => true, 'default' => '0'), '1' => array('type' => 'TEXT'), '2' => array('type' => 'TEXT'), '3' => array('type' => 'TEXT'), '4' => array('type' => 'TEXT'), '5' => array('type' => 'TEXT'), '6' => array('type' => 'TEXT'), '7' => array('type' => 'TEXT'), '8' => array('type' => 'TEXT'), '9' => array('type' => 'TEXT'), '10' => array('type' => 'TEXT'), '11' => array('type' => 'TEXT'), '12' => array('type' => 'TEXT'), '13' => array('type' => 'TEXT'), '14' => array('type' => 'TEXT'), '15' => array('type' => 'TEXT'), '16' => array('type' => 'TEXT'), '17' => array('type' => 'TEXT'), '18' => array('type' => 'TEXT'), 'lang_id' => array('type' => 'INT(2)', 'unsigned' => true, 'notnull' => true, 'default' => '1')));
        $arrSettings = array('default_listing' => array('1', '1'), 'max_height' => array('400', '1'), 'max_width' => array('500', '1'));
        foreach ($arrSettings as $key => $arrSetting) {
            if (!\Cx\Lib\UpdateUtil::sql("SELECT 1 FROM `" . DBPREFIX . "module_memberdir_settings` WHERE `setname` = '" . $key . "'")->RecordCount()) {
                \Cx\Lib\UpdateUtil::sql("INSERT INTO `" . DBPREFIX . "module_memberdir_settings`\n                    SET `setname`    = '" . $key . "',\n                        `setvalue`   = '" . $arrSetting[0] . "',\n                        `lang_id`    = '" . $arrSetting[1] . "'\n                ");
            }
        }
    } catch (\Cx\Lib\UpdateException $e) {
        // we COULD do something else here..
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    if (!\Cx\Lib\FileSystem\FileSystem::makeWritable(ASCMS_MEDIA_PATH . '/memberdir')) {
        setUpdateMsg(sprintf($_ARRAYLANG['TXT_SET_WRITE_PERMISSON_TO_DIR_AND_CONTENT'], ASCMS_MEDIA_PATH . '/memberdir/', $_CORELANG['TXT_UPDATE_TRY_AGAIN']), 'msg');
        return false;
    }
    return true;
}
Exemple #18
0
 /**
  * Handle uploads
  * @see Contact::_uploadFilesLegacy()
  * @param array $arrFields
  * @param boolean move should the files be moved or
  *                do we just want an array of filenames?
  *                defaults to false. no effect in legacy mode.
  * @return array A list of files that have been stored successfully in the system
  */
 protected function _uploadFiles($arrFields, $move = false)
 {
     /* the field unique_id has been introduced with the new uploader.
      * it helps us to tell whether we're handling an form generated
      * before the new uploader using the classic input fields or
      * if we have to treat the files already uploaded by the uploader.
      */
     if ($this->legacyMode) {
         //legacy function for old uploader
         return $this->_uploadFilesLegacy($arrFields);
     } else {
         //new uploader used
         if (!$this->hasFileField) {
             //nothing to do for us, no files
             return array();
         }
         $arrFiles = array();
         //we'll collect name => path of all files here and return this
         $documentRootPath = \Env::get('cx')->getWebsiteDocumentRootPath();
         foreach ($arrFields as $fieldId => $arrField) {
             // skip non-upload fields
             if (!in_array($arrField['type'], array('file', 'multi_file'))) {
                 continue;
             }
             $tup = self::getTemporaryUploadPath($this->submissionId, $fieldId);
             $tmpUploadDir = $tup[1] . '/' . $tup[2] . '/';
             //all the files uploaded are in here
             $depositionTarget = "";
             //target folder
             //on the first call, _uploadFiles is called with move=false.
             //this is done in order to get an array of the moved files' names, but
             //the files are left in place.
             //the second call is done with move=true - here we finally move the
             //files.
             //
             //the target folder is created in the first call, because if we can't
             //create the folder, the target path is left pointing at the path
             //specified by $arrSettings['fileUploadDepositionPath'].
             //
             //to remember the target folder for the second call, it is stored in
             //$this->depositionTarget.
             if (!$move) {
                 //first call - create folder
                 //determine where form uploads are stored
                 $arrSettings = $this->getSettings();
                 $depositionTarget = $arrSettings['fileUploadDepositionPath'] . '/';
                 //find an unique folder name for the uploaded files
                 $folderName = date("Ymd") . '_' . $fieldId;
                 $suffix = "";
                 if (file_exists($documentRootPath . $depositionTarget . $folderName)) {
                     $suffix = 1;
                     while (file_exists($documentRootPath . $depositionTarget . $folderName . '-' . $suffix)) {
                         $suffix++;
                     }
                     $suffix = '-' . $suffix;
                 }
                 $folderName .= $suffix;
                 //try to make the folder and change target accordingly on success
                 if (\Cx\Lib\FileSystem\FileSystem::make_folder($documentRootPath . $depositionTarget . $folderName)) {
                     \Cx\Lib\FileSystem\FileSystem::makeWritable($documentRootPath . $depositionTarget . $folderName);
                     $depositionTarget .= $folderName . '/';
                 }
                 $this->depositionTarget[$fieldId] = $depositionTarget;
             } else {
                 $depositionTarget = $this->depositionTarget[$fieldId];
             }
             //move all files
             if (!\Cx\Lib\FileSystem\FileSystem::exists($tmpUploadDir)) {
                 throw new \Cx\Core_Modules\Contact\Controller\ContactException("could not find temporary upload directory '{$tmpUploadDir}'");
             }
             $h = opendir(\Env::get('cx')->getWebsitePath() . $tmpUploadDir);
             while (false !== ($f = readdir($h))) {
                 if ($f != '..' && $f != '.') {
                     //do not overwrite existing files.
                     $prefix = '';
                     while (file_exists($documentRootPath . $depositionTarget . $prefix . $f)) {
                         if (empty($prefix)) {
                             $prefix = 0;
                         }
                         $prefix++;
                     }
                     if ($move) {
                         // move file
                         try {
                             $objFile = new \Cx\Lib\FileSystem\File($tmpUploadDir . $f);
                             $objFile->move($documentRootPath . $depositionTarget . $prefix . $f, false);
                         } catch (\Cx\Lib\FileSystem\FileSystemException $e) {
                             \DBG::msg($e->getMessage());
                         }
                     }
                     $arrFiles[$fieldId][] = array('name' => $f, 'path' => $depositionTarget . $prefix . $f);
                 }
             }
         }
         //cleanup
         //TODO: this does not work for certain reloads - add cleanup routine
         //@rmdir($tmpUploadDir);
         return $arrFiles;
     }
 }
Exemple #19
0
 /**
  * Write all settings into the config-file
  *
  */
 function _createSettingsFile()
 {
     global $_ARRLANG;
     $objDb = $this->_getDbObject($statusMsg);
     if ($objDb === false) {
         return $statusMsg;
     } else {
         $strSettingsFile = $_SESSION['installer']['config']['documentRoot'] . $_SESSION['installer']['config']['offsetPath'] . '/config/settings.php';
         if (!\Cx\Lib\FileSystem\FileSystem::touch($strSettingsFile) || !\Cx\Lib\FileSystem\FileSystem::makeWritable($strSettingsFile)) {
             return sprintf($_ARRLANG['TXT_SETTINGS_ERROR_WRITABLE'], $strSettingsFile);
         }
         //Header & Footer
         $strHeader = "<?php\n";
         $strHeader .= "/**\n";
         $strHeader .= "* This file is generated by the \"settings\"-menu in your CMS.\n";
         $strHeader .= "* Do not try to edit it manually!\n";
         $strHeader .= "*/\n\n";
         $strFooter = "\n";
         //Get module-names
         $objResult = $objDb->Execute("SELECT id, name FROM `" . $_SESSION['installer']['config']['dbTablePrefix'] . "modules`");
         if ($objResult->RecordCount() > 0) {
             while (!$objResult->EOF) {
                 $arrModules[$objResult->fields['id']] = $objResult->fields['name'];
                 $objResult->MoveNext();
             }
         }
         //Get values
         $objResult = $objDb->Execute("SELECT setname, setmodule, setvalue FROM `" . $_SESSION['installer']['config']['dbTablePrefix'] . "settings` ORDER BY    setmodule ASC, setname ASC");
         $intMaxLen = 0;
         if ($objResult->RecordCount() > 0) {
             while (!$objResult->EOF) {
                 $intMaxLen = strlen($objResult->fields['setname']) > $intMaxLen ? strlen($objResult->fields['setname']) : $intMaxLen;
                 $arrValues[$objResult->fields['setmodule']][$objResult->fields['setname']] = $objResult->fields['setvalue'];
                 $objResult->MoveNext();
             }
         }
         $intMaxLen += strlen('$_CONFIG[\'\']') + 1;
         //needed for formatted output
         //Write values
         $data = $strHeader;
         $strBody = '';
         foreach ($arrValues as $intModule => $arrInner) {
             $strBody .= "/**\n";
             $strBody .= "* -------------------------------------------------------------------------\n";
             $strBody .= "* " . ucfirst(isset($arrModules[$intModule]) ? $arrModules[$intModule] : '') . "\n";
             $strBody .= "* -------------------------------------------------------------------------\n";
             $strBody .= "*/\n";
             foreach ($arrInner as $strName => $strValue) {
                 $strBody .= sprintf("%-" . $intMaxLen . "s", '$_CONFIG[\'' . $strName . '\']');
                 $strBody .= "= ";
                 $strBody .= (is_numeric($strValue) ? $strValue : '"' . str_replace('"', '\\"', $strValue) . '"') . ";\n";
             }
             $strBody .= "\n";
         }
         $data .= $strBody;
         $data .= $strFooter;
         try {
             $objFile = new \Cx\Lib\FileSystem\File($strSettingsFile);
             $objFile->write($data);
             return true;
         } catch (\Cx\Lib\FileSystem\FileSystemException $e) {
             DBG::msg($e->getMessage());
         }
         return false;
     }
 }
 public function delete()
 {
     \Cx\Lib\FileSystem\FileSystem::makeWritable(dirname($this->filePath));
     if (!unlink($this->filePath)) {
         throw new FileSystemFileException('Unable to delete file ' . $this->filePath . '!');
     }
 }
 /**
  * Prepare file access
  *
  * Creates the file specified by $path if it doesn't exist
  * and removes the write-protection mode on the file if there's one.
  *
  * @param string $path
  * @return boolean  Returns TRUE if the specified file exists and has no write-protection on it at the end. Returns FALSE if something fails.
  */
 private function prepareFileAccess($path)
 {
     $file = $this->document_root . $path;
     return (file_exists($file) || \Cx\Lib\FileSystem\FileSystem::touch($file)) && \Cx\Lib\FileSystem\FileSystem::makeWritable($file);
 }
Exemple #22
0
/**
 * Cloudrexx
 *
 * @link      http://www.cloudrexx.com
 * @copyright Cloudrexx AG 2007-2015
 *
 * According to our dual licensing model, this program can be used either
 * under the terms of the GNU Affero General Public License, version 3,
 * or under a proprietary license.
 *
 * The texts of the GNU Affero General Public License with an additional
 * permission and of our proprietary license can be found at and
 * in the LICENSE file you have received along with this program.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Affero General Public License for more details.
 *
 * "Cloudrexx" is a registered trademark of Cloudrexx AG.
 * The licensing of the program under the AGPLv3 does not imply a
 * trademark license. Therefore any rights, title and interest in
 * our trademarks remain entirely with us.
 */
function _downloadsUpdate()
{
    global $objDatabase, $_ARRAYLANG, $_CORELANG, $objUpdate, $_CONFIG;
    /************************************************
     * EXTENSION:    Initial creation of the         *
     *               database tables                 *
     * ADDED:        Contrexx v2.1.0                 *
     ************************************************/
    $arrTables = $objDatabase->MetaTables('TABLES');
    if (!sizeof($arrTables)) {
        setUpdateMsg($_ARRAYLANG['TXT_UNABLE_DETERMINE_DATABASE_STRUCTURE']);
        return false;
    }
    $tables = array(DBPREFIX . 'module_downloads_category' => "CREATE TABLE `" . DBPREFIX . "module_downloads_category` (\n             `id` int(11) unsigned NOT NULL auto_increment,\n             `parent_id` int(11) unsigned NOT NULL default '0',\n             `is_active` tinyint(1) unsigned NOT NULL default '1',\n             `visibility` tinyint(1) unsigned NOT NULL default '1',\n             `owner_id` int(5) unsigned NOT NULL default '0',\n             `order` int(3) unsigned NOT NULL default '0',\n             `deletable_by_owner` tinyint(1) unsigned NOT NULL default '1',\n             `modify_access_by_owner` tinyint(1) unsigned NOT NULL default '1',\n             `read_access_id` int(11) unsigned NOT NULL default '0',\n             `add_subcategories_access_id` int(11) unsigned NOT NULL default '0',\n             `manage_subcategories_access_id` int(11) unsigned NOT NULL default '0',\n             `add_files_access_id` int(11) unsigned NOT NULL default '0',\n             `manage_files_access_id` int(11) unsigned NOT NULL default '0',\n             `image` varchar(255) NOT NULL default '',\n              PRIMARY KEY (`id`),\n              KEY `is_active` (`is_active`),\n              KEY `visibility` (`visibility`)\n            ) ENGINE=MyISAM", DBPREFIX . 'module_downloads_category_locale' => "CREATE TABLE `" . DBPREFIX . "module_downloads_category_locale` (\n             `lang_id` int(11) unsigned NOT NULL default '0',\n             `category_id` int(11) unsigned NOT NULL default '0',\n             `name` varchar(255) NOT NULL default '',\n             `description` text NOT NULL,\n              PRIMARY KEY (`lang_id`,`category_id`),\n              FULLTEXT KEY `name` (`name`),\n              FULLTEXT KEY `description` (`description`)\n            ) ENGINE=MyISAM", DBPREFIX . 'module_downloads_download_locale' => "CREATE TABLE `" . DBPREFIX . "module_downloads_download_locale` (\n             `lang_id` int(11) unsigned NOT NULL default '0',\n             `download_id` int(11) unsigned NOT NULL default '0',\n             `name` varchar(255) NOT NULL default '',\n             `description` text NOT NULL,\n              PRIMARY KEY (`lang_id`,`download_id`),\n              FULLTEXT KEY `name` (`name`),\n              FULLTEXT KEY `description` (`description`)\n            ) ENGINE=MyISAM", DBPREFIX . 'module_downloads_rel_download_category' => "CREATE TABLE `" . DBPREFIX . "module_downloads_rel_download_category` (\n             `download_id` int(10) unsigned NOT NULL default '0',\n             `category_id` int(10) unsigned NOT NULL default '0',\n             `order` int(3) unsigned NOT NULL default '0',\n              PRIMARY KEY (`download_id`,`category_id`)\n            ) ENGINE=MyISAM", DBPREFIX . 'module_downloads_rel_download_download' => "CREATE TABLE `" . DBPREFIX . "module_downloads_rel_download_download` (\n             `id1` int(10) unsigned NOT NULL default '0',\n             `id2` int(10) unsigned NOT NULL default '0',\n              PRIMARY KEY (`id1`,`id2`)\n            ) ENGINE=MyISAM", DBPREFIX . 'module_downloads_settings' => "CREATE TABLE `" . DBPREFIX . "module_downloads_settings` (\n             `id` int(11) NOT NULL auto_increment,\n             `name` varchar(32) NOT NULL default '',\n             `value` varchar(255) NOT NULL default '',\n              PRIMARY KEY (`id`)\n            ) ENGINE=MyISAM");
    foreach ($tables as $name => $query) {
        #print_r($arrTables);
        if (in_array($name, $arrTables)) {
            continue;
        }
        if ($objDatabase->Execute($query) === false) {
            return _databaseError($query, $objDatabase->ErrorMsg());
        }
    }
    try {
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_downloads_download', array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'type' => array('type' => 'ENUM(\'file\',\'url\')', 'notnull' => true, 'default' => 'file'), 'mime_type' => array('type' => 'ENUM(\'image\',\'document\',\'pdf\',\'media\',\'archive\',\'application\',\'link\')', 'notnull' => true, 'default' => 'image'), 'source' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => ''), 'source_name' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => ''), 'icon' => array('type' => 'ENUM(\'_blank\',\'avi\',\'bmp\',\'css\',\'doc\',\'dot\',\'exe\',\'fla\',\'gif\',\'htm\',\'html\',\'inc\',\'jpg\',\'js\',\'mp3\',\'nfo\',\'pdf\',\'php\',\'png\',\'pps\',\'ppt\',\'rar\',\'swf\',\'txt\',\'wma\',\'xls\',\'zip\')', 'notnull' => true, 'default' => '_blank'), 'size' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'image' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => ''), 'owner_id' => array('type' => 'INT(5)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'access_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'license' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => ''), 'version' => array('type' => 'VARCHAR(10)', 'notnull' => true, 'default' => ''), 'author' => array('type' => 'VARCHAR(100)', 'notnull' => true, 'default' => ''), 'website' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => ''), 'ctime' => array('type' => 'INT(14)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'mtime' => array('type' => 'INT(14)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'is_active' => array('type' => 'TINYINT(3)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'visibility' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'notnull' => true, 'default' => '1'), 'order' => array('type' => 'INT(3)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'views' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'download_count' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'expiration' => array('type' => 'INT(14)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'validity' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0')), array('is_active' => array('fields' => array('is_active')), 'visibility' => array('fields' => array('visibility'))));
    } catch (\Cx\Lib\UpdateException $e) {
        // we COULD do something else here..
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    /************************************************
     * EXTENSION:    Initial adding of the           *
     *               settings values                 *
     * ADDED:        Contrexx v2.1.0                 *
     ************************************************/
    $arrSettings = array('overview_cols_count' => '2', 'overview_max_subcats' => '5', 'use_attr_size' => '1', 'use_attr_license' => '1', 'use_attr_version' => '1', 'use_attr_author' => '1', 'use_attr_website' => '1', 'most_viewed_file_count' => '5', 'most_downloaded_file_count' => '5', 'most_popular_file_count' => '5', 'newest_file_count' => '5', 'updated_file_count' => '5', 'new_file_time_limit' => '604800', 'updated_file_time_limit' => '604800', 'associate_user_to_groups' => '');
    foreach ($arrSettings as $name => $value) {
        $query = "SELECT 1 FROM `" . DBPREFIX . "module_downloads_settings` WHERE `name` = '" . $name . "'";
        $objResult = $objDatabase->SelectLimit($query, 1);
        if ($objResult) {
            if ($objResult->RecordCount() == 0) {
                $query = "INSERT INTO `" . DBPREFIX . "module_downloads_settings` (`name`, `value`) VALUES ('" . $name . "', '" . $value . "')";
                if ($objDatabase->Execute($query) === false) {
                    return _databaseError($query, $objDatabase->ErrorMsg());
                }
            }
        } else {
            return _databaseError($query, $objDatabase->ErrorMsg());
        }
    }
    /************************************************
     * BUGFIX:   Set write access to the upload dir  *
     ************************************************/
    if (\Cx\Lib\FileSystem\FileSystem::makeWritable(ASCMS_DOWNLOADS_IMAGES_PATH)) {
        if ($mediaDir = @opendir(ASCMS_DOWNLOADS_IMAGES_PATH)) {
            while ($file = readdir($mediaDir)) {
                if ($file != '.' && $file != '..') {
                    if (!\Cx\Lib\FileSystem\FileSystem::makeWritable(ASCMS_DOWNLOADS_IMAGES_PATH . '/' . $file)) {
                        setUpdateMsg(sprintf($_ARRAYLANG['TXT_SET_WRITE_PERMISSON_TO_FILE'], ASCMS_DOWNLOADS_IMAGES_PATH . '/' . $file, $_CORELANG['TXT_UPDATE_TRY_AGAIN']), 'msg');
                        return false;
                    }
                }
            }
        } else {
            setUpdateMsg(sprintf($_ARRAYLANG['TXT_SET_WRITE_PERMISSON_TO_DIR_AND_CONTENT'], ASCMS_DOWNLOADS_IMAGES_PATH . '/', $_CORELANG['TXT_UPDATE_TRY_AGAIN']), 'msg');
            return false;
        }
    } else {
        setUpdateMsg(sprintf($_ARRAYLANG['TXT_SET_WRITE_PERMISSON_TO_DIR_AND_CONTENT'], ASCMS_DOWNLOADS_IMAGES_PATH . '/', $_CORELANG['TXT_UPDATE_TRY_AGAIN']), 'msg');
        return false;
    }
    /************************************************
     * EXTENSION:    Groups                          *
     * ADDED:        Contrexx v2.1.2                 *
     ************************************************/
    try {
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_downloads_group', array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'is_active' => array('type' => 'TINYINT(1)', 'notnull' => true, 'default' => '1'), 'type' => array('type' => 'ENUM(\'file\',\'url\')', 'notnull' => true, 'default' => 'file'), 'info_page' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '')));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_downloads_group_locale', array('lang_id' => array('type' => 'INT(11)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'primary' => true), 'group_id' => array('type' => 'INT(11)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'primary' => true), 'name' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '')), array('name' => array('fields' => array('name'), 'type' => 'FULLTEXT')));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_downloads_rel_group_category', array('group_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'primary' => true), 'category_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'primary' => true)));
    } catch (\Cx\Lib\UpdateException $e) {
        // we COULD do something else here..
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    /*******************************************************
     * EXTENSION:    Localisation of download source fields *
     * ADDED:        Contrexx v3.0.0                        *
     ********************************************************/
    try {
        $arrColumns = $objDatabase->MetaColumns(DBPREFIX . 'module_downloads_download_locale');
        if ($arrColumns === false) {
            setUpdateMsg(sprintf($_ARRAYLANG['TXT_UNABLE_GETTING_DATABASE_TABLE_STRUCTURE'], DBPREFIX . 'module_downloads_download_locale'));
            return false;
        }
        if (!isset($arrColumns['SOURCE']) && !isset($arrColumns['SOURCE_NAME'])) {
            \Cx\Lib\UpdateUtil::sql('
                ALTER TABLE `' . DBPREFIX . 'module_downloads_download_locale`
                ADD `source` VARCHAR(255) NULL DEFAULT NULL AFTER `name`,
                ADD `source_name` VARCHAR(255) NULL DEFAULT NULL AFTER `source`,
                ADD `metakeys` TEXT NOT NULL AFTER `description`
            ');
            \Cx\Lib\UpdateUtil::sql('
                UPDATE `' . DBPREFIX . 'module_downloads_download` AS download INNER JOIN `' . DBPREFIX . 'module_downloads_download_locale` AS download_locale ON download.id = download_locale.download_id
                SET download_locale.source = download.source, download_locale.source_name = download.source_name
            ');
            \Cx\Lib\UpdateUtil::sql('
                ALTER TABLE `' . DBPREFIX . 'module_downloads_download`
                DROP COLUMN `source`,
                DROP COLUMN `source_name`
            ');
        }
    } catch (\Cx\Lib\UpdateException $e) {
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    /**********************************************************
     * EXTENSION:    Increase length of download source fields *
     * ADDED:        Contrexx v3.1.0                           *
     **********************************************************/
    try {
        if ($objUpdate->_isNewerVersion($_CONFIG['coreCmsVersion'], '3.1.0')) {
            \Cx\Lib\UpdateUtil::sql('
                ALTER TABLE `' . DBPREFIX . 'module_downloads_download_locale`
                CHANGE `source` `source` VARCHAR(1024) NULL DEFAULT NULL,
                CHANGE `source_name` `source_name` VARCHAR(1024) NULL DEFAULT NULL
            ');
        }
    } catch (\Cx\Lib\UpdateException $e) {
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    /**********************************************************
     * EXTENSION:    Add access ids of "editing all downloads" *
     *               to groups which had access to "administer"*
     * ADDED:        Contrexx v3.1.1                           *
     **********************************************************/
    try {
        if ($objUpdate->_isNewerVersion($_CONFIG['coreCmsVersion'], '3.1.0.2')) {
            $result = \Cx\Lib\UpdateUtil::sql("SELECT `group_id` FROM `" . DBPREFIX . "access_group_static_ids` WHERE access_id = 142 GROUP BY `group_id`");
            if ($result !== false) {
                while (!$result->EOF) {
                    \Cx\Lib\UpdateUtil::sql("INSERT IGNORE INTO `" . DBPREFIX . "access_group_static_ids` (`access_id`, `group_id`)\n                                                VALUES (143, " . intval($result->fields['group_id']) . ")");
                    $result->MoveNext();
                }
            }
        }
    } catch (\Cx\Lib\UpdateException $e) {
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    return true;
}
Exemple #23
0
 public function getTempPath()
 {
     $this->cleanTempPaths();
     if (!\Cx\Lib\FileSystem\FileSystem::make_folder($this->sessionPath)) {
         return false;
     }
     if (!\Cx\Lib\FileSystem\FileSystem::makeWritable($this->sessionPath)) {
         return false;
     }
     return ASCMS_PATH . $this->sessionPath;
 }
Exemple #24
0
 /**
  * Get thumbnails
  *
  * Get the thumbnails from a day in the archive.
  * Create the thumbnails if they don't already exists.
  *
  * @return  boolean TRUE if the thumbs have been loaded, otherwise FALSE
  */
 protected function _getThumbs()
 {
     // set and sanitize the archive path
     $path = \Cx\Core\Core\Controller\Cx::instanciate()->getWebsitePath() . $this->camSettings['archivePath'] . '/' . $this->date . '/';
     $path = \Cx\Lib\FileSystem\FileSystem::sanitizePath($path);
     // set and sanitize the thumbnail path
     $thumbPath = \Cx\Core\Core\Controller\Cx::instanciate()->getWebsitePath() . $this->camSettings['thumbnailPath'];
     $thumbPath = \Cx\Lib\FileSystem\FileSystem::sanitizePath($thumbPath);
     if (!$path || !$thumbPath) {
         return false;
     }
     $objDirectory = @opendir($path);
     $chmoded = false;
     if (!$objDirectory) {
         return false;
     }
     while ($file = readdir($objDirectory)) {
         if ($file != "." && $file != "..") {
             //check and create thumbs
             $thumb = $thumbPath . '/tn_' . $this->date . '_' . $file;
             if (!\Cx\Lib\FileSystem\FileSystem::exists($thumb)) {
                 if (!$chmoded) {
                     \Cx\Lib\FileSystem\FileSystem::makeWritable($this->camSettings['thumbnailPath']);
                     $chmoded = true;
                 }
                 //create thumb
                 $im1 = @imagecreatefromjpeg($path . $file);
                 //erstellt ein Abbild im Speicher
                 if ($im1) {
                     /* Pr�fen, ob fehlgeschlagen */
                     // check_jpeg($thumb, $fix=false );
                     $size = getimagesize($path . $file);
                     //ermittelt die Gr��e des Bildes
                     $breite = $size[0];
                     //die Breite des Bildes
                     $hoehe = $size[1];
                     //die H�he des Bildes
                     $breite_neu = $this->camSettings['thumbMaxSize'];
                     //die breite des Thumbnails
                     $factor = $breite / $this->camSettings['thumbMaxSize'];
                     //berechnungsfaktor
                     $hoehe_neu = $size[1] / $factor;
                     //die H�he des Thumbnails
                     //$im2=imagecreate($breite_neu,$hoehe_neu); //Thumbnail im Speicher erstellen
                     $im2 = @imagecreatetruecolor($breite_neu, $hoehe_neu);
                     imagecopyresized($im2, $im1, 0, 0, 0, 0, $breite_neu, $hoehe_neu, $breite, $hoehe);
                     imagejpeg($im2, $thumb);
                     //Thumbnail speichern
                     imagedestroy($im1);
                     //Speicherabbild wieder l�schen
                     imagedestroy($im2);
                     //Speicherabbild wieder l�schen
                 }
             }
             //show pictures
             $minHour = date('G', $this->camSettings['showFrom']);
             $minMinutes = date('i', $this->camSettings['showFrom']);
             $maxHour = date('G', $this->camSettings['showTill']);
             $maxMinutes = date('i', $this->camSettings['showTill']);
             $hour = substr($file, 4, 2);
             $min = substr($file, 13, 2);
             $min = !empty($min) ? $min : "00";
             $time = $hour . ":" . $min . "&nbsp;Uhr";
             $minTime = mktime($minHour, $minMinutes);
             $maxTime = mktime($maxHour, $maxMinutes);
             $nowTime = mktime($hour, $min);
             /*
              * only show archive images if they are in range
              */
             if ($nowTime <= $maxTime && $nowTime >= $minTime) {
                 if ($this->camSettings['shadowboxActivate'] == 1) {
                     $linkUrl = \Cx\Core\Core\Controller\Cx::instanciate()->getWebsiteOffsetPath() . $this->camSettings['archivePath'] . '/' . $this->date . '/' . $file;
                 } else {
                     $linkUrl = '[[NODE_LIVECAM]]?file=' . $this->date . '/' . $file;
                 }
                 $arrThumbnail = array('link_url' => $linkUrl, 'image_url' => $this->camSettings['thumbnailPath'] . "/tn_" . $this->date . "_" . $file, 'time' => $time);
                 array_push($this->_arrArchiveThumbs, $arrThumbnail);
             }
         }
     }
     closedir($objDirectory);
     return true;
 }
Exemple #25
0
 /**
  * Saves the new image wherever you want
  * @todo    In case the PHP script has no write access to the location set by $this->newImageFile,
  *          the image shall be sent to the output buffer and then be put into the new file
  *          location using the FileSystemFile object.
  * @access  public
  * @param   string    $file             The path for the image file to be written.
  * @param   booelan   $forceOverwrite   Force overwriting existing files if true.
  * @return  boolean                     True on success, false otherwise.
  */
 public function saveNewImage($file, $forceOverwrite = false)
 {
     // TODO: Add some sort of diagnostics (Message) here and elsewhere in this class
     if (!$this->imageCheck) {
         return false;
     }
     if (empty($this->newImage)) {
         return false;
     }
     if (file_exists($file)) {
         if (!$forceOverwrite) {
             return false;
         }
         \Cx\Lib\FileSystem\FileSystem::makeWritable($file);
     } else {
         try {
             $objFile = new \Cx\Lib\FileSystem\File($file);
             $objFile->touch();
         } catch (\Cx\Lib\FileSystem\FileSystemException $e) {
             \DBG::msg($e->getMessage());
         }
     }
     // TODO: Unfortunately, the functions imagegif(), imagejpeg() and imagepng() can't use the Contrexx FileSystem wrapper,
     //       therefore we need to set the global write access image files.
     //       This issue might be solved by using the output-buffer and write the image manually afterwards.
     //
     //       IMPORTANT: In case something went wrong (see bug #1441) and the path $strPathNew.$strFileNew refers to a directory
     //       we must abort the operation here, otherwise we would remove the execution flag on a directory, which would
     //       cause to remove any browsing access to the directory.
     if (is_dir($file)) {
         return false;
     }
     \Cx\Lib\FileSystem\FileSystem::chmod($file, 0666);
     //\Cx\Lib\FileSystem\FileSystem::CHMOD_FILE);
     $this->newImageFile = $file;
     if ($this->newImageType == self::IMG_TYPE_PNG) {
         $this->setTransparency();
     }
     switch ($this->newImageType) {
         case self::IMG_TYPE_GIF:
             $function = 'imagegif';
             if (!function_exists($function)) {
                 $function = 'imagejpeg';
             }
             break;
         case self::IMG_TYPE_JPEG:
             $function = 'imagejpeg';
             break;
         case self::IMG_TYPE_PNG:
             // make a jpeg thumbnail, too
             $function = 'imagepng';
             break;
         default:
             return false;
     }
     // Only adjust quality, if it is set.
     if ($this->newImageQuality != '') {
         $function($this->newImage, $this->newImageFile, $this->getQuality());
     } else {
         $function($this->newImage, $this->newImageFile);
     }
     return true;
 }
Exemple #26
0
 /**
  * Read NewsML documents
  *
  * Read the NewsML documents of the category with the id $categoryId from its data directory
  * and delete the documents after they are inserted into the database
  * @access public
  * @param integer $categoryId
  * @global object $objDatabase
  */
 function readDocuments($categoryId, $matchFilenamePattern = null)
 {
     global $objDatabase;
     $objDir = @opendir(ASCMS_DOCUMENT_ROOT . $this->arrCategories[$categoryId]['path']);
     if ($objDir) {
         $arrDocuments = array();
         $document = @readdir($objDir);
         while ($document) {
             if (!in_array($document, $this->_arrExcludeFiles) && strtolower(substr($document, -3)) == 'xml' && (!$matchFilenamePattern || preg_match($matchFilenamePattern, $document))) {
                 array_push($arrDocuments, $document);
             }
             $document = @readdir($objDir);
         }
         @closedir($objDir);
         \Cx\Lib\FileSystem\FileSystem::makeWritable(ASCMS_DOCUMENT_ROOT . $this->arrCategories[$categoryId]['path']);
         foreach ($arrDocuments as $document) {
             if ($this->_readDocument($categoryId, $document)) {
                 \Cx\Lib\FileSystem\FileSystem::makeWritable(ASCMS_DOCUMENT_ROOT . $this->arrCategories[$categoryId]['path'] . '/' . $document);
                 @copy(ASCMS_DOCUMENT_ROOT . $this->arrCategories[$categoryId]['path'] . '/' . $document, ASCMS_DOCUMENT_ROOT . '/si_online_archive/' . $document);
                 \Cx\Lib\FileSystem\FileSystem::makeWritable(ASCMS_DOCUMENT_ROOT . '/si_online_archive/' . $document);
                 \Cx\Lib\FileSystem\FileSystem::delete_file(ASCMS_DOCUMENT_ROOT . $this->arrCategories[$categoryId]['path'] . '/' . $document);
             }
         }
         //          print_r($this->_arrDocuments);
         foreach ($this->_arrDocuments as $dateId => $arrNewsItems) {
             foreach ($arrNewsItems as $newsItemId => $arrRevisions) {
                 krsort($arrRevisions, SORT_NUMERIC);
                 reset($arrRevisions);
                 $arrRevision = current($arrRevisions);
                 $revisionUpdateStatus = isset($arrRevision['revisionUpdateStatus']) ? $arrRevision['revisionUpdateStatus'] : '';
                 switch ($revisionUpdateStatus) {
                     case 'A':
                         $objDatabase->Execute("DELETE FROM " . DBPREFIX . "module_feed_newsml_documents WHERE providerId='" . $this->arrCategories[$categoryId]['providerId'] . "' AND dateId=" . $dateId . " AND newsItemId='" . $newsItemId . "'");
                         break;
                     default:
                         $objDatabase->Execute("DELETE FROM " . DBPREFIX . "module_feed_newsml_documents WHERE providerId='" . $this->arrCategories[$categoryId]['providerId'] . "' AND dateId=" . $dateId . " AND newsItemId='" . $newsItemId . "' AND revisionId != " . $arrRevision['revisionId']);
                         if (isset($arrRevision['dateId'])) {
                             $this->_addDocument($arrRevision['publicIdentifier'], $this->arrCategories[$categoryId]['providerId'], $dateId, $newsItemId, $arrRevision['revisionId'], $arrRevision['thisRevisionDate'], $arrRevision['urgency'], $arrRevision['subjectCode'], $arrRevision['headLine'], $arrRevision['dataContent'], $arrRevision['associatedNewsItems']);
                         }
                         break;
                 }
             }
         }
     }
 }
Exemple #27
0
 /**
  * Saves the image to the path given as a jpeg file
  * @access  public
  * @param   string    $file   The path for the jpeg image file to be written
  * @param   booelan   $force  Force overwriting existing files if true
  * @return  boolean           True on success, false otherwise
  */
 function saveJpeg($image, $path, $quality = 90, $force = false)
 {
     if (File::exists($path) && !$force) {
         return false;
     }
     File::delete_file($path);
     if (imagejpeg($image, ASCMS_DOCUMENT_ROOT . '/' . $path, $quality)) {
         return \Cx\Lib\FileSystem\FileSystem::makeWritable($path);
     }
     return false;
 }
Exemple #28
0
 /**
  * Writes RSS feed containing the latest N messages of each category the feed-directory. This is done for every language seperately.
  *
  * @global  array
  * @global  array
  * @global  FWLanguage
  */
 function writeCategoryRSS()
 {
     global $_CONFIG, $_ARRAYLANG;
     if (intval($this->_arrSettings['blog_rss_activated'])) {
         $arrCategories = $this->createCategoryArray();
         //Iterate over all languages
         foreach ($this->_arrLanguages as $intLanguageId => $arrLanguageValues) {
             $arrEntries = $this->createEntryArray($intLanguageId);
             //If there exist entries in this language go on, otherwise skip
             if (count($arrEntries) > 0) {
                 //Iterate over all categories
                 foreach ($arrCategories as $intCategoryId => $arrCategoryTranslation) {
                     //If the category is activated in this language, find assigned messages
                     if ($arrCategoryTranslation[$intLanguageId]['is_active']) {
                         $intNumberOfMessages = 0;
                         //Counts found messages for this category
                         $objRSSWriter = new \RSSWriter();
                         $objRSSWriter->characterEncoding = CONTREXX_CHARSET;
                         $objRSSWriter->channelTitle = $_CONFIG['coreGlobalPageTitle'] . ' - ' . $_ARRAYLANG['TXT_BLOG_LIB_RSS_MESSAGES_TITLE'];
                         $objRSSWriter->channelLink = \Cx\Core\Routing\Url::fromModuleAndCmd('Blog', '', $intLanguageId)->toString();
                         $objRSSWriter->channelDescription = $_CONFIG['coreGlobalPageTitle'] . ' - ' . $_ARRAYLANG['TXT_BLOG_LIB_RSS_MESSAGES_TITLE'] . ' (' . $arrCategoryTranslation[$intLanguageId]['name'] . ')';
                         $objRSSWriter->channelCopyright = 'Copyright ' . date('Y') . ', http://' . $_CONFIG['domainUrl'];
                         //Function doesn't exist
                         //$objRSSWriter->channelLanguage = \FWLanguage::getLanguageParameter($intLanguageId, 'lang');
                         $objRSSWriter->channelWebMaster = $_CONFIG['coreAdminEmail'];
                         //Find assigned messages
                         $entryUrl = \Cx\Core\Routing\Url::fromModuleAndCmd('Blog', 'details', $intLanguageId);
                         foreach ($arrEntries as $intEntryId => $arrEntryValues) {
                             if ($this->categoryMatches($intCategoryId, $arrEntryValues['categories'][$intLanguageId])) {
                                 //Message is in category, add to feed
                                 $entryUrl->setParam('id', $intEntryId);
                                 $objRSSWriter->addItem(html_entity_decode($arrEntryValues['subject'], ENT_QUOTES, CONTREXX_CHARSET), contrexx_raw2xhtml($entryUrl->toString()), htmlspecialchars($arrEntryValues['translation'][$intLanguageId]['content'], ENT_QUOTES, CONTREXX_CHARSET), htmlspecialchars($arrEntryValues['user_name'], ENT_QUOTES, CONTREXX_CHARSET), '', '', '', '', $arrEntryValues['time_created_ts'], '');
                                 $intNumberOfMessages++;
                                 //Check for message-limit
                                 if ($intNumberOfMessages >= intval($this->_arrSettings['blog_rss_messages'])) {
                                     break;
                                 }
                             }
                         }
                         $objRSSWriter->xmlDocumentPath = \Env::get('cx')->getWebsiteFeedPath() . '/blog_category_' . $intCategoryId . '_' . $arrLanguageValues['short'] . '.xml';
                         $objRSSWriter->write();
                         \Cx\Lib\FileSystem\FileSystem::makeWritable(\Env::get('cx')->getWebsiteFeedPath() . '/blog_category_' . $intCategoryId . '_' . $arrLanguageValues['short'] . '.xml');
                     }
                 }
             }
         }
     }
 }
Exemple #29
0
 /**
  * Write all settings to the config file
  *
  */
 public static function updatePhpCache()
 {
     global $_ARRAYLANG, $_CONFIG;
     if (!\Cx\Lib\FileSystem\FileSystem::makeWritable(self::getSettingsFile())) {
         \Message::add(self::getSettingsFile() . ' ' . $_ARRAYLANG['TXT_SETTINGS_ERROR_WRITABLE'], \Message::CLASS_ERROR);
         return false;
     }
     //get values from ymlsetting
     \Cx\Core\Setting\Controller\Setting::init('Config', NULL, 'Yaml');
     $ymlArray = \Cx\Core\Setting\Controller\Setting::getArray('Config', null);
     $intMaxLen = 0;
     $ymlArrayValues = array();
     foreach ($ymlArray as $key => $ymlValue) {
         $_CONFIG[$key] = $ymlValue['value'];
         $ymlArrayValues[$ymlValue['group']][$key] = $ymlValue['value'];
         // special case to add legacy domainUrl configuration option
         if ($key == 'mainDomainId') {
             $domainRepository = new \Cx\Core\Net\Model\Repository\DomainRepository();
             $objMainDomain = $domainRepository->findOneBy(array('id' => $ymlArray[$key]['value']));
             if ($objMainDomain) {
                 $domainUrl = $objMainDomain->getName();
             } else {
                 $domainUrl = $_SERVER['SERVER_NAME'];
             }
             $ymlArrayValues[$ymlValue['group']]['domainUrl'] = $domainUrl;
             if ($_CONFIG['xmlSitemapStatus'] == 'on') {
                 \Cx\Core\PageTree\XmlSitemapPageTree::write();
             }
         }
         $intMaxLen = strlen($key) > $intMaxLen ? strlen($key) : $intMaxLen;
     }
     $intMaxLen += strlen('$_CONFIG[\'\']') + 1;
     //needed for formatted output
     // update environment
     \Env::set('config', $_CONFIG);
     $strHeader = "<?php\n";
     $strHeader .= "/**\n";
     $strHeader .= "* This file is generated by the \"settings\"-menu in your CMS.\n";
     $strHeader .= "* Do not try to edit it manually!\n";
     $strHeader .= "*/\n\n";
     $strFooter = "?>";
     //Write values
     $data = $strHeader;
     $strBody = '';
     foreach ($ymlArrayValues as $group => $sectionValues) {
         $strBody .= "/**\n";
         $strBody .= "* -------------------------------------------------------------------------\n";
         $strBody .= "* " . ucfirst($group) . "\n";
         $strBody .= "* -------------------------------------------------------------------------\n";
         $strBody .= "*/\n";
         foreach ($sectionValues as $sectionName => $sectionNameValue) {
             $strBody .= sprintf("%-" . $intMaxLen . "s", '$_CONFIG[\'' . $sectionName . '\']');
             $strBody .= "= ";
             $strBody .= (self::isANumber($sectionNameValue) ? $sectionNameValue : '"' . str_replace('"', '\\"', $sectionNameValue) . '"') . ";\n";
         }
         $strBody .= "\n";
     }
     $data .= $strBody;
     $data .= $strFooter;
     try {
         $objFile = new \Cx\Lib\FileSystem\File(self::getSettingsFile());
         $objFile->write($data);
         return true;
     } catch (\Cx\Lib\FileSystem\FileSystemException $e) {
         \DBG::msg($e->getMessage());
     }
     return false;
 }
 /**
  * Makes sure that the cache directory exists and is writable
  * @param \Cx\Core\Core\Controller\Cx $cx The contrexx instance
  */
 protected function checkCacheDir($cx)
 {
     if (!is_dir($cx->getWebsiteCachePath())) {
         \Cx\Lib\FileSystem\FileSystem::make_folder($cx->getWebsiteCachePath());
     }
     if (!is_writable($cx->getWebsiteCachePath())) {
         \Cx\Lib\FileSystem\FileSystem::makeWritable($cx->getWebsiteCachePath());
     }
 }