Пример #1
0
 static function getExtensions()
 {
     if (ExtensionsFactory::$extensions == null) {
         $extensions = array();
         $directoryName = dirname(dirname(__FILE__)) . DS . 'features';
         $handle = opendir($directoryName);
         while (false !== ($file = readdir($handle))) {
             if (substr($file, strlen($file) - 4) == ".php") {
                 include $directoryName . DS . $file;
             }
         }
         ExtensionsFactory::$extensions = $extensions;
     }
     return ExtensionsFactory::$extensions;
 }
Пример #2
0
 public function onContentAfterSave($context, &$article, $isNew)
 {
     $db =& JFactory::getDBO();
     $db->setQuery("SELECT enable_google_ping from  #__seoboss_settings ");
     $settings =& $db->loadObject();
     if ($settings->enable_google_ping) {
         $className = get_class($article);
         require_once JPATH_ADMINISTRATOR . DS . "components" . DS . "com_seoboss" . DS . "classes" . DS . "ExtensionsFactory.php";
         $extensions = ExtensionsFactory::getExtensions();
         if (is_array($extensions) && is_array($extensions['ping'])) {
             foreach ($extensions['ping'] as $pingHandler) {
                 if ($pingHandler['class'] == $className) {
                     require_once JPATH_ADMINISTRATOR . DS . "components" . DS . "com_seoboss" . DS . $pingHandler['file'];
                     $url = '';
                     $rss = '';
                     if (function_exists($pingHandler['function'])) {
                         eval('$url=' . $pingHandler['function'] . '(&$article, $isNew);');
                     }
                     if (function_exists($pingHandler['rss_function'])) {
                         eval('$rss=' . $pingHandler['rss_function'] . '();');
                     }
                     if ($url) {
                         $db->setQuery("SELECT `domain` FROM `#__seoboss_settings`");
                         $domainName = $db->loadResult();
                         require_once JPATH_ADMINISTRATOR . DS . "components" . DS . "com_seoboss" . DS . "classes" . DS . "Pinger.php";
                         $config =& JFactory::getConfig();
                         $pinger = new Pinger();
                         $result = $pinger->pingGoogle($config->getValue('config.sitename'), "http://{$domainName}", "http://{$domainName}{$url}", "http://{$domainName}{$rss}");
                         $db->setQuery("INSERT INTO #__seoboss_ping_status\n                                    (`date`, `title`, `url`, `response_code`, `response_text`) VALUES (\n                                    NOW(), " . $db->quote($article->title) . ", " . $db->quote($url) . ", " . $db->quote($result[0]) . "," . $db->quote($result[1]) . ")");
                         $db->query();
                     }
                     break;
                 }
             }
         }
     }
 }