X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=mod%2Fitem.php;h=a681ca70da192a739a2293be62eabf73a49010f6;hb=5ab697e7264d2609e764723f708b647349f2004f;hp=f696a96a7ee7d1c10d4965325cfe01a344a6d200;hpb=8f253f6c1288534c50fac34f05afb1a2c07c9335;p=friendica.git diff --git a/mod/item.php b/mod/item.php index f696a96a7e..a681ca70da 100644 --- a/mod/item.php +++ b/mod/item.php @@ -16,6 +16,7 @@ */ use Friendica\App; +use Friendica\Core\System; require_once 'include/crypto.php'; require_once 'include/enotify.php'; @@ -66,7 +67,7 @@ function item_post(App $a) { if (!$preview && x($_REQUEST, 'post_id_random')) { if (x($_SESSION, 'post-random') && $_SESSION['post-random'] == $_REQUEST['post_id_random']) { logger("item post: duplicate post", LOGGER_DEBUG); - item_post_return(App::get_baseurl(), $api_source, $return_path); + item_post_return(System::baseUrl(), $api_source, $return_path); } else { $_SESSION['post-random'] = $_REQUEST['post_id_random']; } @@ -139,8 +140,8 @@ function item_post(App $a) { // If the contact id doesn't fit with the contact, then set the contact to null $thrparent = q("SELECT `author-link`, `network` FROM `item` WHERE `uri` = '%s' LIMIT 1", dbesc($thr_parent)); - if (dbm::is_result($thrparent) AND ($thrparent[0]["network"] === NETWORK_OSTATUS) - AND (normalise_link($parent_contact["url"]) != normalise_link($thrparent[0]["author-link"]))) { + if (dbm::is_result($thrparent) && ($thrparent[0]["network"] === NETWORK_OSTATUS) + && (normalise_link($parent_contact["url"]) != normalise_link($thrparent[0]["author-link"]))) { $parent_contact = get_contact_details_by_url($thrparent[0]["author-link"]); if (!isset($parent_contact["nick"])) { @@ -175,7 +176,7 @@ function item_post(App $a) { $object = ((x($_REQUEST, 'object')) ? $_REQUEST['object'] : ''); // Check for multiple posts with the same message id (when the post was created via API) - if (($message_id != '') AND ($profile_uid != 0)) { + if (($message_id != '') && ($profile_uid != 0)) { $r = q("SELECT * FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1", dbesc($message_id), intval($profile_uid) @@ -309,8 +310,8 @@ function item_post(App $a) { // for non native networks use the network of the original post as network of the item if (($parent_item['network'] != NETWORK_DIASPORA) - AND ($parent_item['network'] != NETWORK_OSTATUS) - AND ($network == "")) { + && ($parent_item['network'] != NETWORK_OSTATUS) + && ($network == "")) { $network = $parent_item['network']; } @@ -436,7 +437,7 @@ function item_post(App $a) { $objecttype = ACTIVITY_OBJ_IMAGE; foreach ($images as $image) { - if (! stristr($image,App::get_baseurl() . '/photo/')) { + if (! stristr($image,System::baseUrl() . '/photo/')) { continue; } $image_uri = substr($image,strrpos($image,'/') + 1); @@ -504,7 +505,7 @@ function item_post(App $a) { $bookmark = 0; $data = get_attachment_data($body); - if (preg_match_all("/\[bookmark\=([^\]]*)\](.*?)\[\/bookmark\]/ism", $body, $match, PREG_SET_ORDER) OR isset($data["type"])) { + if (preg_match_all("/\[bookmark\=([^\]]*)\](.*?)\[\/bookmark\]/ism", $body, $match, PREG_SET_ORDER) || isset($data["type"])) { $objecttype = ACTIVITY_OBJ_BOOKMARK; $bookmark = 1; } @@ -543,7 +544,7 @@ function item_post(App $a) { * add a statusnet style reply tag if the original post was from there * and we are replying, and there isn't one already */ - if ($parent AND ($parent_contact['network'] == NETWORK_OSTATUS)) { + if ($parent && ($parent_contact['network'] == NETWORK_OSTATUS)) { $contact = '@[url=' . $parent_contact['url'] . ']' . $parent_contact['nick'] . '[/url]'; if (!in_array($contact, $tags)) { @@ -625,7 +626,7 @@ function item_post(App $a) { if (strlen($attachments)) { $attachments .= ','; } - $attachments .= '[attach]href="' . App::get_baseurl() . '/attach/' . $r[0]['id'] . '" length="' . $r[0]['filesize'] . '" type="' . $r[0]['filetype'] . '" title="' . (($r[0]['filename']) ? $r[0]['filename'] : '') . '"[/attach]'; + $attachments .= '[attach]href="' . System::baseUrl() . '/attach/' . $r[0]['id'] . '" length="' . $r[0]['filesize'] . '" type="' . $r[0]['filetype'] . '" title="' . (($r[0]['filename']) ? $r[0]['filename'] : '') . '"[/attach]'; } $body = str_replace($match[1],'',$body); } @@ -720,7 +721,7 @@ function item_post(App $a) { // $datarray['prvnets'] = $user['prvnets']; $datarray['parent-uri'] = ($parent == 0) ? $uri : $parent_item['uri']; - $datarray['plink'] = App::get_baseurl() . '/display/' . urlencode($datarray['guid']); + $datarray['plink'] = System::baseUrl() . '/display/' . urlencode($datarray['guid']); $datarray['last-child'] = 1; $datarray['visible'] = 1; @@ -765,7 +766,7 @@ function item_post(App $a) { $json = array('cancel' => 1); if (x($_REQUEST, 'jsreload') && strlen($_REQUEST['jsreload'])) { - $json['reload'] = App::get_baseurl() . '/' . $_REQUEST['jsreload']; + $json['reload'] = System::baseUrl() . '/' . $_REQUEST['jsreload']; } echo json_encode($json); @@ -887,12 +888,7 @@ function item_post(App $a) { ); if (dbm::is_result($r)) { - $r = q("SELECT LAST_INSERT_ID() AS `item-id`"); - if (dbm::is_result($r)) { - $post_id = $r[0]['item-id']; - } else { - $post_id = 0; - } + $post_id = dba::lastInsertId(); } else { logger('mod_item: unable to create post.'); $post_id = 0; @@ -940,7 +936,7 @@ function item_post(App $a) { 'to_email' => $user['email'], 'uid' => $user['uid'], 'item' => $datarray, - 'link' => App::get_baseurl().'/display/'.urlencode($datarray['guid']), + 'link' => System::baseUrl().'/display/'.urlencode($datarray['guid']), 'source_name' => $datarray['author-name'], 'source_link' => $datarray['author-link'], 'source_photo' => $datarray['author-avatar'], @@ -972,7 +968,7 @@ function item_post(App $a) { 'to_email' => $user['email'], 'uid' => $user['uid'], 'item' => $datarray, - 'link' => App::get_baseurl().'/display/'.urlencode($datarray['guid']), + 'link' => System::baseUrl().'/display/'.urlencode($datarray['guid']), 'source_name' => $datarray['author-name'], 'source_link' => $datarray['author-link'], 'source_photo' => $datarray['author-avatar'], @@ -994,14 +990,14 @@ function item_post(App $a) { } $disclaimer = '
' . sprintf( t('This message was sent to you by %s, a member of the Friendica social network.'), $a->user['username']) . '
'; - $disclaimer .= sprintf( t('You may visit them online at %s'), App::get_baseurl() . '/profile/' . $a->user['nickname']) . EOL; + $disclaimer .= sprintf( t('You may visit them online at %s'), System::baseUrl() . '/profile/' . $a->user['nickname']) . EOL; $disclaimer .= t('Please contact the sender by replying to this post if you do not wish to receive these messages.') . EOL; if (!$datarray['title']=='') { $subject = email_header_encode($datarray['title'], 'UTF-8'); } else { $subject = email_header_encode('[Friendica]' . ' ' . sprintf( t('%s posted an update.'), $a->user['username']), 'UTF-8'); } - $link = '' . $a->user['username'] . '

'; + $link = '' . $a->user['username'] . '

'; $html = prepare_body($datarray); $message = '' . $link . $html . $disclaimer . ''; include_once 'include/html2plain.php'; @@ -1041,7 +1037,7 @@ function item_post(App $a) { logger('post_complete'); - item_post_return(App::get_baseurl(), $api_source, $return_path); + item_post_return(System::baseUrl(), $api_source, $return_path); // NOTREACHED } @@ -1226,7 +1222,7 @@ function handle_tag(App $a, &$body, &$inform, &$str_tags, $profile_uid, $tag, $n } // select someone by attag or nick and the name passed in the current network - if(!dbm::is_result($r) AND ($network != "")) + if(!dbm::is_result($r) && ($network != "")) $r = q("SELECT `id`, `url`, `nick`, `name`, `alias`, `network` FROM `contact` WHERE `attag` = '%s' OR `nick` = '%s' AND `network` = '%s' AND `uid` = %d ORDER BY `attag` DESC LIMIT 1", dbesc($name), dbesc($name), @@ -1235,7 +1231,7 @@ function handle_tag(App $a, &$body, &$inform, &$str_tags, $profile_uid, $tag, $n ); //select someone from this user's contacts by name in the current network - if (!dbm::is_result($r) AND ($network != "")) { + if (!dbm::is_result($r) && ($network != "")) { $r = q("SELECT `id`, `url`, `nick`, `name`, `alias`, `network` FROM `contact` WHERE `name` = '%s' AND `network` = '%s' AND `uid` = %d LIMIT 1", dbesc($name), dbesc($network), @@ -1262,7 +1258,7 @@ function handle_tag(App $a, &$body, &$inform, &$str_tags, $profile_uid, $tag, $n } if (dbm::is_result($r)) { - if (strlen($inform) AND (isset($r[0]["notify"]) OR isset($r[0]["id"]))) { + if (strlen($inform) && (isset($r[0]["notify"]) || isset($r[0]["id"]))) { $inform .= ','; } @@ -1275,14 +1271,14 @@ function handle_tag(App $a, &$body, &$inform, &$str_tags, $profile_uid, $tag, $n $profile = $r[0]["url"]; $alias = $r[0]["alias"]; $newname = $r[0]["nick"]; - if (($newname == "") OR (($r[0]["network"] != NETWORK_OSTATUS) AND ($r[0]["network"] != NETWORK_TWITTER) - AND ($r[0]["network"] != NETWORK_STATUSNET) AND ($r[0]["network"] != NETWORK_APPNET))) { + if (($newname == "") || (($r[0]["network"] != NETWORK_OSTATUS) && ($r[0]["network"] != NETWORK_TWITTER) + && ($r[0]["network"] != NETWORK_STATUSNET) && ($r[0]["network"] != NETWORK_APPNET))) { $newname = $r[0]["name"]; } } //if there is an url for this persons profile - if (isset($profile) AND ($newname != "")) { + if (isset($profile) && ($newname != "")) { $replaced = true; // create profile link