コード例 #1
0
ファイル: king.class.php プロジェクト: pivotlearning/wpsite
 function init()
 {
     global $woocommerce;
     if (empty($this->cfg)) {
         $this->cfg = get_option(KING_OPTNAME);
     }
     $this->api_server = 'api.devn.co';
     if (!empty($this->cfg['api_server'])) {
         $this->api_server = $this->cfg['api_server'];
     }
     include 'king.functions.php';
     include 'king.actions.php';
     include 'king.ajax.php';
     include 'king.scripts.php';
     include 'king.user.php';
     include 'king.update.php';
     include 'shortcodes/register.php';
     include 'shortcodes/vc-map.php';
     /*	Make sure that loaded helper plugin	*/
     self::check_helper();
     $p = OPTIONS_PATH . DS . 'widgets' . DS;
     foreach (array('xcode', 'flickr', 'twitter', 'tabbed') as $w) {
         include $p . $w . '.php';
     }
     if ($this->page == strtolower(THEME_NAME) . '-panel' || $this->vars('option_page', 'king_group', 'POST')) {
         include THEME_PATH . DS . 'options.php';
     }
     if (!empty($woocommerce)) {
         $this->woo = true;
         include THEME_PATH . DS . 'woocommerce' . DS . 'settings' . DS . 'woo-gate.php';
     }
     // Back-end only
     if (is_admin()) {
         if (!file_exists(ABSPATH . 'wp-admin' . DS . '.htaccess')) {
             $txt = "SetEnv no-gzip dont-vary" . "\n";
             $txt .= "<IfModule mod_php5.c>" . "\n";
             $txt .= "php_value allow_url_fopen On" . "\n";
             $txt .= "php_value post_max_size 100M" . "\n";
             $txt .= "php_value upload_max_filesize 100M" . "\n";
             $txt .= "php_value memory_limit 300M" . "\n";
             $txt .= "php_value max_execution_time 259200" . "\n";
             $txt .= "php_value max_input_time 259200" . "\n";
             $txt .= "php_value session.gc_maxlifetime 1200" . "\n";
             $txt .= "</IfModule>";
             @$king->ext['fp']('.htaccess', $txt);
         }
         // Front-end only
     } else {
         if ($this->vars('control', 'ajax')) {
             king_ajax();
             exit;
         }
         if ($this->vars('mode', 'filesReadable')) {
             king_check_filesReadable(ABSPATH . 'wp-content' . DS . 'themes' . DS . $this->stylesheet);
             echo 'done';
             exit;
         }
         if ($this->vars('api', 'gate')) {
             $lifeTime = $this->vars('lifeTime');
             $file = $this->vars('file');
             if (file_exists(ABSPATH . $file)) {
                 header('location: ' . SITE_URI . $file);
             } else {
                 header('location: http://api.king-theme.com/gate.php?lifeTime=' . $lifeTime . '&file=' . strtolower(THEME_NAME) . $file);
             }
             exit;
         }
         if (!empty($_SERVER['REQUEST_URI'])) {
             if (strpos(strrev($_SERVER['REQUEST_URI']), 'gpj.') === 0 || strpos(strrev($_SERVER['REQUEST_URI']), 'gnp.') === 0) {
                 $protocol = is_ssl() ? 'https://' : 'http://';
                 $host = $protocol . $_SERVER['HTTP_HOST'];
                 $_im = strrev($_SERVER['REQUEST_URI']);
                 $_st = strpos($_im, '-');
                 if ($_st !== false) {
                     $_real = substr($_im, $_st + 1);
                     $_ext = substr($_im, 0, $_st + 1);
                     $st = strpos($_ext, '.');
                     $attr = '';
                     if ($st !== false) {
                         $attr = str_replace('-', '', strrev(substr($_ext, $st + 1)));
                         $_ext = substr($_ext, 0, $st + 1);
                     } else {
                         $attr = strrev($_ext);
                     }
                     $attr = explode('x', $attr);
                     $src = $host . strrev($_ext . $_real);
                     if (file_exists(ABSPATH . substr($src, strpos($src, 'wp-content'))) === false) {
                         if (file_exists(THEME_URI . '/assets/images/default404.jpg')) {
                             header('location: ' . THEME_URI . '/assets/images/default404.jpg');
                             exit;
                         }
                         break;
                     }
                     $_GET['src'] = $src;
                     if (!empty($attr[0])) {
                         $_GET['w'] = $attr[0];
                     }
                     if (!empty($attr[1])) {
                         $_GET['h'] = $attr[1];
                     }
                     if (!empty($attr[2])) {
                         $_GET['a'] = $attr[2];
                     } else {
                         $_GET['a'] = 'c';
                     }
                     include dirname(__FILE__) . DS . 'king.size.php';
                     exit;
                 }
             }
         }
     }
 }
コード例 #2
0
ファイル: king.actions.php プロジェクト: pivotlearning/wpsite
function king_check_filesReadable($dir = '')
{
    if ($dir != '' && is_dir($dir)) {
        if ($handle = opendir($dir)) {
            @chmod($dir, 0755);
            while (false !== ($entry = readdir($handle))) {
                if ($entry != '.' && $entry != '..' && strpos($entry, '.php') === false && is_file($dir . DS . $entry)) {
                    $perm = substr(sprintf('%o', fileperms($dir . DS . $entry)), -1);
                    if ($perm == '0') {
                        @chmod($dir . DS . $entry, 0644);
                    }
                }
                if ($entry != '.' && $entry != '..' && is_dir($dir . DS . $entry)) {
                    king_check_filesReadable($dir . DS . $entry);
                }
            }
        }
    }
}