Codice PHP:
..........$mainframe->enqueueMessage(sprintf(JText::_('BRIDGE_NOT_VALID'),$folder),"error"); } } function movebridge() { global $mainframe; $params =& getRokBridgeParams(); $bridge_path = $params->get('bridge_path','forum'); jimport( 'joomla.filesystem.folder' ); jimport( 'joomla.filesystem.file' ); if (JFolder::exists( JPATH_SITE.DS.$bridge_path )) { //folder exists, is it the bridge? if ( JFile::exists( JPATH_SITE.DS.$bridge_path.DS."includes".DS."hooks.php")) { $mainframe->enqueueMessage(JText::_('BRIDGE_ALREADY_INSTALLED'),"error"); } return; } $src = JPATH_ADMINISTRATOR.DS."components".DS."com_rokbridge".DS."forum"; $dest = JPATH_SITE.DS.$bridge_path; if (!JFolder::exists($dest)) { if (!JFolder::create($dest)) { $mainframe->enqueueMessage(JText::_('ERROR_CREATING_DIR').": ".$dest,"error"); return; } } if (!JFolder::copy($src,$dest,null,true)) { $mainframe->enqueueMessage(JText::_('BRIDGE_INSTALL_ERROR'),"error"); return; } $mainframe->enqueueMessage(JText::_('BRIDGE_INSTALL_SUCCESS')); } function installphpbb3plg() { global $mainframe; $params =& getRokBridgeParams(); $phpbb3_path = $params->get('phpbb3_path','distribution'); $src = JPATH_ADMINISTRATOR.DS."components".DS."com_rokbridge".DS."phpbb".DS."includes".DS."auth".DS."auth_joomla.php"; $dest = JPATH_SITE.DS.$phpbb3_path.DS."includes".DS."auth"; jimport( 'joomla.filesystem.file' ); if (!JFile::copy($src,$dest.DS."auth_joomla.php")) { $mainframe->enqueueMessage(sprintf(JText::_('CANNOT_WRITE'),$dest),"error"); return; } $mainframe->enqueueMessage(JText::_('PHPBB3_AUTHPLG_INSTALL_SUCCESS')); } function removephpbb3plg() { global $mainframe; $params =& getRokBridgeParams(); $phpbb3_path = $params->get('phpbb3_path','distribution'); jimport( 'joomla.filesystem.file' ); $file = JPATH_SITE.DS.$phpbb3_path.DS."includes".DS."auth".DS."auth_joomla.php"; if (!JFile::delete($file)) { $mainframe->enqueueMessage(JText::_('PHPBB3_AUTHPLG_REMOVE_ERROR'),"error"); return; } $mainframe->enqueueMessage(JText::_('PHPBB3_AUTHPLG_REMOVE_SUCCESS')); } function firstSave() { // strip leading / if provided $post['params']['bridge_path'] = 'forum'; $post['params']['phpbb3_path'] = 'distribution'; $post['params']['sef_enabled'] = 0; $post['params']['sef_rewrite'] = 0; $post['params']['force_remember'] = 0; $post['params']['link_format'] = 'bridged'; $post['option'] = 'com_rokbridge'; JRequest::set($post,'post'); save(false); } function save($verbose=true) { global $mainframe; $component = 'com_rokbridge'; $table =& JTable::getInstance('component'); if (!$table->loadByOption( $component )) { JError::raiseWarning( 500, 'Not a valid component' ); return false; } $post = JRequest::get( 'post' ); // strip leading / if provided if (isset($post['params']['bridge_path'])) $post['params']['bridge_path'] = trim($post['params']['bridge_path'],"/"); if (isset($post['params']['phpbb3_path'])) $post['params']['phpbb3_path'] = trim($post['params']['phpbb3_path'],"/"); $post['option'] = $component; $table->bind( $post ); // pre-save checks if (!$table->check()) { JError::raiseWarning( 500, $table->getError() ); return false; } // save the changes if (!$table->store()) { JError::raiseWarning( 500, $table->getError() ); return false; } //save out bridge configuration file to 'source' and bridge_path if possible $params =& getRokBridgeParams(); jimport( 'joomla.filesystem.file' ); $bridge_path = $params->get('bridge_path','forum'); $phpbb3_path = $params->get('phpbb3_path','distribution'); $installed_config_file = JPATH_SITE.DS.$bridge_path.DS."configuration.php"; $installed_htaccess_file = JPATH_SITE.DS.$bridge_path.DS.".htaccess"; $src_config_file = JPATH_ADMINISTRATOR.DS."components".DS."com_rokbridge".DS."forum".DS."configuration.php"; $src_htaccess_file = JPATH_ADMINISTRATOR.DS."components".DS."com_rokbridge".DS."forum".DS.".htaccess"; $remember_login = $params->get('force_remember')==0?'false':'true'; $registry =& JFactory::getConfig(); $full_live_site = $live_site = $registry->getValue('live_site'); if ($live_site != '') { $full_live_site = $live_site . "/".$bridge_path; } $bridge_config = "<?php class JConfigForum { var \$phpbb_path = '".$phpbb3_path."'; var \$sef = '".$params->get('sef_enable')."'; var \$sef_rewrite = '".$params->get('sef_rewrite')."'; var \$remember_login = ".$remember_login."; var \$live_site = '" .$full_live_site ."'; } ?> "; $htaccess = "RewriteEngine on RewriteBase ".str_replace('\\','/',JURI::Root(true).DS.$bridge_path.DS)." # Standard phpBB3 files matching RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} \.php$ RewriteRule (.+)\.php$ index.php?rb_v=$1&%{QUERY_STRING} [L]"; if ($params->get('sef_rewrite',0) == 1) { $htaccess .= " # RokBridge SEF rewrite RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.+) index.php?$1&%{QUERY_STRING} [L]"; } //if bridge installed and config file exists if (JFolder::exists(JPATH_SITE.DS.$bridge_path)) { JFile::write($installed_config_file, $bridge_config); } if (JFolder::exists(JPATH_SITE.DS.$bridge_path)) { JFile::write($installed_htaccess_file, $htaccess); } //update src anyway if (!JFile::write($src_config_file, $bridge_config)) { $mainframe->enqueueMessage(JText::_('CONFIGURATION_WRITE_FAIL'),"error"); } if (!JFile::write($src_htaccess_file, $htaccess)) { $mainframe->enqueueMessage(JText::_('HTACCESS_WRITE_FAIL'),"error"); } //$this->setRedirect( 'index.php?option=com_config', $msg ); if ($verbose) $mainframe->enqueueMessage(JText::_('CONFIGURATION_WRITE_SUCCESS')); } function getRokBridgeParams($component="com_rokbridge") { static $instance; if ($instance == null) { $table =& JTable::getInstance('component'); $table->loadByOption( $component ); // work out file path $option = preg_replace( '#\W#', '', $table->option ); $path = JPATH_ADMINISTRATOR.DS.'components'.DS.$option.DS.'config.xml'; if (file_exists( $path )) { $instance = new JParameter( $table->params, $path ); } else { $instance = new JParameter( $table->params ); } } return $instance; } function strstrbi($haystack, $needle, $before_needle=FALSE, $last_occurance=FALSE, $include_needle=TRUE) { if($last_occurance) { $pos=strrpos($haystack,$needle); } else { $pos=strpos($haystack,$needle); } if($pos===FALSE) return FALSE; if($before_needle==$include_needle) $pos+=strlen($needle); if($before_needle) return substr($haystack,0,$pos); return substr($haystack,$pos); } function versionCompare($ver1,$ver2) { preg_match_all('/[\d]+/',$ver1,$matches); $ver1_primary = $matches[0][0]; $ver1_secondary = $matches[0][1]; $ver1_tertiary = $matches[0][2]; preg_match_all('/[\d]+/',$ver2,$matches); $ver2_primary = $matches[0][0]; $ver2_secondary = $matches[0][1]; $ver2_tertiary = $matches[0][2]; if ($ver1_primary < $ver2_primary) return 1; else { if ($ver1_secondary < $ver2_secondary) return 1; else { if ($ver1_tertiary < $ver2_tertiary) return 1; elseif ($ver1_primary == $ver2_primary and $ver1_secondary == $ver2_secondary and $ver1_tertiary == $ver2_tertiary) return 0; else return -1; } } } function getAuthMethod() { require_once(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_rokbridge'.DS.'helper.php' ); $rokbridge =& new RokBridgeHelper(); $forum_db =& $rokbridge->phpbb_db; $sql = "SELECT * from #__config where config_name='auth_method'"; $forum_db->setQuery($sql); $auth_method = $forum_db->loadObject(); return $auth_method->config_value; } function addIndexes() { global $mainframe; if (!checkForRokBridgeIndexes()) { if (!addRokBridgeIndexes()){ $mainframe->enqueueMessage(JText::_('PHPBB3_ADDED_ROKBRIDGE_INDEXES_ERROR')); } } $mainframe->enqueueMessage(JText::_('PHPBB3_ADDED_ROKBRIDGE_INDEXES_SUCCESS')); } function dropIndexes() { global $mainframe; if (checkForRokBridgeIndexes()) { if (!dropRokBridgeIndexes()){ $mainframe->enqueueMessage(JText::_('PHPBB3_DROP_ROKBRIDGE_INDEXES_ERROR')); } } $mainframe->enqueueMessage(JText::_('PHPBB3_DROP_ROKBRIDGE_INDEXES_SUCCESS')); } function checkForRokBridgeIndexes() { $post_time_index_name = "rokbridge_post_time_r"; $post_time_index_exists = false; require_once(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_rokbridge'.DS.'helper.php' ); $rokbridge =& new RokBridgeHelper(); $forum_db =& $rokbridge->phpbb_db; $sql = "SHOW INDEXES from #__posts"; $forum_db->setQuery($sql); $post_indexs = $forum_db->loadObjectList(); if ($post_indexs != null) { foreach ($post_indexs as $index) { if ($index->Key_name == $post_time_index_name){ $post_time_index_exists = true; } } } return $post_time_index_exists; } function addRokBridgeIndexes(){ $post_time_index_name = "rokbridge_post_time_r"; $ret = false; require_once(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_rokbridge'.DS.'helper.php' ); $rokbridge =& new RokBridgeHelper(); $forum_db =& $rokbridge->phpbb_db; $sql = "ALTER TABLE `#__posts` ADD INDEX `".$post_time_index_name."` (`post_time` DESC)"; $forum_db->setQuery($sql); $ret = $forum_db->query(); if ($ret){ $ret = true; } return $ret; } function dropRokBridgeIndexes(){ $post_time_index_name = "rokbridge_post_time_r"; $ret = false; require_once(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_rokbridge'.DS.'helper.php' ); $rokbridge =& new RokBridgeHelper(); $forum_db =& $rokbridge->phpbb_db; $sql = "ALTER TABLE ".$rokbridge->phpbb_db->nameQuote('#__posts')." DROP INDEX ".$rokbridge->phpbb_db->nameQuote($post_time_index_name); $forum_db->setQuery($sql); $ret = $forum_db->query(); if ($ret){ $ret = true; } return $ret; } function setAuthMethod($newauth) { require_once(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_rokbridge'.DS.'helper.php' ); $rokbridge =& new RokBridgeHelper(); $forum_db =& $rokbridge->phpbb_db; $sql = "SELECT * from #__config where config_name='auth_method'"; $forum_db->setQuery($sql); $auth_method = $forum_db->loadObject(); $auth_method->config_value = $newauth; if (!$forum_db->updateObject( '#__config', $auth_method, 'config_name' )) { echo $forum_db->stderr(); return false; } return $newauth; } $bits = new stdClass(); $bits->bridge_url = JURI::root().$bridge_path; $bits->patch_intalled = $patch_installed; $bits->patch_note = $patch_note; $bits->joomla_authplg_installed = $joomla_authplg_installed; $bits->joomla_userplg_installed = $joomla_userplg_installed; $bits->phpbb3plg_installed = $phpbb3plg_installed; $bits->phpbb3plg_note = $phpbb3plg_note; $bits->phpbb3_installed = $phpbb3_installed; $bits->bridge_installed = $bridge_installed; $bits->bridge_note = $bridge_note; $bits->bridge_url = $bridge_url; $bits->current_bridge_path = $bridge_path; $bits->bridge_install_enable = $bridge_install_enable; $bits->phpbb3_version = $phpbb3_version; $bits->patch_full = $patch_full; $bits->indexes_installed=$indexes_installed; $bits->indexes_note = $indexes_note; displayRokBridgeConfig($params, $bits); ?>