Skip to content
Snippets Groups Projects
Commit e8ffa36f authored by ale's avatar ale
Browse files

initial commit

parents
No related branches found
No related tags found
No related merge requests found
BIN_PROGRAMS = \
noblogs \
noblogsmr \
on-all-blogs \
on-local-blogs
LIB_FILES = \
$(wildcard lib/*.php)
NOBLOGS_LIB_DIR = @NOBLOGS_LIB_DIR@
all:
install:
$(INSTALL) -d -m 755 $(DESTDIR)$(bindir)
(for f in $(BIN_PROGRAMS) ; do \
$(INSTALL) -m 755 $(srcdir)/bin/$$f $(DESTDIR)$(bindir)/$$f ; \
done)
$(INSTALL) -d -m 755 $(DESTDIR)$(NOBLOGS_LIB_DIR)
(for f in $(LIB_FILES:lib/%=%) ; do \
$(INSTALL) -m 755 $(srcdir)/lib/$$f $(DESTDIR)$(NOBLOGS_LIB_DIR)/$$f ; \
done)
README 0 → 100644
Tool di gestione di Noblogs
---------------------------
Per qualche ulteriore informazione, lanciare il comando 'noblogs'
senza argomenti, mostrera' un piccolo help.
Alcuni esempi di come usare i tool in bin/:
- Aggiornare tutti i blog dopo un upgrade di WP:
$ bin/on-all-blogs upgrade
- Aggiornare un singolo blog:
$ bin/noblogs upgrade cavallette
- Lanciare i cron job per i blog che sono ospitati sul server locale:
$ bin/on-local-blogs run-cron
#!/usr/bin/python
#
# Collects info on all blog, and aggregate it.
import os
import subprocess
import re
import sys
import json
from collections import defaultdict
ALL_BLOGS_BIN = os.path.abspath(
os.path.join(os.path.dirname(__file__), 'on-all-blogs'))
def get_option(opt):
pipe = subprocess.Popen([ALL_BLOGS_BIN, 'get-option', opt],
stdout=subprocess.PIPE)
data = defaultdict(int)
for match in re.finditer('(.*): (.*)',pipe.communicate()[0]):
value = match.group(2)
try:
for v in eval(value):
data[v] += 1
except (NameError, SyntaxError):
data[value] += 1
return dict(data)
def run(args):
print json.dumps(get_option(args[0]))
if __name__ == '__main__':
run(sys.argv[1:])
#!/opt/noblogs/bin/php-noblogs -f
<?php
function usage(){
echo USAGE<<
generate-noblogsmv-map <old_backend_list> <new_backend_list>
USAGE
}
//
//
// Stampa una mappa delle assegnazioni blog -> backend, per NGINX.
// IP interno del master.
define('NOBLOGS_MASTER', '172.16.1.10');
#
# Expected format of output:
#
# blog_id { "old_host": old_host, "new_host": new_host, "old_port": old_port, "old_user": old_user, "old_pass": old_pass, "old_db": old_db_name, ... }
#
// Load wordpress api.
define('WP_CACHE',false);
require_once('/opt/noblogs/www/wp-load.php');
// Get the maps
$new_topology = array_pop($argv);
$old_topology = array_pop($argv);
$replicas = array_pop($argv)
if (!($new_topology && $old_topology)) {
usage();
exit(-1);
}
//create the consistently hashed blog topologies
//note that if one of the files does not exist, this script will die here.
$n_hashmap = new Flexihash();
$new_map = noblogs_load_backends($old_topology, $n_hashmap);
$o_hashmap = new Flexihash(null, $replicas);
$old_map = noblogs_load_backends($new_topology, $o_hashmap);
//get all blogs
$blogs = noblogs_get_blogs();
foreach ($blogs as $blog) {
$id = $blog->blog_id;
if ( !preg_match('/^\d+$/', $blog_id) || $blog_id == 1 ) {
continue;
}
$old_params = fhash($blog_id, $old_map, $o_hashmap);
$new_params = fhash($blog_id, $new_map, $n_hashmap);
if (! is_blog_migrated($old_params, $new_params)) {
continue;
}
$map = array(
'old_host': $old_params['host'],
'old_port': $old_params['port'],
'old_user': $old_params['user'],
'old_pass': $old_params['password'],
'old_db': $old_params['db'],
'new_host': $new_params['host'],
'new_port': $new_params['port'],
'new_user': $new_params['user'],
'new_pass': $new_params['password'],
'new_db': $new_params['db']
);
printf("%s %s\n", $id, json_encode($map));
}
function fhash($dbid, $reversemap, $hashptr) {
$lookup = $hashptr->lookup($dbid);
$backend = $reversemap[$lookup];
$result = array();
if (preg_match('/^(.*):([0-9]*)$/', $backend['host'], $matches)) {
$result['host'] = $matches[1];
$result['port'] = $matches[2];
}
$result['user'] = $backend['user'];
$result['password'] = $backend['password'];
$result['db'] = $backend['name'];
$result['id'] = $dbid;
return $result;
}
function is_blog_migrated(&$old, &$new) {
if ($old['host'] != $new['host']) {
return 2;
}
if ($old['db'] != $new['db']) {
return 1;
}
return 0;
}
// Return all blogs.
function get_blogs() {
global $wpdb;
$sql = "SELECT blog_id, domain FROM $wpdb->blogs WHERE deleted = 0 AND archived = '0' ORDER BY domain ASC";
$result = $wpdb->get_results($sql);
return ($result);
}
function printline($s) {
echo $s . "\n";
}
function backend_to_http_endpoint($backend) {
if (substr($backend, 0, 8) != 'backend_') {
error_log('diamine, di questo backend non so che farmene: ' . $backend);
return NOBLOGS_MASTER . ':82';
}
$id = substr($backend, 8);
return '172.16.1.' . $id . ':82';
}
// Print the blog -> backend map.
function generate_map() {
global $wpdb;
$wpdb_hash = &$wpdb->hash_map;
$blogs = get_blogs();
printline('map $http_host $backend_noblogs {');
printline(' default http://' . NOBLOGS_MASTER . ':82;');
foreach ($blogs as $blog) {
$blog_id = $blog->blog_id;
if ($blog_id == 1)
continue;
$backend_id = $wpdb_hash->lookup($blog_id);
$backend_http = backend_to_http_endpoint($backend_id);
printline(' ' . $blog->domain . ' http://' . $backend_http . ';');
}
printline('}');
}
generate_map();
bin/mr 0 → 100755
#!/usr/bin/python
#
# Run a command on every Noblogs backend, with the local blog IDs
# as arguments.
#
# It is meant to be used just like 'xargs': pass a list of blog
# IDs as standard input, and give it a command to execute as
# argument: it will run the command locally on every backend,
# splitting the blog IDs.
import json
import os
import subprocess
import sys
import optparse
NOBLOGS_BIN = os.path.abspath(
os.path.join(os.path.dirname(__file__), 'noblogs'))
def get_backend_map():
pipe = subprocess.Popen([NOBLOGS_BIN, 'dump-shards'],
stdout=subprocess.PIPE)
data = json.loads(pipe.communicate()[0])
return dict((x, set(y)) for x, y in data.iteritems())
def host_from_backend(be):
return '172.16.1.%s' % be[8:]
def run(args):
# Read all blog IDs from standard input.
blog_ids = set(int(x.strip()) for x in sys.stdin)
backend_map = get_backend_map()
procs = {}
for backend, blogs in backend_map.iteritems():
blogs_on_this_backend = blog_ids.intersection(blogs)
if not blogs_on_this_backend:
continue
host = host_from_backend(backend)
cmd = 'echo %s | xargs -n 30 %s' % (
' '.join(map(str, blogs_on_this_backend)),
' '.join(args))
procs[host] = subprocess.Popen(['ssh', host, cmd])
for host, p in procs.iteritems():
status = p.wait()
if status != 0:
print 'ERROR on %s: command exited with status %d' % (
host, status)
if __name__ == '__main__':
run(sys.argv[1:])
#!@PHP@ -f
<?php
include('@NOBLOGS_LIB_DIR@/noblogs.php');
function help() {
?>
Usage: noblogs <COMMAND> [<ARGS>...]
Known commands:
info BLOG [...]
Print some basic information about one or more blogs.
connectdb BLOG
Connect to the MySQL instance that has the blog db.
get-option OPTION_NAME BLOG [...]
Print the value of an option for the specified blogs.
set-option OPTION_NAME OPTION_VALUE BLOG [...]
Set the value of an option for the specified blogs.
print-all-blogs
Print a list of all existing blog IDs.
print-local-blogs
Print a list of just those blog IDs that are hosted on this
server.
dump-shards
Print a JSON dictionary representing the full backend -> blogs
map.
check-upgrade BLOG [...]
Check whether the specified blogs need to be upgraded.
upgrade BLOG [...]
Upgrade the specified blogs. NOTE: upgrading a blog that is
not local is dangerous! Use the 'on-local-blogs' wrapper.
run-cron BLOG [...]
Run cron jobs for the specified blogs. NOTE: running cron jobs
for a blog that is not local is dangerous! Use the 'on-local-blogs'
wrapper.
fix-rewrites BLOG [...]
Fix broken rewrite rules for the specified blogs. NOTE: dangerous!!!!
close-comments-if-inactive BLOG [...]
Closes old posts for comments on non-active blogs.
remove-network-upgrade-message
Remove the 'network upgrade' message when all the blogs have
been upgraded individually.
update-friend-domains
Update the list of 'friend' email domains.
check-updates
Check for updates of core, plugins and themes.
Options:
-force prints the known updates when not checking for the new ones
-mail sends email to ai-changes@investici.org
-json print JSON output
<?php
exit(1);
}
// 'info': Return information about a single blog.
function do_info($args) {
foreach ($args as $arg) {
$blog = noblogs_get_blog($arg);
if (!$blog) {
die("Blog not found.\n");
}
$status = 'active';
if ($blog->deleted) {
$status = 'deleted';
} elseif ($blog->archived) {
$status = 'archived';
}
$dbinfo = noblogs_get_backend_for_blog($blog->blog_id);
echo "ID: {$blog->blog_id}\n";
echo "Name: {$blog->domain}\n";
echo "Host: {$dbinfo['host']}\n";
echo "Status: {$status}\n";
echo "Registered: {$blog->registered}\n";
echo "Last Update: {$blog->last_updated}\n";
echo "\n";
}
}
// 'connectdb': Connect to the database hosting a specific blog.
function do_connectdb($args) {
$blog = noblogs_get_blog($args[0]);
if (!$blog) {
die("Blog not found.\n");
}
$backend = noblogs_get_backend_for_blog($blog->blog_id);
echo "ID: {$blog->blog_id}\n";
$cmd = "mysql -A -h {$backend['host']} -P {$backend['port']} -u{$backend['user']} -p{$backend['password']} {$backend['db']}";
echo "$cmd\n";
//system($cmd);
}
// 'get-option': Print the value of a blog option.
function do_get_option($args) {
$option = $args[0];
if (!$option) {
echo "Not enough arguments\n";
help();
}
foreach (array_splice($args, 1) as $arg) {
$blog = noblogs_get_blog($arg);
if (!$blog) {
echo "Blog {$arg} not found.\n";
continue;
}
switch_to_blog($blog->blog_id);
$value = get_option($option);
if ($value) {
if (is_array($value)) {
// Use JSON as a string representation.
$value = json_encode($value);
}
echo "{$arg}: {$value}\n";
}
restore_current_blog();
}
}
// 'set-option': Set the value of a blog option.
function do_set_option($args) {
$option = array_shift($args);
if (!$option) {
echo "Not enough arguments\n";
help();
}
$value = array_shift($args);
if ($value === null) {
echo "Not enough arguments\n";
help();
}
foreach ($args as $arg) {
$blog = noblogs_get_blog($arg);
if (!$blog) {
echo "Blog {$arg} not found.\n";
continue;
}
switch_to_blog($blog->blog_id);
update_option($option, $value);
$nv = get_option($option);
echo "{$arg}: {$nv}\n";
restore_current_blog();
}
}
// 'dump-shards': Print a JSON dictionary representing the full map
// of backend -> blogs database mappings.
function do_dump_shards($args) {
$backend_map = noblogs_get_backend_map();
echo json_encode($backend_map);
echo "\n";
}
// 'print-all-blogs': List all blog IDs.
function do_print_all_blogs($args) {
$blogs = noblogs_get_blogs();
foreach ($blogs as $blog) {
echo "{$blog->blog_id}\n";
}
}
// 'print-local-blogs': List the blog IDs that are local to this machine.
function do_print_local_blogs($args) {
$local_blogs = noblogs_get_local_blogs();
foreach ($local_blogs as $b) {
echo $b . "\n";
}
}
// 'remove-network-upgrade-message': Remove the annoying "network
// upgrade necessary" banner from the dashboard.
function do_remove_network_upgrade_message($args) {
global $wp_db_version;
update_site_option('wpmu_upgrade_site', $wp_db_version);
}
// 'check-upgrade': Check if a blog needs to be upgraded.
function do_check_upgrade($args) {
global $wp_db_version;
foreach ($args as $arg) {
$blog = noblogs_get_blog($arg);
if (!$blog) {
echo "Blog {$arg} not found.\n";
continue;
}
switch_to_blog($blog->blog_id);
$db_version = get_option('db_version');
if ($db_version != $wp_db_version) {
echo "{$arg}: UPGRADE\n";
} else {
echo "{$arg}: ok\n";
}
restore_current_blog();
}
}
// 'upgrade': Upgrade a blog.
function do_upgrade($args) {
include(NOBLOGS_ROOT . "/wp-admin/includes/upgrade.php");
foreach ($args as $arg) {
$blog = noblogs_get_blog($arg);
if (!$blog) {
echo "Blog {$arg} not found.\n";
continue;
}
switch_to_blog($blog->blog_id);
wp_upgrade();
echo "{$arg}: ok\n";
restore_current_blog();
}
}
// 'run-cron': Run cron jobs.
function do_run_cron($args) {
foreach ($args as $arg) {
$blog = noblogs_get_blog($arg);
if (!$blog) {
echo "Blog {$arg} not found.\n";
continue;
}
switch_to_blog($blog->blog_id);
noblogs_run_cron_for_current_blog();
echo "{$arg}: ok\n";
restore_current_blog();
}
}
// 'fix-rewrites': Fix rewrite rules
function do_fix_rewrites($args) {
global $wp_rewrite;
foreach ($args as $arg) {
$blog = noblogs_get_blog($arg);
if (!$blog) {
echo "Blog {$arg} not found.\n";
continue;
}
switch_to_blog($blog->blog_id);
$wp_rewrite->init();
create_initial_taxonomies();
$wp_rewrite->flush_rules();
echo "{$arg}: ok\n";
restore_current_blog();
}
}
function do_update_friend_domains($args) {
$domains = noblogs_list_friend_domains();
update_site_option('limited_email_domains', $domains);
echo "Update done.\n";
}
function do_check_spam($args) {
global $wpdb;
$spamcount = 0;
foreach ($args as $arg) {
$blog = noblogs_get_blog($arg);
if (!$blog) {
echo "Blog {$arg} not found.\n";
continue;
}
$spam = $wpdb->get_var("SELECT count(*) FROM wp_".$blog->blog_id ."_comments where comment_approved = 'spam';");
$spamcount+=$spam;
printf("%s - %d : %d\n", $blog->domain, $blog->blog_id, $spam);
}
printf("Found %d spam comments\n", $spamcount);
}
function do_nuke_spam($args) {
global $wpdb;
foreach ($args as $arg) {
$blog = noblogs_get_blog($arg);
if (!$blog) {
echo "Blog {$arg} not found.\n";
continue;
}
$spam = $wpdb->get_var("DELETE FROM wp_".$blog->blog_id ."_comments where comment_approved = 'spam' and comment_date < '".date('Y-m-d',time() - (86400 * 60))."';");
printf("%s - %d : %d\n", $blog->domain, $blog->blog_id, $spam);
}
}
function do_close_comments_if_inactive($args) {
global $wpdb;
foreach ($args as $arg) {
$blog = noblogs_get_blog($arg);
if (!$blog) {
echo "Blog {$arg} not found.\n";
continue;
}
switch_to_blog($blog->blog_id);
if (get_option('close_comments_for_old_posts') == '1') {
echo "Blog {$blog->domain} already closed to comments, skipping.\n";
continue;
} else if (noblogs_is_stale()) {
echo "Closing comments on blog {$blog->domain}.\n";
update_option('close_comments_for_old_posts', '1');
update_option('close_comments_days_old', '90');
} else {
echo "Leaving comments opened on blog {$blog->domain}.\n";
}
}
}
function check_updates_parse_flags($args) {
$flags = array();
foreach (array('json', 'force', 'mail') as $f){
$flags[$f] = in_array('-' . $f, $args);
}
return $flags;
}
// 'check-updates': check for core, plugins and theme updates
function do_check_updates($args) {
$alertmail = "@ALERT_EMAIL@";
$flags = check_updates_parse_flags($args);
global $wp_version;
$updates = array();
$updates['core'] = array();
$updates['plugins'] = array();
$updates['themes'] = array();
$txt = '';
$check = $flags['force'];
$check = wp_version_check() || $check;
$check = wp_update_plugins() || $check;
$check = wp_update_themes() || $check;
if (!$check) {
$flags['json'] || print "Check is too soon, exiting\n" ;
exit(1);
}
foreach(get_site_transient('update_core')->updates as $update) {
if($update->current != $wp_version) {
$txt .= sprintf("Core version: %s\n\n", $update->current);
$updates['core'][] = array('version' => $update->current,
'url' => $update->package);
}
}
foreach(get_site_transient('update_plugins')->response as $update) {
$txt .= sprintf("Plugin: %s\nVersion: %s\nURL: %s\n\n",
$update->slug, $update->new_version, $update->package);
$updates['plugins'][] = array('name' => $update->slug,
'version' => $update->new_version,
'url' => $update->package);
}
foreach(get_site_transient('update_themes')->response as $name => $update) {
$txt .= sprintf("Theme: %s\nVersion: %s\nURL: %s\n\n",
$name, $update['new_version'], $update['package']);
$updates['themes'][] = array('name' => $name,
'version' => $update['new_version'],
'url' => $update['package']);
}
if ($flags['mail']){
wp_mail($alertmail, "[Noblogs-Alert] Updates are available", $txt);
}
if ($flags['json']){
print json_encode($updates);
} else {
print $txt;
}
}
// Command-line parsing.
$cmd = $argv[1];
if (!$cmd) {
help();
}
$cmd_func = "do_" . str_replace('-', '_', $cmd);
if (!function_exists($cmd_func)) {
echo "Unknown command '".$cmd."'\n\n";
help();
}
call_user_func($cmd_func, array_slice($argv, 2));
#!/bin/bash
#
# Run a 'noblogs' command on all blogs.
#
# The arguments are passed along to the 'noblogs' command, and
# the local blog IDs will be appended to the resulting command
# line (using 'xargs' to group them in batches).
#
# Commands will be run locally on each backend.
#
# Example:
# $ on-all-blogs check-upgrade
#
dir=$(dirname $0)
dir=${dir:-.}
abs_dir=$(cd ${dir} && pwd)
${dir}/noblogs print-all-blogs | grep -v Warning \
| ${dir}/mr ${abs_dir}/noblogs "$@"
#!/bin/bash
#
# Run a 'noblogs' command on just those blogs that are hosted
# on this server.
#
# The arguments are passed along to the 'noblogs' command, and
# the local blog IDs will be appended to the resulting command
# line (using 'xargs' to group them in batches).
#
# Example:
# $ on-local-blogs check-upgrade
#
dir=$(dirname $0)
dir=${dir:-.}
php="/opt/noblogs/bin/php-noblogs"
${php} ${dir}/noblogs print-local-blogs | grep -v Warning \
| xargs -n 30 ${php} ${dir}/noblogs "$@"
AC_INIT([noblogs-cli], [1.0], [info@autistici.org])
AC_CONFIG_SRCDIR([lib/blogs.php])
AC_ARG_WITH(php,
AC_HELP_STRING([[--with-php=BINARY]],
[Path to the PHP interpreter]),
[php_bin="$withval"],
[AC_PATH_PROGS(php_bin, [php5-cli php5 php], [no], [])]
)
if test "$php_bin" = "no" ; then
AC_MSG_ERROR(No PHP interpreter could be found)
exit 1
else
PHP="$php_bin"
AC_SUBST(PHP)
fi
AC_ARG_WITH(wp-root,
AC_HELP_STRING([[--with-wp-root=PATH]],
[Path to the Wordpress installation]),
[wp_root="$withval"],
[wp_root=no]
)
if test "$wp_root" = "no" ; then
AC_MSG_ERROR([The path to the Wordpress installation must be specified (--with-wp-root=PATH)])
exit 1
else
WP_ROOT="$wp_root"
AC_SUBST(WP_ROOT)
fi
AC_ARG_WITH(alert-email,
AC_HELP_STRING([[--with-alert-email=EMAIL]],
[Email where to send update alerts (defaults to root@localhost)]),
[wp_root="$withval"],
[alert_email="root@localhost"]
)
ALERT_EMAIL="$alert_email"
AC_SUBST(ALERT_EMAIL)
NOBLOGS_LIB_DIR=`eval echo "$prefix/lib/noblogs-cli"`
AC_SUBST(NOBLOGS_LIB_DIR)
AC_OUTPUT(
Makefile
bin/noblogs
lib/noblogs.php
)
<?php
// Return a list of all blog IDs.
// (Does not include deleted and archived blogs).
function noblogs_get_blogs() {
global $wpdb;
$sql = "SELECT blog_id FROM $wpdb->blogs WHERE deleted = 0 AND archived = '0'";
$result = $wpdb->get_results($sql);
return ($result);
}
// Find a blog by its name or ID.
function noblogs_get_blog($blogname) {
global $wpdb;
if (preg_match('/^\d+$/', $blogname)) {
$sql = "SELECT * FROM $wpdb->blogs WHERE blog_id='" . $blogname . "'";
} else {
if (!preg_match('/\.noblogs\.org$/', $blogname)) {
$blogname = $blogname . '.noblogs.org';
}
$sql = "SELECT * FROM $wpdb->blogs WHERE domain = '" . $blogname . "'";
}
$result = $wpdb->get_results($sql);
return $result[0];
}
// Return the database connection information associated with a blog.
function noblogs_get_backend_for_blog($blog_id) {
global $wpdb;
// Create a temporary hash object just to load the backends
// (we cannot use the map in $wpdb because it doesn't have the
// backend array anymore).
$hashmap = new Flexihash();
$reversemap = noblogs_load_backends(NOBLOGS_BACKEND_CONFIG, $hashmap);
// Lookup the blog ID using the $wpdb hash just to be safe (though
// we should get an identical result using $hashmap).
$lookup = $wpdb->hash_map->lookup($blog_id);
$backend = $reversemap[$lookup];
// Be nice and split the database host into 'host' and 'port' elements.
$result = array();
if (preg_match('/^(.*):([0-9]*)$/', $backend['host'], $matches)) {
$result['host'] = $matches[1];
$result['port'] = $matches[2];
} else {
$result['host'] = $backend['host'];
}
$result['user'] = $backend['user'];
$result['password'] = $backend['password'];
$result['db'] = $backend['name'];
return $result;
}
// Return the full backend -> blogs map.
function noblogs_get_backend_map() {
global $wpdb;
$wpdb_hash = &$wpdb->hash_map;
$blogs = noblogs_get_blogs();
$backend_map = array();
foreach ($blogs as $blog) {
$blog_id = $blog->blog_id;
$backend_id = $wpdb_hash->lookup($blog_id);
if (!array_key_exists($backend_id, $backend_map)) {
$backend_map[$backend_id] = array();
}
array_push($backend_map[$backend_id], (int)$blog_id);
}
return $backend_map;
}
// Return the backend ID for the local host.
function noblogs_get_local_backend_id() {
$id = trim(file_get_contents("/etc/ai/public_id"));
return "backend_{$id}";
}
// Return a list of blogs that are local to this server.
function noblogs_get_local_blogs() {
$backend_map = noblogs_get_backend_map();
$local_id = noblogs_get_local_backend_id();
return $backend_map[$local_id];
}
// Return true if the blog has not been updated in some time.
function noblogs_is_stale($days = 180) {
global $wpdb;
$recent = new WP_Query("showposts=1&orderby=modified&post_status=publish");
if ($recent->have_posts()) {
$recent->the_post();
$last_update = get_the_modified_time('U');
$now = time();
if ( ($now - $last_update) > 86400*$days )
return true;
}
return false;
}
<?php
// Run cron jobs for the current blog.
// (Use switch_to_blog() before calling this).
function noblogs_run_cron_for_current_blog() {
$crons = _get_cron_array();
if ($crons === false) {
return;
}
$local_time = time();
foreach ($crons as $timestamp => $cronhooks) {
if ($timestamp > $local_time)
continue;
foreach ($cronhooks as $hook => $keys) {
foreach ($keys as $k => $v) {
$args_str = implode(', ', $v['args']);
echo " {$k} -> {$hook} ({$args_str})\n";
$schedule = $v['schedule'];
if ($schedule != false) {
$new_args = array($timestamp, $schedule, $hook, $v['args']);
call_user_func_array('wp_reschedule_event', $new_args);
}
wp_unschedule_event($timestamp, $hook, $v['args']);
do_action_ref_array($hook, $v['args']);
}
}
}
}
<?php
function _is_domain($x) {
return ($x != "" && $x[0] != "#");
}
function noblogs_list_friend_domains() {
exec("ldapsearch -LLL -u -x '(&(status=active)(acceptMail=true))' cn | awk '/^cn:/ {print $2}'", $ldap_domains);
$ext_domains = explode("\n", file_get_contents("/etc/noblogs/friend_domains"));
$all_domains = array_filter(array_merge($ldap_domains, $ext_domains),
"_is_domain");
sort($all_domains);
return $all_domains;
}
<?php
define('NOBLOGS_ROOT', '@WP_ROOT@');
// allows for updates check of themes, plugins and core (the name is misleading!)
define('AI_CRON_SCRIPT', true);
// Load our includes.
require_once(dirname(__FILE__) . '/blogs.php');
require_once(dirname(__FILE__) . '/cron.php');
require_once(dirname(__FILE__) . '/friends.php');
// Load the Wordpress api.
define('WP_CACHE',false);
require_once(NOBLOGS_ROOT . '/wp-load.php');
require_once(NOBLOGS_ROOT . '/db-config.php');
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment