~ubuntu-drupal-devs/ubuntu-drupal-countdown/6.x

41 by Michael Lustfield
Moving settings and cron to individual files
1
<?php
2
// $Id$
3
4
/**
5
 * @file
6
 * Cron function
7
 *
8
 * The cron for this module is large so it's in it's own file.
9
 */
10
11
/**
12
 * Cron function
13
 */
42 by Michael Lustfield
Adding ability to force cron and using it during installation process.
14
function udcountdown_cron_run($force = FALSE) {
41 by Michael Lustfield
Moving settings and cron to individual files
15
  $cache = file_directory_path() . "/countdown/";
16
  $pointerver = trim(file_get_contents('http://edge.launchpad.net/ubuntu-drupal-countdown/misc/release-version/+download/pointer'));
17
  $pointer = 'https://launchpad.net/ubuntu-drupal-countdown/banners/' . $pointerver;
18
43 by Michael Lustfield
Fixing simple bug
19
  udcountdown_checkver($cache, $pointer, $force);
41 by Michael Lustfield
Moving settings and cron to individual files
20
}
21
22
/**
23
 * Check if banner source changed
24
 */
43 by Michael Lustfield
Fixing simple bug
25
function udcountdown_checkver($cache, $pointer, $force = FALSE) {
45 by Robert Grønning
No longer using php_curl to get rv based on patch in bug 540603.
26
  $curval = file_get_contents($pointer .  '/+download/rv');
41 by Michael Lustfield
Moving settings and cron to individual files
27
47 by Michael Lustfield
Fixing minor bugs (probably wouldn't affect anyone anyway)
28
  $relver = variable_get('udcountdown_relver', 'aaaa01');
41 by Michael Lustfield
Moving settings and cron to individual files
29
42 by Michael Lustfield
Adding ability to force cron and using it during installation process.
30
  if ($relver != $curval || $force == TRUE) {
41 by Michael Lustfield
Moving settings and cron to individual files
31
    udcountdown_pullver($cache, $pointer);
32
    variable_set('udcountdown_relver', $curval);
33
  }
34
}
35
36
/**
37
 * Pull latest banner source
38
 */
39
function udcountdown_pullver($cache, $pointer) {
40
  shell_exec('rm -rf ' . $cache);
47 by Michael Lustfield
Fixing minor bugs (probably wouldn't affect anyone anyway)
41
  shell_exec('mkdir ' . $cache);
49 by Michael Lustfield
Adding --quiet to wget to prevent excess logs
42
  shell_exec('/usr/bin/wget --quiet -nd -m -P ' . $cache . ' ' . $pointer . '/+download/banners.tgz');
47 by Michael Lustfield
Fixing minor bugs (probably wouldn't affect anyone anyway)
43
  shell_exec('cd ' . $cache . ' && tar zxf banners.tgz ');
41 by Michael Lustfield
Moving settings and cron to individual files
44
}
45