function updateAddons($addons) { $installedHash = getInstalledHash(); $currentGeneralSettings = Reg::get('settings'); foreach ($addons as $key => $addon) { appUpdateMsg('Checking download for ' . $addon['slug'] . '...'); $downloadCheckLink = getOption('serviceURL') . 'download.php?appInstallHash=' . APP_INSTALL_HASH . '&installedHash=' . $installedHash . '&appVersion=' . APP_VERSION . '&type=addon&downloadType=update&download=' . $addon['slug'] . '&downloadVersion=' . $addon['version']; if ($currentGeneralSettings['participateBeta'] == 1) { $downloadCheckLink .= '&participateBeta=1'; } $temp = doCall($downloadCheckLink, '', $timeout = 30); list($result, , , $curlInfo) = $temp; //$result = base64_decode($result); //$result = @unserialize($result); $result = getServiceResponseToArray($result); $cURLErrors = new cURLErrors($curlInfo); if ($cURLErrors->isOk()) { if ($result['status'] == 'success') { $addons[$key]['downloadLink'] = $result['downloadLink']; //$downloadCheckLink.'&checked=true'; } elseif ($result['status'] == 'error') { unset($addons[$addon['slug']]); appUpdateMsg('Error while downloading addon ' . $addon['slug'] . ': ' . $result['errorMsg']); } } else { unset($addons[$addon['slug']]); appUpdateMsg('Error while downloading addon ' . $addon['slug'] . ': Unable to communicate with server(' . $cURLErrors->getErrorMsg() . ').'); } } downloadAndUnzipAddons($addons); foreach ($addons as $addon) { if ($addon['process']['unzipDone']) { //$addon['process']['updated'] = true; include APP_ROOT . '/addons/' . $addon['slug'] . '/addon.' . $addon['slug'] . '.php'; $prevVer = DB::getField("?:addons", "updateCurrentVersion", "slug = '" . $addon['slug'] . "'"); if (method_exists('addon' . ucfirst($addon['slug']), 'update')) { call_user_func(array('addon' . ucfirst($addon['slug']), 'update')); } $newAddonVersion = getAddonVersion($addon['slug']); $optionVer['action'] = 'updated'; $optionVer['actionTime'] = time(); $optionVer['prevVer'] = $prevVer; $optionVer['newVer'] = $newAddonVersion; $optionVer['slug'] = $addon['slug']; manipulateOption('versionLogs', $optionVer); DB::update("?:addons", array('updateCurrentVersion' => $newAddonVersion), "slug = '" . $addon['slug'] . "'"); //updating in database that addon is updated //remove updateAvailable for this addon so that it will stop false update notification in next browser app load $updateAddonsAvailable = @unserialize(getOption('updateAddonsAvailable')); if (isset($updateAddonsAvailable[$addon['slug']]['updateAvailable']) && !empty($updateAddonsAvailable[$addon['slug']]['updateAvailable'])) { unset($updateAddonsAvailable[$addon['slug']]['updateAvailable']); updateOption('updateAddonsAvailable', serialize($updateAddonsAvailable)); } appUpdateMsg('Addon ' . $addon['slug'] . ' successfully updated.'); } } appUpdateMsg('<br>Please <a href="' . APP_URL . '" target="_top">click here</a> to reload the app.'); updateOption('updateLastCheck', 0); //to trigger checkUpdate in next page load //$_SESSION['addonAlertCount'] = 0; //manageCookies::cookieSet('addonAlertCount',0,array('expire'=>0)); updateOption('addonAlertCount', '0'); }
public static function IWPAuthUser($params) { $registerURL = IWP_SITE_URL . 'app-login/'; $noCache = '?no-cache-iwp=' . md5(microtime(true) . uniqid('', true) . substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, rand(20, 60))); $registerURL .= $noCache; $data = array('appInstallHash' => APP_INSTALL_HASH, 'installedHash' => getInstalledHash()); $params['appDetails'] = base64_encode(serialize($data)); list($rawResponseData, , , $curlInfo) = doCall($registerURL, $params, $timeout = 30, array('normalPost' => 1)); $cURLErrors = new cURLErrors($curlInfo); if (!$cURLErrors->isOk() && $curlInfo['info']['http_code'] != 403) { $errorResponse = array(); $errorResponse['netError'] = 1; $errorResponse['errorMsg'] = $cURLErrors->getErrorMsg(); return $errorResponse; } return json_decode($rawResponseData); }