function fixIt()
{
    global $mainframe;
    $mode = JRequest::getCmd('mode');
    $code = (int) JRequest::getCmd('code');
    $db =& JFactory::getDBO();
    if ($mode == 'cb') {
        $code = check_cb_plugin();
        if ($code == 0) {
            //not enabled
            $query = "UPDATE `#__comprofiler_plugin` SET `published` = 1 WHERE `element` = 'cacl_usersync'";
            $db->setQuery($query);
            if ($db->query()) {
                $mainframe->redirect('index.php?option=com_community_acl&task=about', JText::_('Community ACL CB plugin enabled successfully.'));
                die;
            } else {
                JError::raiseError(500, $row->getError());
            }
        } elseif ($code == -1) {
            //not installed
            $path_src = JPATH_SITE . '/administrator/components/com_community_acl/plug_cbcacl_usersync';
            $path_dst = JPATH_SITE . '/components/com_comprofiler/plugin/user/plug_caclplugin';
            $msg = '';
            $result = @mkdir(JPATH_SITE . "/components/com_comprofiler/plugin/user/plug_caclplugin");
            if ($result) {
                $result = @chmod(JPATH_SITE . "/components/com_comprofiler/plugin/user/plug_caclplugin", 0777);
            } else {
                $msg .= 'Error: Unable create dir `.../components/com_comprofiler/plugin/user/plug_caclplugin`<br/>';
            }
            if ($result) {
                $result = @copy($path_src . "/cacl_usersync.php", $path_dst . "/cacl_usersync.php");
            } else {
                $msg .= 'Error: Unable chmod dir `.../components/com_comprofiler/plugin/user/plug_caclplugin`<br/>';
            }
            if ($result) {
                $result = @copy($path_src . "/cacl_usersync.xml", $path_dst . "/cacl_usersync.xml");
            } else {
                $msg .= 'Error: Unable copy file `.../administrator/components/com_community_acl/plug_caclplugin/cacl_usersync.php`<br/>';
            }
            if ($result) {
                $result = @chmod(JPATH_SITE . "/components/com_comprofiler/plugin/user/plug_caclplugin", 0775);
            } else {
                $msg .= 'Error: Unable copy file `.../components/com_comprofiler/plugin/user/plug_caclplugin/cacl_usersync.xml`<br/>';
            }
            if (!$result) {
                $msg .= 'Error: Unable chmod dir `.../components/com_comprofiler/plugin/user/plug_caclplugin`><br/>';
            }
            if ($result) {
                $db->setQuery("DELETE FROM `#__comprofiler_plugin` WHERE `element` = 'cacl_usersync';");
                $db->query();
                $db->setQuery("INSERT INTO `#__comprofiler_plugin` ( `id` , `name` , `element` , `type` , `folder` , `backend_menu` , `access` , `ordering` , `published` , `iscore` , `client_id` , `checked_out` , `checked_out_time` , `params` ) VALUES ('', 'cACL plugin', 'cacl_usersync', 'user', 'plug_caclplugin', '', '0', '0', '1', '0', '0', '0', '0000-00-00 00:00:00', '');");
                $db->query();
                if ($db->getErrorNum()) {
                    $msg .= 'Error: ' . $db->stderr() . '<br/>';
                }
            }
            if ($msg == '') {
                $mainframe->redirect('index.php?option=com_community_acl&task=about', JText::_('Community ACL CB plugin installed successfully.'));
                die;
            } else {
                $mainframe->redirect('index.php?option=com_community_acl&task=about', $msg, 'error');
            }
        }
    } elseif ($mode == 'joomla') {
        $code = check_plugin();
        if ($code == 0) {
            //not enabled
            $query = "UPDATE `#__plugins` SET `published` = 1 WHERE `element` = 'community_acl'";
            $db->setQuery($query);
            if ($db->query()) {
                $mainframe->redirect('index.php?option=com_community_acl&task=about', JText::_('Community ACL Joomla plugin enabled successfully.'));
                die;
            } else {
                JError::raiseError(500, $row->getError());
            }
        } elseif ($code == -1) {
            //not installed
            $msg = '';
            $result = @chmod(JPATH_SITE . "/administrator/components/com_community_acl/joomla_plugin/community_acl.php", 0666);
            /* * /
            			if ($result)
            				$result = @chmod (JPATH_SITE. "/administrator/components/com_community_acl/joomla_plugin/community_acl.xml", 0666);
            			else
            				$msg .= 'Error: Unable chmod file `.../administrator/components/com_community_acl/joomla_plugin/community_acl.php`<br/>';
            
            			if ($result)
            				$result = @copy( JPATH_SITE. "/administrator/components/com_community_acl/joomla_plugin/community_acl.php", JPATH_SITE."/plugins/system/community_acl.php");
            			else
            				$msg .= 'Error: Unable chmod file `.../administrator/components/com_community_acl/joomla_plugin/community_acl.xml`<br/>';
            
            			if ($result)
            				$result = @copy( JPATH_SITE. "/administrator/components/com_community_acl/joomla_plugin/community_acl.xml", JPATH_SITE."/plugins/system/community_acl.xml");
            			else
            				$msg .= 'Error: Unable copy file `.../administrator/components/com_community_acl/joomla_plugin/community_acl.php`<br/>';
            
            			if ($result) {
            				$result = @copy( JPATH_SITE. "/administrator/components/com_community_acl/joomla_plugin/en-GB.plg_system_community_acl.ini", JPATH_SITE."/administrator/language/en-GB/en-GB.plg_system_community_acl.ini");
            				$result = @copy( JPATH_SITE. "/administrator/components/com_community_acl/joomla_plugin/en-GB.plg_system_community_acl.ini", JPATH_SITE."/language/en-GB/en-GB.plg_system_community_acl.ini");
            			} else
            				$msg .= 'Error: Unable copy file `.../administrator/components/com_community_acl/joomla_plugin/community_acl.xml`<br/>';
            
            			if (!$result)
            				$msg .= 'Error: Unable copy file `.../administrator/components/com_community_acl/joomla_plugin/en-GB.plg_system_community_acl.ini`<br/>';
            
            			if ($result) {
            				$db->setQuery("DELETE FROM `#__plugins` WHERE `element` = 'community_acl'");
            				$db->query();
            
            				$db->setQuery( "INSERT INTO `#__plugins` (`name`, `element`, `folder`, `access`, `ordering`, `published`, `iscore`, `client_id`, `checked_out`, `checked_out_time`, `params`) VALUES('System - Community ACL', 'community_acl', 'system', 0, 9, 1, 0, 0, 0, '0000-00-00 00:00:00', '')");
            				$db->query();
            
            				if ($db->getErrorNum()) {
            					$msg .= 'Error: '. $db->stderr() .'<br/>';
            				}
            			}
            
            			if ($msg == '') {
            				$mainframe->redirect('index.php?option=com_community_acl&task=about', JText::_('Community ACL Joomla plugin installed successfully.'));
            				die;
            			} else {
            				$mainframe->redirect('index.php?option=com_community_acl&task=about', $msg, 'error');
            			}
            			/* */
        }
    } elseif ($mode == 'hack') {
        switch ($code) {
            case 1:
                $dst_file = JPATH_SITE . "/administrator/modules/mod_menu/helper.php";
                $src_file = JPATH_SITE . "/administrator/components/com_community_acl/patch/mod_menu_helper.php";
                $bk_file = JPATH_SITE . "/administrator/components/com_community_acl/backup/mod_menu_helper.php";
                $success_msg = 'File `' . $dst_file . '` successfully replaced by patched version.';
                break;
            case 2:
                $dst_file = JPATH_SITE . "/modules/mod_mainmenu/helper.php";
                $src_file = JPATH_SITE . "/administrator/components/com_community_acl/patch/mod_mainmenu_helper.php";
                $bk_file = JPATH_SITE . "/administrator/components/com_community_acl/backup/mod_mainmenu_helper.php";
                $success_msg = 'File `' . $dst_file . '` successfully replaced by patched version.';
                break;
            case 3:
                $dst_file = JPATH_SITE . "/modules/mod_mainmenu/legacy.php";
                $src_file = JPATH_SITE . "/administrator/components/com_community_acl/patch/legacy.php";
                $bk_file = JPATH_SITE . "/administrator/components/com_community_acl/backup/legacy.php";
                $success_msg = 'File `' . $dst_file . '` successfully replaced by patched version.';
                break;
            case 4:
                $dst_file = JPATH_SITE . "/libraries/joomla/application/module/helper.php";
                $src_file = JPATH_SITE . "/administrator/components/com_community_acl/patch/module_helper.php";
                $bk_file = JPATH_SITE . "/administrator/components/com_community_acl/backup/module_helper.php";
                $success_msg = 'File `' . $dst_file . '` successfully replaced by patched version.';
                break;
        }
        $msg = '';
        $result = @chmod($dst_file, 0666);
        /* * /
        		if ($result) {
        			@unlink($bk_file);
        			$result = @rename($dst_file, $bk_file);
        		} else
        			$msg .= 'Error: Unable chmod file `'.$dst_file.'`<br/>';
        		if ($result) {
        			$result = @copy($src_file, $dst_file);
        		} else
        			$msg .= 'Error: Unable backup file `'.$dst_file.'`<br/>';
        		if (!$result)
        			$msg .= 'Error: Unable patch(replace) file `'.$dst_file.'`<br/>';
        		/* */
        if ($msg == '') {
            $mainframe->redirect('index.php?option=com_community_acl&task=about', $success_msg);
            die;
        }
        /* else {
        			$mainframe->redirect('index.php?option=com_community_acl&task=about', $msg, 'error');
        		}*/
    }
    $mainframe->redirect('index.php?option=com_community_acl&task=about');
}
Ejemplo n.º 2
0
    function hacks()
    {
        left_menu_header();
        $not_writable = '';
        ?>
		<table border="1" width="100%" style="background-color: #F7F8F9; border: solid 1px #d5d5d5; width: 100%; padding: 10px; border-collapse: collapse;">
		<?php 
        $msg = '';
        # - Kobby Sam: Eliminate the check for Community Builder
        $cb_code = check_cb_plugin();
        switch ($cb_code) {
            case -3:
                $msg .= 'Community Builder is not detected. Please install Community Builder ver 1.1 or above and then install cACL plugin for Community Builder.';
                break;
            case -2:
                $msg .= 'Incorrect version of Community Builder. Please install Community Builder ver 1.1 or above and then install cACL plugin for Community Builder.';
                break;
            case -1:
                $msg .= 'Community ACL plugin for Community Builder is not installed.';
                break;
            case 0:
                $msg .= 'Community ACL plugin for Community Builder is installed, but not enabled.';
                break;
        }
        if ($cb_code < 1) {
            ?>
			
		<!--// <tr>
			<td align="center" width="85"><?php 
            if ($cb_code > -2) {
                ?>
<input type="button" name="install" value="Fix it" onclick="javascript: window.location.href = 'index.php?option=com_community_acl&task=fixit&mode=cb&code=<?php 
                echo $cb_code;
                ?>
'" /><?php 
            }
            ?>
</td><td style="width:auto;"><?php 
            echo $msg;
            ?>
</td>
		</tr> //-->
		<?php 
        }
        $msg = '';
        $j_code = check_plugin();
        switch ($j_code) {
            case -1:
                $msg .= 'Community ACL plugin for Joomla! is not installed.<br/>';
                break;
            case 0:
                $msg .= 'Community ACL plugin for Joomla! is installed, but not enabled.<br/>';
                break;
        }
        if ($j_code < 1) {
            ?>
	
		<tr>
			<td align="center" width="85"><input type="button" name="install" value="Fix it" onclick="javascript: window.location.href = 'index.php?option=com_community_acl&task=fixit&mode=joomla&code=<?php 
            echo $j_code;
            ?>
'" /></td><td style="width:auto;"><?php 
            echo $msg;
            ?>
</td>
		</tr>
		<?php 
        }
        $mod_menu_helper = check_core_file(JPATH_SITE . DS . 'administrator' . DS . 'modules' . DS . 'mod_menu' . DS . 'helper.php');
        $not_writable = '';
        if ($mod_menu_helper < 1) {
            ?>
		<tr>
			<td align="center" width="85">
			<?php 
            if ($mod_menu_helper == 0) {
                ?>
				<input type="button" name="install" value="Fix it" onclick="javascript: window.location.href = 'index.php?option=com_community_acl&task=fixit&mode=hack&code=1'" />
			<?php 
            } else {
                $not_writable = '<br/>The `' . JPATH_SITE . DS . 'administrator' . DS . 'modules' . DS . 'mod_menu' . DS . 'helper.php' . '` file is <font color="#FF0000">not writable</font>. Please make it writable or manually replace the `' . JPATH_SITE . DS . 'administrator' . DS . 'modules' . DS . 'mod_menu' . DS . 'helper.php' . '` file with `' . JPATH_SITE . DS . 'administrator' . DS . 'components' . DS . 'com_community_acl' . DS . 'patch' . DS . 'mod_menu_helper.php`.';
                ?>
				
				<font color="#FF0000" style="font-weight:bold;">NOT WRITABLE!</font>
			<?php 
            }
            ?>
			</td><td style="width:auto;"><?php 
            echo 'Community ACL core hack in the `' . JPATH_SITE . DS . 'administrator' . DS . 'modules' . DS . 'mod_menu' . DS . 'helper.php' . '` file is not detected.' . $not_writable;
            ?>
</td>
		</tr>
		<?php 
        }
        $mod_mainmenu_helper = check_core_file(JPATH_SITE . DS . 'modules' . DS . 'mod_mainmenu' . DS . 'helper.php');
        $not_writable = '';
        if ($mod_mainmenu_helper < 1) {
            ?>
		<tr>
			<td align="center" width="85">
			<?php 
            if ($mod_mainmenu_helper == 0) {
                ?>
				<input type="button" name="install" value="Fix it" onclick="javascript: window.location.href = 'index.php?option=com_community_acl&task=fixit&mode=hack&code=2'" />
			<?php 
            } else {
                $not_writable = '<br/>The `' . JPATH_SITE . DS . 'modules' . DS . 'mod_mainmenu' . DS . 'helper.php' . '` file is <font color="#FF0000">not writable</font>. Please make it writable or manually replace the `' . JPATH_SITE . DS . 'modules' . DS . 'mod_mainmenu' . DS . 'helper.php' . '` file with `' . JPATH_SITE . DS . 'administrator' . DS . 'components' . DS . 'com_community_acl' . DS . 'patch' . DS . 'mod_mainmenu_helper.php`.';
                ?>
				<font color="#FF0000" style="font-weight:bold;">NOT WRITABLE!</font>
			<?php 
            }
            ?>
			</td><td style="width:auto;"><?php 
            echo 'Community ACL core hack in the `' . JPATH_SITE . DS . 'modules' . DS . 'mod_mainmenu' . DS . 'helper.php' . '` file is not detected.' . $not_writable;
            ?>
</td>
		</tr>
		<?php 
        }
        $mod_mainmenu_legacy = check_core_file(JPATH_SITE . DS . 'modules' . DS . 'mod_mainmenu' . DS . 'legacy.php');
        $not_writable = '';
        if ($mod_mainmenu_legacy < 1) {
            ?>
		<tr>
			<td align="center" width="85">
			<?php 
            if ($mod_mainmenu_legacy == 0) {
                ?>
			<input type="button" name="install" value="Fix it" onclick="javascript: window.location.href = 'index.php?option=com_community_acl&task=fixit&mode=hack&code=3'" />
			<?php 
            } else {
                $not_writable = '<br/>The `' . JPATH_SITE . DS . 'modules' . DS . 'mod_mainmenu' . DS . 'legacy.php' . '` file is <font color="#FF0000">not writable</font>. Please make it writable or manually replace the `' . JPATH_SITE . DS . 'modules' . DS . 'mod_mainmenu' . DS . 'legacy.php' . '` file with `' . JPATH_SITE . DS . 'administrator' . DS . 'components' . DS . 'com_community_acl' . DS . 'patch' . DS . 'legacy.php`.';
                ?>
				<font color="#FF0000" style="font-weight:bold;">NOT WRITABLE!</font>
			<?php 
            }
            ?>
			</td><td style="width:auto;"><?php 
            echo 'Community ACL core hack in the `' . JPATH_SITE . DS . 'modules' . DS . 'mod_mainmenu' . DS . 'legacy.php' . '` file is not detected.' . $not_writable;
            ?>
</td>
		</tr>
		<?php 
        }
        $module_helper = check_core_file(JPATH_SITE . DS . 'libraries' . DS . 'joomla' . DS . 'application' . DS . 'module' . DS . 'helper.php');
        $not_writable = '';
        if ($module_helper < 1) {
            ?>
		<tr>
			<td align="center" width="85">
			<?php 
            if ($module_helper == 0) {
                ?>
				<input type="button" name="install" value="Fix it" onclick="javascript: window.location.href = 'index.php?option=com_community_acl&task=fixit&mode=hack&code=4'" />
			<?php 
            } else {
                $not_writable = '<br/>The `' . JPATH_SITE . DS . 'libraries' . DS . 'joomla' . DS . 'application' . DS . 'module' . DS . 'helper.php' . '` file is <font color="#FF0000">not writable</font>. Please make it writable or manually replace the `' . JPATH_SITE . DS . 'libraries' . DS . 'joomla' . DS . 'application' . DS . 'module' . DS . 'helper.php' . '` file with `' . JPATH_SITE . DS . 'administrator' . DS . 'components' . DS . 'com_community_acl' . DS . 'patch' . DS . 'module_helper.php`.';
                ?>
				<font color="#FF0000" style="font-weight:bold;">NOT WRITABLE!</font>
			<?php 
            }
            ?>
			</td><td style="width:auto;"><?php 
            echo 'Community ACL core hack in the `' . JPATH_SITE . DS . 'libraries' . DS . 'joomla' . DS . 'application' . DS . 'module' . DS . 'helper.php' . '` file is not detected.' . $not_writable;
            ?>
</td>
		</tr>
		<?php 
        }
        ?>
		</table><br />

		<?php 
        left_menu_footer();
    }