Ejemplo n.º 1
0
 /**
  *
  *
  * @param bool $Enabled
  * @return array|bool
  * @throws Exception
  */
 public function getAddonUpdates($Enabled = false)
 {
     // Get the addons on this site.
     $MyAddons = $this->getAddons($Enabled);
     // Build the query for them.
     $Slugs = array_keys($MyAddons);
     array_map('urlencode', $Slugs);
     $SlugsString = implode(',', $Slugs);
     $Url = $this->AddonSiteUrl . '/addon/getlist.json?ids=' . $SlugsString;
     $SiteAddons = proxyRequest($Url);
     $UpdateAddons = array();
     if ($SiteAddons) {
         $SiteAddons = val('Addons', json_decode($SiteAddons, true));
         $UpdateAddons = $this->compareAddons($MyAddons, $SiteAddons);
     }
     return $UpdateAddons;
 }
Ejemplo n.º 2
0
 /**
  * Updates provider list which is held in cache.
  *
  * Plugin comes with a fallback if providers can not be loaded from cache.
  * TODO: error checking!
  *
  * @package mailchecker
  * @since 0.2
  * @return integer Number of providers in list.
  */
 private function updateList()
 {
     // Create path for spam providers list file.
     mkdir(PATH_CACHE . '/mailchecker');
     // Get main list from GitHub.
     $url = 'https://raw.githubusercontent.com/FGRibreau/mailchecker/master/list.json';
     $bareboneList = proxyRequest($url);
     // Save as backup.
     file_put_contents(PATH_CACHE . '/mailchecker/list.cjson', $bareboneList);
     // Convert to array.
     $list = '<?php $providerList = ' . $bareboneList . ';';
     file_put_contents(PATH_CACHE . '/mailchecker/list.php', $list);
     // Get array from file.
     require_once PATH_CACHE . '/mailchecker/list.php';
     // "Flatten" array.
     $providers = [];
     array_walk_recursive($providerList, function ($item, $key) use(&$providers) {
         $providers[] = $item;
     });
     // Write flattened array to final file.
     file_put_contents(PATH_CACHE . '/mailchecker/providers.php', '<?php $providers = ' . var_export($providers, true) . ';');
     $providers = '';
     require_once PATH_CACHE . '/mailchecker/providers.php';
     // Return count of spam providers in the list.
     return count($providers);
 }