pingGetServices() public method

Get the ping services
Deprecation:
public pingGetServices ( ) : array
return array
コード例 #1
0
ファイル: Model.php プロジェクト: bwgraves/forkcms
 /**
  * Ping the known webservices
  *
  * @param string $pageOrFeedURL The page/feed that has changed.
  * @param string $category      An optional category for the site.
  * @return bool If everything went fne true will, otherwise false.
  */
 public static function ping($pageOrFeedURL = null, $category = null)
 {
     $siteTitle = self::get('fork.settings')->get('Core', 'site_title_' . Language::getWorkingLanguage(), SITE_DEFAULT_TITLE);
     $siteURL = SITE_URL;
     $pageOrFeedURL = $pageOrFeedURL !== null ? (string) $pageOrFeedURL : null;
     $category = $category !== null ? (string) $category : null;
     // get ping services
     $pingServices = self::get('fork.settings')->get('Core', 'ping_services', null);
     // no ping services available or older than one month ago
     if ($pingServices === null || $pingServices['date'] < strtotime('-1 month')) {
         // get ForkAPI-keys
         $publicKey = self::get('fork.settings')->get('Core', 'fork_api_public_key', '');
         $privateKey = self::get('fork.settings')->get('Core', 'fork_api_private_key', '');
         // validate keys
         if ($publicKey == '' || $privateKey == '') {
             return false;
         }
         // require the class
         require_once PATH_LIBRARY . '/external/fork_api.php';
         // create instance
         $forkAPI = new \ForkAPI($publicKey, $privateKey);
         // try to get the services
         try {
             $pingServices['services'] = $forkAPI->pingGetServices();
             $pingServices['date'] = time();
         } catch (Exception $e) {
             // check if the error should not be ignored
             if (strpos($e->getMessage(), 'Operation timed out') === false && strpos($e->getMessage(), 'Invalid headers') === false) {
                 if (BackendModel::getContainer()->getParameter('kernel.debug')) {
                     throw $e;
                 } else {
                     // stop, hammertime
                     return false;
                 }
             }
         }
         // store the services
         self::get('fork.settings')->set('Core', 'ping_services', $pingServices);
     }
     // make sure services array will not trigger an error (even if we couldn't load any)
     if (!isset($pingServices['services']) || !$pingServices['services']) {
         $pingServices['services'] = array();
     }
     // loop services
     foreach ($pingServices['services'] as $service) {
         $client = new \SpoonXMLRPCClient($service['url']);
         $client->setUserAgent('Fork ' . FORK_VERSION);
         $client->setTimeOut(10);
         $client->setPort($service['port']);
         try {
             // extended ping?
             if ($service['type'] == 'extended') {
                 // no page or feed URL present?
                 if ($pageOrFeedURL === null) {
                     continue;
                 }
                 $parameters[] = array('type' => 'string', 'value' => $siteTitle);
                 $parameters[] = array('type' => 'string', 'value' => $siteURL);
                 $parameters[] = array('type' => 'string', 'value' => $pageOrFeedURL);
                 if ($category !== null) {
                     $parameters[] = array('type' => 'string', 'value' => $category);
                 }
                 $client->execute('weblogUpdates.extendedPing', $parameters);
             } else {
                 // default ping
                 $parameters[] = array('type' => 'string', 'value' => $siteTitle);
                 $parameters[] = array('type' => 'string', 'value' => $siteURL);
                 $client->execute('weblogUpdates.ping', $parameters);
             }
         } catch (Exception $e) {
             // check if the error should not be ignored
             if (strpos($e->getMessage(), 'Operation timed out') === false && strpos($e->getMessage(), 'Invalid headers') === false) {
                 if (BackendModel::getContainer()->getParameter('kernel.debug')) {
                     throw $e;
                 }
             }
             continue;
         }
     }
     return true;
 }
コード例 #2
0
ファイル: installer.php プロジェクト: naujasdizainas/forkcms
 /**
  * Store the settings
  */
 private function setSettings()
 {
     // languages settings
     $this->setSetting('core', 'languages', $this->getLanguages(), true);
     $this->setSetting('core', 'active_languages', $this->getLanguages(), true);
     $this->setSetting('core', 'redirect_languages', $this->getLanguages(), true);
     $this->setSetting('core', 'default_language', $this->getVariable('default_language'), true);
     $this->setSetting('core', 'interface_languages', $this->getInterfaceLanguages(), true);
     $this->setSetting('core', 'default_interface_language', $this->getVariable('default_interface_language'), true);
     // other settings
     $this->setSetting('core', 'theme');
     $this->setSetting('core', 'akismet_key', '');
     $this->setSetting('core', 'google_maps_key', '');
     $this->setSetting('core', 'max_num_revisions', 20);
     $this->setSetting('core', 'site_domains', array($this->getVariable('site_domain')));
     $this->setSetting('core', 'site_html_header', '');
     $this->setSetting('core', 'site_html_footer', '');
     // date & time
     $this->setSetting('core', 'date_format_short', 'j.n.Y');
     $this->setSetting('core', 'date_formats_short', array('j/n/Y', 'j-n-Y', 'j.n.Y', 'n/j/Y', 'n/j/Y', 'n/j/Y', 'd/m/Y', 'd-m-Y', 'd.m.Y', 'm/d/Y', 'm-d-Y', 'm.d.Y', 'j/n/y', 'j-n-y', 'j.n.y', 'n/j/y', 'n-j-y', 'n.j.y', 'd/m/y', 'd-m-y', 'd.m.y', 'm/d/y', 'm-d-y', 'm.d.y'));
     $this->setSetting('core', 'date_format_long', 'l j F Y');
     $this->setSetting('core', 'date_formats_long', array('j F Y', 'D j F Y', 'l j F Y', 'j F, Y', 'D j F, Y', 'l j F, Y', 'd F Y', 'd F, Y', 'F j Y', 'D F j Y', 'l F j Y', 'F d, Y', 'D F d, Y', 'l F d, Y'));
     $this->setSetting('core', 'time_format', 'H:i');
     $this->setSetting('core', 'time_formats', array('H:i', 'H:i:s', 'g:i a', 'g:i A'));
     // number formats
     $this->setSetting('core', 'number_format', 'dot_nothing');
     $this->setSetting('core', 'number_formats', array('comma_nothing' => '10000,25', 'dot_nothing' => '10000.25', 'dot_comma' => '10,000.25', 'comma_dot' => '10.000,25', 'dot_space' => '10000.25', 'comma_space' => '10 000,25'));
     // e-mail settings
     $this->setSetting('core', 'mailer_from', array('name' => 'Fork CMS', 'email' => $this->getVariable('spoon_debug_email')));
     $this->setSetting('core', 'mailer_to', array('name' => 'Fork CMS', 'email' => $this->getVariable('spoon_debug_email')));
     $this->setSetting('core', 'mailer_reply_to', array('name' => 'Fork CMS', 'email' => $this->getVariable('spoon_debug_email')));
     // stmp settings
     $this->setSetting('core', 'smtp_server', $this->getVariable('smtp_server'));
     $this->setSetting('core', 'smtp_port', $this->getVariable('smtp_port'));
     $this->setSetting('core', 'smtp_username', $this->getVariable('smtp_username'));
     $this->setSetting('core', 'smtp_password', $this->getVariable('smtp_password'));
     // default titles
     $siteTitles = array('en' => 'My website', 'cn' => '我的网站', 'nl' => 'Mijn website', 'fr' => 'Mon site web', 'de' => 'Meine Webseite', 'hu' => 'Hhonlapom', 'it' => 'Il mio sito web', 'ru' => 'мой сайт', 'es' => 'Mi sitio web');
     // language specific
     foreach ($this->getLanguages() as $language) {
         // set title
         $this->setSetting('core', 'site_title_' . $language, isset($siteTitles[$language]) ? $siteTitles[$language] : $this->getVariable('site_title'));
     }
     /*
      * We're going to try to install the settings for the api.
      */
     require_once PATH_LIBRARY . '/external/fork_api.php';
     // create new instance
     $api = new ForkAPI();
     try {
         // get the keys
         $keys = $api->coreRequestKeys($this->getVariable('site_domain'), $this->getVariable('api_email'));
         // api settings
         $this->setSetting('core', 'fork_api_public_key', $keys['public']);
         $this->setSetting('core', 'fork_api_private_key', $keys['private']);
         // set keys
         $api->setPublicKey($keys['public']);
         $api->setPrivateKey($keys['private']);
         // get services
         $services = (array) $api->pingGetServices();
         // set services
         if (!empty($services)) {
             $this->setSetting('core', 'ping_services', array('services' => $services, 'date' => time()));
         }
     } catch (Exception $e) {
         // we don't need those keys.
     }
     // ckfinder
     $this->setSetting('core', 'ckfinder_license_name', 'Fork CMS');
     $this->setSetting('core', 'ckfinder_license_key', 'QJH2-32UV-6VRM-V6Y7-A91J-W26Z-3F8R');
 }
