function parse_url_content(&$a) { $text = null; $str_tags = ''; $textmode = false; if (local_user() && !feature_enabled(local_user(), 'richtext')) { $textmode = true; } //if($textmode) $br = $textmode ? "\n" : '<br />'; if (x($_GET, 'binurl')) { $url = trim(hex2bin($_GET['binurl'])); } else { $url = trim($_GET['url']); } if ($_GET['title']) { $title = strip_tags(trim($_GET['title'])); } if ($_GET['description']) { $text = strip_tags(trim($_GET['description'])); } if ($_GET['tags']) { $arr_tags = str_getcsv($_GET['tags']); if (count($arr_tags)) { array_walk($arr_tags, 'arr_add_hashes'); $str_tags = $br . implode(' ', $arr_tags) . $br; } } // add url scheme if missing $arrurl = parse_url($url); if (!x($arrurl, 'scheme')) { if (x($arrurl, 'host')) { $url = "http:" . $url; } else { $url = "http://" . $url; } } logger('parse_url: ' . $url); if ($textmode) { $template = '[bookmark=%s]%s[/bookmark]%s'; } else { $template = "<a class=\"bookmark\" href=\"%s\" >%s</a>%s"; } $arr = array('url' => $url, 'text' => ''); call_hooks('parse_link', $arr); if (strlen($arr['text'])) { echo $arr['text']; killme(); } if ($url && $title && $text) { $title = str_replace(array("\r", "\n"), array('', ''), $title); if ($textmode) { $text = '[quote]' . trim($text) . '[/quote]' . $br; } else { $text = '<blockquote>' . htmlspecialchars(trim($text)) . '</blockquote><br />'; $title = htmlspecialchars($title); } $result = sprintf($template, $url, $title ? $title : $url, $text) . $str_tags; logger('parse_url (unparsed): returns: ' . $result); echo $result; killme(); } $siteinfo = parseurl_getsiteinfo($url); // if ($textmode) { // require_once("include/items.php"); // // echo add_page_info_data($siteinfo); // killme(); // } $url = $siteinfo["url"]; // If the link contains BBCode stuff, make a short link out of this to avoid parsing problems if (strpos($url, '[') or strpos($url, ']')) { require_once "include/network.php"; $url = short_link($url); } $sitedata = ""; if ($siteinfo["title"] != "") { $text = $siteinfo["text"]; $title = $siteinfo["title"]; } $image = ""; if ($siteinfo["type"] != "video" and sizeof($siteinfo["images"]) > 0) { /* Execute below code only if image is present in siteinfo */ $total_images = 0; $max_images = get_config('system', 'max_bookmark_images'); if ($max_images === false) { $max_images = 2; } else { $max_images = intval($max_images); } foreach ($siteinfo["images"] as $imagedata) { if ($textmode) { $image .= '[img=' . $imagedata["width"] . 'x' . $imagedata["height"] . ']' . $imagedata["src"] . '[/img]' . "\n"; } else { $image .= '<img height="' . $imagedata["height"] . '" width="' . $imagedata["width"] . '" src="' . $imagedata["src"] . '" alt="photo" /><br />'; } $total_images++; if ($max_images && $max_images >= $total_images) { break; } } } if (strlen($text)) { if ($textmode) { $text = '[quote]' . trim($text) . '[/quote]'; } else { $text = '<blockquote>' . htmlspecialchars(trim($text)) . '</blockquote>'; } } if ($image) { $text = $br . $br . $image . $text; } else { $text = $br . $text; } $title = str_replace(array("\r", "\n"), array('', ''), $title); $result = sprintf($template, $url, $title ? $title : $url, $text) . $str_tags; logger('parse_url: returns: ' . $result); $sitedata .= trim($result); if ($siteinfo["type"] == "video" and $url != "") { echo "[class=type-video]" . $sitedata . "[/class]"; } elseif ($siteinfo["type"] != "photo") { echo "[class=type-link]" . $sitedata . "[/class]"; } else { echo "[class=type-photo]" . $title . $br . $image . "[/class]"; } killme(); }
function twitter_post_hook(&$a, &$b) { /** * Post to Twitter */ if (!is_item_normal($b) || $b['item_private'] || $b['created'] !== $b['edited']) { return; } if (!perm_is_allowed($b['uid'], '', 'view_stream')) { return; } if (!strstr($b['postopts'], 'twitter')) { return; } if ($b['parent'] != $b['id']) { return; } logger('twitter post invoked'); load_pconfig($b['uid'], 'twitter'); $ckey = get_config('twitter', 'consumerkey'); $csecret = get_config('twitter', 'consumersecret'); $otoken = get_pconfig($b['uid'], 'twitter', 'oauthtoken'); $osecret = get_pconfig($b['uid'], 'twitter', 'oauthsecret'); $intelligent_shortening = get_pconfig($b['uid'], 'twitter', 'intelligent_shortening'); // Global setting overrides this if (get_config('twitter', 'intelligent_shortening')) { $intelligent_shortening = get_config('twitter', 'intelligent_shortening'); } if ($ckey && $csecret && $otoken && $osecret) { logger('twitter: we have customer key and oauth stuff, going to send.', LOGGER_DEBUG); // If it's a repeated message from twitter then do a native retweet and exit // if (twitter_is_retweet($a, $b['uid'], $b['body'])) // return; require_once 'library/twitteroauth.php'; require_once 'include/bbcode.php'; $tweet = new TwitterOAuth($ckey, $csecret, $otoken, $osecret); // in theory max char is 140 but T. uses t.co to make links // longer so we give them 10 characters extra if (!$intelligent_shortening) { $max_char = 130; // max. length for a tweet // we will only work with up to two times the length of the dent // we can later send to Twitter. This way we can "gain" some // information during shortening of potential links but do not // shorten all the links in a 200000 character long essay. if (!$b['title'] == '') { $tmp = $b['title'] . ' : ' . $b['body']; // $tmp = substr($tmp, 0, 4*$max_char); } else { $tmp = $b['body']; // substr($b['body'], 0, 3*$max_char); } // if [url=bla][img]blub.png[/img][/url] get blub.png $tmp = preg_replace('/\\[url\\=(https?\\:\\/\\/[a-zA-Z0-9\\:\\/\\-\\?\\&\\;\\.\\=\\_\\~\\#\\%\\$\\!\\+\\,]+)\\]\\[img\\](\\w+.*?)\\[\\/img\\]\\[\\/url\\]/i', '$2', $tmp); $tmp = preg_replace('/\\[zrl\\=(https?\\:\\/\\/[a-zA-Z0-9\\:\\/\\-\\?\\&\\;\\.\\=\\_\\~\\#\\%\\$\\!\\+\\,]+)\\]\\[zmg\\](\\w+.*?)\\[\\/zmg\\]\\[\\/zrl\\]/i', '$2', $tmp); // preserve links to images, videos and audios $tmp = preg_replace('/\\[img\\=([0-9]*)x([0-9]*)\\](.*?)\\[\\/img\\]/ism', '$3', $tmp); $tmp = preg_replace('/\\[\\/?img(\\s+.*?\\]|\\])/i', '', $tmp); $tmp = preg_replace('/\\[zmg\\=([0-9]*)x([0-9]*)\\](.*?)\\[\\/zmg\\]/ism', '$3', $tmp); $tmp = preg_replace('/\\[\\/?zmg(\\s+.*?\\]|\\])/i', '', $tmp); $tmp = preg_replace('/\\[\\/?video(\\s+.*?\\]|\\])/i', '', $tmp); $tmp = preg_replace('/\\[\\/?youtube(\\s+.*?\\]|\\])/i', '', $tmp); $tmp = preg_replace('/\\[\\/?vimeo(\\s+.*?\\]|\\])/i', '', $tmp); $tmp = preg_replace('/\\[\\/?audio(\\s+.*?\\]|\\])/i', '', $tmp); $linksenabled = get_pconfig($b['uid'], 'twitter', 'post_taglinks'); // if a #tag is linked, don't send the [url] over to SN // that is, don't send if the option is not set in the // connector settings if ($linksenabled == '0') { // #-tags $tmp = preg_replace('/#\\[url\\=(\\w+.*?)\\](\\w+.*?)\\[\\/url\\]/i', '#$2', $tmp); // @-mentions $tmp = preg_replace('/@\\[url\\=(\\w+.*?)\\](\\w+.*?)\\[\\/url\\]/i', '@$2', $tmp); $tmp = preg_replace('/#\\[zrl\\=(\\w+.*?)\\](\\w+.*?)\\[\\/zrl\\]/i', '#$2', $tmp); // @-mentions $tmp = preg_replace('/@\\[zrl\\=(\\w+.*?)\\](\\w+.*?)\\[\\/zrl\\]/i', '@$2', $tmp); // recycle 1 } $tmp = preg_replace('/\\[url\\=(https?\\:\\/\\/[a-zA-Z0-9\\:\\/\\-\\?\\&\\;\\.\\=\\_\\~\\#\\%\\$\\!\\+\\,]+)\\](\\w+.*?)\\[\\/url\\]/i', '$2 $1', $tmp); // find all http or https links in the body of the entry and // apply the shortener if the link is longer then 20 characters if (strlen($tmp) > $max_char && $max_char > 0) { preg_match_all('/(https?\\:\\/\\/[a-zA-Z0-9\\:\\/\\-\\?\\&\\;\\.\\=\\_\\~\\#\\%\\$\\!\\+\\,]+)/i', $tmp, $allurls); foreach ($allurls as $url) { foreach ($url as $u) { if (strlen($u) > 20) { $sl = short_link($u); $tmp = str_replace($u, $sl, $tmp); } } } } // ok, all the links we want to send out are save, now strip // away the remaining bbcode //$msg = strip_tags(bbcode($tmp, false, false)); $msg = bbcode($tmp, false, false); $msg = str_replace(array('<br>', '<br />'), "\n", $msg); $msg = strip_tags($msg); // quotes not working - let's try this $msg = html_entity_decode($msg); if (strlen($msg) > $max_char && $max_char > 0) { $shortlink = short_link($b['plink']); // the new message will be shortened such that "... $shortlink" // will fit into the character limit $msg = nl2br(substr($msg, 0, $max_char - strlen($shortlink) - 4)); $msg = str_replace(array('<br>', '<br />'), ' ', $msg); $e = explode(' ', $msg); // remove the last word from the cut down message to // avoid sending cut words to the MicroBlog array_pop($e); $msg = implode(' ', $e); $msg .= '... ' . $shortlink; } $msg = trim($msg); $image = ""; } else { $msgarr = twitter_shortenmsg($b); $msg = $msgarr["msg"]; $image = $msgarr["image"]; } // and now tweet it :-) // if(strlen($msg) and ($image != "")) { // $img_str = z_fetch_url($image); // $tempfile = tempnam(get_config("system","temppath"), "cache"); // file_put_contents($tempfile, $img_str); // Twitter had changed something so that the old library doesn't work anymore // so we are using a new library for twitter // To-Do: // Switching completely to this library with all functions require_once "addon/twitter/codebird.php"; // $cb = \Codebird\Codebird::getInstance(); // $cb->setConsumerKey($ckey, $csecret); // $cb->setToken($otoken, $osecret); // $post = array('status' => $msg, 'media[]' => $tempfile); // if ($iscomment) // $post["in_reply_to_status_id"] = substr($orig_post["uri"], 9); // $result = $cb->statuses_updateWithMedia($post); // unlink($tempfile); // logger('twitter_post_with_media send, result: ' . print_r($result, true), LOGGER_DEBUG); // if ($result->errors OR $result->error) { // logger('Send to Twitter failed: "' . print_r($result->errors, true) . '"'); // Workaround: Remove the picture link so that the post can be reposted without it // $msg .= " ".$image; // $image = ""; // } elseif ($iscomment) { // logger('twitter_post: Update extid '.$result->id_str." for post id ".$b['id']); // q("UPDATE `item` SET `extid` = '%s', `body` = '%s' WHERE `id` = %d", // dbesc("twitter::".$result->id_str), // dbesc($result->text), // intval($b['id']) // ); // } // } if (strlen($msg) and $image == "") { $url = 'statuses/update'; $post = array('status' => $msg); if ($iscomment) { $post["in_reply_to_status_id"] = substr($orig_post["uri"], 9); } $result = $tweet->post($url, $post); logger('twitter_post send, result: ' . print_r($result, true), LOGGER_DEBUG); if ($result->errors) { logger('Send to Twitter failed: "' . print_r($result->errors, true) . '"'); } // elseif ($iscomment) { // logger('twitter_post: Update extid '.$result->id_str." for post id ".$b['id']); // q("UPDATE `item` SET `extid` = '%s' WHERE `id` = %d", // dbesc("twitter::".$result->id_str), // intval($b['id']) // ); //q("UPDATE `item` SET `extid` = '%s', `body` = '%s' WHERE `id` = %d", // dbesc("twitter::".$result->id_str), // dbesc($result->text), // intval($b['id']) //); // } } } }
function add_page_info_data($data) { call_hooks('page_info_data', $data); // It maybe is a rich content, but if it does have everything that a link has, // then treat it that way if ($data["type"] == "rich" and is_string($data["title"]) and is_string($data["text"]) and sizeof($data["images"]) > 0) { $data["type"] = "link"; } if ($data["type"] != "link" and $data["type"] != "video" and $data["type"] != "photo" or $data["title"] == $url) { return ""; } if ($no_photos and $data["type"] == "photo") { return ""; } // If the link contains BBCode stuff, make a short link out of this to avoid parsing problems if (strpos($data["url"], '[') or strpos($data["url"], ']')) { require_once "include/network.php"; $data["url"] = short_link($data["url"]); } if ($data["type"] != "photo" and is_string($data["title"])) { $text .= "[bookmark=" . $data["url"] . "]" . trim($data["title"]) . "[/bookmark]"; } if ($data["type"] != "video" and $photo != "") { $text .= '[img]' . $photo . '[/img]'; } elseif ($data["type"] != "video" and sizeof($data["images"]) > 0) { $imagedata = $data["images"][0]; $text .= '[img]' . $imagedata["src"] . '[/img]'; } if ($data["type"] != "photo" and is_string($data["text"])) { $text .= "[quote]" . $data["text"] . "[/quote]"; } $hashtags = ""; if (isset($data["keywords"]) and count($data["keywords"])) { $a = get_app(); $hashtags = "\n"; foreach ($data["keywords"] as $keyword) { $hashtag = str_replace(array(" ", "+", "/", ".", "#", "'"), array("", "", "", "", "", ""), $keyword); $hashtags .= "#[url=" . $a->get_baseurl() . "/search?tag=" . rawurlencode($hashtag) . "]" . $hashtag . "[/url] "; } } return "\n[class=type-" . $data["type"] . "]" . $text . "[/class]" . $hashtags; }
function statusnet_post_hook(&$a, &$b) { /** * Post to statusnet */ if (!strstr($b['postopts'], 'statusnet')) { logger('crosspost not enabled.'); return; } if (!is_item_normal($b) || $b['item_private'] || $b['created'] !== $b['edited']) { logger('not a usable post. ' . print_r($b, true), LOGGER_DEBUG); return; } if (!perm_is_allowed($b['uid'], '', 'view_stream')) { logger('permissions prevent crossposting.', LOGGER_DEBUG); return; } if ($b['parent'] != $b['id']) { logger('not a top level post.', LOGGER_DEBUG); return; } // if posts comes from statusnet don't send it back if ($b['app'] == "StatusNet") { logger('potential recursion. Crosspost ignored.'); return; } logger('statusnet post invoked'); load_pconfig($b['uid'], 'statusnet'); $api = get_pconfig($b['uid'], 'statusnet', 'baseapi'); $ckey = get_pconfig($b['uid'], 'statusnet', 'consumerkey'); $csecret = get_pconfig($b['uid'], 'statusnet', 'consumersecret'); $otoken = get_pconfig($b['uid'], 'statusnet', 'oauthtoken'); $osecret = get_pconfig($b['uid'], 'statusnet', 'oauthsecret'); $intelligent_shortening = get_pconfig($b['uid'], 'statusnet', 'intelligent_shortening'); // Global setting overrides this if (get_config('statusnet', 'intelligent_shortening')) { $intelligent_shortening = get_config('statusnet', 'intelligent_shortening'); } if ($ckey && $csecret && $otoken && $osecret) { require_once 'include/bbcode.php'; $dent = new StatusNetOAuth($api, $ckey, $csecret, $otoken, $osecret); $max_char = $dent->get_maxlength(); // max. length for a dent // we will only work with up to two times the length of the dent // we can later send to GNU social. This way we can "gain" some // information during shortening of potential links but do not // shorten all the links in a 200000 character long essay. $tempfile = ""; $intelligent_shortening = get_config('statusnet', 'intelligent_shortening'); if (!$intelligent_shortening) { if (!$b['title'] == '') { $tmp = $b['title'] . ": \n" . $b['body']; // $tmp = substr($tmp, 0, 4*$max_char); } else { $tmp = $b['body']; // substr($b['body'], 0, 3*$max_char); } // if [url=bla][img]blub.png[/img][/url] get blub.png $tmp = preg_replace('/\\[url\\=(https?\\:\\/\\/[a-zA-Z0-9\\:\\/\\-\\?\\&\\;\\.\\=\\_\\~\\#\\%\\$\\!\\+\\,]+)\\]\\[img\\](\\w+.*?)\\[\\/img\\]\\[\\/url\\]/i', '$2', $tmp); $tmp = preg_replace('/\\[zrl\\=(https?\\:\\/\\/[a-zA-Z0-9\\:\\/\\-\\?\\&\\;\\.\\=\\_\\~\\#\\%\\$\\!\\+\\,]+)\\]\\[zmg\\](\\w+.*?)\\[\\/zmg\\]\\[\\/zrl\\]/i', '$2', $tmp); // preserve links to images, videos and audios $tmp = preg_replace('/\\[img\\=([0-9]*)x([0-9]*)\\](.*?)\\[\\/img\\]/ism', '$3', $tmp); $tmp = preg_replace('/\\[\\/?img(\\s+.*?\\]|\\])/i', '', $tmp); $tmp = preg_replace('/\\[zmg\\=([0-9]*)x([0-9]*)\\](.*?)\\[\\/zmg\\]/ism', '$3', $tmp); $tmp = preg_replace('/\\[\\/?zmg(\\s+.*?\\]|\\])/i', '', $tmp); $tmp = preg_replace('/\\[\\/?video(\\s+.*?\\]|\\])/i', '', $tmp); $tmp = preg_replace('/\\[\\/?audio(\\s+.*?\\]|\\])/i', '', $tmp); $linksenabled = get_pconfig($b['uid'], 'statusnet', 'post_taglinks'); // if a #tag is linked, don't send the [url] over to SN // that is, don't send if the option is not set in the // connector settings if ($linksenabled == '0') { // #-tags $tmp = preg_replace('/#\\[url\\=(\\w+.*?)\\](\\w+.*?)\\[\\/url\\]/i', '#$2', $tmp); // @-mentions $tmp = preg_replace('/@\\[url\\=(\\w+.*?)\\](\\w+.*?)\\[\\/url\\]/i', '@$2', $tmp); // #-tags $tmp = preg_replace('/#\\[zrl\\=(\\w+.*?)\\](\\w+.*?)\\[\\/zrl\\]/i', '#$2', $tmp); // @-mentions $tmp = preg_replace('/@\\[zrl\\=(\\w+.*?)\\](\\w+.*?)\\[\\/zrl\\]/i', '@$2', $tmp); // recycle 1 $recycle = html_entity_decode("♲ ", ENT_QUOTES, 'UTF-8'); $tmp = preg_replace('/' . $recycle . '\\[url\\=(\\w+.*?)\\](\\w+.*?)\\[\\/url\\]/i', $recycle . '$2', $tmp); // recycle 2 (test) $recycle = html_entity_decode("◌ ", ENT_QUOTES, 'UTF-8'); $tmp = preg_replace('/' . $recycle . '\\[url\\=(\\w+.*?)\\](\\w+.*?)\\[\\/url\\]/i', $recycle . '$2', $tmp); } // preserve links to webpages $tmp = preg_replace('/\\[url\\=(https?\\:\\/\\/[a-zA-Z0-9\\:\\/\\-\\?\\&\\;\\.\\=\\_\\~\\#\\%\\$\\!\\+\\,]+)\\](\\w+.*?)\\[\\/url\\]/i', '$2 $1', $tmp); $tmp = preg_replace('/\\[zrl\\=(https?\\:\\/\\/[a-zA-Z0-9\\:\\/\\-\\?\\&\\;\\.\\=\\_\\~\\#\\%\\$\\!\\+\\,]+)\\](\\w+.*?)\\[\\/zrl\\]/i', '$2 $1', $tmp); // find all http or https links in the body of the entry and // apply the shortener if the link is longer then 20 characters if (strlen($tmp) > $max_char && $max_char > 0) { preg_match_all('/(https?\\:\\/\\/[a-zA-Z0-9\\:\\/\\-\\?\\&\\;\\.\\=\\_\\~\\#\\%\\$\\!\\+\\,]+)/i', $tmp, $allurls); foreach ($allurls as $url) { foreach ($url as $u) { if (strlen($u) > 20) { $sl = short_link($u); $tmp = str_replace($u, $sl, $tmp); } } } } // ok, all the links we want to send out are save, now strip // away the remaining bbcode $msg = bbcode($tmp, false, false, true); $msg = str_replace(array('<br>', '<br />'), "\n", $msg); $msg = strip_tags($msg); // quotes not working - let's try this $msg = html_entity_decode($msg); if (strlen($msg) > $max_char && $max_char > 0) { $shortlink = short_link($b['plink']); // the new message will be shortened such that "... $shortlink" // will fit into the character limit $msg = nl2br(substr($msg, 0, $max_char - strlen($shortlink) - 4)); $msg = str_replace(array('<br>', '<br />'), ' ', $msg); $e = explode(' ', $msg); // remove the last word from the cut down message to // avoid sending cut words to the MicroBlog array_pop($e); $msg = implode(' ', $e); $msg .= '... ' . $shortlink; } $msg = trim($msg); $postdata = array('status' => $msg); } else { $msgarr = statusnet_shortenmsg($b, $max_char); $msg = $msgarr["msg"]; $image = $msgarr["image"]; if ($image != "") { $x = z_fetch_url($image, true, 0, array('novalidate' => true)); if ($x['success']) { $imagedata = $x['body']; $tempfile = tempnam(get_config("system", "temppath"), "upload"); file_put_contents($tempfile, $imagedata); $postdata = array("status" => $msg, "media" => "@" . $tempfile); } } else { $postdata = array("status" => $msg); } } // and now dent it :-) if (strlen($msg)) { $result = $dent->post('statuses/update', $postdata); logger('statusnet_post send, result: ' . print_r($result, true) . "\nmessage: " . $msg, LOGGER_DEBUG); logger("Original post: " . print_r($b, true) . "\nPost Data: " . print_r($postdata, true), LOGGER_DEBUG); if ($result->error) { logger('Send to GNU social failed: queued."' . $result->error . '"'); // @fixme - unable to queue media uploads if (!$image) { queue_insert(array('hash' => random_string(), 'account_id' => $b['aid'], 'channel_id' => $b['uid'], 'driver' => 'statusnet', 'posturl' => $api, 'msg' => $msg)); } } } if ($tempfile != "") { unlink($tempfile); } } }
function appnet_create_entities($a, $b, $postdata) { require_once "include/bbcode.php"; require_once "include/plaintext.php"; $bbcode = $b["body"]; $bbcode = bb_remove_share_information($bbcode, false, true); // Change pure links in text to bbcode uris $bbcode = preg_replace("/([^\\]\\='" . '"' . "]|^)(https?\\:\\/\\/[a-zA-Z0-9\\:\\/\\-\\?\\&\\;\\.\\=\\_\\~\\#\\%\$\\!\\+\\,]+)/ism", '$1[url=$2]$2[/url]', $bbcode); $URLSearchString = "^\\[\\]"; $bbcode = preg_replace("/#\\[url\\=([{$URLSearchString}]*)\\](.*?)\\[\\/url\\]/ism", '#$2', $bbcode); $bbcode = preg_replace("/@\\[url\\=([{$URLSearchString}]*)\\](.*?)\\[\\/url\\]/ism", '@$2', $bbcode); $bbcode = preg_replace("/\\[bookmark\\=([{$URLSearchString}]*)\\](.*?)\\[\\/bookmark\\]/ism", '[url=$1]$2[/url]', $bbcode); $bbcode = preg_replace("/\\[video\\](.*?)\\[\\/video\\]/ism", '[url=$1]$1[/url]', $bbcode); $bbcode = preg_replace("/\\[youtube\\]https?:\\/\\/(.*?)\\[\\/youtube\\]/ism", '[url=https://$1]https://$1[/url]', $bbcode); $bbcode = preg_replace("/\\[youtube\\]([A-Za-z0-9\\-_=]+)(.*?)\\[\\/youtube\\]/ism", '[url=https://www.youtube.com/watch?v=$1]https://www.youtube.com/watch?v=$1[/url]', $bbcode); $bbcode = preg_replace("/\\[vimeo\\]https?:\\/\\/(.*?)\\[\\/vimeo\\]/ism", '[url=https://$1]https://$1[/url]', $bbcode); $bbcode = preg_replace("/\\[vimeo\\]([0-9]+)(.*?)\\[\\/vimeo\\]/ism", '[url=https://vimeo.com/$1]https://vimeo.com/$1[/url]', $bbcode); //$bbcode = preg_replace("/\[vimeo\](.*?)\[\/vimeo\]/ism",'[url=$1]$1[/url]',$bbcode); $bbcode = preg_replace("/\\[img\\=([0-9]*)x([0-9]*)\\](.*?)\\[\\/img\\]/ism", '[img]$3[/img]', $bbcode); preg_match_all("/\\[url\\=([{$URLSearchString}]*)\\](.*?)\\[\\/url\\]/ism", $bbcode, $urls, PREG_SET_ORDER); $bbcode = preg_replace("/\\[url\\=([{$URLSearchString}]*)\\](.*?)\\[\\/url\\]/ism", '$1', $bbcode); $b["body"] = $bbcode; // To-Do: // Bilder // https://alpha.app.net/heluecht/post/32424376 // https://alpha.app.net/heluecht/post/32424307 $plaintext = plaintext($a, $b, 0, false, 6); $text = $plaintext["text"]; $start = 0; $entities = array(); foreach ($urls as $url) { $lenurl = iconv_strlen($url[1], "UTF-8"); $len = iconv_strlen($url[2], "UTF-8"); $pos = iconv_strpos($text, $url[1], $start, "UTF-8"); $pre = iconv_substr($text, 0, $pos, "UTF-8"); $post = iconv_substr($text, $pos + $lenurl, 1000000, "UTF-8"); $mid = $url[2]; $html = bbcode($mid, false, false, 6); $mid = html2plain($html, 0, true); $mid = trim(html_entity_decode($mid, ENT_QUOTES, 'UTF-8')); $text = $pre . $mid . $post; if ($mid != "") { $entities[] = array("pos" => $pos, "len" => $len, "url" => $url[1], "text" => $mid); } $start = $pos + 1; } if (isset($postdata["url"]) and isset($postdata["title"]) and $postdata["type"] != "photo") { $postdata["title"] = shortenmsg($postdata["title"], 90); $max = 256 - strlen($postdata["title"]); $text = shortenmsg($text, $max); $text .= "\n[" . $postdata["title"] . "](" . $postdata["url"] . ")"; } elseif (isset($postdata["url"]) and $postdata["type"] != "photo") { $postdata["url"] = short_link($postdata["url"]); $max = 240; $text = shortenmsg($text, $max); $text .= " [" . $postdata["url"] . "](" . $postdata["url"] . ")"; } else { $max = 256; $text = shortenmsg($text, $max); } if (iconv_strlen($text, "UTF-8") < $max) { $max = iconv_strlen($text, "UTF-8"); } krsort($entities); foreach ($entities as $entity) { //if (iconv_strlen($text, "UTF-8") >= $entity["pos"] + $entity["len"]) { if ($entity["pos"] + $entity["len"] <= $max) { $pre = iconv_substr($text, 0, $entity["pos"], "UTF-8"); $post = iconv_substr($text, $entity["pos"] + $entity["len"], 1000000, "UTF-8"); $text = $pre . "[" . $entity["text"] . "](" . $entity["url"] . ")" . $post; } } return $text; }
function statusnet_post_hook(&$a, &$b) { /** * Post to GNU Social */ if (!get_pconfig($b["uid"], 'statusnet', 'import')) { if ($b['deleted'] || $b['private'] || $b['created'] !== $b['edited']) { return; } } $api = get_pconfig($b["uid"], 'statusnet', 'baseapi'); $hostname = preg_replace("=https?://([\\w\\.]*)/.*=ism", "\$1", $api); if ($b['parent'] != $b['id']) { logger("statusnet_post_hook: parameter " . print_r($b, true), LOGGER_DATA); // Looking if its a reply to a GNU Social post $hostlength = strlen($hostname) + 2; if (substr($b["parent-uri"], 0, $hostlength) != $hostname . "::" and substr($b["extid"], 0, $hostlength) != $hostname . "::" and substr($b["thr-parent"], 0, $hostlength) != $hostname . "::") { logger("statusnet_post_hook: no GNU Social post " . $b["parent"]); return; } $r = q("SELECT `item`.`author-link`, `item`.`uri`, `contact`.`nick` AS contact_nick\n\t\t\tFROM `item` INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id`\n\t\t\tWHERE `item`.`uri` = '%s' AND `item`.`uid` = %d LIMIT 1", dbesc($b["thr-parent"]), intval($b["uid"])); if (!count($r)) { logger("statusnet_post_hook: no parent found " . $b["thr-parent"]); return; } else { $iscomment = true; $orig_post = $r[0]; } //$nickname = "@[url=".$orig_post["author-link"]."]".$orig_post["contact_nick"]."[/url]"; //$nicknameplain = "@".$orig_post["contact_nick"]; $nick = preg_replace("=https?://(.*)/(.*)=ism", "\$2", $orig_post["author-link"]); $nickname = "@[url=" . $orig_post["author-link"] . "]" . $nick . "[/url]"; $nicknameplain = "@" . $nick; logger("statusnet_post_hook: comparing " . $nickname . " and " . $nicknameplain . " with " . $b["body"], LOGGER_DEBUG); if (strpos($b["body"], $nickname) === false and strpos($b["body"], $nicknameplain) === false) { $b["body"] = $nickname . " " . $b["body"]; } logger("statusnet_post_hook: parent found " . print_r($orig_post, true), LOGGER_DEBUG); } else { $iscomment = false; if ($b['private'] or !strstr($b['postopts'], 'statusnet')) { return; } } if ($b['verb'] == ACTIVITY_POST and $b['deleted']) { statusnet_action($a, $b["uid"], substr($orig_post["uri"], $hostlength), "delete"); } if ($b['verb'] == ACTIVITY_LIKE) { logger("statusnet_post_hook: parameter 2 " . substr($b["thr-parent"], $hostlength), LOGGER_DEBUG); if ($b['deleted']) { statusnet_action($a, $b["uid"], substr($b["thr-parent"], $hostlength), "unlike"); } else { statusnet_action($a, $b["uid"], substr($b["thr-parent"], $hostlength), "like"); } return; } if ($b['deleted'] || $b['created'] !== $b['edited']) { return; } // if posts comes from GNU Social don't send it back if ($b['extid'] == NETWORK_STATUSNET) { return; } if ($b['app'] == "StatusNet") { return; } logger('GNU Socialpost invoked'); load_pconfig($b['uid'], 'statusnet'); $api = get_pconfig($b['uid'], 'statusnet', 'baseapi'); $ckey = get_pconfig($b['uid'], 'statusnet', 'consumerkey'); $csecret = get_pconfig($b['uid'], 'statusnet', 'consumersecret'); $otoken = get_pconfig($b['uid'], 'statusnet', 'oauthtoken'); $osecret = get_pconfig($b['uid'], 'statusnet', 'oauthsecret'); if ($ckey && $csecret && $otoken && $osecret) { // If it's a repeated message from GNU Social then do a native retweet and exit if (statusnet_is_retweet($a, $b['uid'], $b['body'])) { return; } require_once 'include/bbcode.php'; $dent = new StatusNetOAuth($api, $ckey, $csecret, $otoken, $osecret); $max_char = $dent->get_maxlength(); // max. length for a dent set_pconfig($b['uid'], 'statusnet', 'max_char', $max_char); $tempfile = ""; require_once "include/plaintext.php"; require_once "include/network.php"; $msgarr = plaintext($a, $b, $max_char, true, 7); $msg = $msgarr["text"]; if ($msg == "" and isset($msgarr["title"])) { $msg = shortenmsg($msgarr["title"], $max_char - 50); } $image = ""; if (isset($msgarr["url"]) and $msgarr["type"] != "photo") { if (strlen($msgarr["url"]) > 20 and strlen($msg . " \n" . $msgarr["url"]) > $max_char) { $msg .= " \n" . short_link($msgarr["url"]); } else { $msg .= " \n" . $msgarr["url"]; } } elseif (isset($msgarr["image"]) and $msgarr["type"] != "video") { $image = $msgarr["image"]; } if ($image != "") { $img_str = fetch_url($image); $tempfile = tempnam(get_temppath(), "cache"); file_put_contents($tempfile, $img_str); $postdata = array("status" => $msg, "media[]" => $tempfile); } else { $postdata = array("status" => $msg); } // and now dent it :-) if (strlen($msg)) { if ($iscomment) { $postdata["in_reply_to_status_id"] = substr($orig_post["uri"], $hostlength); logger('statusnet_post send reply ' . print_r($postdata, true), LOGGER_DEBUG); } // New code that is able to post pictures require_once "addon/statusnet/codebird.php"; $cb = \CodebirdSN\CodebirdSN::getInstance(); $cb->setAPIEndpoint($api); $cb->setConsumerKey($ckey, $csecret); $cb->setToken($otoken, $osecret); $result = $cb->statuses_update($postdata); //$result = $dent->post('statuses/update', $postdata); logger('statusnet_post send, result: ' . print_r($result, true) . "\nmessage: " . $msg, LOGGER_DEBUG . "\nOriginal post: " . print_r($b, true) . "\nPost Data: " . print_r($postdata, true)); if ($result->source) { set_pconfig($b["uid"], "statusnet", "application_name", strip_tags($result->source)); } if ($result->error) { logger('Send to GNU Social failed: "' . $result->error . '"'); } elseif ($iscomment) { logger('statusnet_post: Update extid ' . $result->id . " for post id " . $b['id']); q("UPDATE `item` SET `extid` = '%s', `body` = '%s' WHERE `id` = %d", dbesc($hostname . "::" . $result->id), dbesc($result->text), intval($b['id'])); } } if ($tempfile != "") { unlink($tempfile); } } }
function buffer_send(&$a, &$b) { if ($b['deleted'] || $b['private'] || $b['created'] !== $b['edited']) { return; } if (!strstr($b['postopts'], 'buffer')) { return; } if ($b['parent'] != $b['id']) { return; } // if post comes from buffer don't send it back //if($b['app'] == "Buffer") // return; $client_id = get_config("buffer", "client_id"); $client_secret = get_config("buffer", "client_secret"); $access_token = get_pconfig($b['uid'], "buffer", "access_token"); if ($access_token) { $buffer = new BufferApp($client_id, $client_secret, $callback_url, $access_token); require_once "include/plaintext.php"; require_once "include/network.php"; $profiles = $buffer->go('/profiles'); if (is_array($profiles)) { logger("Will send these parameter " . print_r($b, true), LOGGER_DEBUG); foreach ($profiles as $profile) { if (!$profile->default) { continue; } $send = false; switch ($profile->service) { case 'appdotnet': $send = $b["extid"] != NETWORK_APPNET; $limit = 256; $markup = false; $includedlinks = true; $htmlmode = 6; break; case 'facebook': $send = $b["extid"] != NETWORK_FACEBOOK; $limit = 0; $markup = false; $includedlinks = false; $htmlmode = 9; break; case 'google': $send = $b["extid"] != NETWORK_GPLUS; $limit = 0; $markup = true; $includedlinks = false; $htmlmode = 9; break; case 'twitter': $send = $b["extid"] != NETWORK_TWITTER; $limit = 140; $markup = false; $includedlinks = true; $htmlmode = 8; break; case 'linkedin': $send = $b["extid"] != NETWORK_LINKEDIN; $limit = 700; $markup = false; $includedlinks = true; $htmlmode = 2; break; } if (!$send) { continue; } $item = $b; // Markup for Google+ if ($markup) { if ($item["title"] != "") { $item["title"] = "*" . $item["title"] . "*"; } $item["body"] = preg_replace("(\\[b\\](.*?)\\[\\/b\\])ism", '*$1*', $item["body"]); $item["body"] = preg_replace("(\\[i\\](.*?)\\[\\/i\\])ism", '_$1_', $item["body"]); $item["body"] = preg_replace("(\\[s\\](.*?)\\[\\/s\\])ism", '-$1-', $item["body"]); } $post = plaintext($a, $item, $limit, $includedlinks, $htmlmode); logger("buffer_send: converted message " . $b["id"] . " result: " . print_r($post, true), LOGGER_DEBUG); // The image proxy is used as a sanitizer. Buffer seems to be really picky about pictures require_once "mod/proxy.php"; if (isset($post["image"])) { $post["image"] = proxy_url($post["image"]); } if (isset($post["preview"])) { $post["preview"] = proxy_url($post["preview"]); } //if ($profile->service == "twitter") { if ($includedlinks) { if (isset($post["url"])) { $post["url"] = short_link($post["url"]); } if (isset($post["image"])) { $post["image"] = short_link($post["image"]); } if (isset($post["preview"])) { $post["preview"] = short_link($post["preview"]); } } // Seems like a bug to me // Buffer doesn't add links to Twitter and App.net (but pictures) //if ($includedlinks AND isset($post["url"])) if ($profile->service == "twitter" and isset($post["url"]) and $post["type"] != "photo") { $post["text"] .= " " . $post["url"]; } elseif ($profile->service == "appdotnet" and isset($post["url"]) and isset($post["title"]) and $post["type"] != "photo") { $post["title"] = shortenmsg($post["title"], 90); $post["text"] = shortenmsg($post["text"], $limit - (24 + strlen($post["title"]))); $post["text"] .= "\n[" . $post["title"] . "](" . $post["url"] . ")"; } elseif ($profile->service == "appdotnet" and isset($post["url"]) and $post["type"] != "photo") { $post["text"] .= " " . $post["url"]; } elseif ($profile->service == "google") { $post["text"] .= html_entity_decode(" ", ENT_QUOTES, 'UTF-8'); } // Send a special blank to identify the post through the "fromgplus" addon $message = array(); $message["text"] = $post["text"]; $message["profile_ids[]"] = $profile->id; $message["shorten"] = false; $message["now"] = true; if (isset($post["title"])) { $message["media[title]"] = $post["title"]; } if (isset($post["description"])) { $message["media[description]"] = $post["description"]; } if (isset($post["url"]) and $post["type"] != "photo") { $message["media[link]"] = $post["url"]; } if (isset($post["image"])) { $message["media[picture]"] = $post["image"]; if ($post["type"] == "photo") { $message["media[thumbnail]"] = $post["image"]; } } if (isset($post["preview"])) { $message["media[thumbnail]"] = $post["preview"]; } //print_r($message); logger("buffer_send: data for message " . $b["id"] . ": " . print_r($message, true), LOGGER_DEBUG); $ret = $buffer->go('/updates/create', $message); logger("buffer_send: send message " . $b["id"] . " result: " . print_r($ret, true), LOGGER_DEBUG); } } } }
function appnetpost_feeditem($pid, $uid) { global $a; require_once 'include/bbcode.php'; require_once "include/html2plain.php"; require_once "include/network.php"; $items = q("SELECT `uri`, `plink`, `author-link`, `author-name`, `created`, `edited`, `id`, `title`, `body` from `item` WHERE id=%d", intval($pid)); foreach ($items as $item) { $item['body'] = bb_CleanPictureLinks($item['body']); // Looking for the first image $image = ''; if (preg_match("/\\[img\\=([0-9]*)x([0-9]*)\\](.*?)\\[\\/img\\]/is", $item['body'], $matches)) { $image = $matches[3]; } if ($image == '') { if (preg_match("/\\[img\\](.*?)\\[\\/img\\]/is", $item['body'], $matches)) { $image = $matches[1]; } } $multipleimages = strpos($item['body'], "[img") != strrpos($item['body'], "[img"); // When saved into the database the content is sent through htmlspecialchars // That means that we have to decode all image-urls $image = htmlspecialchars_decode($image); $link = ''; // look for bookmark-bbcode and handle it with priority if (preg_match("/\\[bookmark\\=([^\\]]*)\\](.*?)\\[\\/bookmark\\]/is", $item['body'], $matches)) { $link = $matches[1]; } $multiplelinks = strpos($item['body'], "[bookmark") != strrpos($item['body'], "[bookmark"); $body = $item['body']; // At first convert the text to html $html = bbcode($body, false, false, 2); // Then convert it to plain text $msg = trim(html2plain($html, 0, true)); $msg = html_entity_decode($msg, ENT_QUOTES, 'UTF-8'); // If there is no bookmark element then take the first link if ($link == '') { $links = collecturls($html); if (sizeof($links) > 0) { reset($links); $link = current($links); } $multiplelinks = sizeof($links) > 1; if ($multiplelinks) { $html2 = bbcode($msg, false, false); $links2 = collecturls($html2); if (sizeof($links2) > 0) { reset($links2); $link = current($links2); $multiplelinks = sizeof($links2) > 1; } } } $msglink = ""; if ($multiplelinks) { $msglink = $item["plink"]; } else { if ($link != "") { $msglink = $link; } else { if ($multipleimages) { $msglink = $item["plink"]; } else { if ($image != "") { $msglink = $image; } } } } // Fetching the title and add all lines if ($item["title"] != "") { $title = $item["title"]; } $lines = explode("\n", $msg); foreach ($lines as $line) { $title .= "\n" . $line; } $max_char = 256; $origlink = $msglink; if (strlen($msglink) > 20) { $msglink = short_link($msglink); } $title = trim(str_replace($origlink, $msglink, $title)); if (strlen(trim($title . " " . $msglink)) > $max_char) { $title = substr($title, 0, $max_char - strlen($msglink)); $lastchar = substr($title, -1); $title = substr($title, 0, -1); $pos = strrpos($title, "\n"); if ($pos > 0) { $title = substr($title, 0, $pos); } else { if ($lastchar != "\n") { $title = substr($title, 0, -3) . "..."; } } } if ($msglink != "" and !strstr($title, $msglink)) { $title = trim($title . " " . $msglink); } else { $title = trim($title); } if ($title == "") { continue; } //$origlink = original_url($origlink); $html = nl2br($title); $origlink = $item["plink"]; $origlink = htmlspecialchars(html_entity_decode($origlink)); $title = str_replace("&", "&", $title); //$html = str_replace("&", "&", $html); echo "\t" . '<entry xmlns="http://www.w3.org/2005/Atom">' . "\n"; echo "\t\t" . '<title type="html" xml:space="preserve"><![CDATA[' . $title . "]]></title>\n"; echo "\t\t" . '<link rel="alternate" type="text/html" href="' . $origlink . '" />' . "\n"; // <link rel="enclosure" type="audio/mpeg" length="1337" href="http://example.org/audio/ph34r_my_podcast.mp3"/> echo "\t\t<id>" . $item["uri"] . "</id>\n"; echo "\t\t<updated>" . date("c", strtotime($item["edited"])) . "</updated>\n"; echo "\t\t<published>" . date("c", strtotime($item["created"])) . "</published>\n"; echo "\t\t<author>\n\t\t\t<name><![CDATA[" . $item["author-name"] . "]]></name>\n"; echo "\t\t\t<uri>" . $item["author-link"] . "</uri>\n\t\t</author>\n"; //echo '<content type="image/png" src="http://media.example.org/the_beach.png"/>'; echo "\t\t" . '<content type="html" xml:space="preserve" xml:base="' . $item["plink"] . '"><![CDATA[' . $html . "]]></content>\n"; echo "\t</entry>\n"; } }
function statusnet_post_hook(&$a, &$b) { /** * Post to statusnet */ if ($b['deleted'] || $b['private'] || $b['created'] !== $b['edited']) { return; } if (!strstr($b['postopts'], 'statusnet')) { return; } load_pconfig($b['uid'], 'statusnet'); $api = get_pconfig($b['uid'], 'statusnet', 'baseapi'); $ckey = get_pconfig($b['uid'], 'statusnet', 'consumerkey'); $csecret = get_pconfig($b['uid'], 'statusnet', 'consumersecret'); $otoken = get_pconfig($b['uid'], 'statusnet', 'oauthtoken'); $osecret = get_pconfig($b['uid'], 'statusnet', 'oauthsecret'); if ($ckey && $csecret && $otoken && $osecret) { require_once 'include/bbcode.php'; $dent = new StatusNetOAuth($api, $ckey, $csecret, $otoken, $osecret); $max_char = $dent->get_maxlength(); // max. length for a dent // we will only work with up to two times the length of the dent // we can later send to StatusNet. This way we can "gain" some // information during shortening of potential links but do not // shorten all the links in a 200000 character long essay. if (!$b['title'] == '') { $tmp = $b['title'] . ' : ' . $b['body']; // $tmp = substr($tmp, 0, 4*$max_char); } else { $tmp = $b['body']; // substr($b['body'], 0, 3*$max_char); } // if [url=bla][img]blub.png[/img][/url] get blub.png $tmp = preg_replace('/\\[url\\=(https?\\:\\/\\/[a-zA-Z0-9\\:\\/\\-\\?\\&\\;\\.\\=\\_\\~\\#\\%\\$\\!\\+\\,]+)\\]\\[img\\](\\w+.*?)\\[\\/img\\]\\[\\/url\\]/i', '$2', $tmp); // preserve links to images, videos and audios $tmp = preg_replace('/\\[img\\=([0-9]*)x([0-9]*)\\](.*?)\\[\\/img\\]/ism', '$3', $tmp); $tmp = preg_replace('/\\[\\/?img(\\s+.*?\\]|\\])/i', '', $tmp); $tmp = preg_replace('/\\[\\/?video(\\s+.*?\\]|\\])/i', '', $tmp); $tmp = preg_replace('/\\[\\/?youtube(\\s+.*?\\]|\\])/i', '', $tmp); $tmp = preg_replace('/\\[\\/?vimeo(\\s+.*?\\]|\\])/i', '', $tmp); $tmp = preg_replace('/\\[\\/?audio(\\s+.*?\\]|\\])/i', '', $tmp); $linksenabled = get_pconfig($b['uid'], 'statusnet', 'post_taglinks'); // if a #tag is linked, don't send the [url] over to SN // that is, don't send if the option is not set in the // connector settings if ($linksenabled == '0') { // #-tags $tmp = preg_replace('/#\\[url\\=(\\w+.*?)\\](\\w+.*?)\\[\\/url\\]/i', '#$2', $tmp); // @-mentions $tmp = preg_replace('/@\\[url\\=(\\w+.*?)\\](\\w+.*?)\\[\\/url\\]/i', '@$2', $tmp); } // preserve links to webpages $tmp = preg_replace('/\\[url\\=(https?\\:\\/\\/[a-zA-Z0-9\\:\\/\\-\\?\\&\\;\\.\\=\\_\\~\\#\\%\\$\\!\\+\\,]+)\\](\\w+.*?)\\[\\/url\\]/i', '$2 $1', $tmp); $tmp = preg_replace('/\\[bookmark\\=(https?\\:\\/\\/[a-zA-Z0-9\\:\\/\\-\\?\\&\\;\\.\\=\\_\\~\\#\\%\\$\\!\\+\\,]+)\\](\\w+.*?)\\[\\/bookmark\\]/i', '$2 $1', $tmp); // find all http or https links in the body of the entry and // apply the shortener if the link is longer then 20 characters if (strlen($tmp) > $max_char && $max_char > 0) { preg_match_all('/(https?\\:\\/\\/[a-zA-Z0-9\\:\\/\\-\\?\\&\\;\\.\\=\\_\\~\\#\\%\\$\\!\\+\\,]+)/i', $tmp, $allurls); foreach ($allurls as $url) { foreach ($url as $u) { if (strlen($u) > 20) { $sl = short_link($u); $tmp = str_replace($u, $sl, $tmp); } } } } // ok, all the links we want to send out are save, now strip // away the remaining bbcode $msg = strip_tags(bbcode($tmp)); // quotes not working - let's try this $msg = html_entity_decode($msg); if (strlen($msg) > $max_char && $max_char > 0) { $shortlink = short_link($b['plink']); // the new message will be shortened such that "... $shortlink" // will fit into the character limit $msg = nl2br(substr($msg, 0, $max_char - strlen($shortlink) - 4)); $msg = str_replace(array('<br>', '<br />'), ' ', $msg); $e = explode(' ', $msg); // remove the last word from the cut down message to // avoid sending cut words to the MicroBlog array_pop($e); $msg = implode(' ', $e); $msg .= '... ' . $shortlink; } // and now dent it :-) if (strlen($msg)) { $result = $dent->post('statuses/update', array('status' => $msg)); logger('statusnet_post send, result: ' . print_r($result, true), LOGGER_DEBUG); if ($result->error) { logger('Send to StatusNet failed: "' . $result->error . '"'); } } } }
} // Full Update Products if (isset($post['submit_products_fullupdate'])) { $all_codes = $products->get_all_codes(); if ($all_codes) { foreach ($all_codes as $key) { $full_update_product = $amazon->productFullUpdate($key); if ($full_update_product) { $fup_toDB = $products->productFullUpdate($full_update_product, $key, $traktor); if (!$fup_toDB) { $keys[] = $key; } else { $errors[] = $fup_toDB; } } else { $errors[] = "Can't get data for code " . short_link($key) . "!"; } } if (!$errors) { $messages[] = "All products successfully updated!"; } } unset($all_codes, $key, $product, $fup_toDB, $full_update_product, $keys); } // Delete product if (isset($post['submit_product_delete']) && isset($post['code']) && $post['code']) { $delete_product = $products->delete_product($post['code'], $traktor); if ($delete_product) { $errors[] = 'ERROR: ' . $delete_product; } else { $messages[] = 'Produc successfully deleted!';