diff --git a/deployed/mightysites/administrator/components/com_mightysites/access.xml b/deployed/mightysites/administrator/components/com_mightysites/access.xml new file mode 100644 index 00000000..7a0de162 --- /dev/null +++ b/deployed/mightysites/administrator/components/com_mightysites/access.xml @@ -0,0 +1,11 @@ + + +
+ + + + + + +
+
\ No newline at end of file diff --git a/deployed/mightysites/administrator/components/com_mightysites/config.xml b/deployed/mightysites/administrator/components/com_mightysites/config.xml new file mode 100644 index 00000000..707c14aa --- /dev/null +++ b/deployed/mightysites/administrator/components/com_mightysites/config.xml @@ -0,0 +1,6 @@ + + +
+ +
+
diff --git a/deployed/mightysites/administrator/components/com_mightysites/controller.php b/deployed/mightysites/administrator/components/com_mightysites/controller.php new file mode 100644 index 00000000..55769216 --- /dev/null +++ b/deployed/mightysites/administrator/components/com_mightysites/controller.php @@ -0,0 +1,57 @@ +input->get('view', $this->default_view); + $layout = $app->input->get('layout', 'default'); + $id = $app->input->getInt('id'); + + // Check for edit form. + if ($view == 'site' && $layout == 'edit' && !$this->checkEditId('com_mightysites.edit.site', $id)) { + // Somehow the person just went to the form - we don't allow that. + $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id)); + $this->setMessage($this->getError(), 'error'); + $this->setRedirect(JRoute::_('index.php?option=com_mightysites&view=sites', false)); + + return false; + } + + if ($view == 'database' && $layout == 'edit' && !$this->checkEditId('com_mightysites.edit.database', $id)) { + // Somehow the person just went to the form - we don't allow that. + $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id)); + $this->setMessage($this->getError(), 'error'); + $this->setRedirect(JRoute::_('index.php?option=com_mightysites&view=databases', false)); + + return false; + } + + // Copy DB scheduled? + $session = JFactory::getSession(); + $copyDB = $session->get('mighty_copy'); + if ($copyDB) { + $session->set('mighty_copy', ''); + $y = JDEBUG ? '350' : '250'; + JFactory::getDocument()->addScriptDeclaration(' + window.addEvent("domready", function(){ + SqueezeBox.open(null, {handler: "iframe", url: "'.$copyDB.'", size: {x: 770, y: '.$y.'} }); + }); + '); + JHtml::_('behavior.modal'); + } + + parent::display(); + return $this; + } +} diff --git a/deployed/mightysites/administrator/components/com_mightysites/controllers/about.php b/deployed/mightysites/administrator/components/com_mightysites/controllers/about.php new file mode 100644 index 00000000..23242e47 --- /dev/null +++ b/deployed/mightysites/administrator/components/com_mightysites/controllers/about.php @@ -0,0 +1,36 @@ +input->get('current')); + + $version = new JVersion(); + + $url = 'http://alterbrains.com/version?id=pkg_mightysites&release='.$version->RELEASE; + + if (!($latest = @file_get_contents($url))) { + echo '', JText::_('COM_MIGHTYSITES_VERSION_ERROR'), ''; + } + else { + if (str_replace('.', '', $latest) == $current) { + echo '', JText::_('COM_MIGHTYSITES_VERSION_CURRENT'), ''; + } + else { + echo '', JText::sprintf('COM_MIGHTYSITES_VERSION_LATEST', $latest), '

', JText::sprintf('COM_MIGHTYSITES_VISIT_DADDY', 'http://alterbrains.com.'); + } + } + jexit(); + } + +} \ No newline at end of file diff --git a/deployed/mightysites/administrator/components/com_mightysites/controllers/database.php b/deployed/mightysites/administrator/components/com_mightysites/controllers/database.php new file mode 100644 index 00000000..d23b534a --- /dev/null +++ b/deployed/mightysites/administrator/components/com_mightysites/controllers/database.php @@ -0,0 +1,312 @@ + false)) + { + $model = parent::getModel($name, $prefix, $config); + return $model; + } + + public function create() + { + // Access check. + if (!JFactory::getUser()->authorise('core.create', 'com_mightysites')) { + return JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR')); + } + + $app = JFactory::getApplication(); + $db = JFactory::getDBO(); + + // Check for request forgeries + JSession::checkToken() or jexit('Invalid Token'); + + // Get vars + $dbname = $app->input->getString('db'); + + if (!$db->connected()) { + echo '', JText::_('COM_MIGHTYSITES_ERROR_INVALID_USER'), ''; + } + else { + $db->setQuery('CREATE DATABASE `'.$dbname.'` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci'); + + try { + $db->execute(); + } + catch (RuntimeException $e) { + echo '', JText::sprintf('COM_MIGHTYSITES_ERROR_CUSTOM', $db->getErrorMsg()), ''; + exit(); + } + + echo '', JText::sprintf('COM_MIGHTYSITES_DATABASE_CREATED', $dbname), ''; + } + + JFactory::getApplication()->close(); + } + + public function check() + { + $app = JFactory::getApplication(); + + // Check for request forgeries + JSession::checkToken() or jexit('Invalid Token'); + + // Get vars + $db = $app->input->getString('db'); + $dbprefix = $app->input->getString('dbprefix'); + $user = $app->input->getString('user'); + $password = $app->input->getString('password'); + $id = $app->input->getInt('id'); + $type = $app->input->getInt('type'); + + // Use current? + if (empty($user)) { + $user = $app->getCfg('user'); + $password = $app->getCfg('password'); + } + + // Close current connection, otherwise no mysql_connect() errors + JFactory::getDBO()->__destruct(); + + // Check connection + $link = @mysql_connect($app->getCfg('host'), $user, $password); + if ($link === false) { + echo '', JText::_('COM_MIGHTYSITES_ERROR_INVALID_USER'), ''; + } else { + if (!mysql_select_db($db, $link)) { + echo '', JText::sprintf('COM_MIGHTYSITES_ERROR_CUSTOM', mysql_error($link)), ''; + } else { + if ($type == 1) { + if ($id) { + echo '', JText::_('COM_MIGHTYSITES_CONNECTED'), ''; + } else { + if (mysql_query('SELECT COUNT(*) FROM '.$dbprefix.'users', $link)) { + echo '', JText::sprintf('COM_MIGHTYSITES_ERROR_TABLES_EXIST', $dbprefix, $db), ''; + } else { + echo '', JText::_('COM_MIGHTYSITES_CONNECTED'), ''; + } + } + } + if ($type == 2) { + if (!mysql_query('SELECT COUNT(*) FROM '.$dbprefix.'users', $link)) { + echo '', JText::sprintf('COM_MIGHTYSITES_ERROR_NO_TABLES_EXIST', $dbprefix, $db), ''; + } else { + echo '', JText::_('COM_MIGHTYSITES_CONNECTED'), ''; + } + } + mysql_close($link); + } + } + + // Fix Joomla db + $this->restoreDB(); + + // Fix ugly mysqli notice + error_reporting(0); + + JFactory::getApplication()->close(); + } + + public function copy() + { + $app = JFactory::getApplication(); + + // Access check. + if (!JFactory::getUser()->authorise('core.create', 'com_mightysites')) { + return JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR')); + } + + $from = $app->input->get('from'); + $to = $app->input->get('to'); + $table = $app->input->getInt('table', 0); + $tmpl = $app->input->get('tmpl'); + + // Get source site + $from = MightysitesHelper::getSite($from, true); + if (!isset($from->id)) { + JError::raiseError(500, JText::_('COM_MIGHTYSITES_INVALID_SOURCE')); + } + + // Get destination site + $to = MightysitesHelper::getSite($to, true); + + // Check + if (($from->db == $to->db) && ($from->dbprefix == $to->dbprefix)) { + $this->setRedirect('index.php?option=com_mightysites', JText::_('COM_MIGHTYSITES_SOURCE_DEST_EQUAL')); + } + + // Get Dbo + $db = MightysitesHelper::getDBO($from); + + // Get tables & views list from site. + $tables = MightysitesHelper::getTables($db); + $views = MightysitesHelper::getViews($db); + + // Main array, tables are copied first because they are used in views. + $tables_views = array_merge($tables, $views); + + // Filter tables without source prefix + if (sizeof($tables_views)) { + foreach($tables_views as $key => $value) { + if (strpos($value, $from->dbprefix) !== 0) { + unset($tables_views[$key]); + } + // Filter dest tables if we use same db + if ($from->db == $to->db && strpos($value, $to->dbprefix) === 0) { + unset($tables_views[$key]); + } + } + // Rebuild keys + $tables_views = explode(',,,', implode(',,,', $tables_views)); + } + + // Remember views code. + $views_code = array(); + foreach($tables_views as $tables_view) { + if (in_array($tables_view, $views)) { + $db->setQuery('SHOW CREATE VIEW `'.$tables_view.'`'); + $vres = $db->loadAssoc(); + if (isset($vres['Create View'])) { + $views_code[$tables_view] = $vres['Create View']; + } + } + } + + // Check tables + if (!sizeof($tables_views)) { + JError::raiseError(500, JText::sprintf('COM_MIGHTYSITES_NO_TABLES', $from->domain, $from->db)); + } + + // source + $source_table = $tables_views[$table]; + + // destination + $dest_table = $to->dbprefix . substr($source_table, strlen($from->dbprefix)); + + // Table or View? + $isTable = in_array($source_table, $tables); + $isView = in_array($source_table, $views); + + // Connect to dest DB + $db2 = MightysitesHelper::getDBO($to); + + JToolBarHelper::title('MightySites : ' . JText::_('COM_MIGHTYSITES_COPYING_TABLES'), 'config'); + + echo '

', JText::sprintf('COM_MIGHTYSITES_CREATING_TABLE', ($table+1), sizeof($tables_views), $dest_table), '

'; + echo '

', JText::sprintf('COM_MIGHTYSITES_SOURCE_DATABASE', $from->db, $from->dbprefix), '

'; + echo '

', JText::sprintf('COM_MIGHTYSITES_DEST_DATABASE', $to->db, $to->dbprefix), '

'; + echo '

', JText::_('COM_MIGHTYSITES_PLEASE_WAIT', $to->db, $to->dbprefix), '

