Merge pull request #1131 from fabrixxm/master

Bug fixes!
This commit is contained in:
tobiasd 2014-09-07 17:52:52 +02:00
commit e767e2d750
9 changed files with 196 additions and 158 deletions

View file

@ -57,6 +57,7 @@ class Emailer {
);
logger("header " . 'To: ' . $params['toEmail'] . "\n" . $messageHeader, LOGGER_DEBUG);
logger("return value " . (($res)?"true":"false"), LOGGER_DEBUG);
return $res;
}
}
?>

View file

@ -1,10 +1,15 @@
<?php
# if PDO is avaible for mysql, use the new database abstraction
# TODO: PDO is disabled for release 3.3. We need to investigate why
# the update from 3.2 fails with pdo
/*
if(class_exists('\PDO') && in_array('mysql', PDO::getAvailableDrivers())) {
require_once("library/dddbl2/dddbl.php");
require_once("include/dba_pdo.php");
}
*/
require_once('include/datetime.php');
@ -14,12 +19,12 @@ require_once('include/datetime.php');
*
* For debugging, insert 'dbg(1);' anywhere in the program flow.
* dbg(0); will turn it off. Logging is performed at LOGGER_DATA level.
* When logging, all binary info is converted to text and html entities are escaped so that
* When logging, all binary info is converted to text and html entities are escaped so that
* the debugging stream is safe to view within both terminals and web pages.
*
*/
if(! class_exists('dba')) {
if(! class_exists('dba')) {
class dba {
private $debug = 0;
@ -227,7 +232,7 @@ class dba {
}
function __destruct() {
if ($this->db)
if ($this->db)
if($this->mysqli)
$this->db->close();
else
@ -245,14 +250,14 @@ function printable($s) {
}}
// Procedural functions
if(! function_exists('dbg')) {
if(! function_exists('dbg')) {
function dbg($state) {
global $db;
if($db)
$db->dbg($state);
}}
if(! function_exists('dbesc')) {
if(! function_exists('dbesc')) {
function dbesc($str) {
global $db;
if($db && $db->connected)
@ -268,7 +273,7 @@ function dbesc($str) {
// Example: $r = q("SELECT * FROM `%s` WHERE `uid` = %d",
// 'user', 1);
if(! function_exists('q')) {
if(! function_exists('q')) {
function q($sql) {
global $db;
@ -285,12 +290,12 @@ function q($sql) {
/**
*
* This will happen occasionally trying to store the
* session data after abnormal program termination
* This will happen occasionally trying to store the
* session data after abnormal program termination
*
*/
logger('dba: no database: ' . print_r($args,true));
return false;
return false;
}}
@ -300,7 +305,7 @@ function q($sql) {
*
*/
if(! function_exists('dbq')) {
if(! function_exists('dbq')) {
function dbq($sql) {
global $db;
@ -312,10 +317,10 @@ function dbq($sql) {
}}
// Caller is responsible for ensuring that any integer arguments to
// Caller is responsible for ensuring that any integer arguments to
// dbesc_array are actually integers and not malformed strings containing
// SQL injection vectors. All integer array elements should be specifically
// cast to int to avoid trouble.
// SQL injection vectors. All integer array elements should be specifically
// cast to int to avoid trouble.
if(! function_exists('dbesc_array_cb')) {

View file

@ -1,6 +1,9 @@
<?php
require_once("boot.php");
require_once("include/text.php");
define('NEW_UPDATE_ROUTINE_VERSION', 1170);
/*
* send the email and do what is needed to do on update fails
*
@ -62,27 +65,6 @@ function update_fail($update_id, $error_message){
break;
}
function dbstructure_run(&$argv, &$argc) {
global $a, $db;
if(is_null($a)){
$a = new App;
}
if(is_null($db)) {
@include(".htconfig.php");
require_once("include/dba.php");
$db = new dba($db_host, $db_user, $db_pass, $db_data);
unset($db_host, $db_user, $db_pass, $db_data);
}
update_structure(true, true);
}
if (array_search(__file__,get_included_files())===0){
dbstructure_run($argv,$argc);
killme();
}
function table_structure($table) {
$structures = q("DESCRIBE `%s`", $table);
@ -1334,3 +1316,29 @@ function db_definition() {
return($database);
}
/*
* run from command line
*/
function dbstructure_run(&$argv, &$argc) {
global $a, $db;
if(is_null($a)){
$a = new App;
}
if(is_null($db)) {
@include(".htconfig.php");
require_once("include/dba.php");
$db = new dba($db_host, $db_user, $db_pass, $db_data);
unset($db_host, $db_user, $db_pass, $db_data);
}
update_structure(true, true);
}
if (array_search(__file__,get_included_files())===0){
dbstructure_run($argv,$argc);
killme();
}

View file

@ -595,7 +595,7 @@ function notification($params) {
// use the Emailer class to send the message
Emailer::send(array(
return Emailer::send(array(
'fromName' => $sender_name,
'fromEmail' => $sender_email,
'replyTo' => $sender_email,
@ -605,7 +605,6 @@ function notification($params) {
'textVersion' => $email_text_body,
'additionalMailHeader' => $datarray['headers'],
));
return True;
}
return False;

View file

@ -2,7 +2,7 @@
// curl wrapper. If binary flag is true, return binary
// results.
// results.
// Set the cookiejar argument to a string (e.g. "/tmp/friendica-cookies.txt")
// to preserve cookies from one request to the next.
@ -24,7 +24,7 @@ function fetch_url($url,$binary = false, &$redirects = 0, $timeout = 0, $accept_
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookiejar);
}
// These settings aren't needed. We're following the location already.
// These settings aren't needed. We're following the location already.
// @curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
// @curl_setopt($ch, CURLOPT_MAXREDIRS, 5);
@ -219,8 +219,8 @@ function post_url($url,$params, $headers = null, &$redirects = 0, $timeout = 0)
}}
// Generic XML return
// Outputs a basic dfrn XML status structure to STDOUT, with a <status> variable
// of $st and an optional text <message> of $message and terminates the current process.
// Outputs a basic dfrn XML status structure to STDOUT, with a <status> variable
// of $st and an optional text <message> of $message and terminates the current process.
if(! function_exists('xml_status')) {
function xml_status($st, $message = '') {
@ -246,7 +246,7 @@ function http_status_exit($val) {
if($val >= 200 && $val < 300)
$err = 'OK';
logger('http_status_exit ' . $val);
logger('http_status_exit ' . $val);
header($_SERVER["SERVER_PROTOCOL"] . ' ' . $val . ' ' . $err);
killme();
@ -298,16 +298,16 @@ function convert_xml_element_to_array($xml_element, &$recursion_depth=0) {
}
}}
// Given an email style address, perform webfinger lookup and
// Given an email style address, perform webfinger lookup and
// return the resulting DFRN profile URL, or if no DFRN profile URL
// is located, returns an OStatus subscription template (prefixed
// is located, returns an OStatus subscription template (prefixed
// with the string 'stat:' to identify it as on OStatus template).
// If this isn't an email style address just return $s.
// Return an empty string if email-style addresses but webfinger fails,
// or if the resultant personal XRD doesn't contain a supported
// or if the resultant personal XRD doesn't contain a supported
// subscription/friend-request attribute.
// amended 7/9/2011 to return an hcard which could save potentially loading
// amended 7/9/2011 to return an hcard which could save potentially loading
// a lengthy content page to scrape dfrn attributes
if(! function_exists('webfinger_dfrn')) {
@ -332,7 +332,7 @@ function webfinger_dfrn($s,&$hcard) {
return $profile_link;
}}
// Given an email style address, perform webfinger lookup and
// Given an email style address, perform webfinger lookup and
// return the array of link attributes from the personal XRD file.
// On error/failure return an empty array.
@ -374,7 +374,7 @@ function lrdd($uri, $debug = false) {
// All we have is an email address. Resource-priority is irrelevant
// because our URI isn't directly resolvable.
if(strstr($uri,'@')) {
if(strstr($uri,'@')) {
return(webfinger($uri));
}
@ -418,7 +418,7 @@ function lrdd($uri, $debug = false) {
foreach($properties as $prop)
if((string) $prop['@attributes'] === 'http://lrdd.net/priority/resource')
$priority = 'resource';
}
}
// save the links in case we need them
@ -449,7 +449,7 @@ function lrdd($uri, $debug = false) {
$tpl = '';
if($priority === 'host') {
if(strlen($tpl))
if(strlen($tpl))
$pxrd = str_replace('{uri}', urlencode($uri), $tpl);
elseif(isset($href))
$pxrd = $href;
@ -623,6 +623,9 @@ function fetch_xrd_links($url) {
if(! function_exists('validate_url')) {
function validate_url(&$url) {
if(get_config('system','disable_url_validation'))
return true;
// no naked subdomains (allow localhost for tests)
if(strpos($url,'.') === false && strpos($url,'/localhost/') === false)
return false;
@ -688,7 +691,7 @@ function allowed_url($url) {
foreach($allowed as $a) {
$pat = strtolower(trim($a));
if(($fnmatch && fnmatch($pat,$host)) || ($pat == $host)) {
$found = true;
$found = true;
break;
}
}
@ -722,7 +725,7 @@ function allowed_email($email) {
foreach($allowed as $a) {
$pat = strtolower(trim($a));
if(($fnmatch && fnmatch($pat,$domain)) || ($pat == $domain)) {
$found = true;
$found = true;
break;
}
}
@ -888,7 +891,7 @@ function scale_external_images($srctext, $include_link = true, $scale_replace =
$new_height = $ph->getHeight();
logger('scale_external_images: ' . $orig_width . '->' . $new_width . 'w ' . $orig_height . '->' . $new_height . 'h' . ' match: ' . $mtch[0], LOGGER_DEBUG);
$s = str_replace($mtch[0],'[img=' . $new_width . 'x' . $new_height. ']' . $scaled . '[/img]'
. "\n" . (($include_link)
. "\n" . (($include_link)
? '[url=' . $mtch[1] . ']' . t('view full size') . '[/url]' . "\n"
: ''),$s);
logger('scale_external_images: new string: ' . $s, LOGGER_DEBUG);
@ -928,8 +931,8 @@ function fix_contact_ssl_policy(&$contact,$new_policy) {
}
if($ssl_changed) {
q("update contact set
url = '%s',
q("update contact set
url = '%s',
request = '%s',
notify = '%s',
poll = '%s',
@ -984,7 +987,7 @@ function xml2array($contents, $namespaces = true, $get_attributes=1, $priority =
return array();
}
xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, "UTF-8");
xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, "UTF-8");
// http://minutillo.com/steve/weblog/2004/6/17/php-xml-and-character-encodings-a-tale-of-sadness-rage-and-data-loss
xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);

View file

@ -382,7 +382,7 @@ function send_register_open_eml($email, $sitename, $siteurl, $username, $passwor
The login details are as follows:
Site Location: %3$s
Login Name: %1$s
Password: %5$
Password: %5$s
You may change your password from your account "Settings" page after logging
in.
@ -407,7 +407,7 @@ function send_register_open_eml($email, $sitename, $siteurl, $username, $passwor
$preamble = sprintf($preamble, $username, $sitename);
$body = sprintf($body, $email, $sitename, $siteurl, $username, $password);
notification(array(
return notification(array(
'type' => "SYSTEM_EMAIL",
'to_email' => $email,
'subject'=> sprintf( t('Registration details for %s'), $sitename),