[phpmix-cvs] drupal/modules/akismet akismet.module,1.14,1.15
Status: Pre-Alpha
Brought to you by:
markus_petrux
From: <php...@li...> - 2006-06-10 02:30:13
|
Update of /cvsroot/phpmix/drupal/modules/akismet In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30743 Modified Files: akismet.module Log Message: Simple relocation of some functions. Index: akismet.module =================================================================== RCS file: /cvsroot/phpmix/drupal/modules/akismet/akismet.module,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** akismet.module 10 Jun 2006 02:19:17 -0000 1.14 --- akismet.module 10 Jun 2006 02:30:10 -0000 1.15 *************** *** 34,116 **** /** - * Check module version. - * - * @param boolean FALSE will return a cached value (if exists); otherwise it will perform a real time connection. - * @return string The latest released module version, - * NFND if the server reports "Module Not Found" (something that shouldn't happen) or - * an empty string if connection fails (reason logged to watchdog). - */ - function _akismet_check_version($refresh = FALSE) { - global $base_url; - $version_string = variable_get('akismet_version_string', FALSE); - $timestamp_now = time(); - if (!$version_string) { - $refresh = TRUE; - } - else { - $timestamp_age = variable_get('akismet_version_check_age', 604800); - if ($timestamp_age > 0) { - $timestamp_last = variable_get('akismet_version_check_timestamp', 0); - if (($timestamp_last + $timestamp_age) < $timestamp_now) { - $refresh = TRUE; - } - } - } - if ($refresh) { - $version_url = AKISMET_MODULE_HOMEURL .'/version'; - $result = drupal_http_request($version_url, array('User-Agent' => AKISMET_MODULE_USERAGENT, 'Referer' => $base_url . base_path())); - if (!isset($result->code) || !in_array($result->code, array(200,302,307)) || empty($result->data)) { - watchdog('version check', t('Could not check version of akismet module, due to "%error".', array('%error' => theme('placeholder', $result->code .' '. $result->error))), WATCHDOG_ERROR, l(t('check'), $version_url, array('target'=>'_blank'), NULL, NULL, TRUE)); - return ''; - } - $new_version = trim($result->data); - if (AKISMET_MODULE_VERSION != $new_version) { - watchdog('version check', t('New version of akismet module seems to be available. Your currently installed version is <strong>%your-version</strong>. The latest available version is <strong>%new-version</strong>.', array('%your-version' => AKISMET_MODULE_VERSION, '%new-version' => $new_version)), WATCHDOG_WARNING, l(t('module home'), AKISMET_MODULE_HOMEURL, array('target'=>'_blank'), NULL, NULL, TRUE)); - } - else { - watchdog('version check', t('Your version of akismet module is up to date.'), WATCHDOG_WARNING, l(t('module home'), AKISMET_MODULE_HOMEURL, array('target'=>'_blank'), NULL, NULL, TRUE)); - } - $version_string = $new_version; - variable_set('akismet_version_string', $version_string); - variable_set('akismet_version_check_timestamp', $timestamp_now); - } - return $version_string; - } - - /** - * Get version information message. - * - * @param string URL of the current page. - * @return string - */ - function _akismet_get_version_message($url) { - global $user; - if ($user->uid != 1) { - return ''; - } - $new_version = _akismet_check_version(isset($_GET['vchk']) ? TRUE : FALSE); - $output = '<p>'; - if (empty($new_version)) { - $output .= t('Sorry, could not connect to remote server to check for version information. Please, consult the <a href="%admin-logs">log</a> for details.', array('%admin-logs' => url('admin/logs'))); - } - else { - if (isset($_GET['vchk'])) { - drupal_goto($url); - } - if ($new_version != AKISMET_MODULE_VERSION) { - $output .= t('Your installation does <strong>not</strong> seem to be up to date. Updates are available, please visit the <a href="%module-url" target="_blank">Akismet module home</a> to obtain the latest version. The latest available version is <strong>%new-version</strong>. ', array('%module-url' => AKISMET_MODULE_HOMEURL, '%new-version' => $new_version)); - } - } - $output .= t('You are running version <strong>%your-version</strong>.', array('%your-version' => AKISMET_MODULE_VERSION)); - $timestamp_last = variable_get('akismet_version_check_timestamp', 0); - if ($timestamp_last) { - $output .= ' '. t('Last time checked: <strong>%last</strong>. The time is now %time.', array('%last' => format_date($timestamp_last), '%time' => format_date(time()))); - } - $output .= ' '. t('<a href="%check">Check for newest version</a>.', array('%check' => url($url, 'vchk=1'))); - $output .= '</p>'; - return $output; - } - - /** * Implementation of hook_help(). */ --- 34,37 ---- *************** *** 1458,1461 **** --- 1379,1465 ---- /************************************************************\ + phpMiX Version Checker + \************************************************************/ + + /** + * Check module version. + * + * @param boolean FALSE will return a cached value (if exists); otherwise it will perform a real time connection. + * @return string The latest released module version, + * NFND if the server reports "Module Not Found" (something that shouldn't happen) or + * an empty string if connection fails (reason logged to watchdog). + */ + function _akismet_check_version($refresh = FALSE) { + global $base_url; + $version_string = variable_get('akismet_version_string', FALSE); + $timestamp_now = time(); + if (!$version_string) { + $refresh = TRUE; + } + else { + $timestamp_age = variable_get('akismet_version_check_age', 604800); + if ($timestamp_age > 0) { + $timestamp_last = variable_get('akismet_version_check_timestamp', 0); + if (($timestamp_last + $timestamp_age) < $timestamp_now) { + $refresh = TRUE; + } + } + } + if ($refresh) { + $version_url = AKISMET_MODULE_HOMEURL .'/version'; + $result = drupal_http_request($version_url, array('User-Agent' => AKISMET_MODULE_USERAGENT, 'Referer' => $base_url . base_path())); + if (!isset($result->code) || !in_array($result->code, array(200,302,307)) || empty($result->data)) { + watchdog('version check', t('Could not check version of akismet module, due to "%error".', array('%error' => theme('placeholder', $result->code .' '. $result->error))), WATCHDOG_ERROR, l(t('check'), $version_url, array('target'=>'_blank'), NULL, NULL, TRUE)); + return ''; + } + $new_version = trim($result->data); + if (AKISMET_MODULE_VERSION != $new_version) { + watchdog('version check', t('New version of akismet module seems to be available. Your currently installed version is <strong>%your-version</strong>. The latest available version is <strong>%new-version</strong>.', array('%your-version' => AKISMET_MODULE_VERSION, '%new-version' => $new_version)), WATCHDOG_WARNING, l(t('module home'), AKISMET_MODULE_HOMEURL, array('target'=>'_blank'), NULL, NULL, TRUE)); + } + else { + watchdog('version check', t('Your version of akismet module is up to date.'), WATCHDOG_WARNING, l(t('module home'), AKISMET_MODULE_HOMEURL, array('target'=>'_blank'), NULL, NULL, TRUE)); + } + $version_string = $new_version; + variable_set('akismet_version_string', $version_string); + variable_set('akismet_version_check_timestamp', $timestamp_now); + } + return $version_string; + } + + /** + * Get version information message. + * + * @param string URL of the current page. + * @return string + */ + function _akismet_get_version_message($url) { + global $user; + if ($user->uid != 1) { + return ''; + } + $new_version = _akismet_check_version(isset($_GET['vchk']) ? TRUE : FALSE); + $output = '<p>'; + if (empty($new_version)) { + $output .= t('Sorry, could not connect to remote server to check for version information. Please, consult the <a href="%admin-logs">log</a> for details.', array('%admin-logs' => url('admin/logs'))); + } + else { + if (isset($_GET['vchk'])) { + drupal_goto($url); + } + if ($new_version != AKISMET_MODULE_VERSION) { + $output .= t('Your installation does <strong>not</strong> seem to be up to date. Updates are available, please visit the <a href="%module-url" target="_blank">Akismet module home</a> to obtain the latest version. The latest available version is <strong>%new-version</strong>. ', array('%module-url' => AKISMET_MODULE_HOMEURL, '%new-version' => $new_version)); + } + } + $output .= t('You are running version <strong>%your-version</strong>.', array('%your-version' => AKISMET_MODULE_VERSION)); + $timestamp_last = variable_get('akismet_version_check_timestamp', 0); + if ($timestamp_last) { + $output .= ' '. t('Last time checked: <strong>%last</strong>. The time is now %time.', array('%last' => format_date($timestamp_last), '%time' => format_date(time()))); + } + $output .= ' '. t('<a href="%check">Check for newest version</a>.', array('%check' => url($url, 'vchk=1'))); + $output .= '</p>'; + return $output; + } + + /************************************************************\ Akismet API implementation \************************************************************/ |