예제 #1
0
 function run_installation_routine($url = '')
 {
     $settings = pl_get_global_settings();
     // Only sets defaults if they are null
     set_default_settings();
     if (!$settings) {
         $this->load_page_templates();
         $this->apply_page_templates();
         // Publish New Templates
         $tpl_handler = new PLCustomTemplates();
         $tpl_handler->update_objects('publish');
     }
     // Add Templates
     $id = $this->page_on_activation();
     // Redirect
     $url = add_query_arg('pl-installed-theme', pl_theme_info('template'), get_permalink($id));
     return $url;
 }
예제 #2
0
 function run_installation_routine($url = '')
 {
     set_theme_mod('pl_installed', true);
     $settings = pl_get_global_settings();
     // Only sets defaults if they are null
     set_default_settings();
     if (is_file(trailingslashit(get_stylesheet_directory()) . 'pl-config.json')) {
         $settings_handler = new PageLinesSettings();
         $settings_handler->import_from_child();
     }
     $this->apply_page_templates();
     // Publish New Templates
     $tpl_handler = new PLCustomTemplates();
     $tpl_handler->update_objects('publish');
     // Add Templates
     $id = $this->page_on_activation();
     // Redirect
     $url = add_query_arg('pl-installed-theme', pl_theme_info('template'), get_permalink($id));
     return $url;
 }
예제 #3
0
    define('__DIR__', dirname(__FILE__));
}
define('THEME_OPTIONS', get_template_directory_uri() . '/admin/theme-options');
define('THEME_URI', get_template_directory_uri());
/* Include Admin */
require_once dirname(__FILE__) . '/admin/inc.php';
if (!is_admin()) {
    /* Include Front-end */
    require_once dirname(__FILE__) . '/include/inc.php';
    if (file_exists(dirname(__FILE__) . '/woocommerce/inc.php')) {
        /* Include Woocommerce */
        require_once dirname(__FILE__) . '/woocommerce/inc.php';
    }
}
if (is_admin() && get_option('defaults_have_been_set') != 'yes') {
    set_default_settings();
}
function set_default_settings()
{
    // changing WordPress default settings
    update_option("users_can_register", "1");
    add_option('defaults_have_been_set', 'yes', '', 'no');
}
/**
 * Set up the content width value based on the theme's design.
 *
 * @see ulysses_content_width()
 *
 * @since ulysses 1.0
 */
if (!isset($content_width)) {
예제 #4
0
/**
 * Manages all the unzipping process of an uploaded file
 *
 * @author Hugues Peeters <*****@*****.**>
 *
 * @param  array  $uploaded_file - follows the $_FILES Structure
 * @param  string $upload_path   - destination of the upload.
 *                                This path is to append to $base_work_dir
 * @param  string $base_work_dir  - base working directory of the module
 * @param  int $max_filled_space  - amount of bytes to not exceed in the base
 *                                working directory
 *
 * @return boolean true if it succeeds false otherwise
 */
function unzip_uploaded_file($uploaded_file, $upload_path, $base_work_dir, $max_filled_space)
{
    $zip_file = new PclZip($uploaded_file['tmp_name']);
    // Check the zip content (real size and file extension)
    if (file_exists($uploaded_file['tmp_name'])) {
        $zip_content_array = $zip_file->listContent();
        $ok_scorm = false;
        $realFileSize = 0;
        foreach ($zip_content_array as &$this_content) {
            if (preg_match('~.(php.*|phtml)$~i', $this_content['filename'])) {
                return api_failure::set_failure('php_file_in_zip_file');
            } elseif (stristr($this_content['filename'], 'imsmanifest.xml')) {
                $ok_scorm = true;
            } elseif (stristr($this_content['filename'], 'LMS')) {
                $ok_plantyn_scorm1 = true;
            } elseif (stristr($this_content['filename'], 'REF')) {
                $ok_plantyn_scorm2 = true;
            } elseif (stristr($this_content['filename'], 'SCO')) {
                $ok_plantyn_scorm3 = true;
            } elseif (stristr($this_content['filename'], 'AICC')) {
                $ok_aicc_scorm = true;
            }
            $realFileSize += $this_content['size'];
        }
        if ($ok_plantyn_scorm1 && $ok_plantyn_scorm2 && $ok_plantyn_scorm3 || $ok_aicc_scorm) {
            $ok_scorm = true;
        }
        if (!$ok_scorm && defined('CHECK_FOR_SCORM') && CHECK_FOR_SCORM) {
            return api_failure::set_failure('not_scorm_content');
        }
        if (!enough_size($realFileSize, $base_work_dir, $max_filled_space)) {
            return api_failure::set_failure('not_enough_space');
        }
        // It happens on Linux that $upload_path sometimes doesn't start with '/'
        if ($upload_path[0] != '/' && substr($base_work_dir, -1, 1) != '/') {
            $upload_path = '/' . $upload_path;
        }
        if ($upload_path[strlen($upload_path) - 1] == '/') {
            $upload_path = substr($upload_path, 0, -1);
        }
        /*	Uncompressing phase */
        /*
            The first version, using OS unzip, is not used anymore
            because it does not return enough information.
            We need to process each individual file in the zip archive to
            - add it to the database
            - parse & change relative html links
        */
        if (PHP_OS == 'Linux' && !get_cfg_var('safe_mode') && false) {
            // *** UGent, changed by OC ***
            // Shell Method - if this is possible, it gains some speed
            exec("unzip -d \"" . $base_work_dir . $upload_path . "/\"" . $uploaded_file['name'] . " " . $uploaded_file['tmp_name']);
        } else {
            // PHP method - slower...
            $save_dir = getcwd();
            chdir($base_work_dir . $upload_path);
            $unzippingState = $zip_file->extract();
            for ($j = 0; $j < count($unzippingState); $j++) {
                $state = $unzippingState[$j];
                // Fix relative links in html files
                $extension = strrchr($state['stored_filename'], '.');
            }
            if ($dir = @opendir($base_work_dir . $upload_path)) {
                while ($file = readdir($dir)) {
                    if ($file != '.' && $file != '..') {
                        $filetype = 'file';
                        if (is_dir($base_work_dir . $upload_path . '/' . $file)) {
                            $filetype = 'folder';
                        }
                        $safe_file = api_replace_dangerous_char($file, 'strict');
                        @rename($base_work_dir . $upload_path . '/' . $file, $base_work_dir . $upload_path . '/' . $safe_file);
                        set_default_settings($upload_path, $safe_file, $filetype);
                    }
                }
                closedir($dir);
            } else {
                error_log('Could not create directory ' . $base_work_dir . $upload_path . ' to unzip files');
            }
            chdir($save_dir);
            // Back to previous dir position
        }
    }
    return true;
}
예제 #5
0
function reset_global_settings()
{
    $settings = pl_get_global_settings();
    $set['draft'] = array();
    pl_update_global_settings($set);
    set_default_settings();
    global $dms_cache;
    $dms_cache->purge('draft');
    return $set;
}