'; + + $error = false; + + // Try to delete first + if ($isTable) { + $query = 'DROP TABLE IF EXISTS `'.$dest_table.'`'; + } + if ($isView) { + $query = 'DROP VIEW IF EXISTS `'.$dest_table.'`'; + } + $db2->setQuery($query); + + if (JDEBUG) { + echo $db2->getQuery().'
'; + } + + if (!$db2->execute()) { + die(''.$db2->getErrorMsg().''); + } + + // Create table or view + if ($isTable) { + $query = 'CREATE TABLE `'.$dest_table.'` LIKE `'.$from->db.'`.`'.$source_table.'`'; + } + if ($isView) { + if (isset($views_code[$source_table])) { + $query = strtr($views_code[$source_table], array( + '`'.$source_table.'`' => '`'.$dest_table.'`', + '`'.$from->dbprefix => '`'.$to->dbprefix, + )); + } else { + $query = 'SELECT 1'; + } + } + + $db2->setQuery($query); + + if (JDEBUG) { + echo $db2->getQuery().'
'; + } + + if (!$db2->execute()) { + // can't copy view + if ($db2->getErrorNum() == 1347) { + // todo - probably do smth here + } + echo '

'.$db2->getErrorMsg().'

'; + $error = true; + } + else { + + // Next copy data table + if ($isTable) { + $query = 'INSERT INTO `'.$dest_table.'` SELECT * FROM `'.$from->db.'`.`'.$source_table.'`'; + $db2->setQuery($query); + + if (JDEBUG) { + echo $db2->getQuery().'
'; + } + + if (!$db2->execute()) { + echo ''.$db2->getErrorMsg().''; + $error = true; + } + } + } + + $table++; + + // Finish + if ($table == sizeof($tables_views)) { + if ($tmpl == 'component') {?> + + setRedirect('index.php?option=com_mightysites&view=databases', JText::sprintf('COM_MIGHTYSITES_TABLES_CREATED', $to->db, $to->dbprefix)); + } + } + // or Continue to next table + else { + JHtml::_('behavior.framework'); + $link = JRoute::_('index.php?option=com_mightysites&task=database.copy&from='.$from->id.'&to='.$to->id.'&table='.$table.'&tmpl='.$tmpl, false); + // no errors - let's auto proceed + if (!$error) { + JFactory::getDocument()->addScriptDeclaration( + 'window.addEvent("load", function(){document.location.href="'.$link.'"});' + ); + } + // errors! show them! + else { + echo '', JText::_('COM_MIGHTYSITES_CONTINUE'), ''; + } + } + } + + protected function restoreDB() + { + JFactory::$database = null; + } + +} diff --git a/deployed/mightysites/administrator/components/com_mightysites/controllers/databases.php b/deployed/mightysites/administrator/components/com_mightysites/controllers/databases.php new file mode 100644 index 00000000..18ec202f --- /dev/null +++ b/deployed/mightysites/administrator/components/com_mightysites/controllers/databases.php @@ -0,0 +1,99 @@ + true)) + { + $model = parent::getModel($name, $prefix, $config); + return $model; + } + + public function remove() + { + // Access check. + if (!JFactory::getUser()->authorise('core.delete', 'com_mightysites')) { + return JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR')); + } + + $app = JFactory::getApplication(); + + $ids = $app->input->get('cid', array(), 'array'); + $n = count($ids); + JArrayHelper::toInteger($ids); + + $delete_tables = $app->input->get('delete_tables'); + + if ($n) { + $n = 0; + foreach($ids as $id) { + $site = MightysitesHelper::getSite($id); + + // Only databases! + if ($site->type == 2) { + // Delete Tables & Views + if ($delete_tables == 'true') { + $db2 = MightysitesHelper::getDBO($site); + + $tables = MightysitesHelper::getTables($db2); + if (sizeof($tables)) { + foreach($tables as $table) { + if (strpos($table, $site->dbprefix) === 0) { + $db2->setQuery('DROP TABLE `'.$table.'`'); + $db2->execute() or $app->enqueueMessage($db2->getErrorMsg(), 'error'); + } + } + } + + $views = MightysitesHelper::getViews($db2); + if (sizeof($views)) { + foreach($views as $view) { + if (strpos($view, $site->dbprefix) === 0) { + $db2->setQuery('DROP VIEW `'.$view.'`'); + $db2->execute() or $app->enqueueMessage($db2->getErrorMsg(), 'error'); + } + } + } + + // restore current $db + $db = JFactory::getDBO(); + $db = null; + } + // delete in database + $db = JFactory::getDBO(); + $query = 'DELETE FROM #__mightysites WHERE id = ' . $id; + $db->setQuery($query); + if (!$db->execute()) { + JError::raiseWarning( 500, $row->getError()); + } + $n++; + } + } + } + + $mes = $n ? JText::_('COM_MIGHTYSITES_DATABASES_DELETED') : null; + $this->setRedirect('index.php?option=com_mightysites&view=databases', $mes); + } + + public function cancel() + { + $this->setRedirect('index.php?option=com_mightysites&view=databases'); + + // Initialize variables + $db = JFactory::getDBO(); + $post = JRequest::get('post'); + $row = JTable::getInstance('Site', 'Mightysites'); + $row->bind($post); + $row->checkin(); + } + +} \ No newline at end of file diff --git a/deployed/mightysites/administrator/components/com_mightysites/controllers/index.html b/deployed/mightysites/administrator/components/com_mightysites/controllers/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/deployed/mightysites/administrator/components/com_mightysites/controllers/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/deployed/mightysites/administrator/components/com_mightysites/controllers/site.php b/deployed/mightysites/administrator/components/com_mightysites/controllers/site.php new file mode 100644 index 00000000..256ffb68 --- /dev/null +++ b/deployed/mightysites/administrator/components/com_mightysites/controllers/site.php @@ -0,0 +1,68 @@ + false)) + { + $model = parent::getModel($name, $prefix, $config); + return $model; + } + + public function add() + { + if (!is_writable(JPATH_SITE)) { + JFactory::getApplication()->enqueueMessage(JText::sprintf('COM_MIGHTYSITES_ERROR_ROOT_NOT_WRITABLE', JPATH_SITE), 'error'); + $this->setRedirect('index.php?option=com_mightysites'); + return; + } + + return parent::add(); + } + + public function login() + { + // Access check. + if (!JFactory::getUser()->authorise('core.edit', 'com_mightysites')) { + return JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR')); + } + + $app = JFactory::getApplication(); + $user = JFactory::getUser(); + + $return = base64_decode(JRequest::getString('return')); + $domain = base64_decode(JRequest::getString('domain')); + + $to = MightysitesHelper::getSite($domain, true); + $folder = $to->tmp_path; + + $token = md5(uniqid(mt_rand(), true)); + $fname = $folder . '/' . md5($token.$to->secret) . '.mighty'; + + $data = serialize(array( + 'user_id' => $user->id, + 'username' => $user->username, + 'return' => $return, + )); + + if (!JFile::write($fname, $data)) { + echo '

', JText::_('COM_MIGHTYSITES_ERROR'), '

'; + echo '

', JText::sprintf('COM_MIGHTYSITES_CANT_WRITE_FILE', $fname), '

'; + die; + } + + $link = 'http://'.$domain.'/administrator/index.php?mighty_token='.$token; + + $this->setRedirect($link); + } + +} diff --git a/deployed/mightysites/administrator/components/com_mightysites/controllers/sites.php b/deployed/mightysites/administrator/components/com_mightysites/controllers/sites.php new file mode 100644 index 00000000..d16492c5 --- /dev/null +++ b/deployed/mightysites/administrator/components/com_mightysites/controllers/sites.php @@ -0,0 +1,209 @@ + true)) + { + $model = parent::getModel($name, $prefix, $config); + return $model; + } + + public function remove() + { + // Access check. + if (!JFactory::getUser()->authorise('core.delete', 'com_mightysites')) { + return JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR')); + } + + $app = JFactory::getApplication(); + + $ids = $app->input->get('cid', array(), 'array'); + $n = count($ids); + JArrayHelper::toInteger($ids); + + $delete_tables = $app->input->get('delete_tables'); + + if ($n) { + $n = 0; + foreach($ids as $id) { + $site = MightysitesHelper::getSite($id, true); + + $config_domain = MightysitesHelper::prepareDomain($site->domain); + if ($config_domain) { + // don't delete ourself :) + if ($site->id == 1 && MightysitesHelper::prepareDomain() == $config_domain) { + $app->enqueueMessage(JText::sprintf('COM_MIGHTYSITES_NOT_DELETE_CURRENT', $site->domain), 'notice'); + } else { + if ($site->type == 1) { + // Delete Tables & Views + if ($delete_tables == 'true') { + $db2 = MightysitesHelper::getDBO($site); + + $tables = MightysitesHelper::getTables($db2); + if (sizeof($tables)) { + foreach($tables as $table) { + if (strpos($table, $site->dbprefix) === 0) { + $db2->setQuery('DROP TABLE `'.$table.'`'); + $db2->execute() or $app->enqueueMessage($db2->getErrorMsg(), 'error'); + } + } + } + + $views = MightysitesHelper::getViews($db2); + if (sizeof($views)) { + foreach($views as $view) { + if (strpos($view, $site->dbprefix) === 0) { + $db2->setQuery('DROP VIEW `'.$view.'`'); + $db2->execute() or $app->enqueueMessage($db2->getErrorMsg(), 'error'); + } + } + } + + // restore current $db + $db = JFactory::getDBO(); + $db = null; + } + + // Delete config + $fname = MightySitesHelper::getConfigFilename($config_domain); + if (!JFile::delete($fname)) { + $app->enqueueMessage(JText::sprintf('COM_MIGHTYSITES_CANT_DELETE_CONFIG', $fname), 'error'); + } + + // Delete symlink + if (strpos($site->domain, '/') !== false) { + $parts = explode('/', $site->domain); + array_shift($parts); + + $path = implode('/', $parts); + $file = JPATH_SITE.'/'.$path; + + if (file_exists($file) && is_link($file)) { + if (!unlink($file)) { + $app->enqueueMessage(JText::sprintf('COM_MIGHTYSITES_ERROR_SYMLINK_DELETE', $file), 'error'); + } + } + } + } + + // Delete in database + $db = JFactory::getDBO(); + $query = 'DELETE FROM #__mightysites WHERE id = ' . $id; + $db->setQuery($query); + if (!$db->execute()) { + JError::raiseWarning( 500, $row->getError()); + } + $n++; + } + } + } + } + + $mes = $n ? JText::_('COM_MIGHTYSITES_DOMAINS_DELETED') : null; + $this->setRedirect('index.php?option=com_mightysites&view=sites', $mes); + } + + public function publish() + { + // Access check. + if (!JFactory::getUser()->authorise('core.edit.state', 'com_mightysites')) { + return JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR')); + } + + jimport('joomla.filesystem.path'); + jimport('joomla.filesystem.file'); + + $app = JFactory::getApplication(); + + $db = JFactory::getDBO(); + $user = JFactory::getUser(); + $ids = $app->input->get('cid', array(), 'array'); + $task = $app->input->get('task'); + $publish = ($task == 'publish'); + $n = count($ids); + + if (empty($ids)) { + return JError::raiseWarning( 500, JText::_('COM_MIGHTYSITES_NO_ITEMS')); + } + + JArrayHelper::toInteger($ids); + + if (sizeof($ids)) { + foreach($ids as $id) { + $config_site = MightysitesHelper::getSite($id); + + if ($config_site->type == 1 && isset($config_site->domain)) { + $file = MightysitesHelper::getConfigFilename($config_site->domain); + if (!file_exists($file)) { + $app->redirect('index.php?option=com_mightysites', JText::sprintf('COM_MIGHTYSITES_FILE_DOESNT_EXIST', $file), 'error'); + } + if (!is_readable($file)) { + $app->redirect('index.php?option=com_mightysites', JText::sprintf('COM_MIGHTYSITES_FILE_NOT_READABLE', $file), 'error'); + } + + $config = JFile::read($file); + + if ($publish) { + $config = preg_replace('#public \$offline = \'1\';#u', 'public $offline = \'0\';', $config); + } else { + $config = preg_replace('#public \$offline = \'0\';#u', 'public $offline = \'1\';', $config); + } + + $ftp = JClientHelper::getCredentials('ftp'); + + // Attempt to make the file writeable if using FTP. + if (!$ftp['enabled'] && JPath::isOwner($file) && !JPath::setPermissions($file, '0644')) + { + JError::raiseNotice('SOME_ERROR_CODE', JText::_('COM_CONFIG_ERROR_CONFIGURATION_PHP_NOTWRITABLE')); + } + + if (!is_writable(JPATH_CONFIGURATION)) { + $app->redirect('index.php?option=com_mightysites', JText::sprintf('COM_MIGHTYSITES_FILE_NOT_WRITABLE', $file), 'error'); + } + + if (!JFile::write($file, $config)) { + $app->redirect('index.php?option=com_mightysites', JText::sprintf('COM_MIGHTYSITES_CANT_WRITE_FILE', $file), 'error'); + } + + // Attempt to make the file unwriteable if using FTP. + if (!$ftp['enabled'] && JPath::isOwner($file) && !JPath::setPermissions($file, '0444')) + { + JError::raiseNotice('SOME_ERROR_CODE', JText::_('COM_CONFIG_ERROR_CONFIGURATION_PHP_NOTUNWRITABLE')); + } + + $mes = $publish ? 'COM_MIGHTYSITES_SITE_PUBLISHED' : 'COM_MIGHTYSITES_SITE_UNPUBLISHED'; + $app->enqueueMessage(JText::sprintf($mes, $config_site->domain)); + } + } + } + + $this->setRedirect('index.php?option=com_mightysites&view=sites'); + } + + public function cancel() + { + $this->setRedirect('index.php?option=com_mightysites&view=sites'); + + // Initialize variables + $db = JFactory::getDBO(); + $post = JRequest::get('post'); + $row = JTable::getInstance('Site', 'Mightysites'); + $row->bind($post); + $row->checkin(); + } + +} \ No newline at end of file diff --git a/deployed/mightysites/administrator/components/com_mightysites/helpers/helper.php b/deployed/mightysites/administrator/components/com_mightysites/helpers/helper.php new file mode 100644 index 00000000..8385a643 --- /dev/null +++ b/deployed/mightysites/administrator/components/com_mightysites/helpers/helper.php @@ -0,0 +1,629 @@ +triggerEvent('onMightysitesGetSynchs', array(&$custom)); + + // Sort by name + $custom2 = array(); + foreach($custom as $key) { + $custom2[$key] = JText::_('COM_MIGHTYSITES_SYNCH_LABEL_'.$key); + } + natcasesort($custom2); + $custom = array_keys($custom2); + + $core = array( + 'extensions', + 'permissions', + 'users', + + // Users don't understand how it works, better skip + // 'sessions', + + 'templates', + 'categories', + 'content', + 'languages', + 'menus', + 'modules', + 'newsfeeds', + 'weblinks', + 'banners', + 'contacts', + 'messages', + 'smartsearch', + 'tags', + 'tags_refs', + 'redirect', + ); + asort($core); + + switch($type) { + case 'custom': + return $custom; + break; + + case 'core': + return $core; + break; + + default: + return array_merge($core, $custom); + break; + } + } + + // In fact returns all Sites & Databases + public static function getSites($key = 'domain') + { + static $sites; + + if (!isset($sites[$key])) + { + $db = JFactory::getDBO(); + + $db->setQuery('SELECT * FROM #__mightysites ORDER BY `domain`'); + + $sites[$key] = $db->loadObjectList($key); + + foreach($sites[$key] as &$site) { + // Prepare domain cmd + $site->domain_cmd = preg_replace('#([^A-Z0-9])#i', '_', $site->domain); + // Params + $site->params = new JRegistry($site->params); + } + } + + return $sites[$key]; + } + + // In fact returns a Site or Database + public static function getSite($id, $attach_config = false) + { + $sites = self::getSites(); + + // By domain + if (isset($sites[$id])) { + return $attach_config ? self::attachConfig($sites[$id]) : $sites[$id]; + } + + // By id or parsed domain + foreach($sites as $site) { + if ($id == $site->id || $id == $site->domain_cmd) { + return $attach_config ? self::attachConfig($site) : $site; + } + } + + return false; + } + + public static function getCurrentSite($attach_config = false) + { + $site = self::getSite(defined('MIGHTY_DOMAIN') ? MIGHTY_DOMAIN : self::getHost(), $attach_config); + + return $site; + } + + public static function sitesList($name, $value = null, $script = null, $skip = null, $first = null, $type = false, $first_value = '', $second = null, $second_value = null) + { + $options = array(); + + if ($first) { + $options[] = JHTML::_('select.option', $first_value, $first, 'value', 'text'); + } + + if ($second) { + $options[] = JHTML::_('select.option', $second_value, $second, 'value', 'text'); + } + + $sites = self::getSites(); + + foreach ($sites as $site) { + if (empty($skip) || ($skip != $site->domain)) { + if ($type && $site->type != $type) {} + else { + $options[] = JHTML::_('select.option', $site->id, $site->domain, 'value', 'text'); + } + } + } + + return JHTML::_('select.genericlist', $options, $name, 'class="inputbox" '.$script, 'value', 'text', $value); + } + + public static function getDatabases($key = 'id') + { + static $databases; + + if (!isset($databases[$key])) { + $db = JFactory::getDBO(); + $db->setQuery('SELECT * FROM #__mightysites ORDER BY `domain`'); + $databases[$key] = $db->loadObjectList($key); + } + + return $databases[$key]; + } + + + public static function databasesList($name, $value = null, $script = null, $skip = array('information_schema')) + { + $options = array(); + $options[] = JHTML::_('select.option', '', JText::_('COM_MIGHTYSITES_SELECT_DATABASE'), 'value', 'text'); + + $db = JFactory::getDBO(); + $db->setQuery('SHOW DATABASES'); + $rows = $db->loadColumn(); + + if (sizeof($rows)) { + foreach($rows as $row) { + if (!in_array($row, $skip)) { + $options[] = JHTML::_('select.option', $row, $row, 'value', 'text'); + } + } + } + return JHTML::_('select.genericlist', $options, $name, 'class="inputbox" '.$script, 'value', 'text', $value); + } + + public static function menuitemsList($name, $value, $script = null) + { + $types = array('default' => array(JHTML::_('select.option', '', JText::_('COM_MIGHTYSITES_DEFAULT_MENUITEM'), 'value', 'text'))); + + $db = JFactory::getDBO(); + $query = 'SELECT id, menutype, title, level FROM #__menu WHERE client_id=0 AND id > 1 AND published=1 ORDER BY lft'; + $db->setQuery($query); + + foreach($db->loadObjectList() as $item) { + if (!isset($types[$item->menutype])) { + $types[$item->menutype] = array(); + } + $types[$item->menutype][] = JHTML::_('select.option', $item->id, str_repeat(' - ', $item->level-1).$item->title, 'value', 'text'); + } + + return JHTML::_('select.groupedlist', $types, $name, array( + 'list.attr' => 'class="inputbox" '.$script, + 'id' => $name, + 'list.select' => $value, + 'group.items' => null, + 'option.key.toHtml' => false, + 'option.text.toHtml' => false + )); + } + + public static function prepareDomain($domain = null) + { + if (!$domain) { + $domain = self::getHost(); + } + + if (substr($domain, 0, 4) == 'www.') { + $domain = substr($domain, 4); + } + + // Use Punycode! + + // Joomla 3.3 + if (class_exists('JStringPunycode')) { + $domain = JStringPunycode::toPunycode($domain); + } + // Joomla 2.5 + else { + require_once(JPATH_SITE.'/libraries/simplepie/idn/idna_convert.class.php'); + $idn = new idna_convert; + $domain = $idn->encode($domain); + } + + // Normalize filename. + $domain = preg_replace('#([^A-Za-z0-9])#i', '_', $domain); + + return $domain; + } + + public static function getConfigFilename($domain = null, $force_root = false) + { + // current config + if (!$domain) { + if (defined('MIGHTY_CONFIG')) { + return MIGHTY_CONFIG; + } + + $domain = self::getHost(); + } + + $fname = JPATH_SITE.'/configuration_'.self::prepareDomain($domain).'.php'; + + if (!file_exists($fname) && !$force_root) { + $fname = JPATH_SITE.'/components/com_mightysites/configuration/configuration_'.self::prepareDomain($domain).'.php'; + } + + return $fname; + } + + public static function attachConfig(&$row, $config = null) + { + $app = JFactory::getApplication(); + + if ($row->type == 1) { + // Load as file into string. + if (!$config) { + $fname = self::getConfigFilename($row->domain); + if (file_exists($fname)) { + $config = JFile::read($fname); + } else { + $app->enqueueMessage(JText::sprintf('COM_MIGHTYSITES_NO_CONFIG', $fname, $row->domain), 'error'); + return $row; + } + } + + // Parse into object. + if (is_string($config)) { + $classname = 'JConfig'.$row->id; + + if (!class_exists($classname)) { + $config = strtr($config, array( + ' "\n", + ' "\r\n", + ' "\r", + 'class JConfig' => 'class '.$classname, + )); + eval($config); + } + + if (class_exists($classname)) { + $config = new $classname; + } + } + + // Parse object + if (is_object($config)) { + foreach((array)$config as $key => $value) { + $row->$key = $value; + } + $row->published = !@$row->offline; + } + } + + return $row; + } + + /* + public static function getToken() + { + $params = JComponentHelper::getParams('com_mightysites'); + return $params->get('support_token'); + } + */ + + public static function patchConfiguration() + { + // Update Joomla config. + $file = JPATH_SITE.'/configuration.php'; + $str = 'load('com_mightysites'); + + // Get the new FTP credentials. + $ftp = JClientHelper::getCredentials('ftp', true); + + // Attempt to make the file writeable if using FTP. + if (!$ftp['enabled'] && JPath::isOwner($file) && !JPath::setPermissions($file, '0644')) { + $app->enqueueMessage(JText::sprintf('COM_MIGHTYSITES_ERROR_CONFIG_PATCH_FAILED', $file), 'error'); + return false; + } + + if (JFile::write($file, $str)) { + // Attempt to make the file unwriteable if using FTP. + if (JFactory::getConfig()->get('ftp_enable') == 0 && !$ftp['enabled'] && JPath::isOwner($file) && !JPath::setPermissions($file, '0644')) { + $app->enqueueMessage(JText::sprintf('COM_MIGHTYSITES_ERROR_CONFIG_PATCH_FAILED', $file), 'error'); + return false; + } + } + else { + $app->enqueueMessage(JText::sprintf('COM_MIGHTYSITES_ERROR_CONFIG_PATCH_FAILED', $file), 'error'); + return false; + } + } + + // Update/create default config. + $default_file = JPATH_SITE.'/components/com_mightysites/configuration/default.php'; + + // Reload master domain from DB, it can be cached in our data. + $db = JFactory::getDbo(); + + $query = 'SELECT domain FROM `#__mightysites` WHERE id=1'; + $db->setQuery($query, 0, 1); + $master_domain = $db->loadResult(); + + if (!file_exists($default_file) + || + (strpos(file_get_contents($default_file), self::getConfigFilename($master_domain)) === false) + ) + { + + $default_str = 'enqueueMessage(JText::sprintf('COM_MIGHTYSITES_CANT_WRITE_FILE', $default_file), 'error'); + } + } + + return true; + } + + public static function &getDBO(&$site, $force_select = false) + { + if (!isset(self::$dbo[$site->id])) { + $conf = JFactory::getConfig(); + $options = array( + 'driver' => isset($site->dbtype) ? $site->dbtype : $conf->get('dbtype'), // can be absent if Database + 'host' => isset($site->host) ? $site->host : $conf->get('host'), // can be absent if Database + 'user' => isset($site->user) ? $site->user : $conf->get('user'), // can be absent if Database + 'password' => isset($site->password) ? $site->password : $conf->get('password'), // can be absent if Database + 'database' => $site->db, + 'prefix' => $site->dbprefix, + 'dummy' => md5(uniqid(mt_rand(), true)) // always get new instance, otherwise it can return db + ); + + // old legacy + // todo - remove in Joomla 3.0 + if ($options['driver'] == 'mightysites') { + $options['driver'] = 'mysql'; + } + + self::$dbo[$site->id] = JDatabase::getInstance($options); + + $version = new JVersion; + if ($version->RELEASE != '2.5') { + if (self::$dbo[$site->id]) { + self::$dbo[$site->id]->connect(); + } + } + + if (!self::$dbo[$site->id] || !self::$dbo[$site->id]->connected()) { + JError::raiseError(500, JText::sprintf('COM_MIGHTYSITES_CANT_CONNECT_DB', $options['database'], $options['user'], @self::$dbo[$site->id]->getErrorMsg())); + } + } + + if ($force_select) { + self::$dbo[$site->id]->select($site->db); + } + + return self::$dbo[$site->id]; + } + + public static function getTables(&$db) + { + $db->setQuery('SHOW FULL TABLES WHERE Table_Type = "BASE TABLE"'); + return $db->loadColumn(); + } + + public static function getViews(&$db) + { + $db->setQuery('SHOW FULL TABLES WHERE Table_Type = "VIEW"'); + return $db->loadColumn(); + } + + public static function topmenu() + { + $app = JFactory::getApplication(); + + $view = $app->input->get('view', 'sites'); + + $version = new JVersion; + if ($version->RELEASE == '2.5') { + $classname = 'JSubMenuHelper'; + } else { + $classname = 'JHtmlSidebar'; + } + + $classname::addEntry(JText::_('COM_MIGHTYSITES_SUBMENU_SITES'), 'index.php?option=com_mightysites&view=sites', $view == 'sites'); + $classname::addEntry(JText::_('COM_MIGHTYSITES_SUBMENU_DATABASES'), 'index.php?option=com_mightysites&view=databases', $view == 'databases'); + $classname::addEntry(JText::_('COM_MIGHTYSITES_SUBMENU_ABOUT'), 'index.php?option=com_mightysites&view=about', $view == 'about'); + + // check plugins + $db = JFactory::getDBO(); + $query = 'SELECT * FROM #__extensions WHERE `element`="mightysites" AND type="plugin"'; + $db->setQuery($query, 0, 1); + $plg_sys = $db->loadObject(); + + if (!$plg_sys) { + $app->enqueueMessage(JText::_('COM_MIGHTYSITES_PLUGIN_INSTALL_ERROR'), 'notice'); + } + else if (!$plg_sys->enabled) { + $app->enqueueMessage(JText::sprintf('COM_MIGHTYSITES_PLUGIN_UNPUBLISHED', 'System - MightySites'), 'notice'); + } + + // Auto correct ordering: move to first place + if ($plg_sys && $plg_sys->ordering != -99999) { + $query = 'UPDATE #__extensions SET ordering = -99999 WHERE `element`="mightysites" AND type="plugin"'; + $db->setQuery($query); + $db->query(); + + // Clear cache + $conf = JFactory::getConfig(); + $cache = JCache::getInstance('', array( + 'defaultgroup' => '', + 'storage' => $conf->get('cache_handler', ''), + 'caching' => true, + 'cachebase' => $conf->get('cache_path', JPATH_SITE . '/cache') + )); + $cache->clean('com_plugins'); + } + } + +} diff --git a/deployed/mightysites/administrator/components/com_mightysites/helpers/index.html b/deployed/mightysites/administrator/components/com_mightysites/helpers/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/deployed/mightysites/administrator/components/com_mightysites/helpers/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/deployed/mightysites/administrator/components/com_mightysites/images/icon_16.png b/deployed/mightysites/administrator/components/com_mightysites/images/icon_16.png new file mode 100644 index 00000000..16faccad Binary files /dev/null and b/deployed/mightysites/administrator/components/com_mightysites/images/icon_16.png differ diff --git a/deployed/mightysites/administrator/components/com_mightysites/images/index.html b/deployed/mightysites/administrator/components/com_mightysites/images/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/deployed/mightysites/administrator/components/com_mightysites/images/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/deployed/mightysites/administrator/components/com_mightysites/images/mightysites.png b/deployed/mightysites/administrator/components/com_mightysites/images/mightysites.png new file mode 100644 index 00000000..7641ceaa Binary files /dev/null and b/deployed/mightysites/administrator/components/com_mightysites/images/mightysites.png differ diff --git a/deployed/mightysites/administrator/components/com_mightysites/index.html b/deployed/mightysites/administrator/components/com_mightysites/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/deployed/mightysites/administrator/components/com_mightysites/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/deployed/mightysites/administrator/components/com_mightysites/mightysites.php b/deployed/mightysites/administrator/components/com_mightysites/mightysites.php new file mode 100644 index 00000000..fe8fe9da --- /dev/null +++ b/deployed/mightysites/administrator/components/com_mightysites/mightysites.php @@ -0,0 +1,35 @@ +authorise('core.manage', 'com_mightysites')) { + return JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR')); +} + +// Set the table directory +JTable::addIncludePath(JPATH_ADMINISTRATOR.'/components/com_mightysites/tables'); + +// Load Helper +require_once(JPATH_ADMINISTRATOR.'/components/com_mightysites/helpers/helper.php'); + +// Load Plugins +JPluginHelper::importPlugin('mightysites'); + +// Only Daddy rocks! +$host_site = MightysitesHelper::getCurrentSite(); +if (!isset($host_site->id) || $host_site->id != 1) { + JFactory::getApplication()->redirect('index.php', JText::sprintf('COM_MIGHTYSITES_INVALID_HOST', MightysitesHelper::getSite(1)->domain), 'error'); +} + +$controller = JControllerLegacy::getInstance('Mightysites'); +$controller->execute(JFactory::getApplication()->input->get('task')); +$controller->redirect(); diff --git a/deployed/mightysites/administrator/components/com_mightysites/mightysites.script.php b/deployed/mightysites/administrator/components/com_mightysites/mightysites.script.php new file mode 100644 index 00000000..c52ae1f2 --- /dev/null +++ b/deployed/mightysites/administrator/components/com_mightysites/mightysites.script.php @@ -0,0 +1,139 @@ +enqueueMessage('MightySites requires PHP 5.3+, please ask your hosting provider to update PHP.', 'error'); + return; + } + + require_once(JPATH_ADMINISTRATOR.'/components/com_mightysites/helpers/helper.php'); + + // Load our language + JFactory::getLanguage()->load('com_mightysites'); + + // Create current site + $domain = MightysitesHelper::getHost(); + + $query = 'INSERT IGNORE INTO `#__mightysites` (`id`, `type`, `domain`) VALUES(1, 1, '.$db->quote($domain).')'; + $db->setQuery($query); + $db->execute(); + + // Create new config + $fname = MightysitesHelper::getConfigFilename(); + + if (!file_exists($fname)) + { + $config = JFile::read(JPATH_CONFIGURATION.'/configuration.php'); + + if ($config) + { + if (JFile::write($fname, $config)) + { + // Try to make configuration.php unwriteable + $ftp = JClientHelper::getCredentials('ftp'); + jimport('joomla.filesystem.path'); + if (!$ftp['enabled'] && JPath::isOwner($fname) && !JPath::setPermissions($fname, '0644')) { + //JError::raiseNotice('SOME_ERROR_CODE', 'Could not make configuration.php writable'); + } + } + else + { + return; + } + } + } + + // Patch configuration.php! + MightysitesHelper::patchConfiguration(); + + // delete old admin file before 2.1.0 + $old = JPATH_SITE.'/administrator/components/com_mightysites/admin.mightysites.php'; + if (file_exists($old)) + { + jimport('joomla.filesystem.path'); + JFile::delete($old); + } + + // Get columns + $query = 'SELECT * FROM `#__mightysites`'; + $db->setQuery($query, 0, 1); + $columns = $db->loadObject(); + + // New in 3.2.3 + if (!property_exists($columns, 'aliases')) { + $query = 'ALTER TABLE `#__mightysites` ADD `aliases` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL AFTER `domain`'; + $db->setQuery($query); + $db->execute(); + } + + // Move old config files to new location - since 3.2.5 + foreach(MightysitesHelper::getSites() as $site) + { + $fname = JPATH_SITE.'/configuration_'.MightysitesHelper::prepareDomain($site->domain).'.php'; + $fname2 = JPATH_SITE.'/components/com_mightysites/configuration/configuration_'.MightysitesHelper::prepareDomain($site->domain).'.php'; + + if (file_exists($fname) && is_writable(JPATH_SITE.'/components/com_mightysites/configuration')) + { + JFile::move($fname, $fname2); + } + } + } + + function uninstall($parent) + { + // revert config + $db = JFactory::getDBO(); + + $query = 'SELECT * FROM `#__mightysites` WHERE id=1'; + $db->setQuery($query, 0, 1); + $root = $db->loadObject(); + + require_once(JPATH_ADMINISTRATOR.'/components/com_mightysites/helpers/helper.php'); + + jimport('joomla.filesystem.file'); + + if (isset($root->id)) + { + $error = true; + + $fname = MightysitesHelper::getConfigFilename($root->domain); + + if (file_exists($fname)) + { + $new_config = JFile::read($fname); + $old_config = JFile::read(JPATH_SITE.'/configuration.php'); + + if ($new_config && JString::strpos($old_config, 'class JConfig') === false) + { + /* + if (JString::strpos($config, 'var $mighty =') !== false) { + $config = preg_replace('/var \$mighty \= array ([^\;]*)\;\n/u', '', $config); + } + */ + if (JFile::write(JPATH_SITE.'/configuration.php', $new_config)) + { + $error = false; + } + } + } + + if ($error) + { + JFactory::getApplication()->enqueueMessage('Please re-save Global configuration!', 'error'); + } + } + } +} diff --git a/deployed/mightysites/administrator/components/com_mightysites/mightysites.xml b/deployed/mightysites/administrator/components/com_mightysites/mightysites.xml new file mode 100644 index 00000000..6e479e7a --- /dev/null +++ b/deployed/mightysites/administrator/components/com_mightysites/mightysites.xml @@ -0,0 +1,54 @@ + + + MightySites + Joomla multi-site manager. + + AlterBrains + (C) 2009-2014 AlterBrains. All rights reserved. + http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL + alterbrains@gmail.com + http://alterbrains.com + + 09/03/2014 + 3.2.5 + + + + sql/install.mysql.utf8.sql + + + + + index.html + format_25.php + format_30.php + format_33.php + mightysites.php + configuration + + + + MightySites + + controllers + helpers + images + models + sql + tables + views + index.html + controller.php + mightysites.php + access.xml + config.xml + + + admin/language/en-GB.com_mightysites.ini + admin/language/en-GB.com_mightysites.sys.ini + + + + mightysites.script.php + + \ No newline at end of file diff --git a/deployed/mightysites/administrator/components/com_mightysites/models/database.php b/deployed/mightysites/administrator/components/com_mightysites/models/database.php new file mode 100644 index 00000000..aa321788 --- /dev/null +++ b/deployed/mightysites/administrator/components/com_mightysites/models/database.php @@ -0,0 +1,125 @@ +id)) { + // Don't delete sites! + if ($record->type == 1) { + return ; + } + + return parent::canDelete($record); + } + } + + public function getTable($type = 'Database', $prefix = 'MightysitesTable', $config = array()) + { + return JTable::getInstance($type, $prefix, $config); + } + + /** + * Method to get the record form. + * + * @param array $data An optional array of data for the form to interogate. + * @param boolean $loadData True if the form is to load its own data (default case), false if not. + * @return JForm A JForm object on success, false on failure + * @since 1.6 + */ + public function getForm($data = array(), $loadData = true) + { + // Initialise variables. + $app = JFactory::getApplication(); + + // Get the form. + $form = $this->loadForm('com_mightysites.database', 'database', array('control' => 'jform', 'load_data' => $loadData)); + if (empty($form)) { + return false; + } + + return $form; + } + + /** + * Method to get the data that should be injected in the form. + * + * @return mixed The data for the form. + * @since 1.6 + */ + protected function loadFormData() + { + // Check the session for previously entered form data. + $data = JFactory::getApplication()->getUserState('com_mightysites.edit.database.data', array()); + + if (empty($data)) { + $data = $this->getItem(); + + // Prime some default values. + if ($this->getState('database.id') == 0) { + $app = JFactory::getApplication(); + + $data->set('type', 2); + $data->set('db', $app->getCfg('db')); + } + } + + return $data; + } + + public function getItem($pk = null) + { + if ($item = parent::getItem($pk)) { + + if ($item->id) { + + } + else { + // Force type + $item->type = 2; + } + } + + return $item; + } + + public function save($data) + { + // Update database + $result = parent::save($data); + if ($result !== true) { + return $result; + } + + $isNew = $this->getState($this->getName() . '.new'); + $id = $this->getState($this->getName() . '.id'); + + // Load new row + $row = $this->getTable(); + $row->load($id); + $row->params = new JRegistry($row->params); + + // Copy tables + if ($isNew) { + if ($data['source_db']) { + $session = JFactory::getSession(); + $session->set('mighty_copy', 'index.php?option=com_mightysites&task=database.copy&from='.$data['source_db'].'&to='.$row->id.'&tmpl=component'); + } + } + + return true; + } + +} diff --git a/deployed/mightysites/administrator/components/com_mightysites/models/databases.php b/deployed/mightysites/administrator/components/com_mightysites/models/databases.php new file mode 100644 index 00000000..69272229 --- /dev/null +++ b/deployed/mightysites/administrator/components/com_mightysites/models/databases.php @@ -0,0 +1,123 @@ +getUserStateFromRequest($this->context.'.filter.search', 'filter_search'); + $this->setState('filter.search', $search); + + // Load the parameters. + $params = JComponentHelper::getParams('com_mightysites'); + $this->setState('params', $params); + + // List state information. + parent::populateState('a.id', 'asc'); + } + + protected function getStoreId($id = '') + { + // Compile the store id. + $id .= ':' . $this->getState('filter.search'); + $id .= ':' . $this->getState('filter.state'); + + return parent::getStoreId($id); + } + + protected function getListQuery() + { + // Create a new query object. + $db = $this->getDbo(); + $query = $db->getQuery(true); + $user = JFactory::getUser(); + + // Select the required fields from the table. + $query->select( + $this->getState( + 'list.select', + 'a.*' + ) + ); + $query->from($db->quoteName('#__mightysites').' AS a'); + + // Join over the users for the checked out user. + $query->select('uc.name AS editor'); + $query->join('LEFT', '#__users AS uc ON uc.id=a.checked_out'); + + // Filter by type. + $type = $this->getState('filter.type'); + if ($type) { + $query->where('a.type='.$type); + } + + // Filter by search in title + $search = $this->getState('filter.search'); + if (!empty($search)) { + if (stripos($search, 'id:') === 0) { + $query->where('a.id = '.(int) substr($search, 3)); + } else { + $search = $db->Quote('%'.$db->escape($search, true).'%'); + $query->where('( + a.domain LIKE '.$search.' + OR a.db LIKE '.$search.' + OR a.dbprefix LIKE '.$search.' + )'); + } + } + + // Add the list ordering clause. + $orderCol = $this->state->get('list.ordering'); + $orderDirn = $this->state->get('list.direction'); + $query->order($db->escape($orderCol.' '.$orderDirn)); + + return $query; + } + + public function getItems() + { + $items = parent::getItems(); + + if ($items) { + $app = JFactory::getApplication(); + + foreach($items as &$item) { + // Init params + $item->params = new JRegistry($item->params); + + // Add config for sites + if ($item->type == 1) { + MightysitesHelper::attachConfig($item); + } + } + } + + return $items; + } + +} diff --git a/deployed/mightysites/administrator/components/com_mightysites/models/fields/index.html b/deployed/mightysites/administrator/components/com_mightysites/models/fields/index.html new file mode 100644 index 00000000..2efb97f3 --- /dev/null +++ b/deployed/mightysites/administrator/components/com_mightysites/models/fields/index.html @@ -0,0 +1 @@ + diff --git a/deployed/mightysites/administrator/components/com_mightysites/models/fields/mightydatabase.php b/deployed/mightysites/administrator/components/com_mightysites/models/fields/mightydatabase.php new file mode 100644 index 00000000..6a5f5f90 --- /dev/null +++ b/deployed/mightysites/administrator/components/com_mightysites/models/fields/mightydatabase.php @@ -0,0 +1,32 @@ +id, $site->domain, 'value', 'text'); + } + + // Merge any additional options in the XML definition. + $options = array_merge( + parent::getOptions(), + $options + ); + + return $options; + } +} diff --git a/deployed/mightysites/administrator/components/com_mightysites/models/fields/mightysite.php b/deployed/mightysites/administrator/components/com_mightysites/models/fields/mightysite.php new file mode 100644 index 00000000..76743d57 --- /dev/null +++ b/deployed/mightysites/administrator/components/com_mightysites/models/fields/mightysite.php @@ -0,0 +1,34 @@ +type == 1 || (string)$this->element['database'] !== 'false') { + $options[] = JHTML::_('select.option', $site->id, $site->domain, 'value', 'text'); + } + } + + // Merge any additional options in the XML definition. + $options = array_merge( + parent::getOptions(), + $options + ); + + return $options; + } +} diff --git a/deployed/mightysites/administrator/components/com_mightysites/models/fields/templatestyle.php b/deployed/mightysites/administrator/components/com_mightysites/models/fields/templatestyle.php new file mode 100644 index 00000000..12b05b29 --- /dev/null +++ b/deployed/mightysites/administrator/components/com_mightysites/models/fields/templatestyle.php @@ -0,0 +1,66 @@ +setQuery($query); + + $tmp = ''; + foreach($db->loadObjectList() as $style) { + if ($tmp != $style->template) { + if ($tmp) { + $options[] = JHtml::_('select.optgroup', $tmp); + } + $options[] = JHtml::_('select.optgroup', $style->template); + $tmp = $style->template; + } + $options[] = JHTML::_('select.option', $style->id, $style->title, 'value', 'text'); + } + + + // Merge any additional options in the XML definition. + $options = array_merge( + parent::getOptions(), + $options + ); + + return $options; + } +} diff --git a/deployed/mightysites/administrator/components/com_mightysites/models/forms/database.xml b/deployed/mightysites/administrator/components/com_mightysites/models/forms/database.xml new file mode 100644 index 00000000..a9b92097 --- /dev/null +++ b/deployed/mightysites/administrator/components/com_mightysites/models/forms/database.xml @@ -0,0 +1,28 @@ + +
+
+ + + + + + + +
+ +
+ + + +
+ + + +
diff --git a/deployed/mightysites/administrator/components/com_mightysites/models/forms/index.html b/deployed/mightysites/administrator/components/com_mightysites/models/forms/index.html new file mode 100644 index 00000000..2efb97f3 --- /dev/null +++ b/deployed/mightysites/administrator/components/com_mightysites/models/forms/index.html @@ -0,0 +1 @@ + diff --git a/deployed/mightysites/administrator/components/com_mightysites/models/forms/site.xml b/deployed/mightysites/administrator/components/com_mightysites/models/forms/site.xml new file mode 100644 index 00000000..0846efc9 --- /dev/null +++ b/deployed/mightysites/administrator/components/com_mightysites/models/forms/site.xml @@ -0,0 +1,144 @@ + +
+
+ + + + + + + + + + + + + +
+ +
+ + + + + + + + + + +
+ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + + + +
+ +
+ + + + + + + + + +
+ +
+ + + + + + + +
+ +
+
diff --git a/deployed/mightysites/administrator/components/com_mightysites/models/index.html b/deployed/mightysites/administrator/components/com_mightysites/models/index.html new file mode 100644 index 00000000..2efb97f3 --- /dev/null +++ b/deployed/mightysites/administrator/components/com_mightysites/models/index.html @@ -0,0 +1 @@ + diff --git a/deployed/mightysites/administrator/components/com_mightysites/models/site.php b/deployed/mightysites/administrator/components/com_mightysites/models/site.php new file mode 100644 index 00000000..d0e2de69 --- /dev/null +++ b/deployed/mightysites/administrator/components/com_mightysites/models/site.php @@ -0,0 +1,1164 @@ +id)) { + // Don't delete root! + if ($record->id == 1) { + return ; + } + // Don't delete databases! + if ($record->type == 2) { + return ; + } + + return parent::canDelete($record); + } + } + + public function getTable($type = 'Site', $prefix = 'MightysitesTable', $config = array()) + { + return JTable::getInstance($type, $prefix, $config); + } + + /** + * Method to get the record form. + * + * @param array $data An optional array of data for the form to interogate. + * @param boolean $loadData True if the form is to load its own data (default case), false if not. + * @return JForm A JForm object on success, false on failure + * @since 1.6 + */ + public function getForm($data = array(), $loadData = true) + { + // Initialise variables. + $app = JFactory::getApplication(); + + // Get the form. + $form = $this->loadForm('com_mightysites.site', 'site', array('control' => 'jform', 'load_data' => $loadData)); + if (empty($form)) { + return false; + } + + // Require fields + if ($this->getState('site.id')) { + $form->setFieldAttribute('source_config', 'required', 'false'); + + // Don't edit secret of this site. + /* + if ($this->getState('site.id') == MightysitesHelper::getCurrentSite()->id) { + $form->setFieldAttribute('secret', 'readonly', 'true', 'params'); + } + */ + + // If site uses same database - we can prettify it a bit + $config = JFactory::getConfig(); + $site = MightysitesHelper::getSite($this->getState('site.id'), true); + + if ($site->db == $config->get('db') && $site->dbprefix == $config->get('dbprefix')) { + // Pretiify Template Style + $form->setFieldAttribute('template', 'type', 'templatestyle', 'params'); + $form->setFieldAttribute('template', 'class', '', 'params'); + + // Pretiify Home + $form->setFieldAttribute('home', 'type', 'menuitem', 'params'); + $form->setFieldAttribute('home', 'class', '', 'params'); + } + } + + return $form; + } + + /** + * Method to get the data that should be injected in the form. + * + * @return mixed The data for the form. + * @since 1.6 + */ + protected function loadFormData() + { + // Check the session for previously entered form data. + $data = JFactory::getApplication()->getUserState('com_mightysites.edit.site.data', array()); + + if (empty($data)) { + $data = $this->getItem(); + + // Prime some default values. + if ($this->getState('site.id') == 0) { + $app = JFactory::getApplication(); + + $data->set('type', 1); + $data->set('db', $app->getCfg('db')); + $data->set('dbprefix', $app->getCfg('dbprefix')); + $data->set('user', $app->getCfg('user')); + $data->set('password', $app->getCfg('password')); + } + } + + return $data; + } + + public function getItem($pk = null) + { + if ($item = parent::getItem($pk)) { + + if ($item->id) { + // add config + MightysitesHelper::attachConfig($item); + + // pass legacy vars + // todo - remove for Joomla 3.0 + if (isset($item->mighty_language)) { + $item->params['language'] = $item->mighty_language; + } + if (isset($item->mighty_template)) { + $item->params['template'] = $item->mighty_template; + } + if (isset($item->mighty_home)) { + $item->params['home'] = $item->mighty_home; + } + if (isset($item->mighty_langoverride)) { + $item->params['langoverride'] = $item->mighty_langoverride; + } + if (isset($item->mighty_enable)) { + $item->params['enable_replacements'] = $item->mighty_enable; + } + if (isset($item->params['slogin'])) { + $item->params['single_login'] = $item->params['slogin']; + } + if (isset($item->params['slogout'])) { + $item->params['single_logout'] = $item->params['slogout']; + } + if (isset($item->secret)) { + $item->params['secret'] = $item->secret; + } + if (isset($item->cookie_domain)) { + $item->params['cookie_domain'] = $item->cookie_domain; + } + } + else { + // Force type + $item->type = 1; + } + } + + return $item; + } + + public function save($data) + { + $app = JFactory::getApplication(); + + // Prepare domain name + $data['domain'] = trim(strtolower($data['domain']), ' ./\\'); + + if (substr($data['domain'], 0, 7) == 'http://') { + $data['domain'] = substr($data['domain'], 7); + } + if (substr($data['domain'], 0, 8) == 'https://') { + $data['domain'] = substr($data['domain'], 8); + } + if (substr($data['domain'], 0, 4) == 'www.') { + $data['domain'] = substr($data['domain'], 4); + } + if (empty($data['domain'])) { + $this->setError(JText::_('COM_MIGHTYSITES_ERROR_DOMAIN_EMPTY')); + return false; + } + + // Prepare single login/logout params + $single_domain = $app->input->get('single_domain', array(), 'array'); + $single_key = $app->input->get('single_key', array(), 'array'); + + if (sizeof($single_domain)) { + $i = 0; + $data['params']['single_domains'] = array(); + foreach($single_domain as $value) + { + if (!empty($value)) + { + $value = trim(strtolower($value)); + if (substr($value, 0, 7) == 'http://') { + $value = substr($value, 7); + } + if (substr($value, 0, 8) == 'https://') { + $value = substr($value, 8); + } + $value = trim($value, ' /'); + + // Not to itself! + if ($value == $data['domain']) { + continue; + } + + $data['params']['single_domain'.(string)$i] = $value; + $data['params']['single_key'.(string)$i] = trim($single_key[$i]); + + $data['params']['single_domains'][$value] = trim($single_key[$i]); + } + $i++; + } + } + + // Prepare Aliases + if (strlen($data['aliases'])) + { + $data['aliases'] = strtolower($data['aliases']); + $data['aliases'] = strtr($data['aliases'], "\r\n", "\n"); + $data['aliases'] = array_filter(explode("\n", $data['aliases'])); + + foreach($data['aliases'] as &$alias) + { + $alias = trim($alias, '/ '); + if (substr($alias, 0, 7) == 'http://') { + $alias = substr($alias, 7); + } + if (substr($alias, 0, 8) == 'https://') { + $alias = substr($alias, 8); + } + if (substr($alias, 0, 4) == 'www.') { + $alias = substr($alias, 4); + } + // Still smbd will try to enter this here! + if ($alias == $data['domain']) { + $alias = ''; + } + // Alias can't be current domain + if (MightysitesHelper::getSite($alias)) { + $app->enqueueMessage(JText::sprintf('COM_MIGHTYSITES_ERROR_ALIAS_EXISTS_SITE', $alias), 'error'); + $alias = ''; + } + // Check aliases of other sites - no duplicates! + foreach(MightysitesHelper::getSites() as $site2) + { + if ($site2->aliases) + { + $aliases2 = explode("\n", $site2->aliases); + + if (in_array($alias, $aliases2) && $site2->id != $data['id']) + { + $app->enqueueMessage(JText::sprintf('COM_MIGHTYSITES_ERROR_ALIAS_EXISTS', $alias, $site2->domain), 'error'); + $alias = ''; + } + } + } + } + + $data['aliases'] = implode("\n", array_filter($data['aliases'])); + } + + // get all fields + $jform = $app->input->get('jform', array(), 'array'); + + // add tables + if (isset($jform['tables']) && is_array($jform['tables'])) + { + foreach($jform['tables'] as $i => $value) { + if ($value) { + $data['params']['table_'.$i] = $value; + } + } + } + + // add content + if (isset($jform['content']) && is_array($jform['content'])) { + foreach($jform['content'] as $i => $value) { + if ($value) { + $data['params'][$i] = $value; + } + } + } + + // New site? + $isNew = empty($data['id']); + + if ($isNew) + { + // Load source site. + $source_site = $data['source_config']; + $source_site = MightysitesHelper::getSite($source_site); + + // New site will get source params + $data['params'] = $source_site->params->toArray(); + + // But not this, otherwise for sure nobody will login. + unset($data['params']['cookie_domain']); + } + + // Load current row + $id = $this->getState($this->getName() . '.id'); + + $before = $this->getTable(); + $before->load($id); + $before->params = new JRegistry($before->params); + + // Update database + $result = parent::save($data); + if ($result !== true) { + return $result; + } + + // Load new row + $id = $this->getState($this->getName() . '.id'); + + $row = $this->getTable(); + $row->load($id); + $row->params = new JRegistry($row->params); + + + $params = isset($data['params']) ? $data['params'] : array(); + + if ($isNew) + { + // Create config + $config = $this->loadConfig($source_site->domain); + + // New secret key + jimport('joomla.user.helper'); + $config->secret = JUserHelper::genRandomPassword(16); + // new $live_site, just empty + $config->live_site = ''; + // none session handler, database doesn't work sometimes + $config->session_handler = 'none'; + // empty cookie domain + $config->cookie_domain = ''; + } + else + { + // Domain changed? + if ($before->domain != $row->domain) { + $this->copyConfig($before->domain, $row->domain); + } + + // Load current config + $config = $this->loadConfig($row->domain); + } + + // New system settings. + $config->db = $data['db']; + $config->user = $data['user']; + $config->dbprefix = $data['dbprefix']; + $config->password = $data['password']; + $config->dbtype = $data['dbtype']; + + if (isset($params['secret']) && $params['secret']) { + $config->secret = $params['secret']; + } + if (isset($params['cookie_domain']) && $params['cookie_domain']) { + $config->cookie_domain = $params['cookie_domain']; + } + + // Create replacements + MightysitesHelper::attachConfig($row, $config); + + // Next part is only active for existing site, so new site with config cloned from source config has data of source site. + if (!$isNew) + { + $replacements = $this->createTablesReplacements($row); + + // Check dummies + if (isset($replacements[0]) && is_array($replacements[0]) && sizeof($replacements[0]) > 20) { + $app->enqueueMessage(JText::_('СOM_MIGHTYSITES_ERROR_TOO_MUCH_SHARINGS'), 'notice'); + } + + // Inject our settings + // Params can be absent for new site! + $config->mighty = $replacements; + $config->mighty_enable = isset($params['enable_replacements']) ? $params['enable_replacements'] : ''; + $config->mighty_language = isset($params['language']) ? $params['language'] : ''; + $config->mighty_template = isset($params['template']) ? $params['template'] : ''; + $config->mighty_home = isset($params['home']) ? $params['home'] : ''; + $config->mighty_langoverride = isset($params['langoverride']) ? $params['langoverride'] : ''; + $config->cache_path = isset($params['cache_path']) ? $params['cache_path'] : ''; + $config->mighty_slogin = isset($params['single_login']) ? $params['single_login'] : ''; + $config->mighty_slogout = isset($params['single_logout']) ? $params['single_logout'] : ''; + $config->mighty_sdomains = isset($params['single_domains']) ? $params['single_domains'] : ''; + $config->mighty_css = isset($params['custom_css']) ? ( $params['custom_css'] ? explode("\n", str_replace("\r\n", "\n", $params['custom_css'])) : array() ) : array(); + $config->mighty_js = isset($params['custom_js']) ? $params['custom_js'] : ''; + $config->mighty_hidemenus = isset($params['hidemenus']) ? array_filter($params['hidemenus']) : ''; + $config->mighty_hidemodules = isset($params['hidemodules']) ? array_filter($params['hidemodules']) : ''; + $config->mighty_favicon = isset($params['favicon']) ? $params['favicon'] : ''; + $config->mighty_mijoshopid = isset($params['mijoshopid']) ? $params['mijoshopid'] : ''; + $config->mighty_file_path = isset($params['file_path']) ? $params['file_path'] : ''; + $config->mighty_image_path = isset($params['file_path']) ? $params['image_path'] : ''; + $config->mighty_new_usertype = isset($params['new_usertype']) ? $params['new_usertype'] : ''; + } + + // Save config + $this->saveConfig($data['domain'], $config, $isNew); + + // Copy tables + if ($isNew) + { + if ($data['source_db']) + { + $session = JFactory::getSession(); + $session->set('mighty_copy', 'index.php?option=com_mightysites&task=database.copy&from='.$data['source_db'].'&to='.$row->id.'&tmpl=component'); + } + } + + // Domain changed? Remove old config. + if (!$isNew && $before->domain != $row->domain) + { + $this->removeConfig($before->domain); + } + + // Update aliases + if ($before->aliases != $row->aliases || $before->domain != $row->domain) + { + $before->aliases = explode("\n", $before->aliases); + $row->aliases = explode("\n", $row->aliases); + + $old_aliases = array_diff($before->aliases, $row->aliases); + $new_aliases = array_diff($row->aliases, $before->aliases); + + // Domain was changed - change all! + if ($before->domain != $row->domain) { + $new_aliases = $row->aliases; + } + + if ($old_aliases) { + foreach($old_aliases as $old_alias) { + $this->removeAlias($old_alias); + } + } + + if ($new_aliases) { + foreach($new_aliases as $new_alias) { + $this->createAlias($row->domain, $new_alias); + } + } + } + + // Auto-check if configuration.php is patched + auto-update default.php config + MightysitesHelper::patchConfiguration(); + + return true; + } + + protected function loadConfig($domain) + { + $app = JFactory::getApplication(); + + $fname = MightysitesHelper::getConfigFilename($domain); + if (!file_exists($fname)) { + $app->redirect('index.php?option=com_mightysites', JText::sprintf('COM_MIGHTYSITES_ERROR_NEW_CONFIG_DOESNT_EXIST', $fname), 'error'); + } + if (!is_readable($fname)) { + $app->redirect('index.php?option=com_mightysites', JText::sprintf('COM_MIGHTYSITES_ERROR_NEW_CONFIG_NOT_READABLE', $fname), 'error'); + } + if (!is_writable(JPATH_CONFIGURATION)) { + // not used, can be writable by FTP! + //$app->redirect('index.php?option=com_mightysites', JText::sprintf('COM_MIGHTYSITES_ERROR_NEW_CONFIG_NOT_WRITABLE', fname), 'error'); + } + + $config = JFile::read($fname); + + $classname = 'JConfig'.uniqid(); + + if (!class_exists($classname)) { + $config = strtr($config, array( + ' '', + 'class JConfig' => 'class '.$classname, + )); + eval($config); + } + + if (class_exists($classname)) { + $config = new $classname; + } + + return $config; + } + + protected function saveConfig($domain, $config, $isNew = false) + { + $app = JFactory::getApplication(); + + $file = MightysitesHelper::getConfigFilename($domain); + + // Get the FTP credentials. + $ftp = JClientHelper::getCredentials('ftp', true); + + // Attempt to make the file writeable if using FTP. + if (file_exists($file)) { + if (!$ftp['enabled'] && JPath::isOwner($file) && !JPath::setPermissions($file, '0644')) { + $app->redirect('index.php?option=com_mightysites', JText::sprintf('COM_MIGHTYSITES_ERROR_CONFIG_NOT_WRITABLE', $file), 'error'); + } + } + + $registry = new JRegistry($config); + + // Don't use JConfig to not trigger our plugin. + $configuration = $registry->toString('PHP', array('class' => 'JConfigggg', 'closingtag' => false)); + $configuration = strtr($configuration, array( + 'JConfigggg' => 'JConfig', + )); + + if (!JFile::write($file, $configuration)) { + $app->redirect('index.php?option=com_mightysites', JText::sprintf('COM_MIGHTYSITES_ERROR_CONFIG_WRITE_FAILED', $file), 'error'); + } + + // Try to make configuration.php unwriteable + if (!$ftp['enabled'] && JPath::isOwner($file) && !JPath::setPermissions($file, '0444')) { + $app->redirect('index.php?option=com_mightysites', JText::sprintf('COM_MIGHTYSITES_ERROR_CONFIG_NOT_UNWRITABLE', $file), 'error'); + } + } + + protected function copyConfig($domain_from, $domain_to) + { + $app = JFactory::getApplication(); + + $file_from = MightysitesHelper::getConfigFilename($domain_from); + $file_to = MightysitesHelper::getConfigFilename($domain_to); + + if (!JFile::copy($file_from, $file_to)) { + $app->redirect('index.php?option=com_mightysites', JText::sprintf('COM_MIGHTYSITES_ERROR_CONFIG_WRITE_FAILED', $file_to), 'error'); + } + } + + protected function removeConfig($domain) + { + $file = MightysitesHelper::getConfigFilename($domain); + + return JFile::delete($file); + } + + protected function removeAlias($alias) + { + if (empty($alias)) { + return; + } + + $filename = MightysitesHelper::getConfigFilename($alias); + + if (file_exists($filename)) { + JFile::delete($filename); + } + } + + protected function createAlias($domain, $alias) + { + if (empty($alias)) { + return; + } + + $filename = MightysitesHelper::getConfigFilename($alias); + + if (file_exists($filename)) { + JFile::delete($filename); + } + + $str = 'enqueueMessage(JText::sprintf('COM_MIGHTYSITES_ERROR_ALIAS_WRITE_FAILED', $filename, $alias)); + } + } + + protected function createTablesReplacements(&$site, $tables = array()) + { + $params = $site->params; + + $data = array(); + $tables = array(); + + // Core extensions + if ($params->get('extensions')) { + $tables['extensions'] = $params->get('extensions'); + //$tables['schemas'] = $params->get('extensions'); // not share, otherwise Joomla version is lost in slave sites + $tables['updates'] = $params->get('extensions'); + $tables['update_categories'] = $params->get('extensions'); + $tables['update_sites'] = $params->get('extensions'); + $tables['update_sites_extensions'] = $params->get('extensions'); + + // load backend menu components also, for backend only. + $data['/SELECT m.id, m.title, m.alias, m.link, m.parent_id, m.img, e.element\r?\nFROM #__menu AS m/'] = + 'SELECT m.id, m.title, m.alias, m.link, m.parent_id, m.img, e.element FROM '.$this->_createTableReplacements($site, 'menu', $params->get('extensions')).' AS m'; + } + if ($params->get('permissions')) { + $tables['assets'] = $params->get('permissions'); + } + if ($params->get('users')) { + $tables['usergroups'] = $params->get('users'); + $tables['users'] = $params->get('users'); + $tables['user_notes'] = $params->get('users'); + $tables['user_profiles'] = $params->get('users'); + $tables['user_usergroup_map'] = $params->get('users'); + $tables['user_keys'] = $params->get('users'); + $tables['viewlevels'] = $params->get('users'); + } + if ($params->get('sessions')) { + $tables['session'] = $params->get('sessions'); + } + if ($params->get('templates')) { + $tables['template_styles'] = $params->get('templates'); + } + if ($params->get('categories')) { + $tables['categories'] = $params->get('categories'); + } + if ($params->get('content')) { + $tables['content'] = $params->get('content'); + $tables['content_frontpage'] = $params->get('content'); + $tables['content_rating'] = $params->get('content'); + $tables['content_types'] = $params->get('content'); + $tables['ucm_base'] = $params->get('content'); + $tables['ucm_content'] = $params->get('content'); + $tables['ucm_history'] = $params->get('content'); + } + if ($params->get('languages')) { + $tables['languages'] = $params->get('languages'); + $tables['overrider'] = $params->get('languages'); + } + if ($params->get('menus')) { + $tables['menu'] = $params->get('menus'); + $tables['menu_types'] = $params->get('menus'); + $tables['associations'] = $params->get('menus'); + } + if ($params->get('modules')) { + $tables['modules'] = $params->get('modules'); + $tables['modules_menu'] = $params->get('modules'); + } + if ($params->get('newsfeeds')) { + $tables['newsfeeds'] = $params->get('newsfeeds'); + } + if ($params->get('weblinks')) { + $tables['weblinks'] = $params->get('weblinks'); + } + if ($params->get('banners')) { + $tables['banners'] = $params->get('banners'); + $tables['banner_clients'] = $params->get('banners'); + $tables['banner_tracks'] = $params->get('banners'); + } + if ($params->get('contacts')) { + $tables['contact_details'] = $params->get('contacts'); + } + if ($params->get('messages')) { + $tables['messages'] = $params->get('messages'); + $tables['messages_cfg'] = $params->get('messages'); + } + if ($params->get('tags')) { + $tables['tags'] = $params->get('tags'); + } + if ($params->get('tags_refs')) { + $tables['contentitem_tag_map'] = $params->get('tags_refs'); + } + if ($params->get('redirect')) { + $tables['redirect_links'] = $params->get('redirect'); + } + + // 3rd-party extensions + if ($params->get('smartsearch')) { + $data['/`?#__finder_([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'finder_', $params->get('smartsearch'), '') . '$1`'; + } + if ($params->get('js')) { + $data['/`?#__community_([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'community_', $params->get('js'), '') . '$1`'; + } + if ($params->get('js_no_config')) { + $data['/(`?)(\#__community)((?!_config)[^0-9a-z_]*)/u'] = '$1' . str_replace('`.`', '$1.$1', $this->_createTableReplacements($site, 'community', $params->get('js_no_config'), '')) . '$4'; + } + if ($params->get('cb')) { + $data['/`?#__comprofiler([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'comprofiler', $params->get('cb'), '') . '$1`'; + } + if ($params->get('mtree')) { + $data['/`?#__mt_([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'mt_', $params->get('mtree'), '') . '$1`'; + } + if ($params->get('sobi2')) { + $data['/`?#__sobi2_([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'sobi2_', $params->get('sobi2'), '') . '$1`'; + } + if ($params->get('sobipro')) { + $data['/`?#__sobipro_([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'sobipro_', $params->get('sobipro'), '') . '$1`'; + } + if ($params->get('gridiron')) { + $data['/`?#__gridiron_([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'gridiron_', $params->get('gridiron'), '') . '$1`'; + } + if ($params->get('uddeim')) { + $data['/`?#__uddeim([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'uddeim', $params->get('uddeim'), '') . '$1`'; + } + if ($params->get('zoo')) { + $data['/`?#__zoo_([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'zoo_', $params->get('zoo'), '') . '$1`'; + } + if ($params->get('dtregister')) { + $data['/`?#__dtregister([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'dtregister', $params->get('dtregister'), '') . '$1`'; + } + if ($params->get('easyblog')) { + $data['/`?#__easyblog_([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'easyblog_', $params->get('easyblog'), '') . '$1`'; + } + if ($params->get('joomsport')) { + $data['/`?#__bl_([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'bl_', $params->get('joomsport'), '') . '$1`'; + } + if ($params->get('rsform')) { + $data['/`?#__rsform_([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'rsform_', $params->get('rsform'), '') . '$1`'; + } + if ($params->get('rsfiles')) { + $data['/`?#__rsfiles_([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'rsfiles_', $params->get('rsfiles'), '') . '$1`'; + } + if ($params->get('acymailing')) { + $data['/`?#__acymailing_([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'acymailing_', $params->get('acymailing'), '') . '$1`'; + } + if ($params->get('jce')) { + $tables['wf_profiles'] = $params->get('jce'); + } + if ($params->get('adsmanager')) { + $data['/`?#__adsmanager_([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'adsmanager_', $params->get('adsmanager'), '') . '$1`'; + } + if ($params->get('joomshopping')) { + $data['/`?#__jshopping_([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'jshopping_', $params->get('joomshopping'), '') . '$1`'; + } + if ($params->get('kunena')) { + $data['/`?#__kunena_([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'kunena_', $params->get('kunena'), '') . '$1`'; + } + if ($params->get('k2')) { + $data['/`?#__k2_([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'k2_', $params->get('k2'), '') . '$1`'; + } + if ($params->get('pf')) { + $data['/`?#__pf_([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'pf_', $params->get('pf'), '') . '$1`'; + } + if ($params->get('jcp')) { + $data['/`?#__jcp_([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'jcp_', $params->get('jcp'), '') . '$1`'; + } + if ($params->get('enmasse')) { + $data['/`?#__enmasse_([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'enmasse_', $params->get('enmasse'), '') . '$1`'; + } + if ($params->get('phocadownload')) { + $data['/`?#__phocadownload([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'phocadownload', $params->get('phocadownload'), '') . '$1`'; + } + if ($params->get('phocagallery')) { + $data['/`?#__phocagallery([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'phocagallery', $params->get('phocagallery'), '') . '$1`'; + } + if ($params->get('jreviews')) { + $data['/`?#__jreviews_([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'jreviews_', $params->get('jreviews'), '') . '$1`'; + } + // A bit more complex for VM, it uses queries like + // WHERE #__virtuemart_products_en_gb.`virtuemart_product_id` + // FROM `#__virtuemart_products_en_gb` `p` + if ($params->get('virtuemart')) { + $data['/(`?)(\#__virtuemart)([^0-9a-z_]*)/u'] = '$1' . str_replace('`.`', '$1.$1', $this->_createTableReplacements($site, 'virtuemart', $params->get('virtuemart'), '')) . '$3'; + } + if ($params->get('virtuemart_no_config')) { + $data['/(`?)(\#__virtuemart)((?!_configs)[^0-9a-z_]*)/u'] = '$1' . str_replace('`.`', '$1.$1', $this->_createTableReplacements($site, 'virtuemart', $params->get('virtuemart_no_config'), '')) . '$4'; + } + if ($params->get('jevents')) { + $data['/`?#__jevents_([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'jevents_', $params->get('jevents'), '') . '$1`'; + } + if ($params->get('hwdms')) { + $data['/`?#__hwdms_([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'hwdms_', $params->get('hwdms'), '') . '$1`'; + } + if ($params->get('admintools')) { + $data['/`?#__admintools_([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'admintools_', $params->get('admintools'), '') . '$1`'; + } + if ($params->get('ak')) { + $data['/`?#__ak_([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'ak_', $params->get('ak'), '') . '$1`'; + } + if ($params->get('akeebasubs')) { + $data['/`?#__akeebasubs_([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'akeebasubs_', $params->get('akeebasubs'), '') . '$1`'; + } + if ($params->get('feedgator')) { + $data['/`?#__feedgator([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'feedgator', $params->get('feedgator'), '') . '$1`'; + } + if ($params->get('jxtc_ezimg')) { + $tables['jxtc_ezimg_images'] = $params->get('jxtc_ezimg'); + } + if ($params->get('invitex')) { + $tables['techjoomlaAPI_users'] = $params->get('invitex'); + $data['/`?#__invitex_([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'invitex_', $params->get('invitex'), '') . '$1`'; + } + if ($params->get('jbolo')) { + $data['/`?#__jbolo([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'jbolo', $params->get('jbolo'), '') . '$1`'; + } + if ($params->get('jxtc_appbook')) { + $data['/`?#__jxtc_appbook_([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'jxtc_appbook_', $params->get('jxtc_appbook'), '') . '$1`'; + } + if ($params->get('jxtc_albumplayer')) { + $data['/`?#__jxtc_albumplayer([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'jxtc_albumplayer', $params->get('jxtc_albumplayer'), '') . '$1`'; + } + if ($params->get('geo')) { + $data['/`?#__geo_([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'geo_', $params->get('geo'), '') . '$1`'; + } + if ($params->get('jxtc_powertabs')) { + $data['/`?#__jxtc_powertabs([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'jxtc_powertabs', $params->get('jxtc_powertabs'), '') . '$1`'; + } + if ($params->get('payplans')) { + $data['/`?#__payplans_([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'payplans_', $params->get('payplans'), '') . '$1`'; + } + if ($params->get('jxtc_readinglist')) { + $tables['jxtc_readinglist'] = $params->get('jxtc_readinglist'); + } + if ($params->get('ad')) { + $data['/`?#__ad_([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'ad_', $params->get('ad'), '') . '$1`'; + } + if ($params->get('locator')) { + $data['/`?#__location_([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'location_', $params->get('locator'), '') . '$1`'; + $tables['locations'] = $params->get('locator'); + } + if ($params->get('pin')) { + $data['/`?#__pin_([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'pin_', $params->get('pin'), '') . '$1`'; + } + if ($params->get('hikashop')) { + $data['/`?#__hikashop_([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'hikashop_', $params->get('hikashop'), '') . '$1`'; + } + if ($params->get('docman')) { + $data['/`?#__docman([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'docman', $params->get('docman'), '') . '$1`'; + } + if ($params->get('swmenu')) { + $data['/`?#__swmenu_([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'swmenu_', $params->get('swmenu'), '') . '$1`'; + } + if ($params->get('virtueuploads')) { + $data['/`?#__virtueuploads([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'virtueuploads', $params->get('virtueuploads'), '') . '$1`'; + } + if ($params->get('djcf')) { + $data['/`?#__djcf_([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'djcf_', $params->get('djcf'), '') . '$1`'; + } + if ($params->get('chronoforms')) { + $tables['chronoforms'] = $params->get('chronoforms'); + $tables['chronoform_actions'] = $params->get('chronoforms'); + } + if ($params->get('eventlist')) { + $data['/`?#__eventlist_([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'eventlist_', $params->get('eventlist'), '') . '$1`'; + } + if ($params->get('fpss')) { + $data['/`?#__fpss_([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'fpss_', $params->get('fpss'), '') . '$1`'; + } + if ($params->get('imageshow')) { + $data['/`?#__imageshow_([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'imageshow_', $params->get('imageshow'), '') . '$1`'; + $tables['jsn_imageshow_messages'] = $params->get('imageshow'); + $tables['jsn_imageshow_config'] = $params->get('imageshow'); + } + if ($params->get('uniform')) { + $data['/`?#__jsn_uniform_([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'jsn_uniform_', $params->get('uniform'), '') . '$1`'; + } + if ($params->get('widgetkit')) { + $tables['widgetkit_widget'] = $params->get('widgetkit'); + } + if ($params->get('listbingo')) { + $data['/`?#__listbingo_([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'listbingo_', $params->get('listbingo'), '') . '$1`'; + } + if ($params->get('redshop')) { + $data['/`?#__redshop_([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'redshop_', $params->get('redshop'), '') . '$1`'; + } + if ($params->get('jvle')) { + $data['/`?#__jvle_([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'jvle_', $params->get('listbingo'), '') . '$1`'; + } + if ($params->get('bfstop')) { + $tables['bfstop_failedlogin'] = $params->get('bfstop'); + $tables['bfstop_bannedip'] = $params->get('bfstop'); + } + if ($params->get('komento')) { + $data['/`?#__komento_([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'komento_', $params->get('komento'), '') . '$1`'; + } + if ($params->get('jsn_poweradmin')) { + $tables['jsn_poweradmin_history'] = $params->get('jsn_poweradmin'); + $tables['jsn_poweradmin_config'] = $params->get('jsn_poweradmin'); + $tables['jsn_poweradmin_menu_assets'] = $params->get('jsn_poweradmin'); + } + if ($params->get('securitycheck')) { + $data['/`?#__securitycheck([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'securitycheck', $params->get('securitycheck'), '') . '$1`'; + } + if ($params->get('expautos')) { + $data['/`?#__expautos_([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'expautos_', $params->get('expautos'), '') . '$1`'; + } + if ($params->get('mijosearch')) { + $data['/`?#__mijosearch_([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'mijosearch_', $params->get('mijosearch'), '') . '$1`'; + } + if ($params->get('advancedmodules')) { + $tables['advancedmodules'] = $params->get('advancedmodules'); + } + if ($params->get('jck')) { + $tables['jckplugins'] = $params->get('jck'); + $tables['jcktoolbars'] = $params->get('jck'); + $tables['jcktoolbarplugins'] = $params->get('jck'); + $tables['update_jckplugins'] = $params->get('jck'); + } + if ($params->get('rereplacer')) { + $tables['rereplacer'] = $params->get('rereplacer'); + } + if ($params->get('magebridge')) { + $data['/`?#__magebridge_([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'magebridge_', $params->get('magebridge'), '') . '$1`'; + } + if ($params->get('preachit')) { + $tables['pibooks'] = $params->get('preachit'); + $tables['picomments'] = $params->get('preachit'); + $tables['pifilepath'] = $params->get('preachit'); + $tables['pimime'] = $params->get('preachit'); + $tables['pipodcast'] = $params->get('preachit'); + $tables['piseries'] = $params->get('preachit'); + $tables['piministry'] = $params->get('preachit'); + $tables['piteachers'] = $params->get('preachit'); + $tables['pistudies'] = $params->get('preachit'); + $tables['pimediaplayers'] = $params->get('preachit'); + $tables['pibckadmin'] = $params->get('preachit'); + $tables['pitemplates'] = $params->get('preachit'); + $tables['pipodmes'] = $params->get('preachit'); + $tables['piadminpodmes'] = $params->get('preachit'); + $tables['pibiblevers'] = $params->get('preachit'); + } + if ($params->get('osmembership')) { + $data['/`?#__osmembership_([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'osmembership_', $params->get('osmembership'), '') . '$1`'; + } + if ($params->get('mijosef')) { + $data['/`?#__mijosef_([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'mijosef_', $params->get('mijosef'), '') . '$1`'; + } + if ($params->get('osemsc')) { + $data['/`?#__osemsc_([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'osemsc_', $params->get('osemsc'), '') . '$1`'; + $tables['ose_activation'] = $params->get('osemsc'); + } + if ($params->get('easydiscuss')) { + $data['/`?#__discuss_([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'discuss_', $params->get('easydiscuss'), '') . '$1`'; + } + if ($params->get('hsusers')) { + $tables['users_authentications'] = $params->get('hsusers'); + $tables['users_extended'] = $params->get('hsusers'); + } + if ($params->get('quiz')) { + $data['/`?#__quiz_([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'quiz_', $params->get('quiz'), '') . '$1`'; + } + if ($params->get('muscol')) { + $data['/`?#__muscol_([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'muscol_', $params->get('muscol'), '') . '$1`'; + } + if ($params->get('allvideoshare')) { + $data['/`?#__allvideoshare_([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'allvideoshare_',$params->get('allvideoshare'), '') . '$1`'; + } + if ($params->get('fua')) { + $data['/`?#__fua_([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'fua_', $params->get('fua'), '') . '$1`'; + } + if ($params->get('joaktree')) { + $data['/`?#__joaktree_([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'joaktree_', $params->get('joaktree'), '') . '$1`'; + } + if ($params->get('rsticketspro')) { + $data['/`?#__rsticketspro_([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'rsticketspro_', $params->get('rsticketspro'), '') . '$1`'; + } + if ($params->get('acesef')) { + $data['/`?#__acesef_([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'acesef_', $params->get('acesef'), '') . '$1`'; + } + if ($params->get('aup')) { + $data['/`?#__alpha_userpoints([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'alpha_userpoints', $params->get('aup'), '') . '$1`'; + } + if ($params->get('vq')) { + $data['/`?#__vq_([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'vq_', $params->get('vq'), '') . '$1`'; + } + if ($params->get('fsf_faq')) { + $data['/`?#__fsf_faq_([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'fsf_faq_', $params->get('fsf_faq'), '') . '$1`'; + } + if ($params->get('spidercalendar')) { + $data['/`?#__spidercalendar_([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'spidercalendar_', $params->get('spidercalendar'), '') . '$1`'; + } + if ($params->get('jcomments')) { + $data['/`?#__jcomments([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'jcomments', $params->get('jcomments'), '') . '$1`'; + } + if ($params->get('mem')) { + $data['/`?#__mem_([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'mem_', $params->get('mem'), '') . '$1`'; + } + if ($params->get('paidsystem')) { + $data['/`?#__paidsystem_([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'paidsystem_', $params->get('paidsystem'), '') . '$1`'; + } + if ($params->get('hikamarket')) { + $data['/`?#__hikamarket_([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'hikamarket_', $params->get('hikamarket'), '') . '$1`'; + } + if ($params->get('rsmembership')) { + $data['/`?#__rsmembership_([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'rsmembership_', $params->get('rsmembership'), '') . '$1`'; + } + if ($params->get('jfbconnect')) { + $data['/`?#__jfbconnect_([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'jfbconnect_', $params->get('jfbconnect'), '') . '$1`'; + $data['/`?#__opengraph_([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'opengraph_', $params->get('jfbconnect'), '') . '$1`'; + } + if ($params->get('adagency')) { + $data['/`?#__ad_agency_([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'ad_agency_', $params->get('adagency'), '') . '$1`'; + } + if ($params->get('fw_realestate')) { + $data['/`?#__fw_realestate_([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'fw_realestate_',$params->get('fw_realestate'), '') . '$1`'; + } + if ($params->get('iproperty')) { + $data['/`?#__iproperty([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'iproperty', $params->get('iproperty'), '') . '$1`'; + } + if ($params->get('mijoshop')) { + $data['/`?#__mijoshop_([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'mijoshop_', $params->get('mijoshop'), '') . '$1`'; + } + if ($params->get('snippets')) { + $tables['snippets'] = $params->get('snippets'); + } + if ($params->get('zhgooglemap')) { + $data['/`?#__zhgooglemap_([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'zhgooglemap_', $params->get('zhgooglemap'), '') . '$1`'; + } + if ($params->get('cddir')) { + $data['/`?#__cddir_([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'cddir_', $params->get('cddir'), '') . '$1`'; + } + if ($params->get('ajaxregister')) { + $data['/`?#__ajaxregister_([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'ajaxregister_', $params->get('ajaxregister'), '') . '$1`'; + } + if ($params->get('jmap')) { + $data['/`?#__jmap([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'jmap', $params->get('jmap'), '') . '$1`'; + } + if ($params->get('emerald')) { + $data['/`?#__emerald_([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'emerald_', $params->get('emerald'), '') . '$1`'; + } + if ($params->get('rseventspro')) { + $data['/`?#__rseventspro_([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'rseventspro_', $params->get('rseventspro'), '') . '$1`'; + } + if ($params->get('jblance')) { + $data['/`?#__jblance_([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'jblance_', $params->get('jblance'), '') . '$1`'; + } + if ($params->get('xmap')) { + $tables['xmap_items'] = $params->get('xmap'); + $tables['xmap_sitemap'] = $params->get('xmap'); + } + if ($params->get('j2store')) { + $data['/`?#__j2store_([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'j2store_', $params->get('j2store'), '') . '$1`'; + } + if ($params->get('lovefactory')) { + $data['/`?#__lovefactory_([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'lovefactory_', $params->get('lovefactory'), '') . '$1`'; + } + if ($params->get('social')) { + $data['/`?#__social_([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'social_', $params->get('social'), '') . '$1`'; + } + if ($params->get('auctionfactory')) { + $data['/`?#__bid_([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'bid_', $params->get('auctionfactory'), '') . '$1`'; + $tables['bids'] = $params->get('auctionfactory'); + } + if ($params->get('hdwplayer')) { + $data['/`?#__hdwplayer_([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'hdwplayer_', $params->get('hdwplayer'), '') . '$1`'; + } + if ($params->get('jomcl')) { + $data['/`?#__jomcl_([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'jomcl_', $params->get('jomcl'), '') . '$1`'; + } + if ($params->get('regreminder')) { + $data['/`?#__regreminder([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'regreminder', $params->get('regreminder'), '') . '$1`'; + } + if ($params->get('flexicontact')) { + $tables['flexicontact_log'] = $params->get('flexicontact'); + } + if ($params->get('comment')) { + $data['/`?#__comment([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'comment', $params->get('comment'), '') . '$1`'; + } + if ($params->get('xtdir')) { + $data['/`?#__xtdir_([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'xtdir_', $params->get('xtdir'), '') . '$1`'; + } + if ($params->get('offlajn')) { + $data['/`?#__offlajn_([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'offlajn_', $params->get('offlajn'), '') . '$1`'; + } + if ($params->get('jobsfactory')) { + $data['/`?#__jobsfactory_([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'jobsfactory_', $params->get('jobsfactory'), '') . '$1`'; + } + if ($params->get('vmvendor')) { + $tables['vmvendor_vendorratings'] = $params->get('vmvendor'); + } + if ($params->get('eshop')) { + $data['/`?#__eshop_([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'eshop_', $params->get('eshop'), '') . '$1`'; + } + if ($params->get('flexicontent')) { + $data['/`?#__flexicontent_([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'flexicontent_', $params->get('flexicontent'), '') . '$1`'; + } + if ($params->get('cmgroupbuying')) { + $data['/`?#__cmgroupbuying_([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'cmgroupbuying_', $params->get('cmgroupbuying'), '') . '$1`'; + } + if ($params->get('joomgallery')) { + $data['/`?#__joomgallery([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'joomgallery', $params->get('joomgallery'), '') . '$1`'; + } + if ($params->get('joomgalaxy')) { + $data['/`?#__joomgalaxy_([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'joomgalaxy_', $params->get('joomgalaxy'), '') . '$1`'; + } + if ($params->get('jdownloads')) { + $data['/`?#__jdownloads_([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'jdownloads_', $params->get('jdownloads'), '') . '$1`'; + } + if ($params->get('jsn')) { + $tables['jsn_fields'] = $params->get('jsn'); + $tables['jsn_users'] = $params->get('jsn'); + $data['/`?#__jsnsocial_([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'jsnsocial_', $params->get('jsnsocial'), '') . '$1`'; + } + if ($params->get('icagenda')) { + $data['/`?#__icagenda([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'icagenda', $params->get('icagenda'), '') . '$1`'; + } + if ($params->get('booking')) { + $data['/`?#__booking_([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'booking_', $params->get('booking'), '') . '$1`'; + } + if ($params->get('cobalt')) { + $data['/`?#__js_res_([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'js_res_', $params->get('cobalt'), '') . '$1`'; + } + if ($params->get('vikappointments')) { + $data['/`?#__vikappointments_([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'vikappointments_', $params->get('vikappointments'), '') . '$1`'; + } + if ($params->get('joomcareer')) { + $data['/`?#__joomcareer([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'joomcareer', $params->get('joomcareer'), '') . '$1`'; + } + if ($params->get('kart')) { + $data['/`?#__kart_([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'kart_', $params->get('kart'), '') . '$1`'; + $tables['order_item_fee'] = $params->get('kart'); + $tables['q2c_order_history'] = $params->get('kart'); + } + if ($params->get('tjfields')) { + $data['/`?#__tjfields_([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'tjfields_', $params->get('tjfields'), '') . '$1`'; + $tables['tj_city'] = $params->get('tjfields'); + $tables['tj_country'] = $params->get('tjfields'); + $tables['tj_region'] = $params->get('tjfields'); + } + if ($params->get('guru')) { + $data['/`?#__guru_([0-9a-z_]*)`?/u'] = '`' . $this->_createTableReplacements($site, 'guru_', $params->get('guru'), '') . '$1`'; + } + + + // to be continued... + + // Apply plugins + JFactory::getApplication()->triggerEvent('onMightysitesCreateReplacements', array($params, $site, &$data, &$tables, $this)); + + // Custom tables + foreach($params->toArray() as $table => $from) { + if (substr($table, 0, 6) == 'table_' && $from) { + $tables[substr($table, 6)] = $from; + } + } + + // Tables + if (sizeof($tables)) { + foreach($tables as $table => $from) { + if ($from) { + $data['/`?#__'.$table.'[` \n]+/u'] = $this->_createTableReplacements($site, $table, $from); + } + } + } + + // always load mighty from root + $data['/`?#__mightysites[` \n]+/u'] = $this->_createTableReplacements($site, 'mightysites', 1); + + // remove empty data + if (sizeof($data)) { + foreach($data as $key => $value) { + if (empty($value)) { + unset($data[$key]); + } + } + } + + return sizeof($data) ? array(array_keys($data), array_values($data)) : array(); + } + + public function _createTableReplacements($site, $table, $from, $enclosure = '`') + { + $from = MightysitesHelper::getSite($from, true); + + if ($from) { + $ending = $enclosure ? ' ' : ''; + if ($site->db == $from->db) { + return $enclosure . $from->dbprefix . $table . $enclosure . $ending; + } else { + return $enclosure . $from->db . '`.`' . $from->dbprefix . $table . $enclosure . $ending; + } + } + } +} diff --git a/deployed/mightysites/administrator/components/com_mightysites/models/sites.php b/deployed/mightysites/administrator/components/com_mightysites/models/sites.php new file mode 100644 index 00000000..19fe3bfd --- /dev/null +++ b/deployed/mightysites/administrator/components/com_mightysites/models/sites.php @@ -0,0 +1,121 @@ +getUserStateFromRequest($this->context.'.filter.search', 'filter_search'); + $this->setState('filter.search', $search); + + // Load the parameters. + $params = JComponentHelper::getParams('com_mightysites'); + $this->setState('params', $params); + + // List state information. + parent::populateState('a.id', 'asc'); + } + + protected function getStoreId($id = '') + { + // Compile the store id. + $id .= ':' . $this->getState('filter.search'); + $id .= ':' . $this->getState('filter.state'); + + return parent::getStoreId($id); + } + + protected function getListQuery() + { + // Create a new query object. + $db = $this->getDbo(); + $query = $db->getQuery(true); + $user = JFactory::getUser(); + + // Select the required fields from the table. + $query->select( + $this->getState( + 'list.select', + 'a.*' + ) + ); + $query->from($db->quoteName('#__mightysites').' AS a'); + + // Join over the users for the checked out user. + $query->select('uc.name AS editor'); + $query->join('LEFT', '#__users AS uc ON uc.id=a.checked_out'); + + // Filter by type. + $type = $this->getState('filter.type'); + if ($type) { + $query->where('a.type='.$type); + } + + // Filter by search in title + $search = $this->getState('filter.search'); + if (!empty($search)) { + if (stripos($search, 'id:') === 0) { + $query->where('a.id = '.(int) substr($search, 3)); + } else { + $search = $db->Quote('%'.$db->escape($search, true).'%'); + $query->where('( + a.domain LIKE '.$search.' + OR a.db LIKE '.$search.' + OR a.dbprefix LIKE '.$search.' + )'); + } + } + + // Add the list ordering clause. + $orderCol = $this->state->get('list.ordering'); + $orderDirn = $this->state->get('list.direction'); + $query->order($db->escape($orderCol.' '.$orderDirn)); + + return $query; + } + + public function getItems() + { + $items = parent::getItems(); + + if ($items) { + $app = JFactory::getApplication(); + + foreach($items as &$item) { + // Init params + $item->params = new JRegistry($item->params); + + // Add config + MightysitesHelper::attachConfig($item); + } + } + + return $items; + } + +} diff --git a/deployed/mightysites/administrator/components/com_mightysites/sql/index.html b/deployed/mightysites/administrator/components/com_mightysites/sql/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/deployed/mightysites/administrator/components/com_mightysites/sql/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/deployed/mightysites/administrator/components/com_mightysites/sql/install.mysql.utf8.sql b/deployed/mightysites/administrator/components/com_mightysites/sql/install.mysql.utf8.sql new file mode 100644 index 00000000..b89d6398 --- /dev/null +++ b/deployed/mightysites/administrator/components/com_mightysites/sql/install.mysql.utf8.sql @@ -0,0 +1,13 @@ +CREATE TABLE IF NOT EXISTS `#__mightysites` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `domain` varchar(255) NOT NULL DEFAULT '', + `aliases` text NOT NULL, + `db` varchar(255) NOT NULL DEFAULT '', + `dbprefix` varchar(255) NOT NULL DEFAULT '', + `params` text NOT NULL, + `checked_out` int(10) unsigned NOT NULL DEFAULT '0', + `checked_out_time` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + `type` tinyint(4) unsigned NOT NULL DEFAULT '1', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; + diff --git a/deployed/mightysites/administrator/components/com_mightysites/tables/database.php b/deployed/mightysites/administrator/components/com_mightysites/tables/database.php new file mode 100644 index 00000000..5796be5a --- /dev/null +++ b/deployed/mightysites/administrator/components/com_mightysites/tables/database.php @@ -0,0 +1,51 @@ +loadArray($array['params']); + $array['params'] = (string)$registry; + } + + // Force type! + $array['type'] = 2; + + return parent::bind($array, $ignore); + } + + public function check() + { + $db = JFactory::getDBO(); + + // Check tables prefix. + if (!preg_match('/^[a-z0-9_]*$/', $this->dbprefix)) { + $this->setError(JText::sprintf('COM_MIGHTYSITES_ERROR_INVALID_DBPREFIX', $this->dbprefix)); + return false; + } + + // Check for unique table prefix. + $db->setQuery('SELECT `id` FROM `#__mightysites` WHERE `db`='.$db->quote($this->db).' AND `dbprefix` = '.$db->quote($this->dbprefix), 0, 1); + $id = $db->loadResult(); + if ($id && $id != $this->id) { + $this->setError(JText::sprintf('COM_MIGHTYSITES_ERROR_DATABASE_EXISTS', $this->db, $this->dbprefix)); + return false; + } + + return true; + } +} \ No newline at end of file diff --git a/deployed/mightysites/administrator/components/com_mightysites/tables/index.html b/deployed/mightysites/administrator/components/com_mightysites/tables/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/deployed/mightysites/administrator/components/com_mightysites/tables/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/deployed/mightysites/administrator/components/com_mightysites/tables/site.php b/deployed/mightysites/administrator/components/com_mightysites/tables/site.php new file mode 100644 index 00000000..3a026372 --- /dev/null +++ b/deployed/mightysites/administrator/components/com_mightysites/tables/site.php @@ -0,0 +1,113 @@ +loadArray($array['params']); + $array['params'] = (string)$registry; + } + + // Force type! + $array['type'] = 1; + + return parent::bind($array, $ignore); + } + + public function check() + { + $db = JFactory::getDBO(); + + // Check tables prefix. + if (!preg_match('/^[a-zA-Z0-9_]*$/', $this->dbprefix)) { + $this->setError(JText::sprintf('COM_MIGHTYSITES_ERROR_INVALID_DBPREFIX', $this->dbprefix)); + return false; + } + + // Check for domain. + $db->setQuery('SELECT `id` FROM `#__mightysites` WHERE `domain`='.$db->quote($this->domain), 0, 1); + $id = $db->loadResult(); + if ($id && $id != $this->id) { + $this->setError(JText::sprintf('COM_MIGHTYSITES_ERROR_DOMAIN_EXISTS', $this->domain)); + return false; + } + + // Check for unique table prefix + $db->setQuery('SELECT `id` FROM `#__mightysites` WHERE `dbprefix` LIKE '.$db->quote('%'.str_replace('_', '\_', $this->dbprefix).'%'), 0, 1); + $id = $db->loadResult(); + if ($id && $id != $this->id) { + //$this->setError(JText::sprintf('COM_MIGHTYSITES_ERROR_PREFIX_EXISTS', $this->dbprefix)); + //return false; + JFactory::getApplication()->enqueueMessage(JText::sprintf('COM_MIGHTYSITES_NOTICE_PREFIX_EXISTS', $this->dbprefix), 'notice'); + } + + // Virtual subfolder via symlink + if (strpos($this->domain, '/') !== false) { + $parts = explode('/', $this->domain); + array_shift($parts); + + // Only site.com/test, not site.com/test/test2/, todo - check parent folder + /* + if (sizeof($parts) > 1) { + $this->setError(JText::sprintf('COM_MIGHTYSITES_ERROR_SYMLINK_LEVEL', $this->domain)); + return false; + } + */ + + $path = implode('/', $parts); + $file = JPATH_SITE.'/'.$path; + $symlink = false; + + // New site + if (!$this->id) { + // Already exists? + if (file_exists($file)) { + // Link? + if (is_link($file)) { + JFactory::getApplication()->enqueueMessage(JText::sprintf('COM_MIGHTYSITES_NOTICE_SYMLINK_EXISTS', $file), 'notice'); + } + // File or folder? + else { + $this->setError(JText::sprintf('COM_MIGHTYSITES_ERROR_SYMLINK_EXISTS', $file)); + return false; + } + } + else { + $symlink = true; + } + } + // Current site + else { + // Absent link? Recreate! + if (!file_exists($file)) { + $symlink = true; + } + } + + // Create symlink + if ($symlink) { + $result = @symlink(JPATH_SITE, $file); + if (!$result) { + $this->setError(JText::sprintf('COM_MIGHTYSITES_ERROR_SYMLINK_FAILED', $file, JPATH_SITE)); + return false; + } + } + } + + return true; + } + +} \ No newline at end of file diff --git a/deployed/mightysites/administrator/components/com_mightysites/views/about/index.html b/deployed/mightysites/administrator/components/com_mightysites/views/about/index.html new file mode 100644 index 00000000..2efb97f3 --- /dev/null +++ b/deployed/mightysites/administrator/components/com_mightysites/views/about/index.html @@ -0,0 +1 @@ + diff --git a/deployed/mightysites/administrator/components/com_mightysites/views/about/tmpl/default.php b/deployed/mightysites/administrator/components/com_mightysites/views/about/tmpl/default.php new file mode 100644 index 00000000..92ce7c2c --- /dev/null +++ b/deployed/mightysites/administrator/components/com_mightysites/views/about/tmpl/default.php @@ -0,0 +1,72 @@ +sidebar = JHtmlSidebar::render(); + +$component = JTable::getInstance('extension'); +$component->load(JComponentHelper::getComponent('com_mightysites')->id); +if (strlen($component->manifest_cache)) { + $data = json_decode($component->manifest_cache); + if ($data) { + foreach($data as $key => $value) { + $component->$key = $value; + } + } +} +?> + + + +
+sidebar)): ?> +
+ sidebar; ?> +
+
+ +
+ + + + + + + + + + + + + + +
version;?>
+ + +
+ +
+ diff --git a/deployed/mightysites/administrator/components/com_mightysites/views/about/tmpl/default_25.php b/deployed/mightysites/administrator/components/com_mightysites/views/about/tmpl/default_25.php new file mode 100644 index 00000000..07b467e3 --- /dev/null +++ b/deployed/mightysites/administrator/components/com_mightysites/views/about/tmpl/default_25.php @@ -0,0 +1,59 @@ +load(JComponentHelper::getComponent('com_mightysites')->id); +if (strlen($component->manifest_cache)) { + $data = json_decode($component->manifest_cache); + if ($data) { + foreach($data as $key => $value) { + $component->$key = $value; + } + } +} +?> + + + +
+
+
+ + + + + + + + + + + +
version;?>
+   + +
+
+
+
diff --git a/deployed/mightysites/administrator/components/com_mightysites/views/about/tmpl/index.html b/deployed/mightysites/administrator/components/com_mightysites/views/about/tmpl/index.html new file mode 100644 index 00000000..2efb97f3 --- /dev/null +++ b/deployed/mightysites/administrator/components/com_mightysites/views/about/tmpl/index.html @@ -0,0 +1 @@ + diff --git a/deployed/mightysites/administrator/components/com_mightysites/views/about/view.html.php b/deployed/mightysites/administrator/components/com_mightysites/views/about/view.html.php new file mode 100644 index 00000000..092c0467 --- /dev/null +++ b/deployed/mightysites/administrator/components/com_mightysites/views/about/view.html.php @@ -0,0 +1,35 @@ +addToolbar(); + + $version = new JVersion; + if ($version->RELEASE == '2.5') { + $tpl = '25'; + } + + parent::display($tpl); + } + + protected function addToolbar() + { + // Title + if (version_compare(JVERSION, '3.2', 'ge')) { + JToolBarHelper::title(JText::_('COM_MIGHTYSITES_TITLE_ABOUT'), 'help'); + } else { + JToolBarHelper::title(JText::_('COM_MIGHTYSITES_TITLE_ABOUT'), 'systeminfo.png'); + } + + MightysitesHelper::topmenu(); + } +} diff --git a/deployed/mightysites/administrator/components/com_mightysites/views/database/index.html b/deployed/mightysites/administrator/components/com_mightysites/views/database/index.html new file mode 100644 index 00000000..2efb97f3 --- /dev/null +++ b/deployed/mightysites/administrator/components/com_mightysites/views/database/index.html @@ -0,0 +1 @@ + diff --git a/deployed/mightysites/administrator/components/com_mightysites/views/database/tmpl/edit.php b/deployed/mightysites/administrator/components/com_mightysites/views/database/tmpl/edit.php new file mode 100644 index 00000000..8c3ab322 --- /dev/null +++ b/deployed/mightysites/administrator/components/com_mightysites/views/database/tmpl/edit.php @@ -0,0 +1,144 @@ + + + + +
+
+
+ +
+ + +
+ +
+
+
form->getLabel('domain'); ?>
+
form->getInput('domain'); ?>
+
+ + item->id) {?> +
+
form->getLabel('source_db'); ?>
+
form->getInput('source_db'); ?>
+
+ +
+ +
+
+
form->getLabel('db'); ?>
+
form->getInput('db'); ?> + item->id) {?> + +   + + + + +
+
+
+
form->getLabel('dbprefix'); ?>
+
form->getInput('dbprefix'); ?>
+
+ +
+
+
+ +   + + +
+
+
+ +
+
+ +
+
+ + + + + +
\ No newline at end of file diff --git a/deployed/mightysites/administrator/components/com_mightysites/views/database/tmpl/edit_25.php b/deployed/mightysites/administrator/components/com_mightysites/views/database/tmpl/edit_25.php new file mode 100644 index 00000000..5884ad7f --- /dev/null +++ b/deployed/mightysites/administrator/components/com_mightysites/views/database/tmpl/edit_25.php @@ -0,0 +1,146 @@ +item); + +JHtml::_('behavior.tooltip'); +JHtml::_('behavior.formvalidation'); +JHTML::_('behavior.keepalive'); + +$pane = JPane::getInstance('tabs'); +?> + + + +
+startPane("domain-pane"); + + echo $pane->startPanel(JText::_('COM_MIGHTYSITES_TAB_SETTINGS'), 'common-page'); + ?> +
+
+
    +
  • form->getLabel('domain'); ?> + form->getInput('domain'); ?>
  • + + item->id) {?> +
  • form->getLabel('source_db'); ?> + form->getInput('source_db'); ?>
  • + +
+
+
+ endPanel(); + + echo $pane->startPanel(JText::_('COM_MIGHTYSITES_TAB_DATABASE'), 'database-page'); + ?> +
+ +
+ +
+
    +
  • form->getLabel('db'); ?> + form->getInput('db'); ?> + + item->id) {?> + +   + +
    + +
  • + +
  • form->getLabel('dbprefix'); ?> + form->getInput('dbprefix'); ?>
  • + +
  • +   + +
    +
  • +
+
+
+
+ endPanel(); + +echo $pane->endPane(); +?> + + + + + + + +
diff --git a/deployed/mightysites/administrator/components/com_mightysites/views/database/tmpl/index.html b/deployed/mightysites/administrator/components/com_mightysites/views/database/tmpl/index.html new file mode 100644 index 00000000..2efb97f3 --- /dev/null +++ b/deployed/mightysites/administrator/components/com_mightysites/views/database/tmpl/index.html @@ -0,0 +1 @@ + diff --git a/deployed/mightysites/administrator/components/com_mightysites/views/database/view.html.php b/deployed/mightysites/administrator/components/com_mightysites/views/database/view.html.php new file mode 100644 index 00000000..ec828d8f --- /dev/null +++ b/deployed/mightysites/administrator/components/com_mightysites/views/database/view.html.php @@ -0,0 +1,68 @@ +state = $this->get('State'); + $this->item = $this->get('Item'); + $this->form = $this->get('Form'); + + $this->params = new JRegistry($this->item->params); + + // Check for errors. + if (count($errors = $this->get('Errors'))) { + JError::raiseError(500, implode("\n", $errors)); + return false; + } + + $this->addToolbar(); + + $version = new JVersion; + if ($version->RELEASE == '2.5') { + $tpl = '25'; + } + + parent::display($tpl); + } + + protected function addToolbar() + { + JRequest::setVar('hidemainmenu', true); + + $user = JFactory::getUser(); + $userId = $user->get('id'); + $isNew = ($this->item->id == 0); + $checkedOut = !($this->item->checked_out == 0 || $this->item->checked_out == $user->get('id')); + + if (version_compare(JVERSION, '3.2', 'ge')) { + JToolBarHelper::title(JText::_($isNew ? 'COM_MIGHTYSITES_TITLE_DATABASE_ADD' : 'COM_MIGHTYSITES_TITLE_DATABASE_EDIT'), 'database'); + } else { + JToolBarHelper::title(JText::_($isNew ? 'COM_MIGHTYSITES_TITLE_DATABASE_ADD' : 'COM_MIGHTYSITES_TITLE_DATABASE_EDIT')); + } + + // If not checked out, can save the item. + if (!$checkedOut && $user->authorise('core.edit', 'com_mightysites')) + { + JToolBarHelper::apply('database.apply'); + JToolBarHelper::save('database.save'); + } + if (empty($this->item->id)) { + JToolBarHelper::cancel('database.cancel'); + } + else { + JToolBarHelper::cancel('database.cancel', 'JTOOLBAR_CLOSE'); + } + } + +} diff --git a/deployed/mightysites/administrator/components/com_mightysites/views/databases/index.html b/deployed/mightysites/administrator/components/com_mightysites/views/databases/index.html new file mode 100644 index 00000000..2efb97f3 --- /dev/null +++ b/deployed/mightysites/administrator/components/com_mightysites/views/databases/index.html @@ -0,0 +1 @@ + diff --git a/deployed/mightysites/administrator/components/com_mightysites/views/databases/tmpl/default.php b/deployed/mightysites/administrator/components/com_mightysites/views/databases/tmpl/default.php new file mode 100644 index 00000000..4b8884b1 --- /dev/null +++ b/deployed/mightysites/administrator/components/com_mightysites/views/databases/tmpl/default.php @@ -0,0 +1,165 @@ +escape($this->state->get('list.ordering')); +$listDirn = $this->escape($this->state->get('list.direction')); + +$this->sidebar = JHtmlSidebar::render(); +?> + + + +
+sidebar)): ?> +
+ sidebar; ?> +
+
+ +
+ +
+ +
+ + +
+
+ + pagination->getLimitBox(); ?> +
+
+ + +
+
+ + +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + items as $i => $item) { + $canEdit = $user->authorise('core.edit', 'com_mightysites'); + $canCheckin = $user->authorise('core.manage', 'com_checkin') || $item->checked_out==$user->get('id') || $item->checked_out==0; + $canChange = $user->authorise('core.edit.state', 'com_mightysites') && $canCheckin; + + // Sites are edited via own link! + if ($item->type == 1) { + $link = 'index.php?option=com_mightysites&task=site.edit&id='.(int) $item->id; + } else { + $link = 'index.php?option=com_mightysites&task=database.edit&id='.(int) $item->id; + } + + ?> + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ diff --git a/deployed/mightysites/administrator/components/com_mightysites/views/databases/tmpl/default_25.php b/deployed/mightysites/administrator/components/com_mightysites/views/databases/tmpl/default_25.php new file mode 100644 index 00000000..df21be04 --- /dev/null +++ b/deployed/mightysites/administrator/components/com_mightysites/views/databases/tmpl/default_25.php @@ -0,0 +1,131 @@ +escape($this->state->get('list.ordering')); +$listDirn = $this->escape($this->state->get('list.direction')); + +JHtml::_('behavior.tooltip'); +?> + + + +
+ + + + + +
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + +items)) { +foreach ($this->items as $i => $item) { + $canEdit = $user->authorise('core.edit', 'com_mightysites'); + $canCheckin = $user->authorise('core.manage', 'com_checkin') || $item->checked_out==$user->get('id') || $item->checked_out==0; + $canChange = $user->authorise('core.edit.state', 'com_mightysites') && $canCheckin; + + // Sites are edited via own link! + if ($item->type == 1) { + $link = 'index.php?option=com_mightysites&task=site.edit&id='.(int) $item->id; + } else { + $link = 'index.php?option=com_mightysites&task=database.edit&id='.(int) $item->id; + } + + ?> + + + + + + + + + + + + + + + + + + + +
+ pagination->getListFooter();?> +
pagination->getRowOffset($i);?>type == 2) {?> + id);?> + + checked_out) : ?> + editor, $item->checked_out_time, 'databases.', $canCheckin);?> + + + + + domain;?> + + domain;?> + + + type == 1) { + echo JText::_('COM_MIGHTYSITES_DATABASE_ORIGIN_SITE'); + } else { + echo JText::_('COM_MIGHTYSITES_DATABASE_ORIGIN_DATABASE'); + }?> + db;?>dbprefix;?>id;?>
+ + + + + + + + +
diff --git a/deployed/mightysites/administrator/components/com_mightysites/views/databases/tmpl/index.html b/deployed/mightysites/administrator/components/com_mightysites/views/databases/tmpl/index.html new file mode 100644 index 00000000..2efb97f3 --- /dev/null +++ b/deployed/mightysites/administrator/components/com_mightysites/views/databases/tmpl/index.html @@ -0,0 +1 @@ + diff --git a/deployed/mightysites/administrator/components/com_mightysites/views/databases/view.html.php b/deployed/mightysites/administrator/components/com_mightysites/views/databases/view.html.php new file mode 100644 index 00000000..1c8731c7 --- /dev/null +++ b/deployed/mightysites/administrator/components/com_mightysites/views/databases/view.html.php @@ -0,0 +1,78 @@ +state = $this->get('State'); + $this->items = $this->get('Items'); + $this->pagination = $this->get('Pagination'); + + // Check for errors. + if (count($errors = $this->get('Errors'))) { + JError::raiseError(500, implode("\n", $errors)); + return false; + } + + $this->addToolbar(); + + $version = new JVersion; + if ($version->RELEASE == '2.5') { + $tpl = '25'; + } + + parent::display($tpl); + } + + protected function addToolbar() + { + // Load the submenu. + MightysitesHelper::topMenu(); + + // Title + if (version_compare(JVERSION, '3.2', 'ge')) { + JToolBarHelper::title(JText::_('COM_MIGHTYSITES_TITLE_DATABASES'), 'database'); + } else { + JToolBarHelper::title(JText::_('COM_MIGHTYSITES_TITLE_DATABASES')); + } + + $user = JFactory::getUser(); + + // Toolbar + if ($user->authorise('core.create', 'com_mightysites')) { + JToolBarHelper::addNew('database.add'); + } + if ($user->authorise('core.edit', 'com_mightysites')) { + JToolBarHelper::editList('database.edit'); + } + if ($user->authorise('core.edit.state', 'com_mightysites')) { + JToolbarHelper::checkin('databases.checkin'); + } + if ($user->authorise('core.delete', 'com_mightysites')) { + JToolBarHelper::divider(); + JToolBarHelper::deleteList(JText::_('COM_MIGHTYSITES_REALLY_DELETE_DATABASES'), 'databases.remove'); + } + if ($user->authorise('core.admin', 'com_mightysites')) { + JToolBarHelper::divider(); + JToolBarHelper::preferences('com_mightysites', '300'); + } + } + + protected function getSortFields() + { + return array( + 'a.domain' => JText::_('COM_MIGHTYSITES_HEADING_DATABASE_TITLE'), + 'a.type' => JText::_('COM_MIGHTYSITES_HEADING_DATABASE_ORIGIN'), + 'a.db' => JText::_('COM_MIGHTYSITES_HEADING_DATABASE_NAME'), + 'a.dbprefix' => JText::_('COM_MIGHTYSITES_HEADING_DATABASE_PREFIX'), + 'a.id' => JText::_('ID'), + ); + } + +} \ No newline at end of file diff --git a/deployed/mightysites/administrator/components/com_mightysites/views/index.html b/deployed/mightysites/administrator/components/com_mightysites/views/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/deployed/mightysites/administrator/components/com_mightysites/views/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/deployed/mightysites/administrator/components/com_mightysites/views/site/index.html b/deployed/mightysites/administrator/components/com_mightysites/views/site/index.html new file mode 100644 index 00000000..2efb97f3 --- /dev/null +++ b/deployed/mightysites/administrator/components/com_mightysites/views/site/index.html @@ -0,0 +1 @@ + diff --git a/deployed/mightysites/administrator/components/com_mightysites/views/site/tmpl/edit.php b/deployed/mightysites/administrator/components/com_mightysites/views/site/tmpl/edit.php new file mode 100644 index 00000000..9b29359f --- /dev/null +++ b/deployed/mightysites/administrator/components/com_mightysites/views/site/tmpl/edit.php @@ -0,0 +1,374 @@ + + + + +
+ +
+
+ +
+ + +
+ +
+
+
form->getLabel('domain'); ?>
+
form->getInput('domain'); ?>
+
+
+
form->getLabel('aliases'); ?>
+
form->getInput('aliases'); ?>
+
+ + item->id) {?> +
+
form->getLabel('source_config'); ?>
+
form->getInput('source_config'); ?>
+
+
+
form->getLabel('source_db'); ?>
+
form->getInput('source_db'); ?>
+
+ +
+ +
+
+
form->getLabel('db'); ?>
+
form->getInput('db'); ?> + item->id) {?> + +   + + + + +
+
+
+
form->getLabel('dbprefix'); ?>
+
form->getInput('dbprefix'); ?>
+
+
+
form->getLabel('user'); ?>
+
form->getInput('user'); ?>
+
+
+
form->getLabel('password'); ?>
+
form->getInput('password'); ?>
+
+
+
form->getLabel('dbtype'); ?>
+
form->getInput('dbtype'); ?>
+
+ +
+
+
+ +   + + +
+
+
+ +
+ item->id) { + echo JText::_('COM_MIGHTYSITES_APPLY_SETTINGS'); + } else {?> + + form->getFieldset('replacements') as $field) : ?> +
+
label; ?>
+
input; ?>
+
+ + +
+
+ +
+
+
+ item->domain, JText::_('COM_MIGHTYSITES_SELECT_ALL_TO'), false, '-1', JText::_('COM_MIGHTYSITES_OWN_DATA'), '');?> +
+
+
+ + synchs_core as $synch => $input) {?> +
+
+
+
+ +
+ +
+ +
+
+
+ item->domain, JText::_('COM_MIGHTYSITES_SELECT_ALL_TO'), false, '-1', JText::_('COM_MIGHTYSITES_OWN_DATA'), '');?> +
+
+
+ + synchs_custom as $synch => $input) {?> +
+
+
+
+ +
+ +
+ + +
+ +   + + + params->toArray() as $key => $value) { + if (strpos($key, 'table_') !== false) { + echo ''; + $tables++; + } + }?> +

