From 52915c6e68672650b2f510b0a230959f800083a2 Mon Sep 17 00:00:00 2001 From: Fabio Comuni Date: Thu, 3 May 2012 15:28:23 +0200 Subject: validate_url() and validate_email() validate also IP address. --- include/network.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/network.php b/include/network.php index 4bec4a172..27a45ec40 100644 --- a/include/network.php +++ b/include/network.php @@ -583,7 +583,7 @@ function fetch_xrd_links($url) { // Take a URL from the wild, prepend http:// if necessary -// and check DNS to see if it's real +// and check DNS to see if it's real (or check if is a valid IP address) // return true if it's OK, false if something is wrong with it if(! function_exists('validate_url')) { @@ -596,7 +596,7 @@ function validate_url(&$url) { $url = 'http://' . $url; $h = @parse_url($url); - if(($h) && (dns_get_record($h['host'], DNS_A + DNS_CNAME + DNS_PTR))) { + if(($h) && (dns_get_record($h['host'], DNS_A + DNS_CNAME + DNS_PTR) || filter_var($h['host'], FILTER_VALIDATE_IP) )) { return true; } return false; @@ -611,7 +611,7 @@ function validate_email($addr) { return false; $h = substr($addr,strpos($addr,'@') + 1); - if(($h) && (dns_get_record($h, DNS_A + DNS_CNAME + DNS_PTR + DNS_MX))) { + if(($h) && (dns_get_record($h, DNS_A + DNS_CNAME + DNS_PTR + DNS_MX) || filter_var($h['host'], FILTER_VALIDATE_IP) )) { return true; } return false; -- cgit v1.2.3 From f3e18df55dc259e70e9acdfd6e851b97ec062f46 Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 3 May 2012 16:55:03 -0700 Subject: string update --- include/notifier.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/notifier.php b/include/notifier.php index 922e869f6..6ce281372 100644 --- a/include/notifier.php +++ b/include/notifier.php @@ -47,7 +47,7 @@ function notifier_run($argv, $argc){ $a->set_baseurl(get_config('system','url')); - logger('notifier: invoked: ' . print_r($argv,true)); + logger('notifier: invoked: ' . print_r($argv,true), LOGGER_DEBUG); $cmd = $argv[1]; @@ -833,6 +833,8 @@ function notifier_run($argv, $argc){ } + logger('notifier: calling hooks', LOGGER_DEBUG); + if($normal_mode) call_hooks('notifier_normal',$target_item); -- cgit v1.2.3 From 15542a8690701b403ed7e7bf56d82d1511cfbd63 Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 3 May 2012 20:47:04 -0700 Subject: yet another bug in remote_friends_in_common --- include/contact_widgets.php | 2 +- include/socgraph.php | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/contact_widgets.php b/include/contact_widgets.php index bf3a86958..4dab6a53e 100644 --- a/include/contact_widgets.php +++ b/include/contact_widgets.php @@ -143,7 +143,7 @@ function common_friends_visitor_widget($profile_uid) { $cid = $zcid = 0; if(can_write_wall($a,$profile_uid)) - $cid = local_user(); + $cid = remote_user(); else { if(get_my_url()) { $r = q("select id from contact where nurl = '%s' and uid = %d limit 1", diff --git a/include/socgraph.php b/include/socgraph.php index a67b3d9e3..b7c4ccc71 100644 --- a/include/socgraph.php +++ b/include/socgraph.php @@ -176,6 +176,7 @@ function count_common_friends($uid,$cid) { intval($cid) ); +// logger("count_common_friends: $uid $cid {$r[0]['total']}"); if(count($r)) return $r[0]['total']; return 0; -- cgit v1.2.3 From 421acee65b846947c24257f256c900d4881256da Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 3 May 2012 21:50:48 -0700 Subject: implement max load average before queuing/deferring delivery and poller processes --- include/delivery.php | 11 +++++++++++ include/poller.php | 13 +++++++++++++ 2 files changed, 24 insertions(+) (limited to 'include') diff --git a/include/delivery.php b/include/delivery.php index 794b8f27a..28d81226a 100644 --- a/include/delivery.php +++ b/include/delivery.php @@ -51,6 +51,17 @@ function delivery_run($argv, $argc){ return; } + $maxsysload = intval(get_config('system','maxloadavg')); + if($maxsysload < 1) + $maxsysload = 50; + if(function_exists('sys_getloadavg')) { + $load = sys_getloadavg(); + if(intval($load[0]) > $maxsysload) { + logger('system: load ' . $load . ' too high. Delivery deferred to next queue run.'); + return; + } + } + // It's ours to deliver. Remove it from the queue. q("delete from deliverq where cmd = '%s' and item = %d and contact = %d limit 1", diff --git a/include/poller.php b/include/poller.php index 0a0e66b86..f6553c846 100644 --- a/include/poller.php +++ b/include/poller.php @@ -30,6 +30,17 @@ function poller_run($argv, $argc){ load_config('config'); load_config('system'); + $maxsysload = intval(get_config('system','maxloadavg')); + if($maxsysload < 1) + $maxsysload = 50; + if(function_exists('sys_getloadavg')) { + $load = sys_getloadavg(); + if(intval($load[0]) > $maxsysload) { + logger('system: load ' . $load . ' too high. Poller deferred to next scheduled run.'); + return; + } + } + $lockpath = get_config('system','lockpath'); if ($lockpath != '') { $pidfile = new pidfile($lockpath, 'poller.lck'); @@ -39,6 +50,8 @@ function poller_run($argv, $argc){ } } + + $a->set_baseurl(get_config('system','url')); load_hooks(); -- cgit v1.2.3