← Back
Editing: fbomatic-fbchecker.php
<?php function fbomatic_is_fb_not_logged_in($url, $status_code, $exec = '') { if (stristr($url, 'login.php') ) { return true; } if (stristr($exec, 'r.php?next')) { return true; } return false; } if(!function_exists('fbomatic_learn_facebook')) { function fbomatic_germanDateToEnglish($dateString) { $germanMonths = [ 'Januar' => 'January', 'Februar' => 'February', 'März' => 'March', 'April' => 'April', 'Mai' => 'May', 'Juni' => 'June', 'Juli' => 'July', 'August' => 'August', 'September' => 'September', 'Oktober' => 'October', 'November' => 'November', 'Dezember' => 'December' ]; foreach ($germanMonths as $german => $english) { $dateString = str_replace($german, $english, $dateString); } $dateString = str_replace(['um', '·'], '', $dateString); return str_replace(' ', ' ', $dateString); } function fbomatic_learn_facebook($fbomatic_cuser, $fbomatic_xs, $ids, $insert_comments, $continue_search, $param, $fbomatic_Main_Settings, $max, $page_timeout, $api_v, $fbomatic_page_type = 'page', $fbomatic_post_type = 'posts', $video_no_img = '') { if ((trim ( $ids ) != '')) { $fbomatic_feed_try = "https://m.facebook.com/page_content_list_view/more/?page_id=" . $ids . "&start_cursor=27&num_to_fetch=4&surface_type=timeline"; if ($fbomatic_page_type == 'profile') { $fbomatic_feed_try = 'https://mbasic.facebook.com/profile/timeline/stream/?profile_id=' . $ids; } elseif ($fbomatic_page_type == 'group') { $fbomatic_feed_try = 'https://mbasic.facebook.com/groups/' . $ids ; } if ($fbomatic_post_type == 'events') { if ($fbomatic_page_type == 'group') { $fbomatic_feed_try = "https://mbasic.facebook.com/" . $ids . "/?view=events&refid=18"; } else { $fbomatic_feed_try = "https://mbasic.facebook.com/" . $ids . "/events?locale=en_US"; } } fbomatic_log_to_file('Searching using URL: ' . $fbomatic_feed_try); if ($continue_search == '1') { $skip_posts_temp = get_transient('fbomatic_continue_search'); if($skip_posts_temp === false) { $skip_posts_temp = array(); } if (isset($skip_posts_temp[$param]) && $skip_posts_temp[$param] != '') { if(substr( $skip_posts_temp[$param], 0, strlen($ids) ) === $ids) { $url = $skip_posts_temp[$param]; $url = substr($url, strlen($ids)); fbomatic_log_to_file('Getting next page URL from: ' . $url); } else { $url = $fbomatic_feed_try; } } else { $url = $fbomatic_feed_try; } } else { $url = $fbomatic_feed_try; } $ch = curl_init(); if ($ch === FALSE) { fbomatic_log_to_file('Failed to init Curl in Facebook learner!'); if ($continue_search == '1') { $skip_posts_temp[$param] = ''; set_transient('fbomatic_continue_search', $skip_posts_temp, 999999999); } return false; } $headers = array(); $headers[] = "sec-fetch-site: none"; $headers[] = "sec-fetch-mode: navigate"; $headers[] = "sec-fetch-user: ?1"; $headers[] = "sec-fetch-dest: document"; curl_setopt($ch, CURLOPT_HTTPGET, 1); curl_setopt($ch, CURLOPT_URL, trim($url)); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_COOKIE, 'xs=' . $fbomatic_xs . ';c_user=' . $fbomatic_cuser . ';datr=QGgFYdhWgha-QOwFUUksCDTg'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36'); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); curl_setopt($ch, CURLOPT_TIMEOUT, 60); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); if($page_timeout != '' && is_numeric($page_timeout)) { usleep($page_timeout * 1000); } $exec = fbomatic_curl_exec_special($ch); $fb_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); $fb_url = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL); $is_not_logged_in = fbomatic_is_fb_not_logged_in($fb_url, $fb_code, $exec); if (stristr($fb_url, '/checkpoint/') ) { $rules = get_option('fbomatic_rules_list'); if(isset($rules[$param]) && isset($rules[$param][42]) && !empty($rules[$param][42]) && is_string($rules[$param][42]) && strlen($rules[$param][42]) > 5) { $rules[$param][42] = 'EXPIRED_' . $rules[$param][42]; update_option('fbomatic_rules_list', $rules, false); } } if ($is_not_logged_in || stristr($exec, 'page_uri:"https://m.facebook.com/login.php') || stristr($exec, 'id="login_error"') || (isset($fb_url) && stristr($fb_url,'login.php') ) ) { fbomatic_log_to_file('Warning(1), the sesion cookies you entered in plugin settings are incorrect or expired, the plugin could not log in to Facebook! ' . esc_html($url)); return false; } elseif ((stristr($exec, 'payload') && stristr($exec, $ids) && !stristr($exec, 'page_uri:"https://m.facebook.com/login.php')) || (stristr($exec, 'notifications.php') && ($fbomatic_page_type == 'group') || $fbomatic_page_type == 'profile')) { } elseif (stristr($exec, '<title>Content Not Found</title>')) { fbomatic_log_to_file('Warning, this is a FB page with a follow button and not a like button, importing might not work.'); } else { fbomatic_log_to_file('Warning(2), the sesion cookies you entered in plugin settings are incorrect or expired, the plugin could not log in to Facebook! ' . esc_html($url)); return false; } require_once(dirname(__FILE__) . "/simple_html_dom.php"); if ($fbomatic_post_type != 'events') { if ($fbomatic_page_type == 'group' || $fbomatic_page_type == 'profile') { $fbomatic_raw_exec = $exec; } else { $fbomatic_raw_exec = $exec = str_replace ( 'for (;;);', '', $exec ); $exec = str_replace ( '&', '&', $exec ); $json = json_decode( $exec ); if(isset ($json->payload)){ $exec = $json->payload->actions[0]->html; } else{ $exec = ''; } } $html_dom_original_html = fb_str_get_html('<html><head></head><body>' . $exec . '</body>'); $items = array(); if (method_exists($html_dom_original_html, 'find')) { $items = $html_dom_original_html->find('//article'); if(count($items) == 0) { $items = $html_dom_original_html->find('//*[@role="article"]'); } if($fbomatic_page_type == 'profile' && count($items) == 0) { curl_setopt($ch, CURLOPT_URL, 'https://www.facebook.com/platform/plugin/tab/renderer/?key=timeline&config_json=%7B%22app_id%22%3A%222012669838949787%22%2C%22href%22%3A%22https%3A%2F%2Fwww.facebook.com%2F' . $ids . '%22%2C%22width%22%3A340%2C%22height%22%3A500%2C%22has_cta%22%3Atrue%2C%22has_small_header%22%3Afalse%2C%22has_adapt_container_width%22%3Atrue%2C%22has_cover%22%3Atrue%2C%22has_posts%22%3Afalse%2C%22tabs%22%3A%22timeline%22%2C%22can_personalize%22%3Afalse%2C%22is_xfbml%22%3Atrue%2C%22referer_uri%22%3A%22%22%7D&__a=1&__req=1'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_ENCODING, ''); curl_setopt($ch, CURLOPT_TIMEOUT, 120); curl_setopt($ch, CURLOPT_MAXREDIRS, 10); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET'); curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'accept: */*', 'accept-language: en-US,en;q=0.9', 'cookie: sb=HVIOZ85N4mcNQyshnKN7QLJO; datr=HVIOZ4fenBe8dMXhjAsizSbU; wd=1440x732; datr=oKvsZadosumemQNmPvLqfVFc; ps_l=1; ps_n=1', 'priority: u=1, i', 'referer: https://www.facebook.com/plugins/page.php?adapt_container_width=true&app_id=2012669838949787&channel=https%3A%2F%2Fstaticxx.facebook.com%2Fx%2Fconnect%2Fxd_arbiter%2F%3Fversion%3D46%23cb%3Df4170a4721d0de06b%26domain%3Dlocalhost%26is_canvas%3Dfalse%26origin%3Dhttp%253A%252F%252Flocalhost%252Ffaad19f5d5420a281%26relation%3Dparent.parent&container_width=650&hide_cover=false&href=https%3A%2F%2Fwww.facebook.com%2Fcnn&locale=en_US&sdk=joey&show_facepile=true&small_header=false&tabs=timeline&width', 'sec-ch-prefers-color-scheme: light', 'sec-ch-ua: "Google Chrome";v="129", "Not=A?Brand";v="8", "Chromium";v="129"', 'sec-ch-ua-full-version-list: "Google Chrome";v="129.0.6668.91", "Not=A?Brand";v="8.0.0.0", "Chromium";v="129.0.6668.91"', 'sec-ch-ua-mobile: ?0', 'sec-ch-ua-model: ""', 'sec-ch-ua-platform: "macOS"', 'sec-ch-ua-platform-version: "14.2.1"', 'sec-fetch-dest: empty', 'sec-fetch-mode: cors', 'sec-fetch-site: same-origin', 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36', 'x-asbd-id: 129477', 'x-fb-lsd: AVrNgmeEzmg' )); $exec = fbomatic_curl_exec_special($ch); preg_match_all('!S:_I\d*?:(\d*?):!', $exec, $matches); if(isset($matches[1]) && count($matches[1]) > 0) { $post_ids = array_unique($matches[1]); foreach($post_ids as $post_id) { $post_link_first = 'https://www.facebook.com/' . $ids . '/posts/' . $post_id; $items[] = $post_link_first; } } } $i=0; foreach ($items as $item) { if (stristr($item, 'og_action_id')) { $item = preg_replace('{"og_action_id":"\d*?",}', '', $item); } $i++; } } else { fbomatic_log_to_file('fb_str_get_html failed for: ' . $url . ', xpath: //*[@role="article"]'); curl_close($ch); if ($continue_search == '1') { $skip_posts_temp[$param] = ''; set_transient('fbomatic_continue_search', $skip_posts_temp, 999999999); } return false; } } else { preg_match_all ( '{<a href="/events/(\d+)}', $exec, $events_matches ); if (count($events_matches[1]) == 0) { preg_match_all('{typename":"Event","id":"(.*?)"}', $exec, $events_matches); } if (isset ( $events_matches [1] )) { $items = $events_matches [1]; } else { $items = array (); } } $i = 0; $ret_obj_arr = array(); foreach ( $items as $item ) { $ret = new stdClass(); $is_an_album = false; $item = preg_replace ( '{<img class="\w*?" height="16".*?>}s', '', $item ); $item = preg_replace ( '{<img src="[^<]*?p32x32[^<]*?>}s', '', $item ); $item = preg_replace ( '{<img src="[^<]*?p40x40[^<]*?>}s', '', $item ); $item = str_replace('"', '"', $item); $imgsrc = ''; $txtContent = ''; $contMatches = array(); if ($fbomatic_post_type != 'events') { if (stristr($item, 'top_level_post_id":')) { preg_match('{top_level_post_id":"(.*?)"}', $item, $pMatches); } elseif (stristr($item, 'top_level_post_id')) { preg_match('{top_level_post_id\.(\d*)}', $item, $pMatches); } elseif (stristr($item, 'feedobjectsIdentifiers')) { preg_match('!feedobjectsIdentifiers":"S:_I\d*?:(\d*?):!', $item, $pMatches); } elseif (stristr($item, '"share_id"')) { preg_match('{share_id":(\d+)}s', $item, $pMatches); } elseif (stristr($item, 'feedback_target')) { preg_match('{feedback_target":"(.*?)"}', $item, $pMatches); } elseif (stristr($item, 'id="like_')) { preg_match('{like_(\d+)}s', $item, $pMatches); } elseif (preg_match('{^https?://}', $item)) { preg_match('{/posts/(\d*)}', $item, $pMatches); } else { preg_match('{/permalink/(\d*)/}', $item, $pMatches); } if(!isset($pMatches[1])) { fbomatic_log_to_file('Skipping post, cannot find top_level_post_id: ' . $item); continue; } $item_id = $ids . '_' . $pMatches[1]; $single_id = $pMatches[1]; $isEvent = false; $id_parts = explode ( '_', $item_id ); $owner_id = $id_parts [0]; $original_content_owner_id =$ids ; if ($fbomatic_page_type == 'profile') { preg_match ( '{content_owner_id_new":"(.*?)"}s', $item, $from_matches2 ); if (isset ( $from_matches2 [1] ) && trim ( $from_matches2 [1] ) != '') { $owner_id = $from_matches2 [1]; } } $url = "https://www.facebook.com/{$owner_id}/posts/{$id_parts[1]}"; if ((stristr ( $item, 'story_attachment_style":"new_album"' ) || stristr ( $item, 'story_attachment_style":"album"' )) && stristr ( $item, 'photo_id' )) { preg_match ( '{photo_id":"(.*?)"}', $item, $cMatches ); $is_an_album = true; if(isset($cMatches[1])) { $album_url = "https://www.facebook.com/{$cMatches[1]}"; } else { fbomatic_log_to_file('Failed to parse photo_id from album'); $album_url = "https://www.facebook.com/"; } } } else { $id_parts = array ( $ids, $item ); $url = "https://www.facebook.com/$item"; $isEvent = true; $item_id = $single_id = $item; } $created_time = ''; if ($fbomatic_post_type != 'events') { preg_match ( '{publish_time":(\d*)}', $item, $tMatches ); if (isset ( $tMatches [1] )) { $created_time = $tMatches [1]; } } if ($fbomatic_post_type == 'events') { $mbasic_event_url = "https://mbasic.facebook.com/events/" . $item . '?locale=en_US'; $x = 'error'; curl_setopt ( $ch, CURLOPT_HTTPGET, 1 ); curl_setopt ( $ch, CURLOPT_URL, trim ( $mbasic_event_url ) ); if($page_timeout != '' && is_numeric($page_timeout)) { usleep($page_timeout * 1000); } curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36'); $item = fbomatic_curl_exec_special ( $ch ); $item = preg_replace ( '{<img class="\w*?" height="16".*?>}s', '', $item ); } preg_match_all ( '{<img src=".*?>}', str_replace ( '&', '&', $item ), $imgMatchs ); $all_imgs = $imgMatchs [0]; $i = 0; foreach ( $all_imgs as $single_img ) { if (stristr ( $single_img, 'static' ) || stristr ( $single_img, '32x32' ) || stristr ( $single_img, '40x40' ) || stristr($single_img,'width="14"') ) { unset ( $all_imgs [$i] ); } $i ++; } $all_imgs = array_values ( $all_imgs ); if ($fbomatic_post_type == 'events') { $type = 'event'; } elseif (stristr ( $item, 'videoID' ) || stristr($item , 'video_redirect') || stristr ( $item, 'youtube.com%2Fwatch' )) { $type = "video"; } elseif (stristr ( $item, '<a href="/notes' )) { $type = "note"; } elseif (stristr ( $item, '/events/' )) { $type = "event"; } elseif (stristr ( $item, 'offerx_' )) { $type = "offer"; } elseif (stristr ( $item, 'l.php?' ) && preg_match('{<a class="\w{2} \w{2}" href="https://lm.facebook.com/l.php}', $item)) { $type = "link"; } elseif (count ( $all_imgs ) > 1 || stristr ( $item, '"story_attachment_style":"photo"' ) || stristr ( $item, '/photos/' )) { $type = "photo"; } elseif (count ( $all_imgs ) > 0) { $type = "photo"; } else { $type = 'status'; } $title = ''; $content = ''; if ($fbomatic_post_type == 'events') { preg_match_all ( '!header></div></div><section class=".*?">(.*?)</section>!s', $item, $contMatches ); } elseif (stristr ( $item, '*s"}\'></div>' ) && stristr ( $item, 'tn":"H"' )) { preg_match_all ( '!(<p>.*?</p>)!s', $item, $contMatches ); preg_match ( '!<span class="\w+?">\(.*?\)</span><span>(.*?)</span>!s', $item, $title_matches ); if (isset ( $title_matches [1] ) && trim ( $title_matches [1] ) != '') { $title = $title_matches [1]; } } elseif(!preg_match('{^https?://}', $item)) { $item = html_entity_decode ($item, ENT_QUOTES); $item_html = str_replace ( '{"tn":"*s"}', 'target', $item ); $html_dom_original_html = fb_str_get_html('<html><head></head><body>' . $item_html . '</body></html>'); $items = array(); if (method_exists($html_dom_original_html, 'find')) { $items = $html_dom_original_html->find(trim('//*[@data-ft="target"]')); if(!isset($items[0])) { fbomatic_log_to_file('Failed to parse content (data-ft) of post: ' . $item_html); return; } } else { fbomatic_log_to_file('Skipping post, failed to load fb_str_get_html for: ' . $item_html); continue; } $found_story_text = isset($items[0]) ? $items[0] : ''; $found_story_text .= isset ( $items [1] ) ? $items [1] : ''; $found_story_text = preg_replace('!<div class=".. ..".*?</div>!', '', $found_story_text); $contMatches = array ( array ( $found_story_text ), array ( $found_story_text ) ); } $is_colored_post = false; if (stristr ( $item, 'background-image:url' )) { $is_colored_post = true; } if(isset($contMatches [1])) { $contMatches = $contMatches [1]; } if (count ( $contMatches ) == 2) { if ($contMatches [0] === $contMatches [1]) { unset ( $contMatches [1] ); } } if (isset ( $contMatches [0] )) { $matched_text_content = implode ( '<br>', $contMatches ); $matched_text_content = preg_replace ( '{<span class="text_exposed_hide.*?span>}su', '', $matched_text_content ); $matched_text_content = preg_replace ( '{<div class="_2pim"><p>.*?</p>}', '', $matched_text_content ); $matched_text_content = preg_replace ( '{<a href="#"><span class="_1_ig">.*?</a>}', '', $matched_text_content ); $matched_text_content = preg_replace ( '{<div class="_x7p _3nc8"><a href="#" .*?</a></div>}', '', $matched_text_content ); $matched_text_content = preg_replace('!<a href="/story.php[^<]*?"></a>!is', '', $matched_text_content); if (stristr ( $matched_text_content, 'background-image' ) || stristr ( $matched_text_content, 'color:rgba' ) || stristr ( $matched_text_content, 'font-size' )) { $matched_text_content = preg_replace('{</p><p>}s', "</p>\n<p>", $matched_text_content); $matched_text_content = strip_tags ( $matched_text_content, '<br><br /><a>' ); } $txtContent = $matched_text_content; if (stristr ( $matched_text_content, '<p> ' )) { $content = $matched_text_content; } else { $content = '<p>' . $matched_text_content . '</p> '; } } $content = str_replace ( 'See Translation', '', $content ); $content = preg_replace ( '{<span class="text_exposed_hide.*?span>}su', '', $content ); $original_post_url = $url; if (false && stristr ( $item, 'original_content_id' )) { preg_match ( '{"original_content_id":"(\d*?)"}s', $item, $original_id_matches ); if (isset ( $original_id_matches [1] ) && trim ( $original_id_matches [1] ) != '') { $original_post_url = 'https://www.facebook.com/' . $original_id_matches [1]; } } $x = 'error'; curl_setopt( $ch, CURLOPT_TIMEOUT, 60 ); curl_setopt ( $ch, CURLOPT_HTTPGET, 1 ); if (false && $is_an_album == true) { curl_setopt ( $ch, CURLOPT_URL, trim ( $album_url ) ); } else { curl_setopt ( $ch, CURLOPT_URL, trim ( $original_post_url ) ); } curl_setopt ( $ch, CURLOPT_FOLLOWLOCATION, 1 ); curl_setopt ( $ch, CURLOPT_COOKIE, 'xs=' . $fbomatic_xs . ';c_user=' . $fbomatic_cuser . ';datr=Q-JAYGHTbnwdfy2CkEPlpo0F' ); $headers = array(); $headers [] = "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9"; $headers [] = "Sec-Fetch-User: ?1"; $headers [] = "sec-fetch-mode: navigate"; curl_setopt ( $ch, CURLOPT_HTTPHEADER, $headers ); if($page_timeout != '' && is_numeric($page_timeout)) { usleep($page_timeout * 1000); } curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36'); $exec2 = fbomatic_curl_exec_special ( $ch ); if( stristr ( $exec2 , 'FB+Login+Page+Visit' ) ){ fbomatic_log_to_file('Not logged in, session cookie expired or not correct'); } if (!stristr($exec2, '"ACCOUNT_ID":"' . trim($fbomatic_cuser) . '"') && strlen($exec2) != 0) { aiomatic_log_to_file('Current session cookie is not correct or got expired'); } if (stristr ( $exec2, 'timeline_pinned_unit":{"id' )) { $exec2 = preg_replace ( '!timeline_pinned_unit":{"id.*?script>!s', '', $exec2 ); } if (stristr ( $exec2, 'timeline_feed_units' )) { $exec2 = preg_replace ( '!timeline_feed_units":{"edges.*?script>!s', '', $exec2 ); } $exec2 = preg_replace('!__isFeedUnit":"Story","post_id.*?script>!s', '', $exec2); $exec2_raw = $exec2 = str_replace ( '&', '&', $exec2 ); $x = curl_error ( $ch ); if (trim ( $exec2 ) == '') { if($is_an_album == true) { fbomatic_log_to_file('Failed to load the full album page: ' . print_r($album_url, true)); } else { fbomatic_log_to_file('Failed to load the full page: ' . print_r($original_post_url, true)); } } $redirec_url = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL); if (stristr($redirec_url, '/videos/') || stristr($redirec_url, '/watch/?v=') || stristr($exec2,'"videoId":"')) { $type = 'video'; } $is_reel = false; $reel_id = ''; if (stristr($redirec_url, '/reel/')) { $type = 'video'; $is_reel = true; preg_match('!/reel/(\d+)/!', $redirec_url, $reel_matches); if (isset($reel_matches[1]) && trim($reel_matches[1]) != '') { $reel_id = $reel_matches[1]; } } $ret->type = $type; if (trim ( $created_time ) == '') { $doc = new DOMDocument(); libxml_use_internal_errors(true); $doc->loadHTML($item); libxml_clear_errors(); $xpath = new DOMXPath($doc); $nodes = $xpath->query('//abbr'); if ($nodes->length > 0) { $dateTimeText = $nodes->item(0)->textContent; $dateTimeText = fbomatic_germanDateToEnglish($dateTimeText); $dateTime = DateTime::createFromFormat('d. F H:i', $dateTimeText); if ($dateTime) { $created_time = $dateTime->getTimestamp(); $created_time += 3600; } } if (trim ( $created_time ) == '') { preg_match ( '{"creation_time":(\d*)}', $exec2, $time_matches ); if (isset ( $time_matches [1] ) && trim ( $time_matches [1] ) != '') { $created_time = $time_matches [1]; } else { preg_match ( '!publish_time.?":(\d{10})!', $exec2 , $time_matches ); if (isset ( $time_matches [1] ) && trim ( $time_matches [1] ) != '') { $created_time = $time_matches [1]; } else { $created_time = time (); } } } } $created_time = date ( 'Y-m-d H:i:s', floatval($created_time) ); $created_time = get_date_from_gmt ( $created_time ); $wpdate = $created_time; if (stristr ( $exec2, 'permalinkPost' )) { preg_match ( '{permalinkPost">.*?<div class="_4-u2 _4-u8}s', $exec2, $post_matches ); if (isset ( $post_matches [0] ) && trim ( $post_matches [0] ) != '') { $exec2 = $post_matches [0]; } } if(preg_match('{^https?://}', $item)) { preg_match('!message":{"text":"(.*?)"!s', $exec2, $full_text_matches); if(isset($full_text_matches[1])) { $txtContent = fbomatic_fix_json_part($full_text_matches[1]) . '<br>'; $content = $txtContent; } } if (! stristr ( $item, '</p></span>' ) && !empty(trim($txtContent)) && ! $is_colored_post) { preg_match ( '! class="_5pbx.*?>(.*?)</div><div class="_3x-2" data-ft!s', str_replace ( '&', '&', $exec2 ), $full_text_matches ); if (stristr ( $exec2, 'ReCaptchav2Captcha' )) { fbomatic_log_to_file('Captcha found in response, please enter a proxy in plugin settings to get full post content.'); } if (isset ( $full_text_matches [1] ) && trim ( $full_text_matches [1] ) != '') { $full_text_matches [1] = preg_replace ( '{<img class="\w*?" height="16".*?>}s', '', $full_text_matches [1] ); $txtContent = $full_text_matches [1]; $content = $full_text_matches [1]; } elseif (stristr($exec2, 'story":{"message":{"text') || preg_match('!"story":.*?"message".*?"text"!', $exec2)) { preg_match('!story":{"message":{"text":"(.*?)"}!s', $exec2, $full_text_matches ); if(isset($full_text_matches[1]) && trim($full_text_matches[1]) != '' ) { if( stristr($full_text_matches[1] , '"') ) { $full_text_matches[1] = preg_replace('{ ".*}' , '' , $full_text_matches[1] ); } $txtContent = fbomatic_json_fix( $full_text_matches [1] ) .'<br>' ; if(!empty($txtContent)) { $content = $txtContent; } } else { preg_match('!"story":.*?"message".*?"text":"(.*?)"}!s', $exec2, $full_text_matches ); if(trim($full_text_matches [1]) != '') { $txtContent = fbomatic_json_fix( $full_text_matches [1] ) .'<br>' ; if(!empty($txtContent)) { $content = $txtContent; } } } } else { preg_match ( '!data-ft="{"tn":"K"}">(.*?)</div>!s', str_replace ( '&', '&', $exec2 ), $full_text_matches ); if (isset ( $full_text_matches [1] ) && trim ( $full_text_matches [1] ) != '') { $full_text_matches [1] = preg_replace ( '{<img class="\w*?" height="16".*?>}s', '', $full_text_matches [1] ); $txtContent = $full_text_matches [1]; $content = $full_text_matches [1]; } } } elseif (stristr ( $txtContent, '...' ) && stristr ( $txtContent, 'story.php' )) { preg_match_all ( '!<div data-ad-preview="message.*?/div>!s', $exec2, $full_text_matches ); $full_text_matches = $full_text_matches [0]; if (is_array($full_text_matches) && count ( $full_text_matches ) > 2) { $full_text_matches = array ( $full_text_matches [0], $full_text_matches [1] ); } $full_text_matches = implode ( '', $full_text_matches ); preg_match_all ( '{<p>(.*?)</p>}s', $full_text_matches, $p_matches ); $p_nobrcket = $p_matches [1]; $p_bracket = $p_matches [0]; if (count ( $p_matches [0] ) == 2) { if (stristr ( $p_nobrcket [1], $p_nobrcket [0] )) { unset ( $p_bracket [0] ); } } $possible_full = implode ( '', $p_bracket ); if (trim ( $possible_full ) != '') { $possible_full = preg_replace ( '{<img class="\w*?" height="16".*?>}s', '', $possible_full ); $txtContent = $possible_full; $content = $possible_full; } } $content = str_replace ( 'See Translation', '', $content ); $exec2 = preg_replace ( '{<ul class="_5ks4.*?ul>}s', '', $exec2 ); $full_imgs_srcs = array (); $exec2 = str_replace ( 'attachments_info:{}', '', $exec2 ); if (stristr($exec2, 'attachments_info')) { preg_match('!attachments_info:{.*?}}!s', $exec2, $full_imgs_html); if (isset($full_imgs_html[0]) && stristr($full_imgs_html[0], 'url')) { preg_match_all('!url:"(.*?)"!s', $full_imgs_html[0], $full_imgs_matches); if (isset($full_imgs_matches[1]) && count($full_imgs_matches[1]) > 0) { $full_imgs_srcs = $full_imgs_matches[1]; } } } elseif (stristr($exec2, 'data-ploi="')) { preg_match_all('!data-ploi="(.*?)"!s', $exec2, $poly_matches); if (isset($poly_matches[1]) && count($poly_matches[1]) > 0) { $full_imgs_srcs = $poly_matches[1]; } } elseif (stristr($exec2, 'data-plsi="')) { preg_match_all('!data-plsi="(.*?)"!s', $exec2, $poly_matches); if (isset($poly_matches[1]) && count($poly_matches[1]) > 0) { $full_imgs_srcs = $poly_matches[1]; } }elseif (stristr($exec2,'"attachment":{"media":{"__typename":"Photo"')){ preg_match_all('!"attachment":{"media":{"__typename":"Photo".*?"uri":"(.*?)"!', $exec2, $photo_matches); if(isset($photo_matches[1]) && is_array($photo_matches[1])){ $json_part = '["' . implode('","', $photo_matches[1]) . '"]'; $full_imgs_srcs = array_unique(json_decode($json_part)); } } elseif (preg_match('!viewer_image":{"height":\d*,"width":\d*,"uri":"(.*?)"!', $exec2)) { preg_match_all('!viewer_image":{"height":\d*,"width":\d*,"uri":"(.*?)"!', $exec2, $photo_matches); $json_part = '["' . implode('","', $photo_matches[1]) . '"]'; $full_imgs_srcs = array_unique(json_decode($json_part)); } elseif (stristr($exec2, '"photo_image":{"uri"')) { preg_match_all('!"photo_image":{"uri":"(.*?)"!', $exec2, $photo_matches); $json_part = '["' . implode('","', $photo_matches[1]) . '"]'; $full_imgs_srcs = array_unique(json_decode($json_part)); } elseif (stristr($exec2, '"large_share_image"')) { preg_match_all('!"large_share_image.*?"uri":"(.*?)"!', $exec2, $photo_matches); $json_part = '["' . implode('","', $photo_matches[1]) . '"]'; $full_imgs_srcs = array_unique(json_decode($json_part)); $all_imgs[0] = $full_imgs_srcs[0]; } elseif (stristr($exec2, 'GenericAttachmentMedia","image"')) { preg_match_all('!GenericAttachmentMedia","image":{"height":\d*,"uri":"(.*?)"!', $exec2, $photo_matches); $json_part = '["' . implode('","', $photo_matches[1]) . '"]'; $full_imgs_srcs = array_unique(json_decode($json_part)); if (stristr($full_imgs_srcs[0], 'safe_image')) { preg_match('{url\=(.*?)&}', $full_imgs_srcs[0], $external_img_founds); $full_imgs_srcs[0] = urldecode($external_img_founds[1]); } $all_imgs[0] = $full_imgs_srcs[0]; } elseif (stristr($exec2, 'scaledImageFit')) { $exec2 = preg_replace('!<div class="uiScaledImageContainer.*?div>!', '', $exec2, 1); preg_match_all('{<img class="scaledImageFit.*?src="(.*?)"}s', $exec2, $poly_matches); if (isset($poly_matches[1]) && is_array($poly_matches[1])) { $full_imgs_srcs = $poly_matches[1]; $all_imgs[0] = $full_imgs_srcs[0]; } }elseif( stristr($exec2,'"full_image":{')){ preg_match_all('!"full_image":.*?"uri":"(.*?)"!', $exec2, $photo_matches); if(isset($photo_matches[1]) && is_array($photo_matches[1])){ $full_imgs_srcs = $photo_matches[1]; $candidate_img = $full_imgs_srcs[0]; if(! empty($candidate_img) && stristr($candidate_img, 'https')){ $candidate_img = fbomatic_fix_json_part($candidate_img); $full_imgs_srcs = array($candidate_img); } $all_imgs[0] = $full_imgs_srcs[0]; } }elseif( stristr($exec2,'<meta property="og:image" content="')){ preg_match_all('!<meta property="og:image" content="(.*?)"!s', $exec2, $photo_matches); if(isset($photo_matches[1]) && is_array($photo_matches[1])){ $full_imgs_srcs = $photo_matches[1]; $candidate_img = $full_imgs_srcs[0]; if(! empty($candidate_img) && stristr($candidate_img, 'https')){ $candidate_img = fbomatic_fix_json_part($candidate_img); $full_imgs_srcs = array($candidate_img); } $all_imgs[0] = $full_imgs_srcs[0]; } } if(count($full_imgs_srcs) == 0){ fbomatic_log_to_file('No full image found'); } if($type == 'status' && count($full_imgs_srcs) > 0) { $type = 'photo'; } if(count($full_imgs_srcs) == 0) { preg_match_all ( '{<meta property="og:image" content="([^"]*?)"}s', $exec2, $ogmatches ); if (isset ( $ogmatches [1][0] ) && is_array ( $ogmatches [1] ) ) { $full_imgs_srcs[] = $ogmatches [1][0]; $all_imgs [0] = $ogmatches [1][0]; } } $ret->vid_url = ''; $ret->vid_id = ''; $scaled_matches = array(); if ($type == 'link') { $link_img = ''; preg_match ( '{l.php\?u=(.*?)&}s', $item, $linkMatches ); $foundLink = $linkMatches [1]; $link = urldecode ( $foundLink ); print_r ( '<br>Found Link:' . $link ); preg_match ( '!<h3 class="[^<]*?"><span class="[^<]*?"><span[^<]*?>([^<]*?)</span></span></h3></header>!s', $item, $linkTMatches ); $title = $linkTitle = isset ( $linkTMatches [1] ) ? $linkTMatches [1] : ''; if (trim($title) == '') { preg_match('!<h3 class="[^<]*?">([^<]*?)</h3>!s', $item, $linkTMatches); $title = $linkTitle = $linkTMatches[1]; } if (trim ( $title ) == '') { preg_match ( '!<h3 style="text-align: right" class="[^<]*?" dir="rtl">([^<]*?)</h3>!s', $item, $linkTMatches ); if(isset($linkTMatches[1])) { $title = $linkTitle = $linkTMatches[1]; } } if (isset ( $all_imgs [0] ) && trim ( $all_imgs [0] ) != '') { $imgsrc = $link_img = str_replace ( '&', '&', $all_imgs [0] ); } if (stristr ( $link_img, 'url=' ) && ! stristr ( $link_img, 'fbcdn.net' )) { $link_img_prts = explode ( 'url=', $link_img ); $link_img = $link_img_prts [1]; $link_img_prts = explode ( '&', $link_img ); $link_img = urldecode ( $link_img_prts [0] ); $imgsrc = $link_img; } else { preg_match ( '{<img class="scaledImageFit.*?src="(.*?)"}s', $exec2, $scaled_matches ); if (isset ( $scaled_matches [1] ) && trim ( $scaled_matches [1] ) != '') { $imgsrc = $link_img = str_replace ( '&', '&', $scaled_matches [1] ); } } if (trim ( $link_img ) != '') { if (stristr ( $link_img, '<img' )) { $content .= '<p><a href="' . $link . '">' . $link_img . '</a> </p>'; } else { $content .= '<p><a href="' . $link . '"><img title="' . $title . '" src="' . $link_img . '" /></a> </p>'; } } $content .= '<p><a href="' . $link . '">' . $linkTitle . '</a></p>'; preg_match ( '{_6m7 _3bt9">(.*?)</div>}s', $exec2, $description_matches ); if (isset ( $description_matches [1] ) && trim ( $description_matches [1] ) != '') { $txtContent .= $description_matches [1]; $content .= $description_matches [1]; } } elseif ($type == 'video') { $style = ''; if (stristr ( $item, 'youtube.com%2Fwatch' )) { $content = ''; preg_match ( '{l.php\?u=(.*?)&}s', $item, $linkMatches ); $foundLink = $linkMatches [1]; $link = urldecode ( $foundLink ); preg_match ( '!><span>([^<]*?)</span></span></h3>!s', $item, $linkTMatches ); if(isset($linkTMatches [1])) { $title = $linkTitle = $linkTMatches [1]; } else { $title = $linkTitle = ''; } if (isset ( $all_imgs [0] )) { if($video_no_img != '1') { $content = '<img ' . $style . ' title="' . $title . '" src="' . $all_imgs [0] . '" /></a><br>' . $content; } } $content .= '<br><br>[embed]' . $link . '[/embed]'; $ret->vid_embed = $link; $vidurl = $link; } else { $content = ''; preg_match('!,"message":{"text":"(.*?)"!s', $exec2, $vid_title_match); $title = ''; preg_match_all('!ideo","preferred_thumbnail":{"image":{"uri":"(.*?)"!', $exec2, $imgMatch); if (count($imgMatch[1]) == 0) { preg_match_all('!<meta property="og:image" content="(.*?)"!s', $exec2, $imgMatch); } $imgMatch = $imgMatch [1]; if (is_array($imgMatch) && count ( $imgMatch ) > 1) { $the_vid_img_raw = $imgMatch [1]; } elseif(count ( $imgMatch ) == 0){ preg_match( "!background: url\('(.*?)'!" , $item , $matches_bg_img ); if(isset($matches_bg_img[1])) { $matches_bg_img[1] = str_replace( '\3a' , ':' , $matches_bg_img[1]); $matches_bg_img[1] = str_replace( '\3d' , '=' , $matches_bg_img[1]); $matches_bg_img[1] = str_replace( '\26' , '&' , $matches_bg_img[1]); $matches_bg_img[1] = str_replace(' ' , '', $matches_bg_img[1]); $the_vid_img_raw = $matches_bg_img[1] ; } else { $the_vid_img_raw = ''; } } else { $the_vid_img_raw = $imgMatch [0]; } $link_img = str_replace ( '\/', '/', $the_vid_img_raw ); $imgsrc = $link_img; if($video_no_img != '1') { if (count ( $full_imgs_srcs ) > 1 && ! stristr ( $exec2, '_3chq' )) { foreach ( $full_imgs_srcs as $imgsrc ) { $content = $content . '<img ' . $style . ' title="' . $title . '" src="' . $imgsrc . '" /></a><br>'; } } else { $content = '<img ' . $style . ' title="' . $title . '" src="' . $imgsrc . '" /></a><br>' . $content; } } $message = isset($vid_title_match[1]) ? fbomatic_fix_json_part($vid_title_match[1]) : ''; $txtContent = $message; $content .= trim($message) != '' ? '<p>'. $message . '</p>' : ''; if(stristr($item, '"videoID"')){ preg_match ( '{videoID":"(.*?)"}s', $item, $id_match ); } elseif (stristr($exec2, '"videoId"')) { preg_match('{videoId":"(.*?)"}s', $exec2, $id_match); } elseif (stristr ( $item, 'photo_id":"' )) { preg_match ( '{photo_id":"(.*?)"}s', $item, $id_match ); } elseif (stristr($exec2, '"videoID"')) { preg_match('{videoID":"(.*?)"}s', $exec2, $id_match); } else { preg_match( '{source=.*?&id=(\d*?)&}', $item, $id_match ); } if(! empty($id_match[1])){ $vid_id = $id_match [1]; $id_match = array($id_match[1]); } else { if(isset($post_id) && !empty($post_id)){ $vid_id = $post_id; $id_match = array($post_id); } } if($is_reel && isset($reel_id) ) { $vid_id = $reel_id; $id_match = array($reel_id); } $vidurl = "https://www.facebook.com/video.php?v=$vid_id"; $ret->vid_url = $vidurl; $ret->vid_id = $vid_id; if($is_reel == true) { $ret->vid_embed = '<iframe src="https://www.facebook.com/plugins/video.php?height=476&href=https%3A%2F%2Fweb.facebook.com%2Freel%2F'.$vid_id.'%2F&show_text=false&width=267&t=0" width="267" height="476" style="border:none;overflow:hidden" scrolling="no" frameborder="0" allowfullscreen="true" allow="autoplay; clipboard-write; encrypted-media; picture-in-picture; web-share" allowFullScreen="true"></iframe>'; } else { $ret->vid_embed = '<div id="fb-root"></div><script>window.fbAsyncInit = function() {FB.init({appId : \'\',xfbml : true,version : \'v2.5\'});var my_video_player;FB.Event.subscribe(\'xfbml.ready\', function(msg) {if (msg.type === \'video\') {my_video_player = msg.instance; my_video_player.unmute();}});};(function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.3"; fjs.parentNode.insertBefore(js, fjs);}(document, \'script\', \'facebook-jssdk\'));</script><div class="fb-video" data-autoplay="false" data-allowfullscreen="true" data-href="https://www.facebook.com/video.php?v=' . $vid_id . '&set=vb.500808182&type=1"><div class="fb-xfbml-parse-ignore"></div></div>'; } $fist = true; foreach ( $id_match as $vid_id_single ) { if($fist == true) { $content .= '<div id="fb-root"></div>'; $content .= '<script>(function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v' . $api_v . '"; fjs.parentNode.insertBefore(js, fjs);}(document, \'script\', \'facebook-jssdk\'));</script>'; } $content .= '<div id="fb-root"></div><script>window.fbAsyncInit = function() {FB.init({appId : \'\',xfbml : true,version : \'v2.5\'});var my_video_player;FB.Event.subscribe(\'xfbml.ready\', function(msg) {if (msg.type === \'video\') {my_video_player = msg.instance; my_video_player.unmute();}});};(function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.3"; fjs.parentNode.insertBefore(js, fjs);}(document, \'script\', \'facebook-jssdk\')); </script><div class="fb-video" data-autoplay="false" data-allowfullscreen="true" data-href="https://www.facebook.com/video.php?v='.$vid_id_single.'&set=vb.500808182&type=1"><div class="fb-xfbml-parse-ignore"></div></div>'; $fist = false; } } } elseif ($type == 'note') { preg_match ( '!<div class="\w{2}">([^<]+?)</div>!s', $item, $title_matches ); if(isset($title_matches [1])) { $title = $title_matches [1]; } else { $title = ''; } if (stristr ( $exec2, '_30q-' )) { preg_match ( '{<div class="_30q-" style="background-image: url\((.*?)\)}s', $exec2, $full_img_matches ); if (isset ( $full_img_matches [1] ) && trim ( $full_img_matches [1] ) != '') { $imgsrc = $link_img = str_replace ( '&', '&', $full_img_matches [1] ); $content = '<img title="' . $title . '" src="' . $link_img . '" /></a><br>' . $content; } } elseif (isset ( $all_imgs [0] )) { preg_match ( '{<img src="(.*?)".*?>}', $all_imgs [0], $imgMatch ); if (isset ( $imgMatch [1] ) && trim ( $imgMatch [1] ) != '') { $imgsrc = $link_img = str_replace ( '&', '&', $imgMatch [1] ); $content = '<img title="' . $title . '" src="' . $link_img . '" /></a><br>' . $content; } } preg_match ( '!<div class="\w{2} \w{2}">([^<]+)</div>!s', $item, $content_matches ); $content = $content . $content_matches [1]; } elseif ($type == 'event') { if ($fbomatic_post_type == 'events') { preg_match ( '!<title>(.*?)</title>!s', $exec2, $title_matches ); } else { preg_match ( '!<h3 class="\w{2} \w{2} \w{2}">([^<]+?)</h3>!s', $item, $title_matches ); } if(isset($title_matches [1])) { $title = $title_matches [1]; } else { $title = ''; } if (stristr ( $exec2, 'profile_picture_for_sticky_bar":{"uri":"' )) { preg_match ( '!CoverPhotoRenderer","cover_photo":{"photo":{"viewer_image.*?"uri":"(.*?)"!s', $exec2, $scaled_matches ); if( empty($scaled_matches[1])) { preg_match ( '!image":{"height":\d*,"uri":"(.*?)"!s', $exec2, $scaled_matches ); } } elseif (stristr ( $exec2, '<video' )) { preg_match ( '{margin-top:0px;" src="(.*?)"}s', $exec2, $scaled_matches ); } if (isset ( $scaled_matches [1] ) && trim ( $scaled_matches [1] ) != '') { $imgsrc = $link_img = str_replace ( '\/', '/', $scaled_matches [1] ); $content = '<img title="' . $title . '" src="' . $link_img . '" /></a><br>' . $content; } } elseif ($type == 'offer') { preg_match ( '!<h3 class="\w{2} \w{2} \w{2}">([^<]+?)</h3>!s', $item, $title_matches ); if(isset($title_matches [1])) { $title = $title_matches [1]; } else { $title = ''; } if (trim ( $content ) == '') { $content = $title; } preg_match ( '{<img class="scaledImageFit.*?src="(.*?)"}s', $exec2, $scaled_matches ); if (isset ( $scaled_matches [1] ) && trim ( $scaled_matches [1] ) != '') { $imgsrc = $link_img = str_replace ( '&', '&', $scaled_matches [1] ); $content = '<img title="' . $title . '" src="' . $link_img . '" /></a><br>' . $content; } } elseif ($type == 'photo') { if (count ( $full_imgs_srcs ) > 0) { foreach ( $full_imgs_srcs as $single_img_src ) { $content .= '<br><a href="' . $single_img_src . '"><img class="fbomatic_fb_img" title="' . $title . '" src="' . $single_img_src . '" /></a>'; } } else { $content = $content . implode ( '', $all_imgs ); } preg_match_all ( '{src="(.*?)"}', $content, $src_matches ); if (isset ( $src_matches[1] ) && is_array($src_matches[1])) { foreach($src_matches[1] as $srxx) { if(trim ( $srxx ) != '') { $imgsrc = str_replace ( '&', '&', $srxx ); break; } } } } if (trim ( $title ) == '') { $tempContent = str_replace ( '</p><p>', "\n", $txtContent ); $tempContent = str_replace ( 'See Translation', '', $tempContent ); $tempContent = str_replace ( '<br />', "\n", $tempContent ); $tempContent = str_replace ( '<br >', "\n", $tempContent ); $tempContent = str_replace ( '<br>', "\n", $tempContent ); $tempContent = str_replace ( '<br/>', "\n", $tempContent ); $tempContent = strip_tags ( strip_shortcodes ( $tempContent ) ); $tempContent = preg_replace ( '@(https?://([-\w\.]+[-\w])+(:\d+)?(/([\w/_\.#-]*(\?\S+)?[^\.\s])?)?)@', '', $tempContent ); $charsCount = 80; if (function_exists ( 'mb_substr' )) { $newTitle = mb_substr ( $tempContent, 0, $charsCount ); if (stristr ( $newTitle, "\n" )) { $suggestedTitle = preg_replace ( "{\n.*}", '', $newTitle ); if (trim ( $suggestedTitle ) != '') { $newTitle = trim ( $suggestedTitle ); $before_title_removal = $content; $content = str_replace ( $suggestedTitle . "<br />", '', $content ); if ($content == $before_title_removal) { $content = str_replace ( '<p>' . $suggestedTitle . "</p>", '', $content ); } if ($content == $before_title_removal) { $content = str_replace ( $suggestedTitle, '', $content ); } } } if (trim ( $newTitle ) != '') { $title = $newTitle; } } else { $newTitle = substr ( $tempContent, 0, $charsCount ); if (stristr ( $newTitle, "\n" )) { $suggestedTitle = preg_replace ( "{\n.*}", '', $newTitle ); if (trim ( $suggestedTitle ) != '') { $newTitle = trim ( $suggestedTitle ); $before_title_removal = $content; $content = str_replace ( $suggestedTitle . "<br />", '', $content ); if ($content == $before_title_removal) { $content = str_replace ( '<p>' . $suggestedTitle . "</p>", '', $content ); } if ($content == $before_title_removal) { $content = str_replace ( $suggestedTitle, '', $content ); } } } if (trim ( $newTitle ) != '') { $title = $newTitle; } } if($tempContent != '') { $content = $tempContent; } } if (stristr ( $content, 'com/l.php' )) { preg_match_all ( '{"http://l\.facebook\.com/l\.php\?u=(.*?)"}', $content, $matches ); $founds = $matches [0]; $links = $matches [1]; $i = 0; foreach ( $founds as $found ) { $found = str_replace ( '"', '', $found ); $link = $links [$i]; $link_parts = explode ( '&h', $link ); $link = $link_parts [0]; $content = str_replace ( $found, urldecode ( $link ), $content ); $i ++; } } if (stristr ( $content, 'safe_image.php' )) { if (! stristr ( $content, 'fbstaging' )) { preg_match_all ( '{https://[^:]*?safe_image\.php.*?url=(.*?)"}', $content, $matches ); $found_imgs = $matches [0]; $found_imgs_links = $matches [1]; $i = 0; foreach ( $found_imgs as $found_img ) { $found_imgs_links [$i] = preg_replace ( '{&.*}', '', $found_imgs_links [$i] ); $found_img_link = urldecode ( $found_imgs_links [$i] ); $content = str_replace ( $found_img, $found_img_link . "\"", $content ); $imgsrc = $found_img_link; } } else { $content = str_replace ( '&w=130', '&w=650', $content ); $content = str_replace ( '&h=130', '&h=650', $content ); $imgsrc = str_replace ( '&w=130', '&w=650', $imgsrc ); $imgsrc = str_replace ( '&h=130', '&h=650', $imgsrc ); } } $content = preg_replace ( '{href="/(\w)}', 'href="https://facebook.com/$1', $content ); $content = str_replace ( 'class="img"', 'class="fbomatic_fb_img"', $content ); if(count($full_imgs_srcs) == 0) { preg_match_all ( '{<img(?:[\s\S]*?)src="([^"]*?)">}s', $content, $imamatches ); if (isset ( $imamatches [1][0] ) && is_array ( $imamatches [1] ) ) { $full_imgs_srcs[] = $imamatches [1][0]; $all_imgs [0] = $imamatches [1][0]; } } if ($isEvent == true) { $ret->facebook_title = $title; $ret->link = $url; $ret->message = $content; $ret->created_time = $wpdate; $ret->image_src = $imgsrc; $ret->id = $item_id; } else { $ret->facebook_title = $title; $ret->link = $url; $ret->message = $content; $ret->created_time = $wpdate; $ret->from_name = ''; preg_match ( '!"actors":\[{"__typename":"\w*?","name":"(.*?)",!', $exec2, $from_matches ); if(isset($from_matches[1])) { $name_arr = json_decode('["' . $from_matches[1] . '"]') ; if(isset($name_arr [0])) { $from_name = $name_arr [0]; } } $sharer_id = $ids; if (stristr ( $exec2, 'sharer_id' )) { preg_match ( '{sharer_id=(.*?)&}s', $exec2, $from_matches ); if (isset ( $from_matches [1] ) && trim ( $from_matches [1] ) != '') { $sharer_id = $from_matches [1]; } preg_match ( '{ownerName:"(.*?)"}s', $exec2, $from_name_matches ); if (isset ( $from_name_matches [1] ) && trim ( $from_name_matches [1] ) != '') { $from_name = $from_name_matches [1]; } } else { preg_match ( '{content_owner_id_new.*?(\d+)}s', $item, $from_matches2 ); if (isset ( $from_matches2 [1] ) && trim ( $from_matches2 [1] ) != '') { $sharer_id = $from_matches2 [1]; } } $from_obj = new stdClass(); $from_obj->id = $sharer_id; $ret->from = $from_obj; $ret->from_url = 'https://facebook.com/' . $sharer_id; $ret->from_thumbnail = 'https://graph.facebook.com/' . $sharer_id . '/picture?type=large'; $ret->id = $item_id; $ret->post_id_single = $single_id; $ret->full_picture = $imgsrc; $ret->picture = $imgsrc; if (trim($title) == '') { $ret->facebook_title = ''; } if ($type == 'link') { $ret->external_url = $link; } else { $ret->external_url = ''; } $ret->post_embed = '<div id="fb-root"></div><script> (function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/en_US/all.js#xfbml=1"; fjs.parentNode.insertBefore(js, fjs); }(document, \'script\', \'facebook-jssdk\')); </script><div class="fb-post" data-href="https://www.facebook.com/' . $ids . '/posts/' . $single_id . '"></div>'; if (stristr ( $ret->message, '#' )) { preg_match_all ( '{>#(.*?)</a>}', $ret->message, $hash_matchs ); if(isset($hash_matchs [1])) { $hash_matchs = $hash_matchs [1]; $hash_tags = implode ( ',', $hash_matchs ); $ret->item_tags = strip_tags ( $hash_tags ); } else { $ret->item_tags = ''; } } else { $ret->item_tags = ''; } } if ($fbomatic_page_type == 'group') { $ret->source_link = 'https://www.facebook.com/groups/' . $ids . '/permalink/' . $single_id; } else { $ret->source_link = $ret->link; } $correct_comment_part = ''; if ( stristr ( $exec2_raw, '"edges":[{"node":' ) ) { $all_the_comments = array (); preg_match_all ( '{"edges":\[\{"node":\{"id"[^<]*,"cursor":.*?\}\]}s', $exec2_raw, $comment_part_matches ); $comment_part_matches = $comment_part_matches [0]; if (isset ( $comment_part_matches [0] ) && trim ( $comment_part_matches [0] ) != '') { $correct_comment_part = '{' . $comment_part_matches [0] . '}'; $comments_json = (json_decode ( $correct_comment_part )); if (isset ( $comments_json->edges )) { $all_comments = $comments_json->edges; foreach ( $all_comments as $single_comment ) { $a_comment = array (); $single_comment = $single_comment->node; if (isset($single_comment->url) && stristr ( $single_comment->url, $single_id )) { $commment_txt = $single_comment->url; $a_comment ['text'] = $single_comment->body->text; if (isset ( $single_comment->attachments [0]->media->image->uri )) { $imgURI = $single_comment->attachments [0]->media->image->uri; if (trim ( $imgURI ) != '') { $a_comment ['text'] .= '<br><img src="' . $imgURI . '"/>'; } } $a_comment ['time'] = $single_comment->created_time; $a_comment ['author_id'] = $single_comment->author->id; $a_comment ['author_name'] = $single_comment->author->name; if (trim ( $a_comment ['text'] ) != '') { $all_the_comments [] = $a_comment; } } } if (count ( $all_the_comments ) > 0) { $ret->comments = array_reverse ( $all_the_comments ); } } } } if (stristr ( $ret->message, 'hash' )) { $ret->message = preg_replace ( '{>#</span><span class="[^<]*?">}s', '>#', $ret->message ); } $ret->created_time_timestamp = strtotime ( $ret->created_time ); $continue_xx = false; foreach($ret_obj_arr as $rar) { if($rar->link == $ret->link) { $continue_xx = true; break; } } if($continue_xx == true) { continue; } $ret_obj_arr[] = $ret; if(count($ret_obj_arr) >= $max) { break; } } $html_dom_original_html->clear(); unset($html_dom_original_html); if(!isset($fbomatic_raw_exec)) { $fbomatic_raw_exec = ''; } if ($continue_search == '1') { $skip_posts_temp = get_transient('fbomatic_continue_search'); if($skip_posts_temp === false) { $skip_posts_temp = array(); } $nextPageUrl = ''; if (stristr($fbomatic_raw_exec, '"see_more_cards_id\",\"href\"') || stristr($fbomatic_raw_exec, 'm_more_item\",\"href') || stristr($fbomatic_raw_exec, 'profile\\\\\\/timeline\\\\\\/stream') || (stristr($exec, 'serialized_cursor') && $fbomatic_post_type == 'events') || ($fbomatic_page_type == 'group' && stristr($fbomatic_raw_exec, "/groups/$ids?bac")) || ($fbomatic_page_type == 'profile' && stristr($fbomatic_raw_exec, "profile/timeline/stream/?cursor"))) { if ($fbomatic_page_type == 'profile' && stristr($fbomatic_raw_exec, "profile/timeline/stream/?cursor")) { preg_match('!<a href="(/profile/timeline/stream/\?cursor=.*?)"!s', $fbomatic_raw_exec, $next_page_matches); $next_page_matches[1] = html_entity_decode($next_page_matches[1]); } elseif ($fbomatic_page_type == 'group' && stristr($fbomatic_raw_exec, "/groups/$ids?bac")) { preg_match('{<a href="(/groups/' . $ids . '\?bacr.*?)"><span>}s', $exec, $next_page_matches); } elseif ((stristr($exec, 'serialized_cursor') && $fbomatic_post_type == 'events')) { preg_match('{<a href="([^"]*?serialized_cursor.*?)"><span>}s', $exec, $next_page_matches); } elseif (stristr($fbomatic_raw_exec, 'm_more_item\",\"href')) { preg_match('{"m_more_item.",."href.":."(.*?)"}s', $fbomatic_raw_exec, $next_page_matches); $possible_pagination_url = fbomatic_fix_json_part(stripslashes($next_page_matches[1])); if (trim($possible_pagination_url) != '') { $next_page_matches[1] = $possible_pagination_url; } } elseif (stristr($fbomatic_raw_exec, 'see_more_cards_id\",\"href\"')) { preg_match('!"(.{4}page_content_list_view.*?)"!s', $fbomatic_raw_exec, $next_page_matches); $possible_pagination_url = fbomatic_fix_json_part(stripslashes($next_page_matches[1])); if (trim($possible_pagination_url) != '') { $next_page_matches[1] = $possible_pagination_url; } } else { preg_match('{"href.":."(.{4}profile.{4}timeline.{4}stream.{4}\?cursor\=.*?)"}s', $fbomatic_raw_exec, $next_page_matches); $possible_pagination_url = fbomatic_fix_json_part(stripslashes($next_page_matches[1])); if (trim($possible_pagination_url) != '') { $next_page_matches[1] = $possible_pagination_url; } } if (isset($foundOldPost) && $foundOldPost) { $skip_posts_temp[$param] = ''; $fbomatic_checked_years[$param] = ''; get_transient('fbomatic_continue_search', $skip_posts_temp, 999999999); update_option('fbomatic_checked_years', $fbomatic_checked_years); } elseif (isset($next_page_matches[1]) && trim($next_page_matches[1]) != '') { if ($fbomatic_post_type == 'events' || $fbomatic_page_type == 'group' || $fbomatic_page_type == 'profile') { $nextPageUrl = "https://mbasic.facebook.com" . $next_page_matches[1]; } else { $nextPageUrl = "https://m.facebook.com" . $next_page_matches[1]; } $skip_posts_temp = get_transient('fbomatic_continue_search'); $skip_posts_temp[$param] = $ids . $nextPageUrl; fbomatic_log_to_file('Setting next URL to: ' . $skip_posts_temp[$param]); set_transient('fbomatic_continue_search', $skip_posts_temp, 999999999); } else { $skip_posts_temp[$param] = ''; $fbomatic_checked_years[$param] = ''; get_transient('fbomatic_continue_search', $skip_posts_temp, 999999999); update_option('fbomatic_checked_years', $fbomatic_checked_years); } } else { $skip_posts_temp[$param] = ''; $fbomatic_checked_years[$param] = ''; get_transient('fbomatic_continue_search', $skip_posts_temp, 999999999); update_option('fbomatic_checked_years', $fbomatic_checked_years); } } return $ret_obj_arr; } else { fbomatic_log_to_file('Incorrect Facebook response: ' . $exec . ' - url: ' . $url . ' -- cookie: ' . 'xs=' . $fbomatic_xs . ';c_user=' . $fbomatic_cuser); return false; } } }
Save File
Cancel