+

+
+
+ +
+ +
+ +
+ item->id) { + echo JText::_('COM_MIGHTYSITES_APPLY_SETTINGS'); + } else {?> + + form->getFieldset('single') as $field) : ?> +
+
label; ?>
+
input; ?>
+
+ + + + + + + + + + + + params->get('single_domain'.(string)$i)) {?> + + + + + + + + + +
+ +

+

+ +
+ +
+ item->id) { + echo JText::_('COM_MIGHTYSITES_APPLY_SETTINGS'); + } else {?> + + form->getFieldset('overrides') as $field) : ?> +
+
label; ?>
+
input; ?>
+
+ + +
+ +
+ item->id) { + echo JText::_('COM_MIGHTYSITES_APPLY_SETTINGS'); + } else {?> + + form->getFieldset('advanced') as $field) : ?> +
+
label; ?>
+
input; ?>
+
+ + +
+
+
+ +
+
+ + + + + +
diff --git a/deployed/mightysites/administrator/components/com_mightysites/views/site/tmpl/edit_25.php b/deployed/mightysites/administrator/components/com_mightysites/views/site/tmpl/edit_25.php new file mode 100644 index 00000000..d369c9ee --- /dev/null +++ b/deployed/mightysites/administrator/components/com_mightysites/views/site/tmpl/edit_25.php @@ -0,0 +1,403 @@ +item); + +JHtml::_('behavior.tooltip'); +JHtml::_('behavior.formvalidation'); +JHTML::_('behavior.keepalive'); + +$pane = JPane::getInstance('tabs'); +?> + + + + + +
+startPane("domain-pane"); + + echo $pane->startPanel(JText::_('COM_MIGHTYSITES_TAB_BASIC'), 'common-page'); + ?> +
+
+
    +
  • form->getLabel('domain'); ?> + form->getInput('domain'); ?>
  • +
  • form->getLabel('aliases'); ?> + form->getInput('aliases'); ?>
  • + + item->id) {?> +
  • form->getLabel('source_config'); ?> + form->getInput('source_config'); ?>
  • +
  • form->getLabel('source_db'); ?> + form->getInput('source_db'); ?>
  • + +
+
+
+ endPanel(); + + echo $pane->startPanel(JText::_('COM_MIGHTYSITES_TAB_DATABASE'), 'database-page'); + ?> +
+ +
+ +
+
    +
  • form->getLabel('db'); ?> + form->getInput('db'); ?> + + item->id) {?> + +   + +
    + +
  • + +
  • form->getLabel('dbprefix'); ?> + form->getInput('dbprefix'); ?>
  • + +
  • form->getLabel('user'); ?> + form->getInput('user'); ?>
  • + +
  • form->getLabel('password'); ?> + form->getInput('password'); ?>
  • + +
  • +   + +
    +
  • + +
  • form->getLabel('dbtype'); ?> + form->getInput('dbtype'); ?>
  • +
+
+
+
+ endPanel(); + + echo $pane->startPanel(JText::_('COM_MIGHTYSITES_TAB_CONTENT_SHARING'), 'content-sharing-page'); + + if (!$this->item->id) { + echo JText::_('COM_MIGHTYSITES_APPLY_SETTINGS'); + } else {?> + +
+ +
+
+
    + form->getFieldset('replacements') as $field) : ?> +
  • label; ?> + input; ?>
  • + +
+
+
+ +
+
+ +
    +
  • + item->domain, JText::_('COM_MIGHTYSITES_SELECT_ALL_TO'), false, '-1', JText::_('COM_MIGHTYSITES_OWN_DATA'), '');?> +
  • + synchs_core as $synch => $input) {?> +
  • + +
  • + +
+
+
+ +
+
+ +
    +
  • + item->domain, JText::_('COM_MIGHTYSITES_SELECT_ALL_TO'), false, '-1', JText::_('COM_MIGHTYSITES_OWN_DATA'), '');?> +
  • + synchs_custom as $synch => $input) {?> +
  • + +
  • + +
+
+
+
+ +
+
+ + +
+ +   + + + params->toArray() as $key => $value) { + if (strpos($key, 'table_') !== false) { + echo ''; + $tables++; + } + }?> +

