static function CheckForUpdate()
 {
     $version = HTML_mobilejoomla::getMJVersion();
     if ($version) {
         $document = JFactory::getDocument();
         $document->addStyleSheet(JUri::base(true) . '/components/com_mobilejoomla/css/mjbanner.css');
         jimport('joomla.plugins.helper');
         if (JPluginHelper::isEnabled('mobile', 'scientia')) {
             $detector = 'wurfl';
         } elseif (JPluginHelper::isEnabled('mobile', 'amdd')) {
             $detector = 'amdd';
         } else {
             $detector = 'simple';
         }
         $js = '(function(d){' . 'var s=d.createElement("link");' . 's.href="//www.mobilejoomla.com/checker.php?v=' . urlencode($version) . '&j=' . urlencode(JVERSION) . '&d=' . $detector . '";' . 's.rel="stylesheet";' . 's.type="text/css";' . 's.media="only x";' . 'd.getElementsByTagName("head")[0].appendChild(s);' . 'setTimeout(function(){s.media="all"});' . '})(document);';
         $document->addScriptDeclaration($js);
     }
 }
예제 #2
0
function saveconfig()
{
    $configfname = JPATH_ADMINISTRATOR . '/components/com_mobilejoomla/config.php';
    /** @var $MobileJoomla_Settings array */
    include $configfname;
    $settings = array('caching', 'httpcaching', 'pcpage', 'templatewidth', 'jpegquality', 'desktop_url', 'mobile_sitename', 'xhtml.template', 'xhtml.homepage', 'xhtml.gzip', 'xhtml.domain', 'xhtml.redirect', 'xhtml.buffer_width', 'wml.template', 'wml.homepage', 'wml.gzip', 'wml.domain', 'wml.redirect', 'wml.buffer_width', 'chtml.template', 'chtml.homepage', 'chtml.gzip', 'chtml.domain', 'chtml.redirect', 'chtml.buffer_width', 'iphone.template', 'iphone.homepage', 'iphone.gzip', 'iphone.domain', 'iphone.redirect', 'iphone.buffer_width', 'global.gzip', 'global.removetags', 'global.img', 'global.img_addstyles', 'global.homepage', 'global.componenthome', 'xhtml.header1', 'xhtml.header2', 'xhtml.header3', 'xhtml.middle1', 'xhtml.middle2', 'xhtml.middle3', 'xhtml.componenthome', 'xhtml.footer1', 'xhtml.footer2', 'xhtml.footer3', 'xhtml.jfooter', 'xhtml.simplehead', 'xhtml.allowextedit', 'xhtml.removetags', 'xhtml.removescripts', 'xhtml.img', 'xhtml.img_addstyles', 'xhtml.entitydecode', 'xhtml.embedcss', 'xhtml.contenttype', 'xhtml.xmlhead', 'xhtml.doctype', 'xhtml.xmlns', 'wml.header1', 'wml.header2', 'wml.header3', 'wml.middle1', 'wml.middle2', 'wml.middle3', 'wml.componenthome', 'wml.footer1', 'wml.footer2', 'wml.footer3', 'wml.cards', 'wml.jfooter', 'wml.removetags', 'wml.img', 'wml.entitydecode', 'wml.doctype', 'chtml.header1', 'chtml.header2', 'chtml.header3', 'chtml.middle1', 'chtml.middle2', 'chtml.middle3', 'chtml.componenthome', 'chtml.footer1', 'chtml.footer2', 'chtml.footer3', 'chtml.jfooter', 'chtml.removetags', 'chtml.img', 'chtml.entitydecode', 'chtml.doctype', 'iphone.header1', 'iphone.header2', 'iphone.header3', 'iphone.middle1', 'iphone.middle2', 'iphone.middle3', 'iphone.componenthome', 'iphone.footer1', 'iphone.footer2', 'iphone.footer3', 'iphone.jfooter', 'iphone.img', 'iphone.img_addstyles', 'iphone.removetags');
    $dispatcher = JDispatcher::getInstance();
    $dispatcher->trigger('onMJBeforeSave', array(&$settings, &$MobileJoomla_Settings));
    if ($_POST['mjconfig_desktop_url'] == '') {
        $_POST['mjconfig_desktop_url'] = JUri::root();
    } elseif (strpos($_POST['mjconfig_desktop_url'], '/') === false) {
        $_POST['mjconfig_desktop_url'] = 'http://' . $_POST['mjconfig_desktop_url'] . '/';
    } else {
        $desktop_url = @parse_url($_POST['mjconfig_desktop_url']);
        if (!isset($desktop_url['scheme'])) {
            $desktop_url['scheme'] = 'http';
        }
        if (!isset($desktop_url['host'])) {
            $desktop_url['host'] = $_SERVER['HTTP_HOST'];
        }
        if (isset($desktop_url['port'])) {
            $desktop_url['host'] .= ':' . $desktop_url['port'];
        }
        if (!isset($desktop_url['path'])) {
            $desktop_url['path'] = '/';
        }
        if (substr($desktop_url['path'], -1, 1) != '/') {
            $desktop_url['path'] .= '/';
        }
        $_POST['mjconfig_desktop_url'] = $desktop_url['scheme'] . '://' . $desktop_url['host'] . $desktop_url['path'];
    }
    $params = array();
    foreach ($settings as $param) {
        $post_name = 'mjconfig_' . str_replace('.', '-', $param);
        if (isset($_POST[$post_name])) {
            if (!get_magic_quotes_gpc()) {
                $_POST[$post_name] = addcslashes($_POST[$post_name], "'");
            }
            $MobileJoomla_Settings[$param] = $_POST[$post_name];
        }
        if (is_numeric($MobileJoomla_Settings[$param])) {
            $params[] = "'{$param}'=>" . $MobileJoomla_Settings[$param];
        } else {
            $params[] = "'{$param}'=>'" . $MobileJoomla_Settings[$param] . "'";
        }
    }
    $config = "<?php\n" . "defined( '_JEXEC' ) or die( 'Restricted access' );\n" . "\n" . "\$MobileJoomla_Settings=array(\n" . "'version'=>'" . HTML_mobilejoomla::getMJVersion() . "',\n" . implode(",\n", $params) . "\n" . ");\n" . "?>";
    $app = JFactory::getApplication();
    if (JFile::write($configfname, $config)) {
        $app->redirect('index.php?option=com_mobilejoomla', JText::_('COM_MJ__CONFIG_UPDATED'));
    } else {
        $app->redirect('index.php?option=com_mobilejoomla', JText::_('COM_MJ__UNABLE_OPEN_CONFIG'));
    }
}