1
0
Fork 0

Continued with coding convention:

- added curly braces around conditional code blocks
- added space between if/foreach/... and brace
- rewrote a code block so if dbm::is_result() fails it will abort, else the id
  is fetched from INSERT statement
- made some SQL keywords upper-cased and added back-ticks to columns/table names

Signed-off-by: Roland Haeder <roland@mxchange.org>
This commit is contained in:
Roland Häder 2016-12-20 21:13:50 +01:00
parent de689583e2
commit 6c0c9d542a
No known key found for this signature in database
GPG key ID: B72F8185C6C7BD78
18 changed files with 82 additions and 67 deletions

View file

@ -34,7 +34,7 @@ function group_select($selname,$selclass,$preselected = false,$size = 4) {
call_hooks($a->module . '_pre_' . $selname, $arr); call_hooks($a->module . '_pre_' . $selname, $arr);
if (dbm::is_result($r)) { if (dbm::is_result($r)) {
foreach($r as $rr) { foreach ($r as $rr) {
if((is_array($preselected)) && in_array($rr['id'], $preselected)) if((is_array($preselected)) && in_array($rr['id'], $preselected))
$selected = " selected=\"selected\" "; $selected = " selected=\"selected\" ";
else else
@ -145,7 +145,7 @@ function contact_selector($selname, $selclass, $preselected = false, $options) {
call_hooks($a->module . '_pre_' . $selname, $arr); call_hooks($a->module . '_pre_' . $selname, $arr);
if (dbm::is_result($r)) { if (dbm::is_result($r)) {
foreach($r as $rr) { foreach ($r as $rr) {
if((is_array($preselected)) && in_array($rr['id'], $preselected)) if((is_array($preselected)) && in_array($rr['id'], $preselected))
$selected = " selected=\"selected\" "; $selected = " selected=\"selected\" ";
else else
@ -221,16 +221,20 @@ function contact_select($selname, $selclass, $preselected = false, $size = 4, $p
$receiverlist = array(); $receiverlist = array();
if (dbm::is_result($r)) { if (dbm::is_result($r)) {
foreach($r as $rr) { foreach ($r as $rr) {
if((is_array($preselected)) && in_array($rr['id'], $preselected)) if ((is_array($preselected)) && in_array($rr['id'], $preselected)) {
$selected = " selected=\"selected\" "; $selected = " selected=\"selected\" ";
else }
else {
$selected = ''; $selected = '';
}
if($privmail) if ($privmail) {
$trimmed = GetProfileUsername($rr['url'], $rr['name'], false); $trimmed = GetProfileUsername($rr['url'], $rr['name'], false);
else }
else {
$trimmed = mb_substr($rr['name'],0,20); $trimmed = mb_substr($rr['name'],0,20);
}
$receiverlist[] = $trimmed; $receiverlist[] = $trimmed;
@ -260,7 +264,7 @@ function prune_deadguys($arr) {
return $arr; return $arr;
$str = dbesc(implode(',',$arr)); $str = dbesc(implode(',',$arr));
$r = q("SELECT `id` FROM `contact` WHERE `id` IN ( " . $str . ") AND `blocked` = 0 AND `pending` = 0 AND `archive` = 0 "); $r = q("SELECT `id` FROM `contact` WHERE `id` IN ( " . $str . ") AND `blocked` = 0 AND `pending` = 0 AND `archive` = 0 ");
if($r) { if ($r) {
$ret = array(); $ret = array();
foreach($r as $rr) foreach($r as $rr)
$ret[] = intval($rr['id']); $ret[] = intval($rr['id']);
@ -554,7 +558,7 @@ function acl_lookup(&$a, $out_type = 'json') {
// autocomplete for global contact search (e.g. navbar search) // autocomplete for global contact search (e.g. navbar search)
$r = navbar_complete($a); $r = navbar_complete($a);
$contacts = array(); $contacts = array();
if($r) { if ($r) {
foreach($r as $g) { foreach($r as $g) {
$contacts[] = array( $contacts[] = array(
"photo" => proxy_url($g['photo'], false, PROXY_SIZE_MICRO), "photo" => proxy_url($g['photo'], false, PROXY_SIZE_MICRO),

View file

@ -3068,8 +3068,8 @@
'image/gif' => 'gif' 'image/gif' => 'gif'
); );
$data = array('photo'=>array()); $data = array('photo'=>array());
if($r) { if ($r) {
foreach($r as $rr) { foreach ($r as $rr) {
$photo = array(); $photo = array();
$photo['id'] = $rr['resource-id']; $photo['id'] = $rr['resource-id'];
$photo['album'] = $rr['album']; $photo['album'] = $rr['album'];

View file

@ -343,7 +343,7 @@ function bb_replace_images($body, $images) {
$newbody = $body; $newbody = $body;
$cnt = 0; $cnt = 0;
foreach($images as $image) { foreach ($images as $image) {
// We're depending on the property of 'foreach' (specified on the PHP website) that // We're depending on the property of 'foreach' (specified on the PHP website) that
// it loops over the array starting from the first element and going sequentially // it loops over the array starting from the first element and going sequentially
// to the last element // to the last element

View file

@ -13,7 +13,7 @@ function contact_profile_assign($current,$foreign_net) {
intval($_SESSION['uid'])); intval($_SESSION['uid']));
if (dbm::is_result($r)) { if (dbm::is_result($r)) {
foreach($r as $rr) { foreach ($r as $rr) {
$selected = (($rr['id'] == $current) ? " selected=\"selected\" " : ""); $selected = (($rr['id'] == $current) ? " selected=\"selected\" " : "");
$o .= "<option value=\"{$rr['id']}\" $selected >{$rr['profile-name']}</option>\r\n"; $o .= "<option value=\"{$rr['id']}\" $selected >{$rr['profile-name']}</option>\r\n";
} }

View file

@ -97,11 +97,13 @@ function networks_widget($baseurl,$selected = '') {
$nets = array(); $nets = array();
if (dbm::is_result($r)) { if (dbm::is_result($r)) {
require_once('include/contact_selectors.php'); require_once('include/contact_selectors.php');
foreach($r as $rr) { foreach ($r as $rr) {
if($rr['network']) /// @TODO If 'network' is not there, this triggers an E_NOTICE
if ($rr['network']) {
$nets[] = array('ref' => $rr['network'], 'name' => network_to_name($rr['network']), 'selected' => (($selected == $rr['network']) ? 'selected' : '' )); $nets[] = array('ref' => $rr['network'], 'name' => network_to_name($rr['network']), 'selected' => (($selected == $rr['network']) ? 'selected' : '' ));
} }
} }
}
if(count($nets) < 2) if(count($nets) < 2)
return ''; return '';

View file

@ -78,7 +78,7 @@ function item_redir_and_replace_images($body, $images, $cid) {
$newbody .= $origbody; $newbody .= $origbody;
$cnt = 0; $cnt = 0;
foreach($images as $image) { foreach ($images as $image) {
// We're depending on the property of 'foreach' (specified on the PHP website) that // We're depending on the property of 'foreach' (specified on the PHP website) that
// it loops over the array starting from the first element and going sequentially // it loops over the array starting from the first element and going sequentially
// to the last element // to the last element

View file

@ -553,7 +553,7 @@ function update_contact_birthdays() {
$r = q("SELECT * FROM contact WHERE `bd` != '' AND `bd` != '0000-00-00' AND SUBSTRING(`bd`,1,4) != `bdyear` "); $r = q("SELECT * FROM contact WHERE `bd` != '' AND `bd` != '0000-00-00' AND SUBSTRING(`bd`,1,4) != `bdyear` ");
if (dbm::is_result($r)) { if (dbm::is_result($r)) {
foreach($r as $rr) { foreach ($r as $rr) {
logger('update_contact_birthday: ' . $rr['bd']); logger('update_contact_birthday: ' . $rr['bd']);

View file

@ -319,8 +319,8 @@ class diaspora {
dbesc(NETWORK_DIASPORA), dbesc(NETWORK_DIASPORA),
dbesc($msg["author"]) dbesc($msg["author"])
); );
if($r) { if ($r) {
foreach($r as $rr) { foreach ($r as $rr) {
logger("delivering to: ".$rr["username"]); logger("delivering to: ".$rr["username"]);
self::dispatch($rr,$msg); self::dispatch($rr,$msg);
} }
@ -806,7 +806,7 @@ class diaspora {
dbesc($guid) dbesc($guid)
); );
if($r) { if ($r) {
logger("message ".$guid." already exists for user ".$uid); logger("message ".$guid." already exists for user ".$uid);
return $r[0]["id"]; return $r[0]["id"];
} }
@ -1577,7 +1577,7 @@ class diaspora {
dbesc($message_uri), dbesc($message_uri),
intval($importer["uid"]) intval($importer["uid"])
); );
if($r) { if ($r) {
logger("duplicate message already delivered.", LOGGER_DEBUG); logger("duplicate message already delivered.", LOGGER_DEBUG);
return false; return false;
} }
@ -2022,7 +2022,7 @@ class diaspora {
FROM `item` WHERE `guid` = '%s' AND `visible` AND NOT `deleted` AND `body` != '' LIMIT 1", FROM `item` WHERE `guid` = '%s' AND `visible` AND NOT `deleted` AND `body` != '' LIMIT 1",
dbesc($guid)); dbesc($guid));
if($r) { if ($r) {
logger("reshared message ".$guid." already exists on system."); logger("reshared message ".$guid." already exists on system.");
// Maybe it is already a reshared item? // Maybe it is already a reshared item?
@ -2623,7 +2623,7 @@ class diaspora {
logger("transmit: ".$logid."-".$guid." returns: ".$return_code); logger("transmit: ".$logid."-".$guid." returns: ".$return_code);
if(!$return_code || (($return_code == 503) && (stristr($a->get_curl_headers(), "retry-after")))) { if (!$return_code || (($return_code == 503) && (stristr($a->get_curl_headers(), "retry-after")))) {
logger("queue message"); logger("queue message");
$r = q("SELECT `id` FROM `queue` WHERE `cid` = %d AND `network` = '%s' AND `content` = '%s' AND `batch` = %d LIMIT 1", $r = q("SELECT `id` FROM `queue` WHERE `cid` = %d AND `network` = '%s' AND `content` = '%s' AND `batch` = %d LIMIT 1",
@ -2632,7 +2632,7 @@ class diaspora {
dbesc($slap), dbesc($slap),
intval($public_batch) intval($public_batch)
); );
if($r) { if ($r) {
logger("add_to_queue ignored - identical item already in queue"); logger("add_to_queue ignored - identical item already in queue");
} else { } else {
// queue message for redelivery // queue message for redelivery

View file

@ -40,7 +40,7 @@ function expire_run(&$argv, &$argc){
$r = q("SELECT `uid`,`username`,`expire` FROM `user` WHERE `expire` != 0"); $r = q("SELECT `uid`,`username`,`expire` FROM `user` WHERE `expire` != 0");
if (dbm::is_result($r)) { if (dbm::is_result($r)) {
foreach($r as $rr) { foreach ($r as $rr) {
logger('Expire: ' . $rr['username'] . ' interval: ' . $rr['expire'], LOGGER_DEBUG); logger('Expire: ' . $rr['username'] . ' interval: ' . $rr['expire'], LOGGER_DEBUG);
item_expire($rr['uid'],$rr['expire']); item_expire($rr['uid'],$rr['expire']);
} }

View file

@ -53,7 +53,7 @@ function group_rmv($uid,$name) {
$r = q("SELECT def_gid, allow_gid, deny_gid FROM user WHERE uid = %d LIMIT 1", $r = q("SELECT def_gid, allow_gid, deny_gid FROM user WHERE uid = %d LIMIT 1",
intval($uid) intval($uid)
); );
if($r) { if ($r) {
$user_info = $r[0]; $user_info = $r[0];
$change = false; $change = false;
@ -199,7 +199,7 @@ function mini_group_select($uid,$gid = 0, $label = "") {
); );
$grps[] = array('name' => '', 'id' => '0', 'selected' => ''); $grps[] = array('name' => '', 'id' => '0', 'selected' => '');
if (dbm::is_result($r)) { if (dbm::is_result($r)) {
foreach($r as $rr) { foreach ($r as $rr) {
$grps[] = array('name' => $rr['name'], 'id' => $rr['id'], 'selected' => (($gid == $rr['id']) ? 'true' : '')); $grps[] = array('name' => $rr['name'], 'id' => $rr['id'], 'selected' => (($gid == $rr['id']) ? 'true' : ''));
} }
@ -257,7 +257,7 @@ function group_side($every="contacts",$each="group",$editmode = "standard", $gro
} }
if (dbm::is_result($r)) { if (dbm::is_result($r)) {
foreach($r as $rr) { foreach ($r as $rr) {
$selected = (($group_id == $rr['id']) ? ' group-selected' : ''); $selected = (($group_id == $rr['id']) ? ' group-selected' : '');
if ($editmode == "full") { if ($editmode == "full") {

View file

@ -294,7 +294,7 @@ function profile_sidebar($profile, $block = 0) {
if (dbm::is_result($r)) { if (dbm::is_result($r)) {
foreach($r as $rr) { foreach ($r as $rr) {
$profile['menu']['entries'][] = array( $profile['menu']['entries'][] = array(
'photo' => $rr['thumb'], 'photo' => $rr['thumb'],
'id' => $rr['id'], 'id' => $rr['id'],
@ -469,7 +469,7 @@ function get_birthdays() {
$cids = array(); $cids = array();
$istoday = false; $istoday = false;
foreach($r as $rr) { foreach ($r as $rr) {
if(strlen($rr['name'])) if(strlen($rr['name']))
$total ++; $total ++;
if((strtotime($rr['start'] . ' +00:00') < $now) && (strtotime($rr['finish'] . ' +00:00') > $now)) if((strtotime($rr['start'] . ' +00:00') < $now) && (strtotime($rr['finish'] . ' +00:00') > $now))
@ -549,7 +549,7 @@ function get_events() {
if (dbm::is_result($r)) { if (dbm::is_result($r)) {
$now = strtotime('now'); $now = strtotime('now');
$istoday = false; $istoday = false;
foreach($r as $rr) { foreach ($r as $rr) {
if(strlen($rr['name'])) if(strlen($rr['name']))
$total ++; $total ++;

View file

@ -130,12 +130,13 @@ function send_message($recipient=0, $body='', $subject='', $replyto=''){
$match = null; $match = null;
if(preg_match_all("/\[img\](.*?)\[\/img\]/",$body,$match)) { if (preg_match_all("/\[img\](.*?)\[\/img\]/",$body,$match)) {
$images = $match[1]; $images = $match[1];
if(count($images)) { if (count($images)) {
foreach($images as $image) { foreach ($images as $image) {
if(! stristr($image,App::get_baseurl() . '/photo/')) if (! stristr($image,App::get_baseurl() . '/photo/')) {
continue; continue;
}
$image_uri = substr($image,strrpos($image,'/') + 1); $image_uri = substr($image,strrpos($image,'/') + 1);
$image_uri = substr($image_uri,0, strpos($image_uri,'-')); $image_uri = substr($image_uri,0, strpos($image_uri,'-'));
$r = q("UPDATE `photo` SET `allow_cid` = '%s' $r = q("UPDATE `photo` SET `allow_cid` = '%s'
@ -149,25 +150,25 @@ function send_message($recipient=0, $body='', $subject='', $replyto=''){
} }
} }
if($post_id) { if ($post_id) {
proc_run(PRIORITY_HIGH, "include/notifier.php", "mail", $post_id); proc_run(PRIORITY_HIGH, "include/notifier.php", "mail", $post_id);
return intval($post_id); return intval($post_id);
} else { }
else {
return -3; return -3;
} }
} }
function send_wallmessage($recipient='', $body='', $subject='', $replyto=''){ function send_wallmessage($recipient='', $body='', $subject='', $replyto=''){
if(! $recipient) return -1; if (! $recipient) {
return -1;
}
if(! strlen($subject)) if (! strlen($subject)) {
$subject = t('[no subject]'); $subject = t('[no subject]');
}
$guid = get_guid(32); $guid = get_guid(32);
$uri = 'urn:X-dfrn:' . App::get_baseurl() . ':' . local_user() . ':' . $guid; $uri = 'urn:X-dfrn:' . App::get_baseurl() . ':' . local_user() . ':' . $guid;
@ -179,8 +180,9 @@ function send_wallmessage($recipient='', $body='', $subject='', $replyto=''){
$me = probe_url($replyto); $me = probe_url($replyto);
if(! $me['name']) if (! $me['name']) {
return -2; return -2;
}
$conv_guid = get_guid(32); $conv_guid = get_guid(32);
@ -193,7 +195,7 @@ function send_wallmessage($recipient='', $body='', $subject='', $replyto=''){
$handles = $recip_handle . ';' . $sender_handle; $handles = $recip_handle . ';' . $sender_handle;
$r = q("insert into conv (uid,guid,creator,created,updated,subject,recips) values(%d, '%s', '%s', '%s', '%s', '%s', '%s') ", $r = q("INSERT INTO `conv` (`uid`,`guid`,`creator`,`created`,`updated`,`subject`,`recips`) values(%d, '%s', '%s', '%s', '%s', '%s', '%s') ",
intval($recipient['uid']), intval($recipient['uid']),
dbesc($conv_guid), dbesc($conv_guid),
dbesc($sender_handle), dbesc($sender_handle),
@ -203,18 +205,19 @@ function send_wallmessage($recipient='', $body='', $subject='', $replyto=''){
dbesc($handles) dbesc($handles)
); );
$r = q("select * from conv where guid = '%s' and uid = %d limit 1", $r = q("SELECT * FROM `conv` WHERE `guid` = '%s' AND `uid` = %d LIMIT 1",
dbesc($conv_guid), dbesc($conv_guid),
intval($recipient['uid']) intval($recipient['uid'])
); );
if (dbm::is_result($r))
$convid = $r[0]['id'];
if(! $convid) {
if (! dbm::is_result($r)) {
logger('send message: conversation not found.'); logger('send message: conversation not found.');
return -4; return -4;
} }
$convid = $r[0]['id'];
$r = q("INSERT INTO `mail` ( `uid`, `guid`, `convid`, `from-name`, `from-photo`, `from-url`, $r = q("INSERT INTO `mail` ( `uid`, `guid`, `convid`, `from-name`, `from-photo`, `from-url`,
`contact-id`, `title`, `body`, `seen`, `reply`, `replied`, `uri`, `parent-uri`, `created`, `unknown`) `contact-id`, `title`, `body`, `seen`, `reply`, `replied`, `uri`, `parent-uri`, `created`, `unknown`)
VALUES ( %d, '%s', %d, '%s', '%s', '%s', %d, '%s', '%s', %d, %d, %d, '%s', '%s', '%s', %d )", VALUES ( %d, '%s', %d, '%s', '%s', '%s', %d, '%s', '%s', %d, %d, %d, '%s', '%s', '%s', %d )",

View file

@ -598,7 +598,7 @@ function notifier_run(&$argv, &$argc){
// throw everything into the queue in case we get killed // throw everything into the queue in case we get killed
foreach($r as $rr) { foreach ($r as $rr) {
if((! $mail) && (! $fsuggest) && (! $followup)) { if((! $mail) && (! $fsuggest) && (! $followup)) {
q("INSERT INTO `deliverq` (`cmd`,`item`,`contact`) VALUES ('%s', %d, %d) q("INSERT INTO `deliverq` (`cmd`,`item`,`contact`) VALUES ('%s', %d, %d)
ON DUPLICATE KEY UPDATE `cmd` = '%s', `item` = %d, `contact` = %d", ON DUPLICATE KEY UPDATE `cmd` = '%s', `item` = %d, `contact` = %d",
@ -608,7 +608,7 @@ function notifier_run(&$argv, &$argc){
} }
} }
foreach($r as $rr) { foreach ($r as $rr) {
// except for Diaspora batch jobs // except for Diaspora batch jobs
// Don't deliver to folks who have already been delivered to // Don't deliver to folks who have already been delivered to

View file

@ -187,8 +187,9 @@ function load_hooks() {
$a = get_app(); $a = get_app();
$a->hooks = array(); $a->hooks = array();
$r = q("SELECT * FROM `hook` WHERE 1 ORDER BY `priority` DESC, `file`"); $r = q("SELECT * FROM `hook` WHERE 1 ORDER BY `priority` DESC, `file`");
if (dbm::is_result($r)) { if (dbm::is_result($r)) {
foreach($r as $rr) { foreach ($r as $rr) {
if(! array_key_exists($rr['hook'],$a->hooks)) if(! array_key_exists($rr['hook'],$a->hooks))
$a->hooks[$rr['hook']] = array(); $a->hooks[$rr['hook']] = array();
$a->hooks[$rr['hook']][] = array($rr['file'],$rr['function']); $a->hooks[$rr['hook']][] = array($rr['file'],$rr['function']);

View file

@ -76,16 +76,19 @@ function pubsubpublish_run(&$argv, &$argc){
load_config('system'); load_config('system');
// Don't check this stuff if the function is called by the poller // Don't check this stuff if the function is called by the poller
if (App::callstack() != "poller_run") if (App::callstack() != "poller_run") {
if (App::is_already_running("pubsubpublish", "include/pubsubpublish.php", 540)) if (App::is_already_running("pubsubpublish", "include/pubsubpublish.php", 540)) {
return; return;
}
}
$a->set_baseurl(get_config('system','url')); $a->set_baseurl(get_config('system','url'));
load_hooks(); load_hooks();
if($argc > 1) if ($argc > 1) {
$pubsubpublish_id = intval($argv[1]); $pubsubpublish_id = intval($argv[1]);
}
else { else {
// We'll push to each subscriber that has push > 0, // We'll push to each subscriber that has push > 0,
// i.e. there has been an update (set in notifier.php). // i.e. there has been an update (set in notifier.php).
@ -95,10 +98,11 @@ function pubsubpublish_run(&$argv, &$argc){
$interval = Config::get("system", "delivery_interval", 2); $interval = Config::get("system", "delivery_interval", 2);
// If we are using the worker we don't need a delivery interval // If we are using the worker we don't need a delivery interval
if (get_config("system", "worker")) if (get_config("system", "worker")) {
$interval = false; $interval = false;
}
foreach($r as $rr) { foreach ($r as $rr) {
logger("Publish feed to ".$rr["callback_url"], LOGGER_DEBUG); logger("Publish feed to ".$rr["callback_url"], LOGGER_DEBUG);
proc_run(PRIORITY_HIGH, 'include/pubsubpublish.php', $rr["id"]); proc_run(PRIORITY_HIGH, 'include/pubsubpublish.php', $rr["id"]);

View file

@ -58,20 +58,21 @@ function queue_run(&$argv, &$argc){
$interval = false; $interval = false;
$r = q("select * from deliverq where 1"); $r = q("select * from deliverq where 1");
if($r) { if ($r) {
foreach($r as $rr) { foreach ($r as $rr) {
logger('queue: deliverq'); logger('queue: deliverq');
proc_run(PRIORITY_HIGH,'include/delivery.php',$rr['cmd'],$rr['item'],$rr['contact']); proc_run(PRIORITY_HIGH,'include/delivery.php',$rr['cmd'],$rr['item'],$rr['contact']);
if($interval) if($interval) {
@time_sleep_until(microtime(true) + (float) $interval); time_sleep_until(microtime(true) + (float) $interval);
}
} }
} }
$r = q("SELECT `queue`.*, `contact`.`name`, `contact`.`uid` FROM `queue` $r = q("SELECT `queue`.*, `contact`.`name`, `contact`.`uid` FROM `queue`
INNER JOIN `contact` ON `queue`.`cid` = `contact`.`id` INNER JOIN `contact` ON `queue`.`cid` = `contact`.`id`
WHERE `queue`.`created` < UTC_TIMESTAMP() - INTERVAL 3 DAY"); WHERE `queue`.`created` < UTC_TIMESTAMP() - INTERVAL 3 DAY");
if($r) { if ($r) {
foreach($r as $rr) { foreach ($r as $rr) {
logger('Removing expired queue item for ' . $rr['name'] . ', uid=' . $rr['uid']); logger('Removing expired queue item for ' . $rr['name'] . ', uid=' . $rr['uid']);
logger('Expired queue data :' . $rr['content'], LOGGER_DATA); logger('Expired queue data :' . $rr['content'], LOGGER_DATA);
} }

View file

@ -912,7 +912,7 @@ function contact_block() {
if (dbm::is_result($r)) { if (dbm::is_result($r)) {
$contacts = sprintf( tt('%d Contact','%d Contacts', $total),$total); $contacts = sprintf( tt('%d Contact','%d Contacts', $total),$total);
$micropro = Array(); $micropro = Array();
foreach($r as $rr) { foreach ($r as $rr) {
$micropro[] = micropro($rr,true,'mpfriend'); $micropro[] = micropro($rr,true,'mpfriend');
} }
} }
@ -1717,7 +1717,7 @@ function bb_translate_video($s) {
$matches = null; $matches = null;
$r = preg_match_all("/\[video\](.*?)\[\/video\]/ism",$s,$matches,PREG_SET_ORDER); $r = preg_match_all("/\[video\](.*?)\[\/video\]/ism",$s,$matches,PREG_SET_ORDER);
if($r) { if ($r) {
foreach($matches as $mtch) { foreach($matches as $mtch) {
if((stristr($mtch[1],'youtube')) || (stristr($mtch[1],'youtu.be'))) if((stristr($mtch[1],'youtube')) || (stristr($mtch[1],'youtu.be')))
$s = str_replace($mtch[0],'[youtube]' . $mtch[1] . '[/youtube]',$s); $s = str_replace($mtch[0],'[youtube]' . $mtch[1] . '[/youtube]',$s);

View file

@ -216,7 +216,7 @@ function create_user($arr) {
dbesc($default_service_class) dbesc($default_service_class)
); );
if($r) { if ($r) {
$r = q("SELECT * FROM `user` $r = q("SELECT * FROM `user`
WHERE `username` = '%s' AND `password` = '%s' LIMIT 1", WHERE `username` = '%s' AND `password` = '%s' LIMIT 1",
dbesc($username), dbesc($username),