+

+
+ +
+
+ +
+ endPanel(); + } + + echo $pane->startPanel(JText::_('COM_MIGHTYSITES_TAB_SINGLE'), 'single-page'); + + if (!$this->item->id) { + echo JText::_('COM_MIGHTYSITES_APPLY_SETTINGS'); + } else {?> +
+
+
    + form->getFieldset('single') as $field) : ?> +
  • label; ?> + input; ?>
  • + +
+
+ +
+ + + + + + + + + + params->get('single_domain'.(string)$i)) {?> + + + + + + + + + +
+ +

+

+
+ +
+ endPanel(); + } + + if ($this->item->id) { + echo $pane->startPanel(JText::_('COM_MIGHTYSITES_TAB_OVERRIDES'), 'overrides-page'); + ?> +
+
+
    + form->getFieldset('overrides') as $field) : ?> +
  • label; ?> + input; ?>
  • + +
+
+
+ endPanel(); + } + + if ($this->item->id) { + echo $pane->startPanel(JText::_('COM_MIGHTYSITES_TAB_ADVANCED'), 'advanced-page'); + ?> +
+
+
    + form->getFieldset('advanced') as $field) : ?> +
  • label; ?> + input; ?>
  • + +
+
+
+ endPanel(); + } + +echo $pane->endPane(); +?> + + + + + + + +
diff --git a/deployed/mightysites/administrator/components/com_mightysites/views/site/tmpl/index.html b/deployed/mightysites/administrator/components/com_mightysites/views/site/tmpl/index.html new file mode 100644 index 00000000..2efb97f3 --- /dev/null +++ b/deployed/mightysites/administrator/components/com_mightysites/views/site/tmpl/index.html @@ -0,0 +1 @@ + diff --git a/deployed/mightysites/administrator/components/com_mightysites/views/site/tmpl/tables.php b/deployed/mightysites/administrator/components/com_mightysites/views/site/tmpl/tables.php new file mode 100644 index 00000000..c33be375 --- /dev/null +++ b/deployed/mightysites/administrator/components/com_mightysites/views/site/tmpl/tables.php @@ -0,0 +1,26 @@ + + +
+
+
+ item->domain, JText::_('COM_MIGHTYSITES_SELECT_ALL_TO'), false, '-1', JText::_('COM_MIGHTYSITES_OWN_DATA'), '');?> +
+
+
+ +tables as $table => $input) {?> +
+
+
+
+ + + + + + + + + tables as $table => $input) {?> + + + + +
item->domain, JText::_('COM_MIGHTYSITES_SELECT_ALL_TO'), false, '-1', JText::_('COM_MIGHTYSITES_OWN_DATA'), '');?>
+state = $this->get('State'); + $this->item = $this->get('Item'); + $this->form = $this->get('Form'); + + $this->params = new JRegistry($this->item->params); + + // load tables + if ($this->getLayout() == 'tables') { + $this->tables = $this->getTables(); + } else { + $this->synchs_core = $this->getSynchs('core'); + $this->synchs_custom = $this->getSynchs('custom'); + } + + // Check for errors. + if (count($errors = $this->get('Errors'))) { + JError::raiseError(500, implode("\n", $errors)); + return false; + } + + $this->addToolbar(); + + $version = new JVersion; + if ($version->RELEASE == '2.5') { + $tpl = '25'; + } + + parent::display($tpl); + } + + protected function addToolbar() + { + JRequest::setVar('hidemainmenu', true); + + $user = JFactory::getUser(); + $userId = $user->get('id'); + $isNew = ($this->item->id == 0); + $checkedOut = !($this->item->checked_out == 0 || $this->item->checked_out == $user->get('id')); + + if (version_compare(JVERSION, '3.2', 'ge')) { + JToolBarHelper::title(JText::_($isNew ? 'COM_MIGHTYSITES_TITLE_SITE_ADD' : 'COM_MIGHTYSITES_TITLE_SITE_EDIT'), 'health'); + } else { + JToolBarHelper::title(JText::_($isNew ? 'COM_MIGHTYSITES_TITLE_SITE_ADD' : 'COM_MIGHTYSITES_TITLE_SITE_EDIT')); + } + + // If not checked out, can save the item. + if (!$checkedOut && $user->authorise('core.edit', 'com_mightysites')) + { + JToolBarHelper::apply('site.apply'); + JToolBarHelper::save('site.save'); + } + if (empty($this->item->id)) { + JToolBarHelper::cancel('site.cancel'); + } + else { + JToolBarHelper::cancel('site.cancel', 'JTOOLBAR_CLOSE'); + } + } + + + protected function getTables() + { + $tables = array(); + + if ($this->item->id) { + $db = MightysitesHelper::getDBO($this->item); + if ($db && $db->connected()) { + // We display both Tables & Views + foreach($db->getTableList() as $table) { + if (strpos($table, $this->item->dbprefix) === 0) { + $name = substr($table, strlen($this->item->dbprefix)); + $tables[$name] = MightysitesHelper::sitesList('jform[tables]['.$name.']', $this->params->get('table_'.$name), null, $this->item->domain, JText::_('COM_MIGHTYSITES_OWN_DATA')); + } + } + } + } + return $tables; + } + + + // Synchs + protected function getSynchs($type) + { + $synchs = array(); + foreach(MightysitesHelper::getSynchs($type) as $synch) { + $synchs[$synch] = MightysitesHelper::sitesList('jform[content]['.$synch.']', $this->params->get($synch), null, $this->item->domain, JText::_('COM_MIGHTYSITES_OWN_DATA')); + } + + return $synchs; + } +} diff --git a/deployed/mightysites/administrator/components/com_mightysites/views/sites/index.html b/deployed/mightysites/administrator/components/com_mightysites/views/sites/index.html new file mode 100644 index 00000000..2efb97f3 --- /dev/null +++ b/deployed/mightysites/administrator/components/com_mightysites/views/sites/index.html @@ -0,0 +1 @@ + diff --git a/deployed/mightysites/administrator/components/com_mightysites/views/sites/tmpl/default.php b/deployed/mightysites/administrator/components/com_mightysites/views/sites/tmpl/default.php new file mode 100644 index 00000000..50e94545 --- /dev/null +++ b/deployed/mightysites/administrator/components/com_mightysites/views/sites/tmpl/default.php @@ -0,0 +1,232 @@ +escape($this->state->get('list.ordering')); +$listDirn = $this->escape($this->state->get('list.direction')); +$sortFields = $this->getSortFields(); + +$this->sidebar = JHtmlSidebar::render(); +?> + + + + +
+sidebar)): ?> +
+ sidebar; ?> +
+
+ +
+ +
+ +
+ + +
+
+ + pagination->getLimitBox(); ?> +
+
+ + +
+
+ + +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + items as $i => $item) { + $canEdit = $user->authorise('core.edit', 'com_mightysites'); + $canCheckin = $user->authorise('core.manage', 'com_checkin') || $item->checked_out==$user->get('id') || $item->checked_out==0; + $canChange = $user->authorise('core.edit.state', 'com_mightysites') && $canCheckin; + + $published = JHtml::_('jgrid.published', !@$item->offline, $i, 'sites.', $canChange, 'cb'); + + ?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +items as $i => $item) : ?> + showForm($item->link, 'siteFormConfig'.$item->id); ?> + showForm($item->link2, 'siteFormAdmin'.$item->id); ?> + + diff --git a/deployed/mightysites/administrator/components/com_mightysites/views/sites/tmpl/default_25.php b/deployed/mightysites/administrator/components/com_mightysites/views/sites/tmpl/default_25.php new file mode 100644 index 00000000..c397ffae --- /dev/null +++ b/deployed/mightysites/administrator/components/com_mightysites/views/sites/tmpl/default_25.php @@ -0,0 +1,180 @@ +escape($this->state->get('list.ordering')); +$listDirn = $this->escape($this->state->get('list.direction')); + +JHtml::_('behavior.tooltip'); +?> + + + +
+ + + + + +
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +items)) { +foreach ($this->items as $i => $item) { + $canEdit = $user->authorise('core.edit', 'com_mightysites'); + $canCheckin = $user->authorise('core.manage', 'com_checkin') || $item->checked_out==$user->get('id') || $item->checked_out==0; + $canChange = $user->authorise('core.edit.state', 'com_mightysites') && $canCheckin; + + $published = JHtml::_('jgrid.published', !@$item->offline, $i, 'sites.', $canChange, 'cb'); + + ?> + + + + + + + + + + + + + + + + + + + + + + + + +
+ pagination->getListFooter(); ?> +
pagination->getRowOffset($i); ?>id); ?>checked_out) : ?> + editor, $item->checked_out_time, 'sites.', $canCheckin); ?> + + + + + title; ?> + + title; ?> + +

