diff options
author | zottel <github@zottel.net> | 2012-05-22 08:46:02 +0200 |
---|---|---|
committer | zottel <github@zottel.net> | 2012-05-22 08:46:02 +0200 |
commit | e9c86c0fd0fb87b49e60669e6d4be810ca426ec4 (patch) | |
tree | cfee80cc9122974a4304591aa7d54ca5fc8a71ea /include | |
parent | 2cd3ec7b983327f8c162845d0f4b8d9753f30e27 (diff) | |
parent | 02502c3a7460a1af3414b65232fd7c672a76d941 (diff) | |
download | volse-hubzilla-e9c86c0fd0fb87b49e60669e6d4be810ca426ec4.tar.gz volse-hubzilla-e9c86c0fd0fb87b49e60669e6d4be810ca426ec4.tar.bz2 volse-hubzilla-e9c86c0fd0fb87b49e60669e6d4be810ca426ec4.zip |
Merge remote branch 'upstream/master'
Diffstat (limited to 'include')
-rw-r--r-- | include/conversation.php | 1 | ||||
-rw-r--r-- | include/crypto.php | 36 | ||||
-rw-r--r-- | include/delivery.php | 2 | ||||
-rw-r--r-- | include/directory.php | 10 | ||||
-rw-r--r-- | include/notifier.php | 32 | ||||
-rw-r--r-- | include/text.php | 38 |
6 files changed, 93 insertions, 26 deletions
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/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/text.php b/include/text.php index e3c683338..e93c24ef4 100644 --- a/include/text.php +++ b/include/text.php @@ -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>'; |