aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorMichael <icarus@dabo.de>2012-05-26 11:59:19 +0200
committerMichael <icarus@dabo.de>2012-05-26 11:59:19 +0200
commit7b3c02057db47a627b56bdd79f1055ea7f876617 (patch)
tree8c9b11fa72e544aea721f385b40bff7254e42ed2 /include
parent6342b3e0bdd5774857a8fca809994f05e0208d25 (diff)
parentf5290a5a107ef2d6c309c4a3205319c9b0d13994 (diff)
downloadvolse-hubzilla-7b3c02057db47a627b56bdd79f1055ea7f876617.tar.gz
volse-hubzilla-7b3c02057db47a627b56bdd79f1055ea7f876617.tar.bz2
volse-hubzilla-7b3c02057db47a627b56bdd79f1055ea7f876617.zip
Merge remote branch 'upstream/master'
Diffstat (limited to 'include')
-rw-r--r--include/Photo.php6
-rw-r--r--include/auth.php7
-rw-r--r--include/config.php4
-rw-r--r--include/conversation.php1
-rw-r--r--include/crypto.php36
-rw-r--r--include/delivery.php2
-rw-r--r--include/directory.php10
-rw-r--r--include/items.php2
-rw-r--r--include/notifier.php32
-rw-r--r--include/socgraph.php30
-rw-r--r--include/text.php40
11 files changed, 126 insertions, 44 deletions
diff --git a/include/Photo.php b/include/Photo.php
index 4d02b5c65..fce559999 100644
--- a/include/Photo.php
+++ b/include/Photo.php
@@ -87,6 +87,12 @@ class Photo {
}
+ public function rotate($degrees) {
+ $this->image = imagerotate($this->image,$degrees,0);
+ $this->width = imagesx($this->image);
+ $this->height = imagesy($this->image);
+ }
+
public function scaleImageUp($min) {
diff --git a/include/auth.php b/include/auth.php
index 1341f3bb8..b87662fea 100644
--- a/include/auth.php
+++ b/include/auth.php
@@ -11,6 +11,13 @@ function nuke_session() {
unset($_SESSION['cid']);
unset($_SESSION['theme']);
unset($_SESSION['page_flags']);
+ unset($_SESSION['submanage']);
+ unset($_SESSION['my_url']);
+ unset($_SESSION['my_address']);
+ unset($_SESSION['addr']);
+ unset($_SESSION['return_url']);
+ unset($_SESSION['theme']);
+ unset($_SESSION['page_flags']);
}
diff --git a/include/config.php b/include/config.php
index 4cff38090..12fc9cafc 100644
--- a/include/config.php
+++ b/include/config.php
@@ -77,11 +77,9 @@ function get_config($family, $key, $instore = false) {
if(! function_exists('set_config')) {
function set_config($family,$key,$value) {
global $a;
-
// manage array value
$dbvalue = (is_array($value)?serialize($value):$value);
- $dbvalue = (is_bool($value) ? intval($value) : $value);
-
+ $dbvalue = (is_bool($dbvalue) ? intval($dbvalue) : $dbvalue);
if(get_config($family,$key,true) === false) {
$a->config[$family][$key] = $value;
$ret = q("INSERT INTO `config` ( `cat`, `k`, `v` ) VALUES ( '%s', '%s', '%s' ) ",
diff --git a/include/conversation.php b/include/conversation.php
index 6bf673b97..dc574ddff 100644
--- a/include/conversation.php
+++ b/include/conversation.php
@@ -174,6 +174,7 @@ function localize_item(&$item){
}
}
+
}
/**
diff --git a/include/crypto.php b/include/crypto.php
index 0feb45c24..6fc9a287e 100644
--- a/include/crypto.php
+++ b/include/crypto.php
@@ -292,4 +292,38 @@ function zot_unencapsulate($data,$prvkey) {
$ret['sender'] = $s;
$ret['data'] = aes_unencapsulate($x,$prvkey);
return $ret;
-} \ No newline at end of file
+}
+
+function new_keypair($bits) {
+
+ $openssl_options = array(
+ 'digest_alg' => 'sha1',
+ 'private_key_bits' => $bits,
+ 'encrypt_key' => false
+ );
+
+ $conf = get_config('system','openssl_conf_file');
+ if($conf)
+ $openssl_options['config'] = $conf;
+
+ $result = openssl_pkey_new($openssl_options);
+
+ if(empty($result)) {
+ logger('new_keypair: failed');
+ return false;
+ }
+
+ // Get private key
+
+ $response = array('prvkey' => '', 'pubkey' => '');
+
+ openssl_pkey_export($result, $response['prvkey']);
+
+ // Get public key
+ $pkey = openssl_pkey_get_details($result);
+ $response['pubkey'] = $pkey["key"];
+
+ return $response;
+
+}
+
diff --git a/include/delivery.php b/include/delivery.php
index 1cee2d697..61b0bd33a 100644
--- a/include/delivery.php
+++ b/include/delivery.php
@@ -41,7 +41,7 @@ function delivery_run($argv, $argc){
for($x = 3; $x < $argc; $x ++) {
- $contact_id = intval($argv[x]);
+ $contact_id = intval($argv[$x]);
// Some other process may have delivered this item already.
diff --git a/include/directory.php b/include/directory.php
index cae78adb4..45386183c 100644
--- a/include/directory.php
+++ b/include/directory.php
@@ -24,6 +24,9 @@ function directory_run($argv, $argc){
load_config('system');
+ load_hooks();
+
+
$a->set_baseurl(get_config('system','url'));
$dir = get_config('system','directory_submit_url');
@@ -31,7 +34,12 @@ function directory_run($argv, $argc){
if(! strlen($dir))
return;
- fetch_url($dir . '?url=' . bin2hex($argv[1]));
+ $arr = array('url' => $argv[1]);
+
+ call_hooks('globaldir_update', $arr);
+
+ if(strlen($arr['url']))
+ fetch_url($dir . '?url=' . bin2hex($arr['url']));
return;
}
diff --git a/include/items.php b/include/items.php
index 91c9056fe..e5b640fd2 100644
--- a/include/items.php
+++ b/include/items.php
@@ -1010,7 +1010,7 @@ function tag_deliver($uid,$item_id) {
'otype' => 'item'
));
- if((! $community_page) && (! prvgroup))
+ if((! $community_page) && (! $prvgroup))
return;
diff --git a/include/notifier.php b/include/notifier.php
index 8b904dbcd..cb4fb2a31 100644
--- a/include/notifier.php
+++ b/include/notifier.php
@@ -478,24 +478,42 @@ function notifier_run($argv, $argc){
}
}
+
+ // This controls the number of deliveries to execute with each separate delivery process.
+ // By default we'll perform one delivery per process. Assuming a hostile shared hosting
+ // provider, this provides the greatest chance of deliveries if processes start getting
+ // killed. We can also space them out with the delivery_interval to also help avoid them
+ // getting whacked.
+
+ // If $deliveries_per_process > 1, we will chain this number of multiple deliveries
+ // together into a single process. This will reduce the overall number of processes
+ // spawned for each delivery, but they will run longer.
+
$deliveries_per_process = intval(get_config('system','delivery_batch_count'));
if($deliveries_per_process <= 0)
$deliveries_per_process = 1;
$this_batch = array();
- foreach($r as $contact) {
+ for($x = 0; $x < count($r); $x ++) {
+ $contact = $r[$x];
+
if($contact['self'])
continue;
// potentially more than one recipient. Start a new process and space them out a bit.
- // we will deliver single recipient types of message and email receipients here.
-
+ // we will deliver single recipient types of message and email recipients here.
+
if((! $mail) && (! $fsuggest) && (! $followup)) {
- // deliveries per process not yet implemented, 1 delivery per process.
- proc_run('php','include/delivery.php',$cmd,$item_id,$contact['id']);
- if($interval)
- @time_sleep_until(microtime(true) + (float) $interval);
+
+ $this_batch[] = $contact['id'];
+
+ if(count($this_batch) == $deliveries_per_process) {
+ proc_run('php','include/delivery.php',$cmd,$item_id,$this_batch);
+ $this_batch = array();
+ if($interval)
+ @time_sleep_until(microtime(true) + (float) $interval);
+ }
continue;
}
diff --git a/include/socgraph.php b/include/socgraph.php
index 592779089..eccb133cc 100644
--- a/include/socgraph.php
+++ b/include/socgraph.php
@@ -71,20 +71,24 @@ function poco_load($cid,$uid = 0,$zcid = 0,$url = null) {
$name = $entry->displayName;
- foreach($entry->urls as $url) {
- if($url->type == 'profile') {
- $profile_url = $url->value;
- continue;
- }
- if($url->type == 'webfinger') {
- $connect_url = str_replace('acct:' , '', $url->value);
- continue;
+ if(isset($entry->urls)) {
+ foreach($entry->urls as $url) {
+ if($url->type == 'profile') {
+ $profile_url = $url->value;
+ continue;
+ }
+ if($url->type == 'webfinger') {
+ $connect_url = str_replace('acct:' , '', $url->value);
+ continue;
+ }
}
- }
- foreach($entry->photos as $photo) {
- if($photo->type == 'profile') {
- $profile_photo = $photo->value;
- continue;
+ }
+ if(isset($entry->photos)) {
+ foreach($entry->photos as $photo) {
+ if($photo->type == 'profile') {
+ $profile_photo = $photo->value;
+ continue;
+ }
}
}
diff --git a/include/text.php b/include/text.php
index e3c683338..d6a9ef5d3 100644
--- a/include/text.php
+++ b/include/text.php
@@ -646,7 +646,7 @@ function search($s,$id='search-box',$url='/search',$save = false) {
$a = get_app();
$o = '<div id="' . $id . '">';
$o .= '<form action="' . $a->get_baseurl((stristr($url,'network')) ? true : false) . $url . '" method="get" >';
- $o .= '<input type="text" name="search" id="search-text" value="' . $s .'" />';
+ $o .= '<input type="text" name="search" id="search-text" placeholder="' . t('Search') . '" value="' . $s .'" />';
$o .= '<input type="submit" name="submit" id="search-submit" value="' . t('Search') . '" />';
if($save)
$o .= '<input type="submit" name="save" id="search-save" value="' . t('Save') . '" />';
@@ -901,24 +901,30 @@ function prepare_body($item,$attach = false) {
foreach($arr as $r) {
$matches = false;
$icon = '';
- $cnt = preg_match('|\[attach\]href=\"(.*?)\" length=\"(.*?)\" type=\"(.*?)\" title=\"(.*?)\"\[\/attach\]|',$r,$matches);
+ $cnt = preg_match_all('|\[attach\]href=\"(.*?)\" length=\"(.*?)\" type=\"(.*?)\" title=\"(.*?)\"\[\/attach\]|',$r,$matches, PREG_SET_ORDER);
if($cnt) {
- $icontype = strtolower(substr($matches[3],0,strpos($matches[3],'/')));
- switch($icontype) {
- case 'video':
- case 'audio':
- case 'image':
- case 'text':
- $icon = '<div class="attachtype icon s22 type-' . $icontype . '"></div>';
- break;
- default:
- $icon = '<div class="attachtype icon s22 type-unkn"></div>';
- break;
+ foreach($matches as $mtch) {
+ $icontype = strtolower(substr($mtch[3],0,strpos($mtch[3],'/')));
+ switch($icontype) {
+ case 'video':
+ case 'audio':
+ case 'image':
+ case 'text':
+ $icon = '<div class="attachtype icon s22 type-' . $icontype . '"></div>';
+ break;
+ default:
+ $icon = '<div class="attachtype icon s22 type-unkn"></div>';
+ break;
+ }
+ $title = ((strlen(trim($mtch[4]))) ? escape_tags(trim($mtch[4])) : escape_tags($mtch[1]));
+ $title .= ' ' . $mtch[2] . ' ' . t('bytes');
+ if((local_user() == $item['uid']) && $item['contact-id'] != $a->contact['id'])
+ $the_url = $a->get_baseurl() . '/redir/' . $item['contact-id'] . '?f=1&url=' . $mtch[1];
+ else
+ $the_url = $mtch[1];
+
+ $s .= '<a href="' . strip_tags($the_url) . '" title="' . $title . '" class="attachlink" target="external-link" >' . $icon . '</a>';
}
- $title = ((strlen(trim($matches[4]))) ? escape_tags(trim($matches[4])) : escape_tags($matches[1]));
- $title .= ' ' . $matches[2] . ' ' . t('bytes');
-
- $s .= '<a href="' . strip_tags($matches[1]) . '" title="' . $title . '" class="attachlink" target="external-link" >' . $icon . '</a>';
}
}
$s .= '<div class="clear"></div></div>';