escape(@$item->sitename); ?>

+
+ authorise('core.edit', 'com_mightysites')) : ?> + link; ?>" rel="{handler: 'iframe', size: {x: 1200, y: 550}}">*/?> + + + +    + + + + +    + + + + + + + mighty_enable) && $item->mighty_enable) : ?> + + + +    + + + mighty_enable) || !$item->mighty_enable) : ?> + + + +    + + + singleTip) : ?> + + + +    + + + aliases) : ?> + + + +    + + db; ?>user; ?>dbprefix; ?>mighty_language) && $item->mighty_language) ? $item->mighty_language : JText::_('JDEFAULT'); ?>id; ?>
+ + + + + + + + +
+ +items as $i => $item) : ?> + showForm($item->link, 'siteFormConfig'.$item->id); ?> + showForm($item->link2, 'siteFormAdmin'.$item->id); ?> + diff --git a/deployed/mightysites/administrator/components/com_mightysites/views/sites/tmpl/index.html b/deployed/mightysites/administrator/components/com_mightysites/views/sites/tmpl/index.html new file mode 100644 index 00000000..2efb97f3 --- /dev/null +++ b/deployed/mightysites/administrator/components/com_mightysites/views/sites/tmpl/index.html @@ -0,0 +1 @@ + diff --git a/deployed/mightysites/administrator/components/com_mightysites/views/sites/view.html.php b/deployed/mightysites/administrator/components/com_mightysites/views/sites/view.html.php new file mode 100644 index 00000000..06938ded --- /dev/null +++ b/deployed/mightysites/administrator/components/com_mightysites/views/sites/view.html.php @@ -0,0 +1,172 @@ +getModel()->setState('filter.type', 1); + + $this->state = $this->get('State'); + $this->items = $this->get('Items'); + $this->pagination = $this->get('Pagination'); + + // Check for errors. + if (count($errors = $this->get('Errors'))) { + JError::raiseError(500, implode("\n", $errors)); + return false; + } + + // Add some data, yes - here, not in model! + foreach ($this->items as &$item) { + // Title + if ($item->id == 1) { + $item->title = ''.$item->domain.''; + } else { + $item->title = $item->domain; + } + + // Links + $mighty = base64_encode(JFactory::getURI()->toString()); + //$item->link = $this->_getLink($item, 'index.php?option=com_config&tmpl=component&mighty='.$mighty); + $item->link = $this->_getLink($item, 'index.php?option=com_config'); + $item->link2 = $this->_getLink($item, 'index.php'); + + // Infotip + $item->contentTip = $this->_getContentInfo($item); + $item->singleTip = $this->_getSingleInfo($item); + } + + $this->addToolbar(); + + $version = new JVersion; + if ($version->RELEASE == '2.5') { + $tpl = '25'; + } + + parent::display($tpl); + } + + protected function addToolbar() + { + // Load the submenu. + MightysitesHelper::topMenu(); + + // Title + if (version_compare(JVERSION, '3.2', 'ge')) { + JToolBarHelper::title(JText::_('COM_MIGHTYSITES_TITLE_SITES'), 'health'); + } else { + JToolBarHelper::title(JText::_('COM_MIGHTYSITES_TITLE_SITES')); + } + + $user = JFactory::getUser(); + + // Toolbar + if ($user->authorise('core.create', 'com_mightysites')) { + JToolBarHelper::addNew('site.add'); + } + if ($user->authorise('core.edit', 'com_mightysites')) { + JToolBarHelper::editList('site.edit'); + JToolBarHelper::divider(); + } + if ($user->authorise('core.edit.state', 'com_mightysites')) { + JToolBarHelper::publishList('sites.publish', 'COM_MIGHTYSITES_ONLINE'); + JToolBarHelper::unpublishList('sites.unpublish', 'COM_MIGHTYSITES_OFFLINE'); + JToolbarHelper::checkin('sites.checkin'); + } + if ($user->authorise('core.delete', 'com_mightysites')) { + JToolBarHelper::divider(); + JToolBarHelper::deleteList(JText::_('COM_MIGHTYSITES_REALLY_DELETE_SITES'), 'sites.remove'); + } + if ($user->authorise('core.admin', 'com_mightysites')) { + JToolBarHelper::divider(); + JToolBarHelper::preferences('com_mightysites', '300'); + } + } + + protected function getSortFields() + { + return array( + 'a.domain' => JText::_('COM_MIGHTYSITES_HEADING_SITE'), + 'a.id' => JText::_('ID'), + ); + } + + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + protected function _getContentInfo($row) + { + $i = 0; + $s = ''; + foreach(MightysitesHelper::getSynchs() as $synch) { + if ($row->params->get($synch)) { + $s .= ''; + $i++; + } + } + $s2 = ''; + foreach($row->params->toArray() as $key => $value) { + if (strpos($key, 'table_') === 0) { + $s2 .= ''; + $i++; + } + } + if ($s2) { + $s .= '' . $s2; + } + $s .= '
'.JText::_('COM_MIGHTYSITES_SYNCH_LABEL_'.$synch).':'.MightysitesHelper::getSite($row->params->get($synch))->domain.'
#__'.substr($key, 6).':'.MightysitesHelper::getSite($value)->domain.'

'; + return $i ? htmlspecialchars($s, ENT_COMPAT, 'UTF-8') : null; + } + + protected function _getSingleInfo($row) + { + if (isset($row->mighty_sdomains) && $row->mighty_sdomains) { + $s = ''; + $s .= ''; + $s .= ''; + $s .= ''; + foreach($row->mighty_sdomains as $key => $value) { + $s .= ''; + } + $s .= '
'.JText::_('COM_MIGHTYSITES_FIELD_SINGLE_LOGIN').':'.((isset($row->mighty_slogin) && $row->mighty_slogin) ? JText::_('JENABLED') : JText::_('JDISABLED')).'
'.JText::_('COM_MIGHTYSITES_FIELD_SINGLE_LOGOUT').':'.((isset($row->mighty_slogout) && $row->mighty_slogout) ? JText::_('JENABLED') : JText::_('JDISABLED')).'

'.$key.'
'; + return htmlspecialchars($s, ENT_COMPAT, 'UTF-8'); + } + } + + protected function _getLink(&$row, $link) + { + if ($row->domain != MightysitesHelper::getHost()) { + $link = 'index.php?option=com_mightysites&task=site.login&domain='.base64_encode($row->domain).'&return='.base64_encode($link); + } + return JRoute::_($link); + } + + // Mod_security - that's for you, my dear! + protected function showForm($link, $name = null) + { + $link = str_replace('&', '&', $link); + + $parts = parse_url($link); + + $hiddens = array(); + + if (isset($parts['query'])) { + parse_str($parts['query'], $vars); + foreach($vars as $key => $value) { + $hiddens[] = ''; + } + } + + $html = ''; + + return $html; + } + +} diff --git a/deployed/mightysites/components/com_mightysites/configuration/configuration_archline_hu.php b/deployed/mightysites/components/com_mightysites/configuration/configuration_archline_hu.php new file mode 100644 index 00000000..4b471069 --- /dev/null +++ b/deployed/mightysites/components/com_mightysites/configuration/configuration_archline_hu.php @@ -0,0 +1,119 @@ + Kérjük, látogasson vissza hozzánk minél előbb.'; + public $display_offline_message = '1'; + public $offline_image = ''; + public $sitename = 'www.archline.hu'; + public $editor = 'jckeditor'; + public $captcha = '0'; + public $list_limit = '20'; + public $access = '1'; + public $debug = '0'; + public $debug_lang = '0'; + public $dbtype = 'mysqli'; + public $host = 'localhost'; + public $user = 'cadline'; + public $password = 'Shea6hoo'; + public $db = 'www_archline_hu'; + public $dbprefix = 'jml_'; + public $live_site = ''; + public $secret = 'tWlnivpYpEaejpEd'; + public $gzip = '0'; + public $error_reporting = 'default'; + public $helpurl = 'https://help.joomla.org/proxy?keyref=Help{major}{minor}:{keyref}&lang={langcode}'; + public $ftp_host = ''; + public $ftp_port = ''; + public $ftp_user = ''; + public $ftp_pass = ''; + public $ftp_root = ''; + public $ftp_enable = '0'; + public $offset = 'UTC'; + public $mailonline = '1'; + public $mailer = 'mail'; + public $mailfrom = 'office@cadline.hu'; + public $fromname = 'www.archline.hu'; + public $sendmail = '/usr/sbin/sendmail'; + public $smtpauth = '0'; + public $smtpuser = ''; + public $smtppass = ''; + public $smtphost = 'localhost'; + public $smtpsecure = 'none'; + public $smtpport = '25'; + public $caching = '0'; + public $cache_handler = 'file'; + public $cachetime = '15'; + public $cache_platformprefix = '0'; + public $MetaDesc = ''; + public $MetaKeys = ''; + public $MetaTitle = '1'; + public $MetaAuthor = '1'; + public $MetaVersion = '0'; + public $robots = ''; + public $sef = '1'; + public $sef_rewrite = '1'; + public $sef_suffix = '0'; + public $unicodeslugs = '0'; + public $feed_limit = '10'; + public $feed_email = 'none'; + public $log_path = '/var/www/hosting/archline.hu/sub/logs'; + public $tmp_path = '/var/www/hosting/archline.hu/sub/tmp'; + public $lifetime = '30'; + public $session_handler = 'database'; + public $mighty = array("0" => array("0" => "/`?#__assets[` \\n]+/u", "1" => "/`?#__usergroups[` \\n]+/u", "2" => "/`?#__users[` \\n]+/u", "3" => "/`?#__user_notes[` \\n]+/u", "4" => "/`?#__user_profiles[` \\n]+/u", "5" => "/`?#__user_usergroup_map[` \\n]+/u", "6" => "/`?#__user_keys[` \\n]+/u", "7" => "/`?#__viewlevels[` \\n]+/u", "8" => "/`?#__mightysites[` \\n]+/u"), "1" => array("0" => "`oldeng_assets` ", "1" => "`oldeng_usergroups` ", "2" => "`oldeng_users` ", "3" => "`oldeng_user_notes` ", "4" => "`oldeng_user_profiles` ", "5" => "`oldeng_user_usergroup_map` ", "6" => "`oldeng_user_keys` ", "7" => "`oldeng_viewlevels` ", "8" => "`jml_mightysites` ")); + public $mighty_enable = '0'; + public $mighty_language = 'hu-HU'; + public $mighty_template = ''; + public $mighty_home = ''; + public $mighty_langoverride = '0'; + public $mighty_slogin = '1'; + public $mighty_slogout = '1'; + public $mighty_sdomains = array(); + public $mighty_css = array(); + public $mighty_js = ''; + public $mighty_hidemenus = array(); + public $mighty_hidemodules = array(); + public $mighty_favicon = ''; + public $mighty_mijoshopid = ''; + public $mighty_file_path = ''; + public $mighty_image_path = ''; + public $mighty_new_usertype = ''; + public $memcache_persist = '1'; + public $memcache_compress = '0'; + public $memcache_server_host = 'localhost'; + public $memcache_server_port = '11211'; + public $memcached_persist = '1'; + public $memcached_compress = '0'; + public $memcached_server_host = 'localhost'; + public $memcached_server_port = '11211'; + public $redis_persist = '1'; + public $redis_server_host = 'localhost'; + public $redis_server_port = '6379'; + public $redis_server_auth = ''; + public $redis_server_db = '0'; + public $proxy_enable = '0'; + public $proxy_host = ''; + public $proxy_port = ''; + public $proxy_user = ''; + public $proxy_pass = ''; + public $massmailoff = '0'; + public $MetaRights = ''; + public $sitename_pagetitles = '0'; + public $force_ssl = '0'; + public $session_memcache_server_host = 'localhost'; + public $session_memcache_server_port = '11211'; + public $session_memcached_server_host = 'localhost'; + public $session_memcached_server_port = '11211'; + public $frontediting = '1'; + public $cookie_domain = ''; + public $cookie_path = ''; + public $asset_id = '1'; + public $replyto = ''; + public $replytoname = ''; + public $session_redis_persist = '1'; + public $session_redis_server_host = 'localhost'; + public $session_redis_server_port = '6379'; + public $session_redis_server_auth = ''; + public $session_redis_server_db = '0'; + public $shared_session = '0'; +} \ No newline at end of file diff --git a/deployed/mightysites/components/com_mightysites/configuration/configuration_archlinexp_com.php b/deployed/mightysites/components/com_mightysites/configuration/configuration_archlinexp_com.php new file mode 100644 index 00000000..b758890b --- /dev/null +++ b/deployed/mightysites/components/com_mightysites/configuration/configuration_archlinexp_com.php @@ -0,0 +1,119 @@ + Please, check back later.'; + public $display_offline_message = '1'; + public $offline_image = ''; + public $sitename = 'archlinexp.com'; + public $editor = 'jckeditor'; + public $captcha = '0'; + public $list_limit = '20'; + public $access = '1'; + public $debug = '0'; + public $debug_lang = '0'; + public $dbtype = 'mysqli'; + public $host = 'localhost'; + public $user = 'cadline'; + public $password = 'Shea6hoo'; + public $db = 'www_archline_hu'; + public $dbprefix = 'eng_'; + public $live_site = ''; + public $secret = 'tWlnivpYpEaejpEd'; + public $gzip = '0'; + public $error_reporting = 'default'; + public $helpurl = 'https://help.joomla.org/proxy?keyref=Help{major}{minor}:{keyref}&lang={langcode}'; + public $ftp_host = ''; + public $ftp_port = ''; + public $ftp_user = ''; + public $ftp_pass = ''; + public $ftp_root = ''; + public $ftp_enable = '0'; + public $offset = 'UTC'; + public $mailonline = '1'; + public $mailer = 'mail'; + public $mailfrom = 'info@archlinexp.com'; + public $fromname = 'www.archlinexp.com'; + public $sendmail = '/usr/sbin/sendmail'; + public $smtpauth = '0'; + public $smtpuser = ''; + public $smtppass = ''; + public $smtphost = 'localhost'; + public $smtpsecure = 'none'; + public $smtpport = '25'; + public $caching = '0'; + public $cache_handler = 'file'; + public $cachetime = '15'; + public $cache_platformprefix = '0'; + public $MetaDesc = ''; + public $MetaKeys = ''; + public $MetaTitle = '1'; + public $MetaAuthor = '1'; + public $MetaVersion = '0'; + public $robots = ''; + public $sef = '1'; + public $sef_rewrite = '0'; + public $sef_suffix = '0'; + public $unicodeslugs = '0'; + public $feed_limit = '10'; + public $feed_email = 'none'; + public $log_path = '/var/www/hosting/archline.hu/sub/logs'; + public $tmp_path = '/var/www/hosting/archline.hu/sub/tmp'; + public $lifetime = '30'; + public $session_handler = 'database'; + public $mighty = array("0" => array("0" => "/`?#__assets[` \\n]+/u", "1" => "/`?#__usergroups[` \\n]+/u", "2" => "/`?#__users[` \\n]+/u", "3" => "/`?#__user_notes[` \\n]+/u", "4" => "/`?#__user_profiles[` \\n]+/u", "5" => "/`?#__user_usergroup_map[` \\n]+/u", "6" => "/`?#__user_keys[` \\n]+/u", "7" => "/`?#__viewlevels[` \\n]+/u", "8" => "/`?#__mightysites[` \\n]+/u"), "1" => array("0" => "`jml_assets` ", "1" => "`jml_usergroups` ", "2" => "`jml_users` ", "3" => "`jml_user_notes` ", "4" => "`jml_user_profiles` ", "5" => "`jml_user_usergroup_map` ", "6" => "`jml_user_keys` ", "7" => "`jml_viewlevels` ", "8" => "`jml_mightysites` ")); + public $mighty_enable = '1'; + public $mighty_language = 'en-GB'; + public $mighty_template = ''; + public $mighty_home = ''; + public $mighty_langoverride = '0'; + public $mighty_slogin = '1'; + public $mighty_slogout = '1'; + public $mighty_sdomains = array("archline.hu" => "tWlnivpYpEaejpEd"); + public $mighty_css = array(); + public $mighty_js = ''; + public $mighty_hidemenus = array(); + public $mighty_hidemodules = array(); + public $mighty_favicon = ''; + public $mighty_mijoshopid = ''; + public $mighty_file_path = ''; + public $mighty_image_path = ''; + public $mighty_new_usertype = ''; + public $cookie_domain = ''; + public $memcache_persist = '1'; + public $memcache_compress = '0'; + public $memcache_server_host = 'localhost'; + public $memcache_server_port = '11211'; + public $memcached_persist = '1'; + public $memcached_compress = '0'; + public $memcached_server_host = 'localhost'; + public $memcached_server_port = '11211'; + public $redis_persist = '1'; + public $redis_server_host = 'localhost'; + public $redis_server_port = '6379'; + public $redis_server_auth = ''; + public $redis_server_db = '0'; + public $proxy_enable = '0'; + public $proxy_host = ''; + public $proxy_port = ''; + public $proxy_user = ''; + public $proxy_pass = ''; + public $massmailoff = '0'; + public $MetaRights = ''; + public $sitename_pagetitles = '0'; + public $force_ssl = '2'; + public $session_memcache_server_host = 'localhost'; + public $session_memcache_server_port = '11211'; + public $session_memcached_server_host = 'localhost'; + public $session_memcached_server_port = '11211'; + public $frontediting = '1'; + public $cookie_path = ''; + public $asset_id = '1'; + public $replyto = ''; + public $replytoname = ''; + public $session_redis_persist = '1'; + public $session_redis_server_host = 'localhost'; + public $session_redis_server_port = '6379'; + public $session_redis_server_auth = ''; + public $session_redis_server_db = '0'; + public $shared_session = '0'; +} \ No newline at end of file diff --git a/deployed/mightysites/components/com_mightysites/configuration/configuration_old_archline_hu.php b/deployed/mightysites/components/com_mightysites/configuration/configuration_old_archline_hu.php new file mode 100644 index 00000000..6eb1a6e3 --- /dev/null +++ b/deployed/mightysites/components/com_mightysites/configuration/configuration_old_archline_hu.php @@ -0,0 +1,105 @@ + array("0" => "/`?#__assets[` \\n]+/u", "1" => "/`?#__usergroups[` \\n]+/u", "2" => "/`?#__users[` \\n]+/u", "3" => "/`?#__user_notes[` \\n]+/u", "4" => "/`?#__user_profiles[` \\n]+/u", "5" => "/`?#__user_usergroup_map[` \\n]+/u", "6" => "/`?#__user_keys[` \\n]+/u", "7" => "/`?#__viewlevels[` \\n]+/u", "8" => "/`?#__mightysites[` \\n]+/u"), "1" => array("0" => "`jml_assets` ", "1" => "`jml_usergroups` ", "2" => "`jml_users` ", "3" => "`jml_user_notes` ", "4" => "`jml_user_profiles` ", "5" => "`jml_user_usergroup_map` ", "6" => "`jml_user_keys` ", "7" => "`jml_viewlevels` ", "8" => "`jml_mightysites` ")); + public $mighty_enable = '1'; + public $mighty_language = 'hu-HU'; + public $mighty_template = ''; + public $mighty_home = ''; + public $mighty_langoverride = '0'; + public $cache_path = ''; + public $mighty_slogin = '1'; + public $mighty_slogout = '1'; + public $mighty_sdomains = array("archline.hu" => "tWlnivpYpEaejpEd"); + public $mighty_css = array(); + public $mighty_js = ''; + public $mighty_hidemenus = array(); + public $mighty_hidemodules = array(); + public $mighty_favicon = ''; + public $mighty_mijoshopid = ''; + public $mighty_file_path = ''; + public $mighty_image_path = ''; + public $mighty_new_usertype = ''; +} \ No newline at end of file diff --git a/deployed/mightysites/components/com_mightysites/configuration/configuration_old_archlinexp_com.php b/deployed/mightysites/components/com_mightysites/configuration/configuration_old_archlinexp_com.php new file mode 100644 index 00000000..1000a58f --- /dev/null +++ b/deployed/mightysites/components/com_mightysites/configuration/configuration_old_archlinexp_com.php @@ -0,0 +1,112 @@ + Kérjük, látogasson vissza hozzánk minél előbb.'; + public $display_offline_message = '1'; + public $offline_image = ''; + public $sitename = 'old.archlinexp.com'; + public $editor = 'jckeditor'; + public $captcha = '0'; + public $list_limit = '20'; + public $access = '1'; + public $debug = '0'; + public $debug_lang = '0'; + public $dbtype = 'mysqli'; + public $host = 'localhost'; + public $user = 'cadline'; + public $password = 'Shea6hoo'; + public $db = 'www_archline_hu'; + public $dbprefix = 'oldeng_'; + public $live_site = ''; + public $secret = 'tWlnivpYpEaejpEd'; + public $gzip = '0'; + public $error_reporting = 'default'; + public $helpurl = 'https://help.joomla.org/proxy/index.php?option=com_help&keyref=Help{major}{minor}:{keyref}'; + public $ftp_host = ''; + public $ftp_port = ''; + public $ftp_user = ''; + public $ftp_pass = ''; + public $ftp_root = ''; + public $ftp_enable = '0'; + public $offset = 'UTC'; + public $mailonline = '1'; + public $mailer = 'mail'; + public $mailfrom = 'zsolt.fekete@cadline.hu'; + public $fromname = 'lakberendezo.archline.hu'; + public $sendmail = '/usr/sbin/sendmail'; + public $smtpauth = '0'; + public $smtpuser = ''; + public $smtppass = ''; + public $smtphost = 'localhost'; + public $smtpsecure = 'none'; + public $smtpport = '25'; + public $caching = '0'; + public $cache_handler = 'file'; + public $cachetime = '15'; + public $cache_platformprefix = '0'; + public $MetaDesc = ''; + public $MetaKeys = ''; + public $MetaTitle = '1'; + public $MetaAuthor = '1'; + public $MetaVersion = '0'; + public $robots = ''; + public $sef = '1'; + public $sef_rewrite = '1'; + public $sef_suffix = '0'; + public $unicodeslugs = '0'; + public $feed_limit = '10'; + public $feed_email = 'none'; + public $log_path = '/var/www/hosting/archline.hu/sub/logs'; + public $tmp_path = '/var/www/hosting/archline.hu/sub/tmp'; + public $lifetime = '15'; + public $session_handler = 'database'; + public $mighty = array("0" => array("0" => "/`?#__usergroups[` \\n]+/u", "1" => "/`?#__users[` \\n]+/u", "2" => "/`?#__user_notes[` \\n]+/u", "3" => "/`?#__user_profiles[` \\n]+/u", "4" => "/`?#__user_usergroup_map[` \\n]+/u", "5" => "/`?#__user_keys[` \\n]+/u", "6" => "/`?#__viewlevels[` \\n]+/u", "7" => "/`?#__mightysites[` \\n]+/u"), "1" => array("0" => "`jml_usergroups` ", "1" => "`jml_users` ", "2" => "`jml_user_notes` ", "3" => "`jml_user_profiles` ", "4" => "`jml_user_usergroup_map` ", "5" => "`jml_user_keys` ", "6" => "`jml_viewlevels` ", "7" => "`jml_mightysites` ")); + public $mighty_enable = '1'; + public $mighty_language = 'en-GB'; + public $mighty_template = ''; + public $mighty_home = ''; + public $mighty_langoverride = '0'; + public $cache_path = ''; + public $mighty_slogin = '1'; + public $mighty_slogout = '1'; + public $mighty_sdomains = array("archline.hu" => "tWlnivpYpEaejpEd"); + public $mighty_css = array(); + public $mighty_js = ''; + public $mighty_hidemenus = array(); + public $mighty_hidemodules = array(); + public $mighty_favicon = ''; + public $mighty_mijoshopid = ''; + public $mighty_file_path = ''; + public $mighty_image_path = ''; + public $mighty_new_usertype = ''; + public $memcache_persist = '1'; + public $memcache_compress = '0'; + public $memcache_server_host = 'localhost'; + public $memcache_server_port = '11211'; + public $memcached_persist = '1'; + public $memcached_compress = '0'; + public $memcached_server_host = 'localhost'; + public $memcached_server_port = '11211'; + public $redis_persist = '1'; + public $redis_server_host = 'localhost'; + public $redis_server_port = '6379'; + public $redis_server_auth = ''; + public $redis_server_db = '0'; + public $proxy_enable = '0'; + public $proxy_host = ''; + public $proxy_port = ''; + public $proxy_user = ''; + public $proxy_pass = ''; + public $massmailoff = '0'; + public $MetaRights = ''; + public $sitename_pagetitles = '0'; + public $force_ssl = '0'; + public $session_memcache_server_host = 'localhost'; + public $session_memcache_server_port = '11211'; + public $session_memcached_server_host = 'localhost'; + public $session_memcached_server_port = '11211'; + public $frontediting = '1'; + public $cookie_domain = ''; + public $cookie_path = ''; + public $asset_id = '1'; +} \ No newline at end of file diff --git a/deployed/mightysites/components/com_mightysites/configuration/default.php b/deployed/mightysites/components/com_mightysites/configuration/default.php new file mode 100644 index 00000000..e37eb850 --- /dev/null +++ b/deployed/mightysites/components/com_mightysites/configuration/default.php @@ -0,0 +1,4 @@ + \ No newline at end of file diff --git a/deployed/mightysites/components/com_mightysites/format_25.php b/deployed/mightysites/components/com_mightysites/format_25.php new file mode 100644 index 00000000..c2a0160e --- /dev/null +++ b/deployed/mightysites/components/com_mightysites/format_25.php @@ -0,0 +1,140 @@ + $v) + { + if (is_scalar($v)) + { + $vars .= "\tpublic $" . $k . " = '" . addcslashes($v, '\\\'') . "';\n"; + } + elseif (is_array($v) || is_object($v)) + { + $vars .= "\tpublic $" . $k . " = " . $this->getArrayString((array) $v) . ";\n"; + } + } + + $str = ""; + } + + // default behavior + if ($params['class'] != 'JConfig') { + return $str; + } + // our behavior + else { + $app = JFactory::getApplication(); + // get domain + require_once(JPATH_ADMINISTRATOR.'/components/com_mightysites/helpers/helper.php'); + + $mighty = $app->input->getString('mighty'); + $file = MightysitesHelper::getConfigFilename(); + + // Get the new FTP credentials. + jimport('joomla.client.helper'); + $ftp = JClientHelper::getCredentials('ftp', true); + + // Attempt to make the file writeable if using FTP. + if (!$ftp['enabled'] && JPath::isOwner($file) && !JPath::setPermissions($file, '0644')) { + $link = $mighty ? 'index.php?option=com_config&tmpl=component&mighty='.$mighty : 'index.php?option=com_config'; + $app->redirect($link, JText::_('COM_CONFIG_ERROR_CONFIGURATION_PHP_NOTWRITABLE'), 'error'); + } + + // Attempt to write the configuration file as a PHP class named JConfig. + if (!JFile::write($file, $str)) { + $link = $mighty ? 'index.php?option=com_config&tmpl=component&mighty='.$mighty : 'index.php?option=com_config'; + $app->redirect($link, JText::_('COM_CONFIG_ERROR_WRITE_FAILED'), 'error'); + } + + MightysitesHelper::patchConfiguration(); + + // Get the new FTP credentials. + $ftp = JClientHelper::getCredentials('ftp', true); + + // Attempt to make the file unwriteable if using FTP. + if (JFactory::getConfig()->get('ftp_enable') == 0 && !$ftp['enabled'] && JPath::isOwner($file) && !JPath::setPermissions($file, '0444')) { + JError::raiseNotice('SOME_ERROR_CODE', JText::_('COM_CONFIG_ERROR_CONFIGURATION_PHP_NOTUNWRITABLE')); + } + + // Redirect appropriately + $task = $app->input->get('task'); + + // Set the success message. + $message = JText::_('COM_CONFIG_SAVE_SUCCESS'); + + if ($mighty) { + switch ($task) { + case 'apply' : + $app->redirect('index.php?option=com_config&tmpl=component&mighty='.$mighty, $message); + break; + + case 'save' : + default : + ?> + +
+ +
+ + + redirect('index.php?option=com_config', $message); + break; + case 'save' : + default : + $app->redirect('index.php', $message); + break; + } + } + } + } + + public function stringToObject($data, $options = array()) + { + return true; + } + + protected function getArrayString($a) + { + $s = 'array('; + $i = 0; + foreach ($a as $k => $v) + { + $s .= ($i) ? ', ' : ''; + $s .= '"' . $k . '" => '; + if (is_array($v) || is_object($v)) + { + $s .= $this->getArrayString((array) $v); + } + else + { + $s .= '"' . addslashes($v) . '"'; + } + $i++; + } + $s .= ')'; + return $s; + } +} diff --git a/deployed/mightysites/components/com_mightysites/format_30.php b/deployed/mightysites/components/com_mightysites/format_30.php new file mode 100644 index 00000000..c52a1d2b --- /dev/null +++ b/deployed/mightysites/components/com_mightysites/format_30.php @@ -0,0 +1,145 @@ + $v) + { + if (is_scalar($v)) + { + $vars .= "\tpublic $" . $k . " = '" . addcslashes($v, '\\\'') . "';\n"; + } + elseif (is_array($v) || is_object($v)) + { + $vars .= "\tpublic $" . $k . " = " . $this->getArrayString((array) $v) . ";\n"; + } + } + + $str = ""; + } + + // default behavior + if ($params['class'] != 'JConfig') { + return $str; + } + // our behavior + else { + $app = JFactory::getApplication(); + // get domain + require_once(JPATH_ADMINISTRATOR.'/components/com_mightysites/helpers/helper.php'); + + $mighty = $app->input->getString('mighty'); + $file = MightysitesHelper::getConfigFilename(); + + // Get the new FTP credentials. + jimport('joomla.client.helper'); + $ftp = JClientHelper::getCredentials('ftp', true); + + // Attempt to make the file writeable if using FTP. + if (!$ftp['enabled'] && JPath::isOwner($file) && !JPath::setPermissions($file, '0644')) { + $link = $mighty ? 'index.php?option=com_config&tmpl=component&mighty='.$mighty : 'index.php?option=com_config'; + $app->redirect($link, JText::_('COM_CONFIG_ERROR_CONFIGURATION_PHP_NOTWRITABLE'), 'error'); + } + + // Attempt to write the configuration file as a PHP class named JConfig. + if (!JFile::write($file, $str)) { + $link = $mighty ? 'index.php?option=com_config&tmpl=component&mighty='.$mighty : 'index.php?option=com_config'; + $app->redirect($link, JText::_('COM_CONFIG_ERROR_WRITE_FAILED'), 'error'); + } + + MightysitesHelper::patchConfiguration(); + + // Get the new FTP credentials. + $ftp = JClientHelper::getCredentials('ftp', true); + + // Attempt to make the file unwriteable if using FTP. + if (JFactory::getConfig()->get('ftp_enable') == 0 && !$ftp['enabled'] && JPath::isOwner($file) && !JPath::setPermissions($file, '0444')) { + JError::raiseNotice('SOME_ERROR_CODE', JText::_('COM_CONFIG_ERROR_CONFIGURATION_PHP_NOTUNWRITABLE')); + } + + // Redirect appropriately + $task = $app->input->get('task'); + + // Set the success message. + $message = JText::_('COM_CONFIG_SAVE_SUCCESS'); + + if ($mighty) { + switch ($task) { + case 'apply': + case 'config.save.application.apply': + $app->redirect('index.php?option=com_config&tmpl=component&mighty='.$mighty, $message, 'message'); + break; + + case 'save': + case 'config.save.application.save': + default: + ?> + +
+ +
+ + + redirect('index.php?option=com_config', $message, 'message'); + break; + + case 'save' : + case 'config.save.application.save': + default : + $app->redirect('index.php', $message, 'message'); + break; + } + } + } + } + + public function stringToObject($data, array $options = array()) + { + return true; + } + + protected function getArrayString($a) + { + $s = 'array('; + $i = 0; + foreach ($a as $k => $v) + { + $s .= ($i) ? ', ' : ''; + $s .= '"' . $k . '" => '; + if (is_array($v) || is_object($v)) + { + $s .= $this->getArrayString((array) $v); + } + else + { + $s .= '"' . addslashes($v) . '"'; + } + $i++; + } + $s .= ')'; + return $s; + } +} diff --git a/deployed/mightysites/components/com_mightysites/format_33.php b/deployed/mightysites/components/com_mightysites/format_33.php new file mode 100644 index 00000000..2208b427 --- /dev/null +++ b/deployed/mightysites/components/com_mightysites/format_33.php @@ -0,0 +1,174 @@ + $v) + { + if (is_scalar($v)) + { + $vars .= "\tpublic $" . $k . " = '" . addcslashes($v, '\\\'') . "';\n"; + } + elseif (is_array($v) || is_object($v)) + { + $vars .= "\tpublic $" . $k . " = " . $this->getArrayString((array) $v) . ";\n"; + } + } + + $str = ""; + } + + // default behavior + if ($params['class'] != 'JConfig') { + return $str; + } + // our behavior + else { + $app = \JFactory::getApplication(); + // get domain + require_once(JPATH_ADMINISTRATOR.'/components/com_mightysites/helpers/helper.php'); + + $file = \MightysitesHelper::getConfigFilename(); + + // Get the new FTP credentials. + jimport('joomla.client.helper'); + $ftp = \JClientHelper::getCredentials('ftp', true); + + // Attempt to make the file writeable if using FTP. + if (!$ftp['enabled'] && \JPath::isOwner($file) && !\JPath::setPermissions($file, '0644')) { + $link = 'index.php?option=com_config'; + $app->redirect($link, \JText::_('COM_CONFIG_ERROR_CONFIGURATION_PHP_NOTWRITABLE'), 'error'); + } + + // Attempt to write the configuration file as a PHP class named JConfig. + if (!\JFile::write($file, $str)) { + $link = 'index.php?option=com_config'; + $app->redirect($link, \JText::_('COM_CONFIG_ERROR_WRITE_FAILED'), 'error'); + } + + \MightysitesHelper::patchConfiguration(); + + // Get the new FTP credentials. + $ftp = \JClientHelper::getCredentials('ftp', true); + + // Attempt to make the file unwriteable if using FTP. + if (\JFactory::getConfig()->get('ftp_enable') == 0 && !$ftp['enabled'] && \JPath::isOwner($file) && !\JPath::setPermissions($file, '0444')) { + JError::raiseNotice('SOME_ERROR_CODE', \JText::_('COM_CONFIG_ERROR_CONFIGURATION_PHP_NOTUNWRITABLE')); + } + + // Redirect appropriately + $task = $app->input->get('task'); + + // Set the success message. + $message = \JText::_('COM_CONFIG_SAVE_SUCCESS'); + + // Save the data in the session. + $app->setUserState('com_config.config.global.data', (array)$object); + + + // Set the success message. + $app->enqueueMessage(\JText::_('COM_CONFIG_SAVE_SUCCESS')); + + // Set the redirect based on the task. + switch ($task) + { + case 'config.save.application.apply': + $app->redirect(\JRoute::_('index.php?option=com_config', false)); + break; + + case 'config.save.application.save': + default: + $app->redirect(\JRoute::_('index.php', false)); + break; + } + } + } + + /** + * Parse a PHP class formatted string and convert it into an object. + * + * @param string $data PHP Class formatted string to convert. + * @param array $options Options used by the formatter. + * + * @return object Data object. + * + * @since 1.0 + */ + public function stringToObject($data, array $options = array()) + { + return true; + } + + /** + * Method to get an array as an exported string. + * + * @param array $a The array to get as a string. + * + * @return array + * + * @since 1.0 + */ + protected function getArrayString($a) + { + $s = 'array('; + $i = 0; + + foreach ($a as $k => $v) + { + $s .= ($i) ? ', ' : ''; + $s .= '"' . $k . '" => '; + + if (is_array($v) || is_object($v)) + { + $s .= $this->getArrayString((array) $v); + } + else + { + $s .= '"' . addslashes($v) . '"'; + } + + $i++; + } + + $s .= ')'; + + return $s; + } +} diff --git a/deployed/mightysites/components/com_mightysites/index.html b/deployed/mightysites/components/com_mightysites/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/deployed/mightysites/components/com_mightysites/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/deployed/mightysites/components/com_mightysites/mightysites.php b/deployed/mightysites/components/com_mightysites/mightysites.php new file mode 100644 index 00000000..aa1f68c1 --- /dev/null +++ b/deployed/mightysites/components/com_mightysites/mightysites.php @@ -0,0 +1,261 @@ +mighty_enable) && $config->mighty_enable && isset($config->mighty[0][0])) +{ + // Remove legacy + if ($config->dbtype == 'mightysites') { + $config->dbtype = 'mysql'; + } + + if (version_compare(JVERSION, '3.0', 'ge')) { + require_once(JPATH_SITE.'/libraries/joomla/database/database.php'); + require_once(JPATH_SITE.'/libraries/joomla/database/driver.php'); + require_once(JPATH_SITE.'/libraries/joomla/database/driver/'.$config->dbtype.'.php'); + class_alias('JDatabaseDriver'.ucfirst($config->dbtype), 'JDatabaseMightysitesBase'); + } + else { + require_once(JPATH_SITE.'/libraries/joomla/database/database.php'); + require_once(JPATH_SITE.'/libraries/joomla/database/database/'.$config->dbtype.'.php'); + class_alias('JDatabase'.$config->dbtype, 'JDatabaseMightysitesBase'); + } + + class JDatabaseMightysites extends JDatabaseMightysitesBase + { + public $count = null; + public $log = null; + public $mighty = null; + + public function __construct($options) + { + parent::__construct($options); + + $this->mighty = JFactory::getConfig()->get('mighty'); + + // stupid IIS uses \r\n + if (PHP_EOL === "\r\n" && isset($this->mighty[0][0])) { + foreach($this->mighty[0] as &$tmp) { + $tmp = str_replace('\n', '\r\n', $tmp); + } + } + } + + // Not here, baby! + public function __destruct() {} + + public function replacePrefix($sql, $prefix = '#__') + { + // We need to allow parent usual method + if (isset($GLOBALS['no_mightysharing'])) { + return parent::replacePrefix($sql, $prefix); + } + + // Initialize variables. + $escaped = false; + $startPos = 0; + $quoteChar = ''; + $literal = ''; + + $sql = trim($sql); + $n = strlen($sql); + + while ($startPos < $n) + { + $ip = strpos($sql, $prefix, $startPos); + if ($ip === false) + { + break; + } + + $j = strpos($sql, "'", $startPos); + $k = strpos($sql, '"', $startPos); + if (($k !== false) && (($k < $j) || ($j === false))) + { + $quoteChar = '"'; + $j = $k; + } + else + { + $quoteChar = "'"; + } + + if ($j === false) + { + $j = $n; + } + + $literal .= str_replace($prefix, $this->tablePrefix, preg_replace($this->mighty[0], $this->mighty[1], substr($sql, $startPos, $j - $startPos).' ')); + $startPos = $j; + + $j = $startPos + 1; + + if ($j >= $n) + { + break; + } + + // quote comes first, find end of quote + while (true) + { + $k = strpos($sql, $quoteChar, $j); + $escaped = false; + if ($k === false) + { + break; + } + $l = $k - 1; + while ($l >= 0 && $sql{$l} == '\\') + { + $l--; + $escaped = !$escaped; + } + if ($escaped) + { + $j = $k + 1; + continue; + } + break; + } + if ($k === false) + { + // error in the query - no end quote; ignore it + break; + } + $literal .= substr($sql, $startPos, $k - $startPos + 1); + $startPos = $k + 1; + } + if ($startPos < $n) + { + $literal .= substr($sql, $startPos, $n - $startPos); + } + + return $literal; + } + + public static function changeHandler() + { + $db = JFactory::getDBO(); + $config = JFactory::getConfig(); + $debug = $config->get('debug'); + $debug ? $log = $db->getLog() : null; + + JFactory::$database = new JDatabaseMightysites(array( + 'driver' => 'mightysites', + 'host' => $config->get('host'), + 'user' => $config->get('user'), + 'password' => $config->get('password'), + 'database' => $config->get('db'), + 'prefix' => $config->get('dbprefix') + )); + + if ($debug) { + $db = JFactory::getDBO(); + $db->setDebug(($debug == 0) ? false : true); + $db->count = sizeof($log); + $db->log = $log; + } + } + } + + JDatabaseMightysites::changeHandler(); +} + +// Overload format +if (defined('JVERSION')) { + if (version_compare(JVERSION, '3.3', 'ge')) { + require_once(dirname(__FILE__).'/format_33.php'); + } + else if (version_compare(JVERSION, '3.0', 'ge')) { + require_once(dirname(__FILE__).'/format_30.php'); + } + else { + require_once(dirname(__FILE__).'/format_25.php'); + } +} diff --git a/deployed/mightysites/plugins/system/mightysites/index.html b/deployed/mightysites/plugins/system/mightysites/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/deployed/mightysites/plugins/system/mightysites/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/deployed/mightysites/plugins/system/mightysites/mightysites.php b/deployed/mightysites/plugins/system/mightysites/mightysites.php new file mode 100644 index 00000000..114a73b2 --- /dev/null +++ b/deployed/mightysites/plugins/system/mightysites/mightysites.php @@ -0,0 +1,579 @@ +isSite()) +{ + class plgSystemMightysites extends plgSystemMightysitesBase + { + // Start single login? + public function onUserLogin($user, $options = array()) + { + $app = JFactory::getApplication(); + + // Not used if we login via our SSI plugin! + if ($app->getCfg('mighty_slogin') && $app->getCfg('mighty_sdomains') && !isset($_REQUEST['mighty_login'])) + { + $_SESSION['mightylogin'] = array( + 'username' => $user['username'], + 'password' => $user['password'], + 'remember' => isset($options['remember']) ? $options['remember'] : 0, + ); + } + } + + // Start single logout? + public function onUserLogout($user, $options = array()) + { + $app = JFactory::getApplication(); + + // Not used if we logout via our SSI plugin! + if ($app->getCfg('mighty_slogout') && $app->getCfg('mighty_sdomains') && !isset($_REQUEST['mighty_logout'])) { + setcookie('mightylogout', 1, time()+3600, '/'); + + // No page cache! At all, othwerwise logout redirect will load cached page. + $this->disableCache(false); + } + } + + // Start single login/logout to other sites! + public function onBeforeCompileHead() + { + $config = JFactory::getConfig(); + $document = JFactory::getDocument(); + + if ($document->getType() == 'html' && isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == 'GET') + { + // Login there + if (isset($_SESSION['mightylogin'])) + { + $user = $_SESSION['mightylogin']; + unset($_SESSION['mightylogin']); + + jimport('joomla.utilities.simplecrypt'); + jimport('joomla.utilities.utility'); + + $domains = $config->get('mighty_sdomains'); + + foreach($domains as $domain => $secret) + { + $key = md5($secret . @$_SERVER['HTTP_USER_AGENT']); + $crypt = new JSimpleCrypt($key); + $hash = base64_encode($crypt->encrypt(serialize($user))); + // possible 'suhosin.get.max_value_length' issue, let's use array + $hash = implode('&mighty_login[]=', str_split($hash, 250)); + + $document->addScript('http://'.$domain.'/index.php?'.md5($_SERVER['REQUEST_TIME']).'=1&mighty_login[]='.$hash, 'text/javascript', true); + } + + // No page cache! + $this->disableCache(); + } + + // Logout there + if (isset($_COOKIE['mightylogout'])) { + setcookie('mightylogout', '', time()-86400, '/'); + + $domains = $config->get('mighty_sdomains'); + + foreach($domains as $domain => $secret) { + $document->addScript('http://'.$domain.'/index.php?mighty_logout=1&'.md5($_SERVER['REQUEST_TIME']).'=1', 'text/javascript', true); + } + + // No page cache! But enable it if previously disabled + $this->disableCache(true); + } + + // Custom CSS files + if ($config->get('mighty_css')) { + foreach((array)$config->get('mighty_css') as $css_file) { + $document->addStylesheet($css_file); + } + } + + // Custom JavaScript + if ($config->get('mighty_js')) { + $document->addScriptDeclaration($config->get('mighty_js')); + } + + // Custom Favicon + if ($config->get('mighty_favicon')) { + foreach($document->_links as $i => $link) { + if ($link['relation'] == 'shortcut icon') { + unset($document->_links[$i]); + } + } + $document->addFavicon($config->get('mighty_favicon')); + } + } + } + + public function onBeforeRender() + { + $config = JFactory::getConfig(); + $document = JFactory::getDocument(); + + if ($document->getType() == 'html') + { + // Remove modules + $mighty_modules = (array)$config->get('mighty_hidemodules'); + + if ($mighty_modules && $mighty_modules != array('')) + { + $mighty_modules = array_flip($mighty_modules); + + if (version_compare(JVERSION, '3.2', 'ge')) { + $rMethod = new ReflectionMethod('JModuleHelper', 'load'); + } else { + $rMethod = new ReflectionMethod('JModuleHelper', '_load'); + } + + $rMethod->setAccessible(true); + $items = $rMethod->invoke(null); + + foreach($items as &$item) { + if (isset($mighty_modules[$item->id]) || isset($mighty_modules[$item->id])) { + $mighty_modules[$item->id] = true; + $item->module = 'unknown'; // ;) + } + } + } + } + } + + public function onAfterDispatch() + { + // Lost database handler? + if (JFactory::getConfig()->get('config.mighty_enable') && get_class(JFactory::$database) != 'JDatabaseMightysites') { + JDatabaseMightysites::changeHandler(); + } + } + + protected function disableCache($plugin_status = null) + { + // Change plugin status + if (isset($plugin_status)) { + $db = JFactory::getDbo(); + + // Disable only if it's currently enabled + if ($plugin_status === false && class_exists('PlgSystemCache')) { + $db->setQuery('UPDATE #__extensions SET `enabled`=0 WHERE `type`="plugin" AND `element`="cache" AND `folder`="system"'); + $db->execute(); + setcookie('mightylogout_cache', 1, time()+3600, '/'); + } + + // Enable only if it was previously disabled + if ($plugin_status === true && isset($_COOKIE['mightylogout_cache'])) { + $db->setQuery('UPDATE #__extensions SET `enabled`=1 WHERE `type`="plugin" AND `element`="cache" AND `folder`="system"'); + $db->execute(); + setcookie('mightylogout_cache', '', time()-86400, '/'); + } + + // Clear system cache + if (JFactory::getConfig()->get('caching') > 0) { + $cache = JFactory::getCache(); + $cache->clean('com_plugins'); + } + } + + // Just disable caching of current page. + if (class_exists('PlgSystemCache')) { + $dispatcher = JDispatcher::getInstance(); + $_methods = $dispatcher->get('_methods'); + foreach($dispatcher->get('_observers') as $oId => $observer) { + if (is_object($observer) && strtolower(get_class($observer)) == 'plgsystemcache') { + foreach($_methods['onafterrender'] as $key => $value) { + if ($value == $oId) { + unset($_methods['onafterrender'][$key]); + $dispatcher->set('_methods', $_methods); + break; + } + } + } + } + } + } + } + + // Implicitely setup language, getLanguage() only next! + if ($lang_code = $config->get('mighty_language')) { + $config->set('language', $lang_code); + + if (version_compare(JVERSION, '3.2', 'ge')) { + // Build our language object + $lang = JLanguage::getInstance($config->get('language'), $config->get('debug_lang')); + + // Load the language to the API + $app->loadLanguage($lang); + + // Register the language object with JFactory + JFactory::$language = $app->getLanguage(); + } + + // Override language in params only if language filter plugin is enabled + if (class_exists('PlgSystemLanguageFilter')) + { + $lparams = JComponentHelper::getParams('com_languages'); + $lparams->set('site', $lang_code); + + $rProperty = new ReflectionProperty('PlgSystemLanguageFilter', 'default_lang'); + $rProperty->setAccessible(true); + $rProperty->setValue('PlgSystemLanguageFilter', $lang_code); + + $rProperty2 = new ReflectionProperty('PlgSystemLanguageFilter', 'default_sef'); + $rProperty2->setAccessible(true); + $rProperty2->setValue('PlgSystemLanguageFilter', substr($lang_code, 0, 2)); // simple, we don't use language->sef + + $rProperty3 = new ReflectionProperty('PlgSystemLanguageFilter', 'cookie'); + $rProperty3->setAccessible(true); + $rProperty3->setValue('PlgSystemLanguageFilter', true); // simple, we don't use language->sef + + // Create a cookie + $cookie_domain = $config->get('config.cookie_domain', ''); + $cookie_path = $config->get('config.cookie_path', '/'); + setcookie(JApplication::getHash('language'), $lang_code, time() + 365 * 86400, $cookie_path, $cookie_domain); + $app->input->cookie->set(JApplication::getHash('language'), $lang_code); + // set the request var + $app->input->set('language', $lang_code); + + // $uri = JFactory::getURI(); + // $uri->setVar('lang', $lang_code); + + } + } + + // Now we can load language, but override it first! + $lang = JFactory::getLanguage(); + + // Implicitely setup template + if ($config->get('mighty_template')) { + $app->input->set('templateStyle', $config->get('mighty_template')); + $app->getTemplate(); + } + + // Implicitely setup home menu item + if ($config->get('mighty_home')) + { + $menu = $app->getMenu(); + if ($menu->getDefault()) { + $menu->getDefault()->home = 0; + } + if ($menu->getDefault($lang->getTag())) { + $menu->getDefault($lang->getTag())->home = 0; + } + $menu->setDefault($config->get('mighty_home'), $lang->getTag()); + $menu->setDefault($config->get('mighty_home'), '*'); + $menu->getDefault()->home = 1; + } + + // Remove menu items + $mighty_menuitems = (array)$config->get('mighty_hidemenus'); + if ($mighty_menuitems && $mighty_menuitems != array('')) + { + $mighty_menuitems = array_flip($mighty_menuitems); + $menu = $app->getMenu(); + + // I hate Joomla sometimes... smbd is crazy on privates which are useless + $rProperty = new ReflectionProperty($menu, '_items'); + $rProperty->setAccessible(true); + $items = $rProperty->getValue($menu); + + foreach($items as $key => &$item) { + if (isset($mighty_menuitems[$item->id]) || isset($mighty_menuitems[$item->id])) { + $mighty_menuitems[$item->id] = true; + unset($items[$key]); + } + } + + $rProperty->setValue($menu, $items); + } + + // Load language overrides, + if ($config->get('mighty_langoverride')) + { + $domain = $_SERVER['HTTP_HOST'] ? $_SERVER['HTTP_HOST'] : $_SERVER['SERVER_NAME']; + $domain = (substr($domain, 0, 4) == 'www.') ? substr($domain, 4) : $domain; + $domain = preg_replace('#([^A-Z0-9])#i', '_', $domain); + + $override_file = JPATH_SITE.'/language/overrides/'.$domain.'.'.$lang->getTag().'.override.ini'; + if (file_exists($override_file)) { + $rProperty = new ReflectionProperty($lang, 'override'); + $rProperty->setAccessible(true); + $override = $rProperty->getValue($lang); + + $rMethod = new ReflectionMethod($lang, 'parse'); + $rMethod->setAccessible(true); + $contents = $rMethod->invoke($lang, $override_file); + + if (is_array($contents)) { + $override = array_merge($override, $contents); + } + + $lang->set('override', $override); + } + } + + // MijoShop ID + if ($config->get('mighty_mijoshopid') !== '') { + $app->input->set('mijoshop_store_id', $config->get('mighty_mijoshopid')); + } +} + +// Backend options +if (JFactory::getApplication()->isAdmin()) +{ + class plgSystemMightysites extends plgSystemMightysitesBase + { + public function onAfterRoute() + { + $app = JFactory::getApplication(); + + if (isset($_REQUEST['mighty_token']) && strlen($_REQUEST['mighty_token'])) { + $token = $app->input->getString('mighty_token'); + $folder = $app->getCfg('tmp_path'); + + jimport('joomla.filesystem.folder'); + jimport('joomla.filesystem.file'); + + $files = JFolder::files($folder, '\.mighty$'); + + if (sizeof($files)) { + $data = false; + foreach($files as $file) { + if ($file == md5($token.$app->getCfg('secret')).'.mighty') { + jimport('joomla.filesystem.file'); + $data = JFile::read($folder.'/'.$file); + } + JFile::delete($folder.'/'.$file); + } + + if ($data) { + $data = unserialize($data); + + if (!JFactory::getUser()->id) { + $user = new JUser(); + $user->load($data['user_id']); + + // try load by username next + if (!$user->id) { + // remove "JUser: :_load: Unable to load user with id: 42" message + $session = JFactory::getSession(); + $session->set('application.queue', null); + + // load other admin by username + $db = JFactory::getDBO(); + $db->setQuery('SELECT id FROM #__users WHERE `username`='.$db->quote($data['username'])); + $user->load($db->loadResult()); + } + + if ($user->id) { + // Mark the user as logged in + $user->set('guest', 0); + + // Register the needed session variables + $session = JFactory::getSession(); + $session->set('user', $user); + + $db = JFactory::getDBO(); + + // Check to see the the session already exists. + $app = JFactory::getApplication(); + $app->checkSession(); + + // Update the user related fields for the Joomla sessions table. + $db->setQuery( + 'UPDATE `#__session`' . + ' SET `guest` = '.$db->quote($user->get('guest')).',' . + ' `username` = '.$db->quote($user->get('username')).',' . + ' `userid` = '.(int) $user->get('id') . + ' WHERE `session_id` = '.$db->quote($session->getId()) + ); + $db->query(); + + // Hit the user last visit field + $user->setLastVisit(); + } + } + + if (strpos($data['return'], 'index.php') === 0) { + $data['return'] = JUri::base(true) . '/' . ltrim($data['return'], '/'); + } + + $app->redirect($data['return']); + } + } + } + } + + public function onAfterDispatch() + { + $app = JFactory::getApplication(); + + // our message from saving modal config + if ($app->input->get('option') == 'com_mightysites') { + if ($app->input->get('mighty_saved')) { + $app->enqueueMessage(JText::sprintf('COM_MIGHTYSITES_CONFIG_UPDATED', $app->input->get('mighty_saved'))); + } + } + + // let's rock + else if ($app->input->get('option') == 'com_config') { + if ($app->input->get('controller') != 'component' && $app->input->get('view') != 'component' && $app->input->get('tmpl') == 'component') { + require_once(JPATH_ADMINISTRATOR.'/components/com_mightysites/helpers/helper.php'); + + $document = JFactory::getDocument(); + + $version = new JVersion; + if ($version->RELEASE == '2.5') { + JToolBarHelper::title(JText::_('COM_CONFIG') . ' :: ' . MightysitesHelper::getHost(), 'config.png'); + + $html = ' +
+
'; + + $toolbar = $document->getBuffer('modules', 'toolbar', array('name'=>'toolbar')); + $toolbar = strtr($toolbar, array( + 'Joomla.submitbutton(\'application.cancel\')' => 'try {window.parent.SqueezeBox.close()} catch(e){self.top.location=\''.base64_decode($app->input->getString('mighty')).'\';}; return false;', + )); + $html .= $toolbar; + + + $html .= $document->getBuffer('modules', 'title', array('name'=>'title')); + $html .= '
+
'; + $html .= $document->getBuffer('modules', 'submenu', array('name'=>'submenu', 'style'=>'rounded', 'id'=>'submenu-box')); + $html .= '
+
'; + + $contents = $document->getBuffer('component'); + $contents = strtr($contents, array( + 'index.php?option=com_config" ' => 'index.php?option=com_config&tmpl=component&mighty='.$app->input->getString('mighty').'" ' + )); + + $html .= $contents; + + $html .= '
+
+
+ '; + } + else { + $html = + ''.JText::_('TPL_ISIS_TOOLBAR').' +
+
+
+
+
+
+ '.JToolBar::getInstance('toolbar')->render('toolbar').' +
+
+
+
+
+ +
+
+

