示例#1
0
 /**
  * Utility function to read the files and folders in a folder
  *
  * @param	string	$path		The path of the folder to read
  * @param	string	$filter		A filter for folder names
  * @param	mixed	$recurse	True to recursively search into sub-folders, or an integer to specify the maximum depth
  * @param	boolean	$fullpath	True to return the full path to the folders
  * @param	array	$exclude	Array with names of folders which should not be shown in the result
  * @return	array	Folders in the given folder
  */
 public static function readDirectory($path, $filter = '.', $recurse = false, $fullpath = false, $exclude = array('.svn', 'CVS'))
 {
     $arr = array();
     $path = preg_replace('#[/\\\\]+#', DS, $path);
     if (!@is_dir($path)) {
         return $arr;
     }
     // read the source directory
     $handle = opendir($path);
     while (($file = readdir($handle)) !== false) {
         $dir = $path . DS . $file;
         $isDir = is_dir($dir);
         if ($file != '.' && $file != '..' && !in_array($file, $exclude)) {
             // removes SVN directores from list
             if (preg_match("/{$filter}/", $file)) {
                 if ($fullpath) {
                     $arr[] = $dir;
                 } else {
                     $arr[] = $file;
                 }
             }
             if ($recurse && $isDir) {
                 if (is_integer($recurse)) {
                     $recurse--;
                 }
                 $arr2 = JoomlaTuneFS::readDirectory($dir, $filter, $recurse, $fullpath);
                 $arr = array_merge($arr, $arr2);
             }
         }
     }
     closedir($handle);
     asort($arr);
     return $arr;
 }
示例#2
0
 public static function convertLanguages10()
 {
     global $mainframe;
     $joomlaLanguagesPath = $mainframe->getCfg('absolute_path') . '/language';
     $componentPath = $mainframe->getCfg('absolute_path') . '/components/com_jcomments';
     require_once $componentPath . '/libraries/convert/utf8.class.php';
     require_once $componentPath . '/libraries/joomlatune/filesystem.php';
     require_once $componentPath . '/libraries/joomlatune/language.tools.php';
     $codeMap = JoomlaTuneLanguageTools::getLanguageCodes();
     $joomlaLanguageFiles = JoomlaTuneFS::readDirectory($joomlaLanguagesPath, '[a-z]+\\.xml', false, false);
     $joomlaLanguages = array();
     foreach ($joomlaLanguageFiles as $file) {
         $joomlaLanguages[] = str_replace('.xml', '', $file);
     }
     $path = $componentPath . '/languages';
     $filter = '[a-z]{2}-[A-Z]{2}\\.com_jcomments\\.ini';
     $files = JoomlaTuneFS::readDirectory($path, $filter, false, true);
     $files2 = JoomlaTuneFS::readDirectory($path . '/administrator', $filter, false, true);
     $files = array_merge($files, $files2);
     foreach ($files as $file) {
         $m = array();
         preg_match('#([a-z]{2}-[A-Z]{2})#', (string) $file, $m);
         $code = $m[0];
         $language = isset($codeMap[$code]) ? $codeMap[$code][0] : '';
         $charset = isset($codeMap[$code]) ? $codeMap[$code][1] : 'iso-8859-1';
         if ($language != '' && in_array($language, $joomlaLanguages)) {
             if (defined('_ISO2')) {
                 $charset = strtolower(_ISO2);
                 if ($charset == 'utf-8' || $charset == 'utf8') {
                     $newFile = str_replace($code . '.com_jcomments.ini', $language . '.ini', $file);
                     @copy((string) $file, $newFile);
                 } else {
                     JCommentsInstallerLanguageHelper::_convertFile10($file, $code, $charset, $language);
                 }
             } else {
                 JCommentsInstallerLanguageHelper::_convertFile10($file, $code, $charset, $language);
             }
         }
     }
     unset($codeMap);
 }
示例#3
0
function com_uninstall()
{
    require_once dirname(__FILE__) . DS . 'version.php';
    $version = new JCommentsVersion();
    ?>
<style type="text/css">
div#jc {width: 600px;margin: 0 auto;}
span.copyright {color: #777;display: block;margin-top: 12px;}
div#element-box span.componentname {color: #FF9900;font-family: Arial, Helvetica, sans-serif;font-size: 16px;font-weight: bold;}
div#element-box span.componentdate {color: #FF9900;font-family: Arial, Helvetica, sans-serif;font-size: 16px;font-weight: normal;}
div#element-box span.installheader {color: #FF9900;font-family: Arial, Helvetica, sans-serif;font-size: 16px;font-weight: bold;}
div#jc table td {padding: 0}
</style>

<div id="jc">

<div id="element-box">
<div class="t">
<div class="t">
<div class="t"></div>
</div>
</div>
<div class="m">

<table width="95%" border="0" cellpadding="0" cellspacing="0">
	<tr valign="top" align="left">
		<td width="50px"><img src="http://www.joomlatune.com/images/logo/jcomments.png" width="48" height="48" border="0" alt="" /></td>
		<td><span class="componentname"><?php 
    echo $version->getLongVersion();
    ?>
</span>
		<span class="componentdate">[<?php 
    echo $version->getReleaseDate();
    ?>
]</span><br />
		<span class="copyright">&copy; 2006-<?php 
    echo date('Y');
    ?>
 smart (<a href="http://www.joomlatune.ru" target="_blank">JoomlaTune.ru</a> | <a href="http://www.joomlatune.com" target="_blank">JoomlaTune.com</a>). <?php 
    echo JText::_('A_ABOUT_COPYRIGHT');
    ?>
<br /></span></td>
	</tr>
	<tr valign="top" align="left">
		<td>&nbsp;</td>
		<td>&nbsp;</td>
	</tr>

		<tr valign="top" align="left">
			<td>&nbsp;</td>
			<td><span class="installheader"><?php 
    echo JText::_('A_UNINSTALL_LOG');
    ?>
</span></td>
		</tr>
		<tr valign="top" align="left">
			<td>&nbsp;</td>
			<td>
			<ul style="padding: 0 0 0 20px; margin: 0;">
<?php 
    JCommentsInstallerHelper::uninstallPlugin('jcomments', 'content');
    ?>
			<li><?php 
    echo JText::_('A_UNINSTALL_PLUGIN_CONTENT');
    ?>
: <span style="color: green">OK</span></li>
<?php 
    JCommentsInstallerHelper::uninstallPlugin('jcomments', 'search');
    ?>
			<li><?php 
    echo JText::_('A_UNINSTALL_PLUGIN_SEARCH');
    ?>
: <span style="color: green">OK</span></li>
<?php 
    JCommentsInstallerHelper::uninstallPlugin('jcomments', 'system');
    ?>
			<li><?php 
    echo JText::_('A_UNINSTALL_PLUGIN_SYSTEM');
    ?>
: <span style="color: green">OK</span></li>
<?php 
    JCommentsInstallerHelper::uninstallPlugin('jcommentson', 'editors-xtd', array('jcommentson.gif'));
    JCommentsInstallerHelper::uninstallPlugin('jcommentsoff', 'editors-xtd', array('jcommentsoff.gif'));
    ?>
			<li><?php 
    echo JText::_('A_UNINSTALL_PLUGIN_EDITORS_XTD');
    ?>
: <span style="color: green">OK</span></li>
<?php 
    if (JCOMMENTS_JVERSION == '1.0') {
        global $mainframe;
        $app = $mainframe;
    } else {
        JCommentsInstallerHelper::uninstallPlugin('jcomments', 'user');
        $app = JFactory::getApplication('administrator');
    }
    // Clean all caches for components with comments
    if ($app->getCfg('caching') == 1) {
        $db = JCommentsFactory::getDBO();
        $db->setQuery("SELECT DISTINCT(object_group) AS name FROM #__jcomments");
        $rows = $db->loadObjectList();
        foreach ($rows as $row) {
            $cache = JCommentsFactory::getCache($row->name);
            $cache->clean();
        }
        unset($rows);
        ?>
			<li><?php 
        echo JText::_('A_UNINSTALL_CLEAN_CACHE');
        ?>
: <span style="color: green">OK</span></li>
<?php 
    }
    ?>
			<li><span style="color: green"><strong><?php 
    echo JText::_('A_UNINSTALL_COMPLETE');
    ?>
</strong></span></li>
			</ul>
			</td>
		</tr>
	</table>

	</div>
	<div class="b">
	<div class="b">
	<div class="b"></div>
	</div>
	</div>
	</div>

	</div>
<?php 
    if (JCOMMENTS_JVERSION == '1.0') {
        global $mainframe;
        $componentPath = $mainframe->getCfg('absolute_path') . DS . 'components' . DS . 'com_jcomments';
        require_once $componentPath . DS . 'libraries' . DS . 'joomlatune' . DS . 'filesystem.php';
        $files = JoomlaTuneFS::readDirectory($componentPath . DS . 'languages', '\\.ini', false, true);
        foreach ($files as $file) {
            if (!preg_match('/[a-z]{2}-[A-Z]{2}\\.com_jcomments/', (string) $file)) {
                @unlink((string) $file);
            }
        }
    }
}
示例#4
0
 public static function showSmiles()
 {
     $app = JCommentsFactory::getApplication('administrator');
     $config = JCommentsFactory::getConfig();
     require_once JCOMMENTS_LIBRARIES . '/joomlatune/filesystem.php';
     $smilesPath = $config->get('smiles_path', 'components' . DS . 'com_jcomments' . DS . 'images' . DS . 'smiles' . DS);
     $smilesAbsPath = $app->getCfg('absolute_path') . DS . $smilesPath;
     $smilesAbsPath = str_replace(DS . DS, DS, $smilesAbsPath);
     $imageFiles = JoomlaTuneFS::readDirectory($smilesAbsPath);
     $lists['images'] = array();
     foreach ($imageFiles as $file) {
         if (preg_match("/(gif|jpg|png)/i", (string) $file)) {
             $lists['images'][] = $file;
         }
     }
     $config = JCommentsFactory::getConfig();
     $lists['smiles'] = $config->get('smiles');
     $lists['smiles_path'] = $app->getCfg('live_site') . str_replace('//', '/', str_replace(DS, '/', $smilesPath) . '/');
     HTML_JComments::showSmiles($lists);
 }
function com_uninstall()
{
    global $mainframe;
    $versionInfo = JCommentsInstallerHelper::getVersionInfo('jcomments');
    ?>
<style type="text/css">
div#jc {width: 600px;margin: 0 auto;}
span.copyright {color: #777;display: block;margin-top: 12px;}
div#element-box span.componentname {color: #FF9900;font-family: Arial, Helvetica, sans-serif;font-size: 16px;font-weight: bold;}
div#element-box span.componentdate {color: #FF9900;font-family: Arial, Helvetica, sans-serif;font-size: 16px;font-weight: normal;}
div#element-box span.installheader {color: #FF9900;font-family: Arial, Helvetica, sans-serif;font-size: 16px;font-weight: bold;}
</style>

<div id="jc">

<div id="element-box">
<div class="t">
<div class="t">
<div class="t"></div>
</div>
</div>
<div class="m">

<table width="95%" border="0" cellpadding="0" cellspacing="0">
	<tr valign="top" align="left">
		<td width="50px"><img src="http://www.joomlatune.com//images/banners/jcomments_logo.png" width="48" height="48" border="0" alt="" /></td>
		<td><span class="componentname">JComments <?php 
    echo $versionInfo->releaseVersion;
    ?>
</span>
		<span class="componentdate">[<?php 
    echo $versionInfo->releaseDate;
    ?>
]</span><br />
		<span class="copyright">&copy; 2006-2010 smart (<a href="http://www.joomlatune.ru" target="_blank">JoomlaTune.ru</a> | <a href="http://www.joomlatune.com" target="_blank">JoomlaTune.com</a>). <?php 
    echo JText::_('All rights reserved!');
    ?>
<br /></span></td>
	</tr>
	<tr valign="top" align="left">
		<td>&nbsp;</td>
		<td>&nbsp;</td>
	</tr>

		<tr valign="top" align="left">
			<td>&nbsp;</td>
			<td><span class="installheader"><?php 
    echo JText::_('Uninstall log');
    ?>
</span></td>
		</tr>
		<tr valign="top" align="left">
			<td>&nbsp;</td>
			<td>
			<ul style="padding: 0 0 0 20px; margin: 0;">
<?php 
    JCommentsInstallerHelper::uninstallPlugin('jcomments', 'content');
    ?>
			<li><?php 
    echo JText::_('Uninstall content plugin');
    ?>
: <span style="color: green">OK</span></li>
<?php 
    JCommentsInstallerHelper::uninstallPlugin('jcomments', 'search');
    ?>
			<li><?php 
    echo JText::_('Uninstall search plugin');
    ?>
: <span style="color: green">OK</span></li>
<?php 
    JCommentsInstallerHelper::uninstallPlugin('jcomments', 'system');
    ?>
			<li><?php 
    echo JText::_('Uninstall system plugin');
    ?>
: <span style="color: green">OK</span></li>
<?php 
    JCommentsInstallerHelper::uninstallPlugin('jcommentson', 'editors-xtd', array('jcommentson.gif'));
    JCommentsInstallerHelper::uninstallPlugin('jcommentsoff', 'editors-xtd', array('jcommentsoff.gif'));
    JCommentsInstallerHelper::uninstallPlugin('jcomments', 'k2');
    ?>
			<li><?php 
    echo JText::_('Uninstall editors-xtd plugins');
    ?>
: <span style="color: green">OK</span></li>
<?php 
    if (defined('JPATH_ROOT')) {
        JCommentsInstallerHelper::uninstallPlugin('jcomments', 'user');
        if (!isset($mainframe)) {
            $mainframe =& JFactory::getApplication('administrator');
        }
    }
    // Clean all caches for components with comments
    if ($mainframe->getCfg('caching') == 1) {
        $db =& JCommentsFactory::getDBO();
        $db->setQuery("SELECT DISTINCT(object_group) AS name FROM #__jcomments");
        $rows = $db->loadObjectList();
        foreach ($rows as $row) {
            JCommentsCache::cleanCache($row->name);
        }
        unset($rows);
        ?>
			<li><?php 
        echo JText::_('Clean components cache');
        ?>
: <span style="color: green">OK</span></li>
<?php 
    }
    ?>
			<li><span style="color: green"><strong><?php 
    echo JText::_('JComments uninstalled');
    ?>
</strong></span></li>
			</ul>
			</td>
		</tr>
	</table>

	</div>
	<div class="b">
	<div class="b">
	<div class="b"></div>
	</div>
	</div>
	</div>

	</div>
<?php 
    if (JCOMMENTS_JVERSION == '1.0') {
        $componentPath = $mainframe->getCfg('absolute_path') . DS . 'components' . DS . 'com_jcomments';
        require_once $componentPath . DS . 'libraries' . DS . 'joomlatune' . DS . 'filesystem.php';
        $path = $componentPath . DS . 'languages';
        $filter = '\\.ini';
        $files = JoomlaTuneFS::readDirectory($path, $filter, false, true);
        foreach ($files as $file) {
            if (!preg_match('/[a-z]{2}-[A-Z]{2}\\.com_jcomments/', (string) $file)) {
                @unlink((string) $file);
            }
        }
    }
}
 function postInstall()
 {
     global $mainframe;
     $db =& JCommentsFactory::getDBO();
     $installer = new HTML_JCommentsInstaller();
     JCommentsInstallerHelper::extractJCommentsPlugins();
     JCommentsInstallerHelper::setPermissions(JCOMMENTS_BASE . DS . 'tpl', '0644');
     // create database tables
     if (JCOMMENTS_JVERSION == '1.0') {
         $installSQL = dirname(__FILE__) . DS . 'install' . DS . 'sql' . DS . 'install.mysql.nonutf8.sql';
         JCommentsInstaller::executeSQL($installSQL);
     } else {
         if (JCOMMENTS_JVERSION == '1.5') {
             require_once JCOMMENTS_LIBRARIES . DS . 'joomlatune' . DS . 'filesystem.php';
             $config =& JFactory::getConfig();
             $mainframe =& JFactory::getApplication();
             if ($config->getValue('config.legacy')) {
                 $installSQL = dirname(__FILE__) . DS . 'install' . DS . 'sql' . DS . 'install.mysql.utf8.sql';
                 JCommentsInstaller::executeSQL($installSQL);
                 // path to languages directory
                 $path = JCOMMENTS_BASE . DS . 'languages';
                 $jpath = JPATH_ROOT . DS . 'language';
                 $languages = JoomlaTuneFS::readDirectory($path);
                 if (!is_writable($jpath)) {
                     @chmod($jpath, 0755);
                 }
                 foreach ($languages as $language) {
                     if (preg_match('#[a-z]{2}\\-[A-Z]{2}\\.com_jcomments.ini#is', (string) $language)) {
                         $languageCode = substr((string) $language, 0, 5);
                         $languageDir = $jpath . DS . $languageCode;
                         if (!is_dir($languageDir)) {
                             if (!JFolder::create($languageDir)) {
                                 continue;
                             }
                         }
                         if (is_dir($languageDir)) {
                             @chmod($languageDir, 0755);
                             $languageSrc = $path . DS . $language;
                             $languageDestination = $languageDir . DS . $language;
                             if (!@copy($languageSrc, $languageDestination)) {
                                 $errorMessage = JText::sprintf('Unable to copy file %s to language folder. Please set write persmission to language folder (%s) and press the Refresh/Reload button of your browser.', $language, $languageDir);
                                 $installer->addError($errorMessage);
                                 continue;
                             }
                         }
                     }
                 }
                 unset($languages);
                 $language =& JFactory::getLanguage();
                 $language->load('com_jcomments', JPATH_SITE, null, true);
             }
             @ob_start();
             // install JomSocial Rule
             $jomSocialRuleSrc = dirname(__FILE__) . DS . 'install' . DS . 'xml' . DS . 'jomsocial_rule.xm';
             $jomSocialRuleDst = JCOMMENTS_BASE . DS . 'jomsocial_rule.xml';
             if (!is_file($jomSocialRuleDst)) {
                 JCommentsInstallerHelper::copyFile($jomSocialRuleSrc, $jomSocialRuleDst);
                 JCommentsInstallerHelper::setPermissions($jomSocialRuleDst, 0755);
             }
             // remove language files
             $path = JCOMMENTS_BASE . DS . 'languages';
             $filter = '\\.ini';
             $files = JoomlaTuneFS::readDirectory($path, $filter, false, true);
             foreach ($files as $file) {
                 JCommentsInstallerHelper::deleteFile($file);
             }
             if (is_dir($path)) {
                 JCommentsInstallerHelper::deleteFolder($path);
             }
             // remove plugins.zip
             if (is_file(JCOMMENTS_BASE . DS . 'plugins' . DS . 'plugins.zip')) {
                 JCommentsInstallerHelper::deleteFile(JCOMMENTS_BASE . DS . 'plugins' . DS . 'plugins.zip');
             }
             @ob_end_clean();
         }
     }
     $jxml10 = dirname(__FILE__) . DS . 'jcomments10.xml';
     $jxml15 = dirname(__FILE__) . DS . 'jcomments15.xml';
     $jxml = dirname(__FILE__) . DS . 'jcomments.xml';
     if (is_file($jxml10)) {
         @rename($jxml10, $jxml);
     } else {
         if (is_file($jxml15)) {
             @rename($jxml15, $jxml);
         }
     }
     unset($jxml10, $jxml15, $jxml);
     // small stuff for future update system
     $db->setQuery('SELECT `version` FROM `#__jcomments_version`');
     $version = $db->loadResult();
     $versionInfo = JCommentsInstallerHelper::getVersionInfo('jcomments');
     $currentVersion = $versionInfo->releaseVersion;
     $currentDate = date('Y-m-d H:i:s');
     if (empty($version)) {
         $db->setQuery("INSERT IGNORE INTO `#__jcomments_version` (`version`,`installed`) VALUES ('{$currentVersion}', '{$currentDate}')");
         @$db->query();
         // if version isn't specified - we think that it was 1.4.0.9 or earlier...
         $version = '1.4.0.9';
     } else {
         $db->setQuery("UPDATE `#__jcomments_version` SET `version` = '{$currentVersion}', `updated` = '{$currentDate}';");
         @$db->query();
     }
     if (version_compare($version, '2.1.0.0') < 0) {
         JCommentsInstallerHelper::uninstallPlugin('jcomments.content', 'content');
         JCommentsInstallerHelper::uninstallPlugin('jcomments.search', 'search');
         JCommentsInstallerHelper::uninstallPlugin('jcomments.system', 'system');
     }
     // install content plugin
     JCommentsInstallerHelper::installPlugin('Content - JComments', 'jcomments', 'content', array(), 'AI_INSTALL_CONTENTBOT', 'AI_INSTALL_CONTENTBOT_WARNING', 1, $installer);
     // install search plugin
     JCommentsInstallerHelper::installPlugin('Search - JComments', 'jcomments', 'search', array(), 'AI_INSTALL_CONTENTSEARCHBOT', 'AI_INSTALL_CONTENTSEARCHBOT_WARNING', 1, $installer);
     // install system plugin
     JCommentsInstallerHelper::installPlugin('System - JComments', 'jcomments', 'system', array(), 'AI_INSTALL_SYSTEMBOT', 'AI_INSTALL_SYSTEMBOT_WARNING', 1, $installer);
     // install editor buttons
     JCommentsInstallerHelper::installPlugin('Editor Button - JComments ON', 'jcommentson', 'editors-xtd', array('jcommentson.gif'), '', '', 1, $installer);
     JCommentsInstallerHelper::installPlugin('Editor Button - JComments OFF', 'jcommentsoff', 'editors-xtd', array('jcommentsoff.gif'), '', '', 1, $installer);
     if (JCOMMENTS_JVERSION == '1.5') {
         // install user plugin
         JCommentsInstallerHelper::installPlugin('User - JComments', 'jcomments', 'user', array(), '', '', 1, $installer);
     }
     // Fix component menu icon
     if (JCOMMENTS_JVERSION == '1.0') {
         $menuiconpath = $mainframe->getCfg('absolute_path') . DS . 'includes' . DS . 'js' . DS . 'ThemeOffice';
         $adminIconsPath = '../administrator/components/com_jcomments/assets';
         if (is_writable($menuiconpath)) {
             $currentIconsPath = dirname(__FILE__) . DS . 'images';
             ob_start();
             $res1 = $res2 = $res3 = $res4 = $res5 = false;
             $res1 = @copy($currentIconsPath . DS . 'jcomments16x16.png', $menuiconpath . DS . 'jcomments16x16.png');
             $res2 = @copy($currentIconsPath . DS . 'import16x16.png', $menuiconpath . DS . 'import16x16.png');
             $res3 = @copy($currentIconsPath . DS . 'settings16x16.png', $menuiconpath . DS . 'settings16x16.png');
             $res4 = @copy($currentIconsPath . DS . 'smiles16x16.png', $menuiconpath . DS . 'smiles16x16.png');
             $res5 = @copy($currentIconsPath . DS . 'comments16x16.png', $menuiconpath . DS . 'comments16x16.png');
             $res6 = @copy($currentIconsPath . DS . 'subscriptions16x16.png', $menuiconpath . DS . 'subscriptions16x16.png');
             $res7 = @copy($currentIconsPath . DS . 'custombbcodes16x16.png', $menuiconpath . DS . 'custombbcodes16x16.png');
             ob_end_clean();
             $result = $res1 && $res2 && $res3 && $res4 && $res5 && $res6 && $res7;
             if ($result && is_file($menuiconpath . DS . 'jcomments16x16.png')) {
                 $adminIconsPath = 'js/ThemeOffice';
             }
         }
         $db->setQuery("UPDATE #__components SET admin_menu_img='{$adminIconsPath}/jcomments16x16.png' " . "\n WHERE admin_menu_link='option=com_jcomments'");
         @$db->query();
         $db->setQuery("UPDATE #__components SET admin_menu_img='{$adminIconsPath}/comments16x16.png', name='" . JText::_('AI_MENU_COMMENTS') . "'" . "\n WHERE admin_menu_link='option=com_jcomments&task=comments'");
         @$db->query();
         $db->setQuery("UPDATE #__components SET admin_menu_img='{$adminIconsPath}/settings16x16.png', name='" . JText::_('AI_MENU_SETTINGS') . "'" . "\n WHERE admin_menu_link='option=com_jcomments&task=settings'");
         @$db->query();
         $db->setQuery("UPDATE #__components SET admin_menu_img='{$adminIconsPath}/smiles16x16.png', name='" . JText::_('AI_MENU_SMILES') . "'" . "\n WHERE admin_menu_link='option=com_jcomments&task=smiles'");
         @$db->query();
         $db->setQuery("UPDATE #__components SET admin_menu_img='{$adminIconsPath}/subscriptions16x16.png', name='" . JText::_('AI_MENU_SUBSCRIPTIONS') . "'" . "\n WHERE admin_menu_link='option=com_jcomments&task=subscriptions'");
         @$db->query();
         $db->setQuery("UPDATE #__components SET admin_menu_img='{$adminIconsPath}/custombbcodes16x16.png', name='" . JText::_('Custom BBCode') . "'" . "\n WHERE admin_menu_link='option=com_jcomments&task=custombbcodes'");
         @$db->query();
         $db->setQuery("UPDATE #__components SET admin_menu_img='{$adminIconsPath}/import16x16.png', name='" . JText::_('AI_MENU_IMPORT') . "'" . "\n WHERE admin_menu_link='option=com_jcomments&task=import'");
         @$db->query();
         $db->setQuery("UPDATE #__components SET admin_menu_img='{$adminIconsPath}/jcomments16x16.png', name='" . JText::_('AI_MENU_ABOUT') . "'" . "\n WHERE admin_menu_link='option=com_jcomments&task=about'");
         @$db->query();
         // clear Joostina administrative menu cache
         if (function_exists('js_menu_cache_clear')) {
             @js_menu_cache_clear();
         }
     } else {
         $adminIconsPath = 'components/com_jcomments/assets';
         $db->setQuery("UPDATE #__components SET admin_menu_img='{$adminIconsPath}/jcomments16x16.png' WHERE admin_menu_link='option=com_jcomments' OR admin_menu_link='option=com_jcomments&task=about'");
         @$db->query();
         $db->setQuery("UPDATE #__components SET admin_menu_img='{$adminIconsPath}/comments16x16.png' WHERE admin_menu_link='option=com_jcomments&task=comments'");
         @$db->query();
         $db->setQuery("UPDATE #__components SET admin_menu_img='{$adminIconsPath}/settings16x16.png' WHERE admin_menu_link='option=com_jcomments&task=settings'");
         @$db->query();
         $db->setQuery("UPDATE #__components SET admin_menu_img='{$adminIconsPath}/smiles16x16.png' WHERE admin_menu_link='option=com_jcomments&task=smiles'");
         @$db->query();
         $db->setQuery("UPDATE #__components SET admin_menu_img='{$adminIconsPath}/subscriptions16x16.png' WHERE admin_menu_link='option=com_jcomments&task=subscriptions'");
         @$db->query();
         $db->setQuery("UPDATE #__components SET admin_menu_img='{$adminIconsPath}/custombbcodes16x16.png' WHERE admin_menu_link='option=com_jcomments&task=custombbcodes'");
         @$db->query();
         $db->setQuery("UPDATE #__components SET admin_menu_img='{$adminIconsPath}/import16x16.png' WHERE admin_menu_link='option=com_jcomments&task=import'");
         @$db->query();
     }
     $installer->addMessage(JText::_('AI_UPDATE_MENU_ICONS'), true);
     // update db tables
     $dbStructureChanged = version_compare($version, '2.2.0.0') <= 0;
     if ($dbStructureChanged) {
         require_once dirname(__FILE__) . DS . 'install' . DS . 'helpers' . DS . 'database.php';
         $upgradeStructure2000 = false;
         if (version_compare($version, '2.0.0.0') < 0) {
             // auto upgrade old table structure
             $upgradeStructure2000 = JCommentsInstallerDatabaseHelper::upgradeStructure();
         }
         $upgradeStructure2200 = JCommentsInstallerDatabaseHelper::upgradeStructure2200();
         if ($upgradeStructure2200) {
             // TODO upgrade tree structure during installation process
             // JCommentsInstallerDatabaseHelper::updateCommentsLevel();
             // JCommentsInstallerDatabaseHelper::updateCommentsPath();
         }
         if ($upgradeStructure2000 || $upgradeStructure2200) {
             $installer->addMessage(JText::_('AI_UPGRADE_TABLES'), true);
         }
     }
     // upgrade subscriptions to new comments
     $subscriptionsChanged = version_compare($version, '2.1.0.0') < 0;
     if ($subscriptionsChanged) {
         $upgradeSubs = JCommentsInstaller::upgradeSubscriptions($version);
         if ($upgradeSubs) {
             $installer->addMessage(JText::_('Upgrade subscriptions'), true);
         }
     }
     // collation synchronization (for MySQL 4.1.2 or higher)
     if (version_compare(preg_replace('~\\-.+?$~', '', $db->getVersion()), '4.1.2') >= 0) {
         require_once dirname(__FILE__) . DS . 'install' . DS . 'helpers' . DS . 'database.php';
         JCommentsInstallerDatabaseHelper::setupCollation();
     }
     $db->setQuery("SELECT `name`, `value` FROM `#__jcomments_settings`");
     $paramsList = $db->loadObjectList('name');
     if (count($paramsList) == 0) {
         $defaultSettings = dirname(__FILE__) . DS . 'install' . DS . 'sql' . DS . 'settings.sql';
         JCommentsInstaller::executeSQL($defaultSettings);
     } else {
         JCommentsInstaller::checkParam($paramsList, 'comment_title', '0');
         JCommentsInstaller::checkParam($paramsList, 'enable_custom_bbcode', '0');
         JCommentsInstaller::checkParam($paramsList, 'enable_bbcode_quote', 'Unregistered,Registered,Author,Editor,Publisher,Manager,Administrator,Super Administrator');
         JCommentsInstaller::checkParam($paramsList, 'notification_type', '1,2');
         JCommentsInstaller::checkParam($paramsList, 'captcha_engine', 'kcaptcha');
         JCommentsInstaller::checkParam($paramsList, 'comment_minlength', '0');
     }
     unset($paramsList);
     $joomfish = $mainframe->getCfg('absolute_path') . DS . 'components' . DS . 'com_joomfish' . DS . 'joomfish.php';
     if (is_file($joomfish)) {
         JCommentsInstaller::upgradeLanguages();
     }
     if (JCOMMENTS_JVERSION == '1.0') {
         // Update Artio JoomSEF configuration (add option to skip JComments urls)
         JCommentsInstaller::updateArtio();
     }
     $db->setQuery("SELECT COUNT(*) FROM `#__jcomments_custom_bbcodes`;");
     $cnt = $db->loadResult();
     if ($cnt == 0) {
         $sql = dirname(__FILE__) . DS . 'install' . DS . 'sql' . DS . 'custom_bbcodes.sql';
         JCommentsInstaller::executeSQL($sql);
     }
     $installer->showInstallLog();
     JCommentsCache::cleanCache('com_jcomments');
 }
示例#7
0
 function showSettings()
 {
     $db =& JCommentsFactory::getDBO();
     $config =& JCommentsFactory::getConfig();
     // check current site template for afterDisplayContent event
     if (JCOMMENTS_JVERSION == '1.5') {
         $db->setQuery('SELECT template FROM #__templates_menu WHERE client_id = 0 AND menuid = 0', 0, 1);
         $template = $db->loadResult();
         $articleTemplate = JPATH_SITE . DS . 'templates' . DS . $template . DS . 'html' . DS . 'com_content' . DS . 'article' . DS . 'default.php';
         if (is_file($articleTemplate)) {
             $tmpl = implode('', file($articleTemplate));
             if (strpos($tmpl, 'afterDisplayContent') === false) {
                 JError::raiseWarning(500, JText::_('Your current site template doesn\'t have afterDisplayContent event!'));
             }
         }
     }
     $languages = array();
     $joomfish = JOOMLATUNE_JPATH_SITE . DS . 'components' . DS . 'com_joomfish' . DS . 'joomfish.php';
     if (is_file($joomfish)) {
         $db =& JCommentsFactory::getDBO();
         $db->setQuery("SELECT `name`, `code` as value FROM `#__languages` WHERE `active` = 1");
         $languages = $db->loadObjectList();
         if (is_array($languages)) {
             $lang = trim(JCommentsInput::getVar('lang', ''));
             if ($lang == '') {
                 if (JCOMMENTS_JVERSION == '1.5') {
                     $params = JComponentHelper::getParams('com_languages');
                     $lang = $params->get("site", 'en-GB');
                 }
                 if ($lang == '') {
                     $lang = JCommentsMultilingual::getLanguage();
                 }
             }
             // reload configuration
             $config =& JCommentsFactory::getConfig($lang);
             $lists['languages'] = JCommentsHTML::selectList($languages, 'lang', 'class="inputbox" size="1" onchange="submitform(\'settings\');"', 'value', 'name', $lang);
         }
     }
     $forbiddenNames = $config->get('forbidden_names');
     $forbiddenNames = preg_replace('#,+#', "\n", $forbiddenNames);
     $config->set('forbidden_names', $forbiddenNames);
     $badWords = $config->get('badwords');
     if ($badWords != '') {
         $config->set('badwords', implode("\n", $badWords));
     }
     require_once JCOMMENTS_LIBRARIES . DS . 'joomlatune' . DS . 'filesystem.php';
     // path to images directory
     $path = JCOMMENTS_BASE . DS . 'tpl' . DS;
     $items = JoomlaTuneFS::readDirectory($path);
     $templates = array();
     foreach ($items as $item) {
         if (is_dir($path . $item)) {
             $tpl = new StdClass();
             $tpl->text = $item;
             $tpl->value = $item;
             $templates[] = $tpl;
         }
     }
     $currentTemplate = $config->get('template');
     $lists['templates'] = JCommentsHTML::selectList($templates, 'cfg_template', 'class="inputbox"', 'value', 'text', $currentTemplate);
     $rows = JCommentsAdmin::getAllGroups();
     $exclude = JCommentsAdmin::getHigherGroups();
     if (count($exclude)) {
         // remove users 'above' me
         $i = 0;
         while ($i < count($rows)) {
             if (in_array($rows[$i]->group_id, $exclude)) {
                 array_splice($rows, $i, 1);
             } else {
                 $i++;
             }
         }
     }
     $captchaError = '';
     $captchaExclude = array();
     if (!extension_loaded('gd') || !function_exists('imagecreatefrompng')) {
         if ($config->get('captcha_engine', 'kcaptcha') != 'recaptcha') {
             foreach ($rows as $row) {
                 $captchaExclude[] = $row->value;
             }
             $captchaError = JText::_('GD library is not installed!');
         }
     }
     $lists['group_names'] = $rows;
     $groups = array();
     // Post
     JCommentsAdmin::loadParam($groups, 'can_comment', $rows, JText::_('A_RIGHTS_POST'), JText::_('AP_CAN_COMMENT'), JText::_('AP_CAN_COMMENT_DESC'));
     JCommentsAdmin::loadParam($groups, 'can_reply', $rows, JText::_('A_RIGHTS_POST'), JText::_('AP_CAN_REPLY'), JText::_('AP_CAN_REPLY_DESC'));
     JCommentsAdmin::loadParam($groups, 'autopublish', $rows, JText::_('A_RIGHTS_POST'), JText::_('AP_AUTOPUBLISH'), JText::_('AP_AUTOPUBLISH_DESC'));
     JCommentsAdmin::loadParam($groups, 'show_policy', $rows, JText::_('A_RIGHTS_POST'), JText::_('AP_SHOW_POLICY'), JText::_('AP_SHOW_POLICY_DESC'));
     JCommentsAdmin::loadParam($groups, 'enable_captcha', $rows, JText::_('A_RIGHTS_POST'), JText::_('AP_ENABLE_CAPTCHA'), JText::_('AP_ENABLE_CAPTCHA_DESC'), $captchaExclude, $captchaError);
     JCommentsAdmin::loadParam($groups, 'floodprotection', $rows, JText::_('A_RIGHTS_POST'), JText::_('AP_ENABLE_FLOODPROTECTION'), JText::_('AP_ENABLE_FLOODPROTECTION_DESC'));
     JCommentsAdmin::loadParam($groups, 'enable_comment_length_check', $rows, JText::_('A_RIGHTS_POST'), JText::_('AP_ENABLE_COMMENT_LENGTH_CHECK'), JText::_('AP_ENABLE_COMMENT_LENGTH_CHECK_DESC'));
     JCommentsAdmin::loadParam($groups, 'enable_autocensor', $rows, JText::_('A_RIGHTS_POST'), JText::_('AP_ENABLE_AUTOCENSOR'), JText::_('AP_ENABLE_AUTOCENSOR_DESC'));
     JCommentsAdmin::loadParam($groups, 'enable_subscribe', $rows, JText::_('A_RIGHTS_POST'), JText::_('AP_ENABLE_SUBSCRIBE'), JText::_('AP_ENABLE_SUBSCRIBE_DESC'));
     // BBCodes
     JCommentsAdmin::loadParam($groups, 'enable_bbcode_b', $rows, JText::_('A_RIGHTS_BBCODE'), JText::_('AP_ENABLE_BBCODE_B'), JText::_('AP_ENABLE_BBCODE_B_DESC'));
     JCommentsAdmin::loadParam($groups, 'enable_bbcode_i', $rows, JText::_('A_RIGHTS_BBCODE'), JText::_('AP_ENABLE_BBCODE_I'), JText::_('AP_ENABLE_BBCODE_I_DESC'));
     JCommentsAdmin::loadParam($groups, 'enable_bbcode_u', $rows, JText::_('A_RIGHTS_BBCODE'), JText::_('AP_ENABLE_BBCODE_U'), JText::_('AP_ENABLE_BBCODE_U_DESC'));
     JCommentsAdmin::loadParam($groups, 'enable_bbcode_s', $rows, JText::_('A_RIGHTS_BBCODE'), JText::_('AP_ENABLE_BBCODE_S'), JText::_('AP_ENABLE_BBCODE_S_DESC'));
     JCommentsAdmin::loadParam($groups, 'enable_bbcode_url', $rows, JText::_('A_RIGHTS_BBCODE'), JText::_('AP_ENABLE_BBCODE_URL'), JText::_('AP_ENABLE_BBCODE_URL_DESC'));
     JCommentsAdmin::loadParam($groups, 'enable_bbcode_img', $rows, JText::_('A_RIGHTS_BBCODE'), JText::_('AP_ENABLE_BBCODE_IMG'), JText::_('AP_ENABLE_BBCODE_IMG_DESC'));
     JCommentsAdmin::loadParam($groups, 'enable_bbcode_list', $rows, JText::_('A_RIGHTS_BBCODE'), JText::_('AP_ENABLE_BBCODE_LIST'), JText::_('AP_ENABLE_BBCODE_LIST_DESC'));
     JCommentsAdmin::loadParam($groups, 'enable_bbcode_hide', $rows, JText::_('A_RIGHTS_BBCODE'), JText::_('AP_ENABLE_BBCODE_HIDE'), JText::_('AP_ENABLE_BBCODE_HIDE_DESC'), array('Unregistered'));
     JCommentsAdmin::loadParam($groups, 'enable_bbcode_quote', $rows, JText::_('A_RIGHTS_BBCODE'), JText::_('AP_ENABLE_BBCODE_QUOTE'), JText::_('AP_ENABLE_BBCODE_QUOTE_DESC'));
     // View
     JCommentsAdmin::loadParam($groups, 'autolinkurls', $rows, JText::_('A_RIGHTS_VIEW'), JText::_('AP_ENABLE_AUTOLINKURLS'), JText::_('AP_ENABLE_AUTOLINKURLS_DESC'));
     JCommentsAdmin::loadParam($groups, 'emailprotection', $rows, JText::_('A_RIGHTS_VIEW'), JText::_('AP_ENABLE_EMAILPROTECTION'), JText::_('AP_ENABLE_EMAILPROTECTION_DESC'));
     JCommentsAdmin::loadParam($groups, 'enable_gravatar', $rows, JText::_('A_RIGHTS_VIEW'), JText::_('AP_ENABLE_GRAVATAR'), JText::_('AP_ENABLE_GRAVATAR_DESC'));
     JCommentsAdmin::loadParam($groups, 'can_view_email', $rows, JText::_('A_RIGHTS_VIEW'), JText::_('AP_CAN_VIEW_AUTHOR_EMAIL'), JText::_('AP_CAN_VIEW_AUTHOR_EMAIL_DESC'));
     JCommentsAdmin::loadParam($groups, 'can_view_homepage', $rows, JText::_('A_RIGHTS_VIEW'), JText::_('AP_CAN_VIEW_AUTHOR_HOMEPAGE'), JText::_('AP_CAN_VIEW_AUTHOR_HOMEPAGE_DESC'));
     JCommentsAdmin::loadParam($groups, 'can_view_ip', $rows, JText::_('A_RIGHTS_VIEW'), JText::_('AP_CAN_VIEW_AUTHOR_IP'), JText::_('AP_CAN_VIEW_AUTHOR_IP_DESC'), array('Unregistered', 'Registered'));
     // Edit
     JCommentsAdmin::loadParam($groups, 'can_edit_own', $rows, JText::_('A_RIGHTS_EDIT'), JText::_('AP_CAN_EDIT_OWN'), JText::_('AP_CAN_EDIT_OWN_DESC'), array('Unregistered'));
     JCommentsAdmin::loadParam($groups, 'can_delete_own', $rows, JText::_('A_RIGHTS_EDIT'), JText::_('AP_CAN_DELETE_OWN'), JText::_('AP_CAN_DELETE_OWN_DESC'), array('Unregistered'));
     // Administration
     JCommentsAdmin::loadParam($groups, 'can_edit', $rows, JText::_('A_RIGHTS_ADMINISTRATION'), JText::_('AP_CAN_EDIT'), JText::_('AP_CAN_EDIT_DESC'), array('Unregistered', 'Registered'));
     JCommentsAdmin::loadParam($groups, 'can_publish', $rows, JText::_('A_RIGHTS_ADMINISTRATION'), JText::_('AP_CAN_PUBLISH'), JText::_('AP_CAN_PUBLISH_DESC'), array('Unregistered', 'Registered'));
     JCommentsAdmin::loadParam($groups, 'can_delete', $rows, JText::_('A_RIGHTS_ADMINISTRATION'), JText::_('AP_CAN_DELETE'), JText::_('AP_CAN_DELETE_DESC'), array('Unregistered', 'Registered'));
     // Votes
     JCommentsAdmin::loadParam($groups, 'can_vote', $rows, JText::_('A_RIGHTS_MISC'), JText::_('AP_CAN_VOTE'), JText::_('AP_CAN_VOTE_DESC'));
     $reportError = '';
     $reportExclude = array();
     if ($config->getInt('enable_notification') == 0 || $config->check('notification_type', 2) == false) {
         foreach ($rows as $row) {
             $reportExclude[] = $row->value;
         }
         $reportError = JText::_('Notifications are disabled! Please, enable notifications first.');
     }
     JCommentsAdmin::loadParam($groups, 'can_report', $rows, JText::_('A_RIGHTS_MISC'), JText::_('AP_CAN_REPORT'), JText::_('AP_CAN_REPORT_DESC'), $reportExclude, $reportError);
     $lists['groups'] =& $groups;
     if ($config->get('enable_categories') != '') {
         $query = "SELECT c.id AS `value`, CONCAT_WS( ' / ', s.title, c.title) AS `text`" . "\n FROM #__sections AS s" . "\n INNER JOIN #__categories AS c ON c.section = s.id" . "\n WHERE c.id IN ( " . $config->get('enable_categories') . " )" . "\n ORDER BY s.name,c.name";
         $db->setQuery($query);
         $lookup = $db->loadObjectList();
     } else {
         $lookup = '';
     }
     $query = "SELECT c.id AS `value`, CONCAT_WS( ' / ', s.title, c.title) AS `text`" . "\n FROM #__sections AS s" . "\n INNER JOIN #__categories AS c ON c.section = s.id" . "\n ORDER BY s.name,c.name";
     $db->setQuery($query);
     $categories = $db->loadObjectList();
     if (!is_array($categories)) {
         $categories = array();
     }
     $lists['categories'] = JCommentsHTML::selectList($categories, 'cfg_enable_categories[]', 'class="inputbox" size="10" multiple="multiple"', 'value', 'text', $lookup);
     $captcha = array();
     $captcha[] = JCommentsHTML::makeOption('kcaptcha', 'KCAPTCHA');
     require_once JCOMMENTS_HELPERS . DS . 'plugin.php';
     JCommentsPluginHelper::importPlugin('jcomments');
     $enginesList = JCommentsPluginHelper::trigger('onJCommentsCaptchaEngines');
     foreach ($enginesList as $engines) {
         foreach ($engines as $code => $text) {
             $captcha[] = JCommentsHTML::makeOption($code, $text);
         }
     }
     $disabledCAPTCHA = count($captcha) == 1 ? ' disabled="disabled"' : '';
     $lists["captcha"] = JCommentsHTML::selectList($captcha, 'cfg_captcha_engine', 'class="inputbox"' . $disabledCAPTCHA, 'value', 'text', $config->get('captcha_engine'));
     HTML_JComments::showSettings($lists);
 }