Boxerman Posted December 9, 2015 Share Posted December 9, 2015 Hey guys, Sorry to waste your time here, but i'm hoping you can help. I'm really not sure how to ask for help here, but the below script basically runs off, checks a webpage for a page then returns results, however, if the title has more than 25 letters or has multiple spaces in like "I Am The One" it struggles to find it correctly. How would one attack such a problem? public function getTitle($title){ $title = trim($title); $title = stripslashes($title); $title = strtolower(urldecode($title)); $title = str_replace(" ","-",$title); $title = str_replace("'","'",$title); $title = str_replace(":",":",$title); return $title; } public function getMovieEmbeds($title) { $misc = new Misc(); //Step1 find key $movie_url = null; $html = file_get_html('https://primewire.unblocked.pe/'); $elements = $html->find('input[name=key]',0); $key = null; if(!is_null($elements)){ $key = $elements->value; } if(is_null($key)){ return array(); } $search = urlencode($title); $html = file_get_html("https://primewire.unblocked.pe/index.php?search_keywords=$search&key=$key&search_section=1"); $elements = $html->find(".index_item h2"); if(!is_null($elements)){ foreach($elements as $element){ $element_title = strtolower(strip_tags(trim(preg_replace('/\s*\([^)]*\)/', '', $element->innertext)))); if ($element_title == strtolower(trim($title))) { $parent = $element->parent(); $movie_url = "https://primewire.unblocked.pe".$parent->href; break; } } } if (is_null($movie_url)) { return array(); } $html = file_get_html($movie_url); $elements = $html->find(".movie_version_link a"); if(!is_null($elements)){ foreach($elements as $element){ $encoded_url = "https://primewire.unblocked.pe".$element->href; $query = parse_url($encoded_url, PHP_URL_QUERY); parse_str($query,$op); $link = base64_decode($op["url"]); if(strpos($link, "affbuzzads")===false && strpos($link, "webtrackerplus")===false){ $embed = $misc->buildEmbed($link); if ($embed) { $embeds[] = array( "embed" => $embed, "link" => $link, "language" => "ENG", ); } } } return $embeds; } return array(); } public function getEmbeds($title, $showid, $season, $episode) { $misc = new Misc(); $movie_url = null; $html = file_get_html('https://primewire.unblocked.pe/?tv'); $elements = $html->find('input[name=key]',0); $key = null; if(!is_null($elements)){ $key = $elements->value; } if(is_null($key)){ return array(); } $search = urlencode($title); $html = file_get_html("https://primewire.unblocked.pe/index.php?search_keywords=$search&key=$key&search_section=2"); $elements = $html->find(".index_item h2"); if(!is_null($elements)){ foreach($elements as $element){ $element_title = strtolower(strip_tags(trim(preg_replace('/\s*\([^)]*\)/', '', $element->innertext)))); if ($element_title == strtolower(trim($title))) { $parent = $element->parent(); $movie_url = "https://primewire.unblocked.pe".$parent->href; break; } } } if (is_null($movie_url)) { return array(); } $episode_url = str_replace("watch", "tv", $movie_url)."/season-".$season."-episode-".$episode; $html = file_get_html($episode_url); $elements = $html->find(".movie_version_link a"); if(!is_null($elements)){ $embeds = array(); foreach($elements as $element){ $encoded_url = "https://primewire.unblocked.pe".$element->href; $query = parse_url($encoded_url, PHP_URL_QUERY); parse_str($query,$op); $link = base64_decode($op["url"]); if(strpos($link, "affbuzzads")===false && strpos($link, "webtrackerplus")===false){ $embed = $misc->buildEmbed($link); if ($embed) { $embeds[] = array( "embed" => $embed, "link" => $link, "language" => "ENG", ); } } } return $embeds; } return array(); Thanks for taking your time to read! - Please be gentle! B-Man Quote Link to comment https://forums.phpfreaks.com/topic/299688-script-struggles-with-more-than-25-letters-or-multiple-spaces/ Share on other sites More sharing options...
NotionCommotion Posted December 10, 2015 Share Posted December 10, 2015 Which of the three methods are you having problems with? Quote Link to comment https://forums.phpfreaks.com/topic/299688-script-struggles-with-more-than-25-letters-or-multiple-spaces/#findComment-1527749 Share on other sites More sharing options...
Boxerman Posted December 10, 2015 Author Share Posted December 10, 2015 Hi Notion, That's where im stuck, i'm struggling to trouble shoot it. I believe its the searching part of the search, however i can't be sure I'm so sorry i can't be helpful, i'm still learning this code, i'm just struggling to troubleshoot it. Quote Link to comment https://forums.phpfreaks.com/topic/299688-script-struggles-with-more-than-25-letters-or-multiple-spaces/#findComment-1527754 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.