'.JText::_('COM_CONFIG') . ' : ' . MightysitesHelper::getHost().'

+
+
' . + $document->getBuffer('component') . + '
+
+
+
'; + + $html = strtr($html, array( + 'Joomla.submitbutton(\'application.cancel\')' => 'try {window.parent.SqueezeBox.close()} catch(e){self.top.location=\''.base64_decode($app->input->getString('mighty')).'\';}; return false;', // < 3.2 + 'Joomla.submitbutton(\'config.cancel.application\')' => 'try {window.parent.SqueezeBox.close()} catch(e){self.top.location=\''.base64_decode($app->input->getString('mighty')).'\';}; return false;', // 3.2 + JRoute::_('index.php?option=com_config') => JRoute::_('index.php?option=com_config&tmpl=component&mighty='.$app->input->getString('mighty')), + )); + + // Prettify + $document->addStyleDeclaration('html, body {padding:0; margin:0; height:auto;} #sidebar.span2 {display:none;} div.container-fluid.container-main {padding:0;}'); + } + + $document->setBuffer($html, 'component'); + } + } + } + + // Let's run the install queries for the component which already exists. + public function onExtensionBeforeInstall($method, $type, $manifest, $extension) + { + if ($method == 'install' && $type == 'component') { + $element = $this->getComponentName($manifest); + + if (file_exists(JPATH_SITE.'/components/'.$element) || file_exists(JPATH_ADMINISTRATOR.'/components/'.$element)) { + if (isset($manifest->install->sql)) { + $installer = JInstaller::getInstance(); + // Pre-create path to use for getting SQL files + $installer->setPath('extension_root', JPath::clean(JPATH_ADMINISTRATOR . '/components/' . $element)); + + // Don't use rewrite! + $GLOBALS['no_mightysharing'] = true; + + $installer->parseSQLFiles($manifest->install->sql); + + unset($GLOBALS['no_mightysharing']); + } + } + } + } + + protected function getComponentName($manifest) + { + $name = strtolower(JFilterInput::getInstance()->clean((string) $manifest->name, 'cmd')); + + if (substr($name, 0, 4) == 'com_') { + $element = $name; + } else { + $element = 'com_' . $name; + } + + return $element; + } + } +} + +// Shared options. + +// Media Manager overrides. +if ($app->input->get('option') == 'com_media') +{ + $mparams = JComponentHelper::getParams('com_media'); + + if ($config->get('mighty_file_path')) { + $mparams->set('file_path', $config->get('mighty_file_path')); + } + if ($config->get('mighty_image_path')) { + $mparams->set('image_path', $config->get('mighty_image_path')); + } +} + +// Users Manager overrides. +if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == 'POST' && in_array($app->input->get('option'), array('com_users', 'com_comprofiler', 'com_community', 'com_easysocial', 'com_k2'))) +{ + $uparams = JComponentHelper::getParams('com_users'); + + if ($config->get('mighty_new_usertype')) { + $uparams->set('new_usertype', $config->get('mighty_new_usertype')); + } +} diff --git a/deployed/mightysites/plugins/system/mightysites/mightysites.script.php b/deployed/mightysites/plugins/system/mightysites/mightysites.script.php new file mode 100644 index 00000000..592bf183 --- /dev/null +++ b/deployed/mightysites/plugins/system/mightysites/mightysites.script.php @@ -0,0 +1,24 @@ +enqueueMessage(JText::_('Successfully installed "System - MightySites" plugin!')); + } + + function uninstall($parent) { + JFactory::getApplication()->enqueueMessage(JText::_('Successfully uninstalled "System - MightySites" plugin!')); + } + + function update($parent) { + JFactory::getApplication()->enqueueMessage(JText::_('Successfully updated "System - MightySites" plugin!')); + } + +} \ No newline at end of file diff --git a/deployed/mightysites/plugins/system/mightysites/mightysites.xml b/deployed/mightysites/plugins/system/mightysites/mightysites.xml new file mode 100644 index 00000000..936b7627 --- /dev/null +++ b/deployed/mightysites/plugins/system/mightysites/mightysites.xml @@ -0,0 +1,28 @@ + + + PLG_SYSTEM_MIGHTYSITES + + AlterBrains + (C) 2009-2012 AlterBrains. All rights reserved. + GNU General Public License version 2 or later; see LICENSE.txt + alterbrains@gmail.com + http://alterbrains.com + + 12/03/2012 + 2.1.5 + PLG_SYSTEM_MIGHTYSITES_DESC + + + mightysites.php + index.html + + + mightysites.script.php + + + en-GB.plg_system_mightysites.ini + en-GB.plg_system_mightysites.sys.ini + + + + \ No newline at end of file diff --git a/deployed/mightysites/plugins/system/mightysites_single/index.html b/deployed/mightysites/plugins/system/mightysites_single/index.html new file mode 100644 index 00000000..2efb97f3 --- /dev/null +++ b/deployed/mightysites/plugins/system/mightysites_single/index.html @@ -0,0 +1 @@ + diff --git a/deployed/mightysites/plugins/system/mightysites_single/mightysites_single.php b/deployed/mightysites/plugins/system/mightysites_single/mightysites_single.php new file mode 100644 index 00000000..21126a03 --- /dev/null +++ b/deployed/mightysites/plugins/system/mightysites_single/mightysites_single.php @@ -0,0 +1,55 @@ +isAdmin()) { + return; +} + +class plgSystemMightysites_single extends JPlugin +{ + public function onAfterRoute() + { + $app = JFactory::getApplication(); + + if (isset($_GET['mighty_login'])) { + if (!JFactory::getUser()->id) { + ob_start(); + jimport('joomla.utilities.simplecrypt'); + jimport('joomla.utilities.utility'); + + $key = md5(JFactory::getConfig()->get('secret') . @$_SERVER['HTTP_USER_AGENT']); + $crypt = new JSimpleCrypt($key); + $str = $crypt->decrypt(base64_decode(implode('', $app->input->get('mighty_login', array(), 'array')))); + + $credentials = @unserialize($str); + + $app->login($credentials, array( + 'silent' => true, + 'remember' => isset($credentials['remember']) ? $credentials['remember'] : false, + )); + ob_end_clean(); + + header('P3P: CP="NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM"'); + } + echo '// ', JFactory::getUser()->id; + exit(); + } + + if (isset($_GET['mighty_logout'])) { + if (JFactory::getUser()->id) { + ob_start(); + $result = $app->logout(); + ob_end_clean(); + } + echo '// ', JFactory::getUser()->id; + exit(); + } + } +} + diff --git a/deployed/mightysites/plugins/system/mightysites_single/mightysites_single.script.php b/deployed/mightysites/plugins/system/mightysites_single/mightysites_single.script.php new file mode 100644 index 00000000..31653243 --- /dev/null +++ b/deployed/mightysites/plugins/system/mightysites_single/mightysites_single.script.php @@ -0,0 +1,22 @@ +enqueueMessage(JText::_('Successfully installed "System - MightySites single login/logout" plugin!')); + } + + function uninstall($parent) { + JFactory::getApplication()->enqueueMessage(JText::_('Successfully uninstalled "System - MightySites single login/logout" plugin!')); + } + + function update($parent) { + JFactory::getApplication()->enqueueMessage(JText::_('Successfully updated "System - MightySites single login/logout" plugin!')); + } + +} \ No newline at end of file diff --git a/deployed/mightysites/plugins/system/mightysites_single/mightysites_single.xml b/deployed/mightysites/plugins/system/mightysites_single/mightysites_single.xml new file mode 100644 index 00000000..c155d828 --- /dev/null +++ b/deployed/mightysites/plugins/system/mightysites_single/mightysites_single.xml @@ -0,0 +1,27 @@ + + + PLG_SYSTEM_MIGHTYSITES_SINGLE + + AlterBrains + (C) 2009-2013 AlterBrains. All rights reserved. + GNU General Public License version 2 or later; see LICENSE.txt + alterbrains@gmail.com + http://alterbrains.com + + 12/03/2012 + 2.1.5 + PLG_SYSTEM_MIGHTYSITES_SINGLE_DESC + + + mightysites_single.php + index.html + + + mightysites_single.script.php + + + en-GB.plg_system_mightysites_single.sys.ini + + + + \ No newline at end of file