コード例 #3
0
ファイル: CoreInstaller.php プロジェクト: forkcms/forkcms
 /**
  * Store the settings
  */
 private function setSettings()
 {
     // languages settings
     $this->setSetting('Core', 'languages', $this->getLanguages(), true);
     $this->setSetting('Core', 'active_languages', $this->getLanguages(), true);
     $this->setSetting('Core', 'redirect_languages', $this->getLanguages(), true);
     $this->setSetting('Core', 'default_language', $this->getVariable('default_language'), true);
     $this->setSetting('Core', 'interface_languages', $this->getInterfaceLanguages(), true);
     $this->setSetting('Core', 'default_interface_language', $this->getVariable('default_interface_language'), true);
     // other settings
     $this->setSetting('Core', 'theme');
     $this->setSetting('Core', 'akismet_key', '');
     $this->setSetting('Core', 'google_maps_key', '');
     $this->setSetting('Core', 'max_num_revisions', 20);
     $this->setSetting('Core', 'site_domains', array($this->getVariable('site_domain')));
     $this->setSetting('Core', 'site_html_header', '');
     $this->setSetting('Core', 'site_html_footer', '');
     // date & time
     $this->setSetting('Core', 'date_format_short', 'j.n.Y');
     $this->setSetting('Core', 'date_formats_short', array('j/n/Y', 'j-n-Y', 'j.n.Y', 'n/j/Y', 'n/j/Y', 'n/j/Y', 'd/m/Y', 'd-m-Y', 'd.m.Y', 'm/d/Y', 'm-d-Y', 'm.d.Y', 'j/n/y', 'j-n-y', 'j.n.y', 'n/j/y', 'n-j-y', 'n.j.y', 'd/m/y', 'd-m-y', 'd.m.y', 'm/d/y', 'm-d-y', 'm.d.y'));
     $this->setSetting('Core', 'date_format_long', 'l j F Y');
     $this->setSetting('Core', 'date_formats_long', array('j F Y', 'D j F Y', 'l j F Y', 'j F, Y', 'D j F, Y', 'l j F, Y', 'd F Y', 'd F, Y', 'F j Y', 'D F j Y', 'l F j Y', 'F d, Y', 'D F d, Y', 'l F d, Y'));
     $this->setSetting('Core', 'time_format', 'H:i');
     $this->setSetting('Core', 'time_formats', array('H:i', 'H:i:s', 'g:i a', 'g:i A'));
     // number formats
     $this->setSetting('Core', 'number_format', 'dot_nothing');
     $this->setSetting('Core', 'number_formats', array('comma_nothing' => '10000,25', 'dot_nothing' => '10000.25', 'dot_comma' => '10,000.25', 'comma_dot' => '10.000,25', 'dot_space' => '10000.25', 'comma_space' => '10 000,25'));
     // e-mail settings
     $this->setSetting('Core', 'mailer_from', array('name' => 'Fork CMS', 'email' => $this->getVariable('spoon_debug_email')));
     $this->setSetting('Core', 'mailer_to', array('name' => 'Fork CMS', 'email' => $this->getVariable('spoon_debug_email')));
     $this->setSetting('Core', 'mailer_reply_to', array('name' => 'Fork CMS', 'email' => $this->getVariable('spoon_debug_email')));
     // stmp settings
     $this->setSetting('Core', 'smtp_server', $this->getVariable('smtp_server'));
     $this->setSetting('Core', 'smtp_port', $this->getVariable('smtp_port'));
     $this->setSetting('Core', 'smtp_username', $this->getVariable('smtp_username'));
     $this->setSetting('Core', 'smtp_password', $this->getVariable('smtp_password'));
     // default titles
     $siteTitles = array('en' => 'My website', 'bg' => 'уебсайта си', 'zh' => '我的网站', 'cs' => 'můj web', 'nl' => 'Mijn website', 'fr' => 'Mon site web', 'de' => 'Meine Webseite', 'el' => 'ιστοσελίδα μου', 'hu' => 'Hhonlapom', 'it' => 'Il mio sito web', 'ja' => '私のウェブサイト', 'lt' => 'mano svetainė', 'pl' => 'moja strona', 'ro' => 'site-ul meu', 'ru' => 'мой сайт', 'es' => 'Mi sitio web', 'sv' => 'min hemsida', 'tr' => 'web siteme', 'uk' => 'мій сайт');
     // language specific
     foreach ($this->getLanguages() as $language) {
         // set title
         $this->setSetting('Core', 'site_title_' . $language, isset($siteTitles[$language]) ? $siteTitles[$language] : $this->getVariable('site_title'));
     }
     // @TODO this should be removed when the api is kicked out
     // create new instance
     require_once PATH_LIBRARY . '/external/fork_api.php';
     $api = new \ForkAPI();
     try {
         // get the keys
         $keys = $api->coreRequestKeys($this->getVariable('site_domain'), $this->getVariable('api_email'));
         // api settings
         $this->setSetting('Core', 'fork_api_public_key', $keys['public']);
         $this->setSetting('Core', 'fork_api_private_key', $keys['private']);
         // set keys
         $api->setPublicKey($keys['public']);
         $api->setPrivateKey($keys['private']);
         // get services
         $services = (array) $api->pingGetServices();
         // set services
         if (!empty($services)) {
             $this->setSetting('Core', 'ping_services', array('services' => $services, 'date' => time()));
         }
     } catch (\Exception $e) {
         // we don't need those keys.
     }
     // ckfinder
     $this->setSetting('Core', 'ckfinder_license_name', 'Fork CMS');
     $this->setSetting('Core', 'ckfinder_license_key', 'VNA6-BP17-T7D3-CP1B-EMJF-X7Q3-5THF');
 }