Jump to content

QuickOldCar

Staff Alumni
  • Posts

    2,972
  • Joined

  • Last visited

  • Days Won

    28

Everything posted by QuickOldCar

  1. Well I tried to help, what I said previous should work for you, just append video to the includes/......php file or add the word video to front of $_GET['vid'] Would be best to create or use an already made video embed script, depending where the url comes from, that embed is used. Here is one that works ok. http://webcodingeasy.com/PHP-classes/Get-information-about-video-and-images-from-link
  2. To be honest I've never played these types of games, but will tell you what I noticed. signed up and logged in fine..but it did take longer than expected for it to allow me to login, I even went and checked my spam email to see if had to verify it, but that wasn't the case and eventually let me log in. Ok now I'm in the game. I had no idea how to start playing this game, everything I tried it wouldn't let me do. I saw the training, kept getting message not enough turns, whatever that means. So maybe a tutorial on how to play your game would be helpful to new users. Style, every page you visit at first is fine, then a second scroll bar to the right that does nothing loads and also shoves the page to the left. Maybe some better spacing on the input boxes and line them up also. I logged out and left the site, I then returned and tried to log in once more and get "Invalid Login Information Provided", and this is the same information that just logged me in previous.
  3. You can just add the word video to the include. $a=file_get_contents("http://www.mysite.co.uk/includes/video" . ($vid . ".php")); But I'm not sure why are passing these to individual php files. Why not use a single php page and pass the id into an embed in just that. Lets take a simple youtube example. <?php if(isset($_GET['vid']) && $_GET['vid'] !=''){ $video = $_GET['vid']; }else{ $video = "JW5meKfy3fY"; } echo "<a href='?vid=uuwfgXD8qV8'>uuwfgXD8qV8</a><br />"; echo "<a href='?vid=4e8L_Z0a_kQ'>4e8L_Z0a_kQ</a><br />"; echo "Video number is $video <br />"; ?> <iframe class="youtube-player" type="text/html" width="640" height="385" src="http://www.youtube.com/embed/<?php echo $video;?>" frameborder="0"> </iframe> Now you don't have to display anything like I did, except the embed. then can just include if wanted to include("script-name.php?vid=$video"); or just link to it echo "<a href='script-name.php?vid=$video'>Video $video</a>";
  4. ahh i see what you are doing, well you don't need to place word video in there, just an id number and use something like this: www.mysite.co.uk/index.php?vid=2 if (isset($_GET['vid']) && is_numeric($_GET['vid']) && $_GET['vid'] !=''){ $video = $_GET['vid']; }else{ $video = 1; } echo "Video number is $video";
  5. not sure what type of id's are gonna be using..but how about seeing if are numeric if (isset($_GET['vid']) && is_numeric($_GET['vid']) && $_GET['vid'] !=''){ $video="video".$_GET['vid']; }else{ $video="video1"; }
  6. if (isset($_GET['vid']) && $_GET['vid'] !=''){ $video="video".$_GET['vid']; }else{ $video="video1"; } That's assuming you want to prepend video to the id. You should be checking if the GET values are numbers most likely.
  7. Have a look here at this pagination tutorial. http://www.phpfreaks.com/tutorial/basic-pagination You can follow that tutorial, but that paginates all the results, would just need to add a limit at the end of your query, and then another query with no limits and see how many rows that result contains to be used for the pagination. To sum it up: $sql = "SELECT id, number FROM numbers WHERE product='product_name' LIMIT $offset,$rowsperpage"; $result = mysql_query($sql, $conn) or trigger_error("SQL", E_USER_ERROR); $sql_count = "SELECT id, number FROM numbers WHERE product='product_name'"; $numrows = mysql_num_rows($sql_count);
  8. for the count need to do another query without the limits, no grouping or ordering is needed.
  9. Personally I use Boolean Full-Text Searches. Be sure to escape and filter the keywords before using in mysql Try this: $sql = "SELECT * FROM rapatterns WHERE MATCH (Pattern,Color,Fabric_Use) AGAINST ('$keyword' IN BOOLEAN MODE) ORDER BY Pattern DESC Limit $offset, $rowsperpage"; To get results that must contain all search words. Explode each word and add a + in front of each word, but only if it's not a dash (dash is used to exclude words). To get results that includes any of the search words. Explode and make sure each word just has a space between them. For exact matches or other types of specific searches it's best to use multiple mysql statements with a switch or if/else statements. An exact match query would look like this. $sql = "SELECT * FROM rapatterns WHERE MATCH (Pattern,Color,Fabric_Use) AGAINST ('\"$keyword\"' IN BOOLEAN MODE) ORDER BY Pattern DESC Limit $offset, $rowsperpage"; Create an index an any columns used in the WHERE clause Can also lower the minimum word length for search results. http://dev.mysql.com/doc/refman/5.6/en/fulltext-fine-tuning.html Located in my.ini for MYSQL [mysqld] ft_min_word_len=3 then repair the tables after restart of the server REPAIR TABLE tbl_name QUICK;//edit tbl_name to your table name As for the $keyword, or multiple keywords directly before each search word can be operators + stands for AND - stands for NOT [no operator] implies OR There are others, but the above are the most beneficial. http://dev.mysql.com/doc/refman/5.6/en/fulltext-boolean.html
  10. Yeah that's the best way scootstah, handles the case as well
  11. Here is 2 easy examples of how to remove everything after a certain character <?php $string = "A blagh blah blah blah blah. http://blah.com"; $removed = explode("http://", $string); $removed = $removed[0]; echo $removed."<br />"; $removed2 = substr($string, 0, strpos("$string*", "http://")); echo $removed2; ?>
  12. http://php.net/manual/en/function.preg-match.php http://php.net/manual/en/function.preg-match-all.php and matching patterns using regex.
  13. //get the url from the address bar $url = filter_var("http://".$_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME'], FILTER_SANITIZE_STRING); if (!empty($_SERVER["QUERY_STRING"])){ $query_string = filter_var($_SERVER['QUERY_STRING'], FILTER_SANITIZE_STRING); $url .= "?".$query_string; }
  14. Made a correction in the code determining if is xml and also xml extension <html> <title>Link scraper</title> <meta name="description" content="Scrape the href links from the body section of a page" /> <meta name="keywords" content="scrape link, scrape urls,links,url,urls,fetch url,grab link" /> <meta name="author" content="Jay Przekop - dynainternet.com" /> <meta http-equiv="content-type" content="text/html;charset=UTF-8" /> <head> <style type="text/css"> #content { width: 800px ; margin-left: auto ; margin-right: auto ; } </style> </head> <body> <div id="content"> <form action="" method="GET"> <input type="text" name="target" size="100" id="target" value="" placeholder="Insert url to get links" /> <input type="submit" value="Get the links" /> <br /> </form> <?php if(isset($_GET['target']) && $_GET['target'] != ''){ $target_url = trim($_GET['target']); echo "<h2>Links from ".htmlentities(urldecode($target_url))."</h2>"; $userAgent = 'Linkhunter/1.0 (http://dynainternet.com/test/grab-links.php)'; //replace hxxp function function replaceHxxp($url){ $url = str_ireplace(array("hxxps://xxx.","hxxps://","hxxp://xxx.","hxxp://"), array("https://www.","https://","http://www.","http://"), trim($url)); return $url; } //parse the host, no http:// returned function parseHOST($url){ $new_parse_url = str_ireplace(array("http://","https://", "http://", "ftp://", "feed://"), "", trim($url)); $parsedUrl = @parse_url("http://$new_parse_url"); return strtolower(trim($parsedUrl['host'] ? $parsedUrl['host'] : array_shift(explode('/', $parsedUrl['path'], 2)))); } function removePaths($url,$number_positions=NULL) { $path = @parse_url($url, PHP_URL_PATH); $trim_path = trim($path, '/'); $positions = ""; $positions = explode('/', $trim_path); if(preg_match("/\./",end($positions))) { array_pop($positions); } if(!is_null($number_positions)){ for ($i = 1; $i <= $number_positions; $i++) { array_pop($positions); } } foreach($positions as $folders){ if(!empty($folders)){ $folder_path .= "$folders/"; } } return $folder_path; } //check relative and fix function fixRELATIVE($target_url,$url) { $url = replaceHxxp($url); $domain = parseHOST($target_url); $ip_check = parse_url($url, PHP_URL_HOST); $up_one = removePaths($target_url,1); $up_two = removePaths($target_url,2); $up_three = removePaths($target_url,3); $up_four = removePaths($target_url,4); $up_five = removePaths($target_url,5); $path = parse_url($target_url, PHP_URL_PATH); $full_path = trim($path, '/'); $explode_path = explode("/", $full_path); $last = end($explode_path); //echo "last path: $last<br />"; $fixed_paths = ""; if(is_array($explode_path)){ foreach($explode_path as $paths){ if(!empty($paths) && !preg_match("/\./",$paths)){ $fixed_paths .= "$paths/"; } } } $fixed_domain = "$domain/$fixed_paths"; //echo "Target: $target_url<br />"; //echo "Original: $url<br />"; $domain_array = array(".ac",".ac.cn",".ac.ae",".ad",".ae",".aero",".af",".ag",".agent","ah.cn",".ai",".ak.us",".al",".al.us",".am",".an",".ao",".aq",".ar",".ar.us",".arpa",".arts",".as",".asia",".at",".au",".au.com",".auction",".aw",".ax",".az",".az.us",".b2b",".b2c",".b2m",".ba",".bb",".bd",".be",".bf",".bg",".bh",".bi",".biz",".bj",".bj.cn",".bl",".bm",".bn",".bo",".boutique",".br",".br.com",".bs",".bt",".bv",".bw",".by",".bz",".ca",".ca.us",".cat",".cc",".cd",".cf",".cg",".ch",".chat",".church",".ci",".ck",".cl",".club",".cm",".cn",".cn.com",".co",".co.uk",".co.us",".com",".com.au",".com.ac",".com.cn",".com.au",".com.tw",".coop",".cq.cn",".cr",".ct.us",".cu",".cv",".cx",".cy",".cz",".dc.us",".de",".de.com",".de.net",".de.us",".dir",".dj",".dk",".dk.org",".dm",".do",".dz",".ec",".edu",".edu.ac",".edu.af",".edu.cn",".ee",".eg",".eh",".er",".es",".et",".eu",".eu.com",".eu.org",".family",".fi",".firm",".fj",".fj.cn",".fk",".fl.us",".fm",".fo",".fr",".free",".ga",".ga.us",".game",".gb",".gb.com",".gb.net",".gd",".gd.cn",".ge",".gf",".gg",".gh",".gi",".gl",".gm",".gmbh",".gn",".golf",".gov",".gov.ac",".gov.ae",".gov.cn",".gp",".gq",".gr",".gs",".gs.cn",".gt",".gu",".gw",".gy",".gx.cn",".gz.cn",".ha.cn",".hb.cn",".he.cn",".health",".hi.cn",".hi.us",".hk",".hl.cn",".hm",".hn",".hn.cn",".hr",".ht",".hu",".hu.com",".ia.us",".id",".id.us",".ie",".il",".il.us",".im",".in",".in.us",".inc",".info",".int",".io",".iq",".ir",".is",".it",".je",".jl.cn",".jm",".jo",".jobs",".jp",".js.cn",".jx.cn",".ke",".kg",".kh",".ki",".kids",".ku",".km",".kn",".kp",".kr",".ks.us",".kw",".ky",".ky.us",".kz",".la",".la.us",".law",".lb",".lc",".li",".lk",".llc",".llp",".ln.cn",".love",".lr",".ls",".lt",".ltd",".ltd.uk",".lu",".lv",".ly",".m2c",".m2m",".ma",".ma.us",".mc",".md",".md.us",".me",".me.us",".med",".me.uk",".mf",".mg",".mh",".mi.us",".mil",".mil.ac",".mil.ae",".mil.cn",".mk",".ml",".mm",".mn",".mn",".mo",".mo.us",".mobi",".movie",".mp",".mq",".mr",".ms",".ms.us",".mt",".mt.us",".mu",".museum",".music",".mv",".mw",".mx",".my",".mz",".na",".ne.us",".name",".nc",".nc.us",".nd.us",".ne",".net",".net.ac",".net.ae","net.cn",".net.tw",".net.uk",".news",".nf",".ng",".nh.us",".ni",".nj.us",".nl",".nm.cn",".nm.us",".no",".no.com",".nom.ad",".np",".nr",".nu",".nv.us",".ny.us",".nx.cn",".nz",".oh.us",".ok.us",".om",".or.us",".org",".org.ac",".org.ae",".org.cn",".org.tw",".org.uk",".pa",".pa.us",".pe",".pf",".pg",".ph",".pk",".pl",".plc",".plc.uk",".pm",".pn",".pr",".pro",".pro.ae",".ps",".pt",".pw",".py",".qa",".qc.com",".qh.cn",".re",".rec",".ri.us",".ro",".rs",".ru",".ru.com",".rw",".sa",".sa.com",".sb",".sc",".sc.cn",".sc.us",".sch.uk",".sch.ae",".school",".sd",".sd.cn",".sd.us",".se",".se.com",".search",".sg",".sh",".sh.cn",".shop",".si",".sj",".sk",".sl",".sm",".sn",".sn.cn",".so",".soc",".sport",".sr",".st",".su",".sv",".sy",".sx.cn",".sz",".tc",".td",".tech",".tel",".tf",".tg",".th",".tj",".tj.cn",".tk",".tl",".tm",".tn",".tn.us",".to",".tp",".tr",".trade",".travel",".tt",".tv",".tw",".tw.cn",".tx.us",".tz",".ua",".ug",".uk",".uk.com",".uk.net",".um",".us",".us.com",".ut.us",".uy",".uy.com",".uz",".va",".va.us",".vc",".ve",".vg",".vi",".video",".vn",".voyage",".vt.us",".vu",".wa.us",".wf",".wi.us",".ws",".wv.us",".wy.us",".xj.cn",".xxx",".xz.cn",".ye",".yn.cn",".yt",".yu",".za",".za.com",".zj.cn",".zm",".zr",".zw"); $url = preg_replace('/\\\\/', "/", $url); $url = str_ireplace(array("http://","https://", "ftp://", "feed://"), "", trim($url)); if(substr(strtolower($url),0,4) == "www."){ $fixed_url[] = "http://$url"; //echo "rule 1<br />"; } $check_array = array('"',"*","'","//","///","////","'","./",".//","../",".../","..../","...../","./../","../../",'"\"',".//.//"); $excludes_array = array("ac","ad","ae","aero","af","ag","agent","ai","al","am","an","ao","aq","ar","arpa","arts","as","asia","at","au","auction","aw","ax","az","b2b","b2c","b2m","ba","bb","bd","be","bf","bg","bh","bi","biz","bj","bl","bm","bn","bo","boutique","br","bs","bt","bv","bw","by","bz","ca","cat","cc","cd","cf","cg","ch","chat","church","ci","ck","cl","club","cm","cn","co","com","coop","cr","cu","cv","cx","cy","cz","de","dir","dj","dk","dm","do","dz","ec","edu","ee","eg","eh","er","es","et","eu","family","fi","firm","fj","fk","fm","fo","fr","free","ga","game","gb","gd","ge","gf","gg","gh","gi","gl","gm","gmbh","gn","golf","gov","gp","gq","gr","gs","gt","gu","gw","gy","hk","hm","hn","hr","ht","hu","id","ie","il","im","in","inc","info","int","io","iq","ir","is","it","je","jm","jo","jobs","jp","ke","kg","kh","ki","kids","ku","km","kn","kp","kr","kw","ky","kz","la","law","lb","lc","li","lk","llc","llp","love","lr","ls","lt","ltd","lu","lv","ly","m2c","m2m","ma","mc","md","me","med","mf","mg","mh","mil","mk","ml","mm","mn","mn","mo","mobi","movie","mp","mq","mr","ms","mt","mu","museum","music","mv","mw","mx","my","mz","na","name","nc","ne","net","news","nf","ng","ni","nl","no","np","nr","nu","nz","om","org","pa","pe","pf","pg","ph","pk","pl","plc","pm","pn","pr","pro","ps","pt","pw","py","qa","re","rec","ro","rs","ru","rw","sa","sb","sc","school","sd","se","search","sg","sh","shop","si","sj","sk","sl","sm","sn","so","soc","sport","sr","st","su","sv","sy","sz","tc","td","tech","tel","tf","tg","th","tj","tk","tl","tm","tn","to","tp","tr","trade","travel","tt","tv","tw","tz","ua","ug","uk","um","us","uy","uz","va","vc","ve","vg","vi","video","vn","voyage","vu","wf","ws","xxx","ye","yt","yu","za","zm","zr","zw"); if(substr($url,0,1) == "/"){ $url = ltrim($url,"/"); $fixed_url[] = "$domain/$url"; //echo "main site and url<br />"; } if(substr($url,0,1) == "#"){ $fixed_url[] = "$domain/$full_path$url"; //echo "target and url<br />"; } if(substr($url,0,15) == "../../../../../"){ $url = str_replace("../../../../../","",$url); $fixed_url[] = "$domain/$up_five$url"; //echo "five directory up<br />"; } if(substr($url,0,12) == "../../../../"){ $url = str_replace("../../../../","",$url); $fixed_url[] = "$domain/$up_four$url"; //echo "four directory up<br />"; } if(substr($url,0,9) == "../../../"){ $url = str_replace("../../../","",$url); $fixed_url[] = "$domain/$up_three$url"; //echo "three directory up<br />"; } if(substr($url,0,6) == "../../"){ $url = str_replace("../../","",$url); $fixed_url[] = "$domain/$up_two$url"; //echo "two directory up<br />"; } if(substr($url,0,3) == "../"){ $url = str_replace("../","",$url); $fixed_url[] = "$domain/$up_one$url"; //echo "one directory up<br />"; } foreach($check_array as $checks){ $check_length = strlen($checks); $temporary_url = $url; $url = @ltrim($url,$checks); $url = @rtrim($url,$checks); if(substr($temporary_url,0,$check_length) == $checks){ $fixed_url[] = "$fixed_domain$url"; //echo "rule 2<br />"; } } $parse_url = parseHOST($url); $parse_ext_explode = end(explode(".",$parse_url)); $parse_ext_check = ".$parse_ext_explode"; //echo "$parse_ext_check<br />"; //the following if statements will do checks on what to be added, only the first $fixed_url will be returned if(in_array($parse_url, $excludes_array)){ $fixed_url[] = "$fixed_domain$url"; //echo "rule 3<br />"; } if(in_array($parse_ext_check, $domain_array)){ $fixed_url[] = "http://$url"; //echo "rule 4<br />"; } if(preg_match("/([1-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])){3}/",$ip_check)){ $fixed_url[] = "http://$url"; //echo "is an ip<br />"; } if(!in_array($parse_ext_check, $domain_array)){ $fixed_url[] = "$fixed_domain$url"; //echo "rule 5<br />"; } if(!preg_match("/^(\w+.)$/siU",$parse_url)){ $fixed_url[] = "$fixed_domain$url"; //echo "rule 6<br />"; } if($parse_url == $fixed_domain) { $fixed_url[] = "http://$url"; //echo "rule 7<br />"; } if (0 !== strpos($fixed_url[0], 'http')) { $fixed_url[0] = "http://$fixed_url[0]"; //echo "rule 8<br />"; } $lower_domain = parseHOST($fixed_url[0]); $lower_url = str_ireplace($lower_domain,strtolower($lower_domain),$fixed_url[0]); $lower_url = trim($lower_url,"'"); $lower_url = trim($lower_url,"#"); return $lower_url; }//end fix relative function $file_type = end(explode(".",strtolower(trim($target_url)))); //try to load as xml file first @$xml = simplexml_load_file($target_url); if($xml!==False && $file_type == "xml") { echo "<h3>Page is xml</h3>"; foreach ($xml->url as $url_list) { $raw_url_array[] = json_decode($url_list->loc,TRUE);//create array } } else {//connect with curl request to $target_url $ch = curl_init(); curl_setopt($ch, CURLOPT_USERAGENT, $userAgent); curl_setopt($ch, CURLOPT_URL,$target_url); curl_setopt($ch, CURLOPT_FAILONERROR, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_AUTOREFERER, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER,true); curl_setopt($ch, CURLOPT_TIMEOUT, 10); $html= curl_exec($ch); if (!$html) { //echo "<br />cURL error number:" .curl_errno($ch); //echo "<br />cURL error:" . curl_error($ch); die("Unable to connect to that url"); } // parse the html into a DOMDocument $dom = new DOMDocument(); @$dom->loadHTML($html); // grab all the links on the page $xpath = new DOMXPath($dom); //only looking for a href links in the body section $hrefs = $xpath->query('/html/body//a'); //loop all the found href links for ($i = 0; $i < $hrefs->length; $i++) { $href = $hrefs->item($i); $raw_url_array[] = $href->getAttribute('href');//create array }//end loop }//end if/else xml type or not //check if is array, loop through urls and clean/fix if(is_array($raw_url_array)){ foreach($raw_url_array as $url){ $url = fixRELATIVE($target_url,$url);//fix the self relative links //only show http links in array if($url != '' || substr($url,0,4) != "http:" || substr($url,0,5) != "https:"){ $url_array[] = $url;//create a url array } }//end foreach //displaying it $url_array = array_unique($url_array); foreach($url_array as $clean_url){ $clean_url = htmlentities(urldecode($clean_url)); echo "<a href='$clean_url' target='_blank'>$clean_url</a><br />"; }//end display }//end if is array }//end if $_GET['target'] set ?> </div> </body> </html>
  15. So you want to get href links from normal pages and also xml pages. I could just respond back saying use DOM , simple_html_dom, or connect to a page and pattern match href links with regex ... , but I'll let you have this link scraper script that I wrote. The code below uses simplexml if is an xml, curl and DOM if it's not to find the urls, most of the code is functions for finding valid urls and fixing relative links. demo of this code: http://dynainternet.com/test/grab-links.php the site you provided as an example (non xml): http://dynainternet.com/test/grab-links.php?target=http://www.php.net/sitemap.php and an xml example: http://dynainternet.com/test/grab-links.php?target=http://www.phpfreaks.com/sitemap.xml <html> <title>Link scraper</title> <meta name="description" content="Scrape the href links from the body section of a page" /> <meta name="keywords" content="scrape link, scrape urls,links,url,urls,fetch url,grab link" /> <meta name="author" content="Jay Przekop - dynainternet.com" /> <meta http-equiv="content-type" content="text/html;charset=UTF-8" /> <head> <style type="text/css"> #content { width: 800px ; margin-left: auto ; margin-right: auto ; } </style> </head> <body> <div id="content"> <form action="" method="GET"> <input type="text" name="target" size="100" id="target" value="" placeholder="Insert url to get links" /> <input type="submit" value="Get the links" /> <br /> </form> <?php if(isset($_GET['target']) && $_GET['target'] != ''){ $target_url = trim($_GET['target']); echo "<h2>Links from ".htmlentities(urldecode($target_url))."</h2>"; $userAgent = 'Linkhunter/1.0 (http://dynainternet.com/test/grab-links.php)'; //replace hxxp function function replaceHxxp($url){ $url = str_ireplace(array("hxxps://xxx.","hxxps://","hxxp://xxx.","hxxp://"), array("https://www.","https://","http://www.","http://"), trim($url)); return $url; } //parse the host, no http:// returned function parseHOST($url){ $new_parse_url = str_ireplace(array("http://","https://", "http://", "ftp://", "feed://"), "", trim($url)); $parsedUrl = @parse_url("http://$new_parse_url"); return strtolower(trim($parsedUrl['host'] ? $parsedUrl['host'] : array_shift(explode('/', $parsedUrl['path'], 2)))); } function removePaths($url,$number_positions=NULL) { $path = @parse_url($url, PHP_URL_PATH); $trim_path = trim($path, '/'); $positions = ""; $positions = explode('/', $trim_path); if(preg_match("/\./",end($positions))) { array_pop($positions); } if(!is_null($number_positions)){ for ($i = 1; $i <= $number_positions; $i++) { array_pop($positions); } } foreach($positions as $folders){ if(!empty($folders)){ $folder_path .= "$folders/"; } } return $folder_path; } //check relative and fix function fixRELATIVE($target_url,$url) { $url = replaceHxxp($url); $domain = parseHOST($target_url); $ip_check = parse_url($url, PHP_URL_HOST); $up_one = removePaths($target_url,1); $up_two = removePaths($target_url,2); $up_three = removePaths($target_url,3); $up_four = removePaths($target_url,4); $up_five = removePaths($target_url,5); $path = parse_url($target_url, PHP_URL_PATH); $full_path = trim($path, '/'); $explode_path = explode("/", $full_path); $last = end($explode_path); //echo "last path: $last<br />"; $fixed_paths = ""; if(is_array($explode_path)){ foreach($explode_path as $paths){ if(!empty($paths) && !preg_match("/\./",$paths)){ $fixed_paths .= "$paths/"; } } } $fixed_domain = "$domain/$fixed_paths"; //echo "Target: $target_url<br />"; //echo "Original: $url<br />"; $domain_array = array(".ac",".ac.cn",".ac.ae",".ad",".ae",".aero",".af",".ag",".agent","ah.cn",".ai",".ak.us",".al",".al.us",".am",".an",".ao",".aq",".ar",".ar.us",".arpa",".arts",".as",".asia",".at",".au",".au.com",".auction",".aw",".ax",".az",".az.us",".b2b",".b2c",".b2m",".ba",".bb",".bd",".be",".bf",".bg",".bh",".bi",".biz",".bj",".bj.cn",".bl",".bm",".bn",".bo",".boutique",".br",".br.com",".bs",".bt",".bv",".bw",".by",".bz",".ca",".ca.us",".cat",".cc",".cd",".cf",".cg",".ch",".chat",".church",".ci",".ck",".cl",".club",".cm",".cn",".cn.com",".co",".co.uk",".co.us",".com",".com.au",".com.ac",".com.cn",".com.au",".com.tw",".coop",".cq.cn",".cr",".ct.us",".cu",".cv",".cx",".cy",".cz",".dc.us",".de",".de.com",".de.net",".de.us",".dir",".dj",".dk",".dk.org",".dm",".do",".dz",".ec",".edu",".edu.ac",".edu.af",".edu.cn",".ee",".eg",".eh",".er",".es",".et",".eu",".eu.com",".eu.org",".family",".fi",".firm",".fj",".fj.cn",".fk",".fl.us",".fm",".fo",".fr",".free",".ga",".ga.us",".game",".gb",".gb.com",".gb.net",".gd",".gd.cn",".ge",".gf",".gg",".gh",".gi",".gl",".gm",".gmbh",".gn",".golf",".gov",".gov.ac",".gov.ae",".gov.cn",".gp",".gq",".gr",".gs",".gs.cn",".gt",".gu",".gw",".gy",".gx.cn",".gz.cn",".ha.cn",".hb.cn",".he.cn",".health",".hi.cn",".hi.us",".hk",".hl.cn",".hm",".hn",".hn.cn",".hr",".ht",".hu",".hu.com",".ia.us",".id",".id.us",".ie",".il",".il.us",".im",".in",".in.us",".inc",".info",".int",".io",".iq",".ir",".is",".it",".je",".jl.cn",".jm",".jo",".jobs",".jp",".js.cn",".jx.cn",".ke",".kg",".kh",".ki",".kids",".ku",".km",".kn",".kp",".kr",".ks.us",".kw",".ky",".ky.us",".kz",".la",".la.us",".law",".lb",".lc",".li",".lk",".llc",".llp",".ln.cn",".love",".lr",".ls",".lt",".ltd",".ltd.uk",".lu",".lv",".ly",".m2c",".m2m",".ma",".ma.us",".mc",".md",".md.us",".me",".me.us",".med",".me.uk",".mf",".mg",".mh",".mi.us",".mil",".mil.ac",".mil.ae",".mil.cn",".mk",".ml",".mm",".mn",".mn",".mo",".mo.us",".mobi",".movie",".mp",".mq",".mr",".ms",".ms.us",".mt",".mt.us",".mu",".museum",".music",".mv",".mw",".mx",".my",".mz",".na",".ne.us",".name",".nc",".nc.us",".nd.us",".ne",".net",".net.ac",".net.ae","net.cn",".net.tw",".net.uk",".news",".nf",".ng",".nh.us",".ni",".nj.us",".nl",".nm.cn",".nm.us",".no",".no.com",".nom.ad",".np",".nr",".nu",".nv.us",".ny.us",".nx.cn",".nz",".oh.us",".ok.us",".om",".or.us",".org",".org.ac",".org.ae",".org.cn",".org.tw",".org.uk",".pa",".pa.us",".pe",".pf",".pg",".ph",".pk",".pl",".plc",".plc.uk",".pm",".pn",".pr",".pro",".pro.ae",".ps",".pt",".pw",".py",".qa",".qc.com",".qh.cn",".re",".rec",".ri.us",".ro",".rs",".ru",".ru.com",".rw",".sa",".sa.com",".sb",".sc",".sc.cn",".sc.us",".sch.uk",".sch.ae",".school",".sd",".sd.cn",".sd.us",".se",".se.com",".search",".sg",".sh",".sh.cn",".shop",".si",".sj",".sk",".sl",".sm",".sn",".sn.cn",".so",".soc",".sport",".sr",".st",".su",".sv",".sy",".sx.cn",".sz",".tc",".td",".tech",".tel",".tf",".tg",".th",".tj",".tj.cn",".tk",".tl",".tm",".tn",".tn.us",".to",".tp",".tr",".trade",".travel",".tt",".tv",".tw",".tw.cn",".tx.us",".tz",".ua",".ug",".uk",".uk.com",".uk.net",".um",".us",".us.com",".ut.us",".uy",".uy.com",".uz",".va",".va.us",".vc",".ve",".vg",".vi",".video",".vn",".voyage",".vt.us",".vu",".wa.us",".wf",".wi.us",".ws",".wv.us",".wy.us",".xj.cn",".xxx",".xz.cn",".ye",".yn.cn",".yt",".yu",".za",".za.com",".zj.cn",".zm",".zr",".zw"); $url = preg_replace('/\\\\/', "/", $url); $url = str_ireplace(array("http://","https://", "ftp://", "feed://"), "", trim($url)); if(substr(strtolower($url),0,4) == "www."){ $fixed_url[] = "http://$url"; //echo "rule 1<br />"; } $check_array = array('"',"*","'","//","///","////","'","./",".//","../",".../","..../","...../","./../","../../",'"\"',".//.//"); $excludes_array = array("ac","ad","ae","aero","af","ag","agent","ai","al","am","an","ao","aq","ar","arpa","arts","as","asia","at","au","auction","aw","ax","az","b2b","b2c","b2m","ba","bb","bd","be","bf","bg","bh","bi","biz","bj","bl","bm","bn","bo","boutique","br","bs","bt","bv","bw","by","bz","ca","cat","cc","cd","cf","cg","ch","chat","church","ci","ck","cl","club","cm","cn","co","com","coop","cr","cu","cv","cx","cy","cz","de","dir","dj","dk","dm","do","dz","ec","edu","ee","eg","eh","er","es","et","eu","family","fi","firm","fj","fk","fm","fo","fr","free","ga","game","gb","gd","ge","gf","gg","gh","gi","gl","gm","gmbh","gn","golf","gov","gp","gq","gr","gs","gt","gu","gw","gy","hk","hm","hn","hr","ht","hu","id","ie","il","im","in","inc","info","int","io","iq","ir","is","it","je","jm","jo","jobs","jp","ke","kg","kh","ki","kids","ku","km","kn","kp","kr","kw","ky","kz","la","law","lb","lc","li","lk","llc","llp","love","lr","ls","lt","ltd","lu","lv","ly","m2c","m2m","ma","mc","md","me","med","mf","mg","mh","mil","mk","ml","mm","mn","mn","mo","mobi","movie","mp","mq","mr","ms","mt","mu","museum","music","mv","mw","mx","my","mz","na","name","nc","ne","net","news","nf","ng","ni","nl","no","np","nr","nu","nz","om","org","pa","pe","pf","pg","ph","pk","pl","plc","pm","pn","pr","pro","ps","pt","pw","py","qa","re","rec","ro","rs","ru","rw","sa","sb","sc","school","sd","se","search","sg","sh","shop","si","sj","sk","sl","sm","sn","so","soc","sport","sr","st","su","sv","sy","sz","tc","td","tech","tel","tf","tg","th","tj","tk","tl","tm","tn","to","tp","tr","trade","travel","tt","tv","tw","tz","ua","ug","uk","um","us","uy","uz","va","vc","ve","vg","vi","video","vn","voyage","vu","wf","ws","xxx","ye","yt","yu","za","zm","zr","zw"); if(substr($url,0,1) == "/"){ $url = ltrim($url,"/"); $fixed_url[] = "$domain/$url"; //echo "main site and url<br />"; } if(substr($url,0,1) == "#"){ $fixed_url[] = "$domain/$full_path$url"; //echo "target and url<br />"; } if(substr($url,0,15) == "../../../../../"){ $url = str_replace("../../../../../","",$url); $fixed_url[] = "$domain/$up_five$url"; //echo "five directory up<br />"; } if(substr($url,0,12) == "../../../../"){ $url = str_replace("../../../../","",$url); $fixed_url[] = "$domain/$up_four$url"; //echo "four directory up<br />"; } if(substr($url,0,9) == "../../../"){ $url = str_replace("../../../","",$url); $fixed_url[] = "$domain/$up_three$url"; //echo "three directory up<br />"; } if(substr($url,0,6) == "../../"){ $url = str_replace("../../","",$url); $fixed_url[] = "$domain/$up_two$url"; //echo "two directory up<br />"; } if(substr($url,0,3) == "../"){ $url = str_replace("../","",$url); $fixed_url[] = "$domain/$up_one$url"; //echo "one directory up<br />"; } foreach($check_array as $checks){ $check_length = strlen($checks); $temporary_url = $url; $url = @ltrim($url,$checks); $url = @rtrim($url,$checks); if(substr($temporary_url,0,$check_length) == $checks){ $fixed_url[] = "$fixed_domain$url"; //echo "rule 2<br />"; } } $parse_url = parseHOST($url); $parse_ext_explode = end(explode(".",$parse_url)); $parse_ext_check = ".$parse_ext_explode"; //echo "$parse_ext_check<br />"; //the following if statements will do checks on what to be added, only the first $fixed_url will be returned if(in_array($parse_url, $excludes_array)){ $fixed_url[] = "$fixed_domain$url"; //echo "rule 3<br />"; } if(in_array($parse_ext_check, $domain_array)){ $fixed_url[] = "http://$url"; //echo "rule 4<br />"; } if(preg_match("/([1-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])){3}/",$ip_check)){ $fixed_url[] = "http://$url"; //echo "is an ip<br />"; } if(!in_array($parse_ext_check, $domain_array)){ $fixed_url[] = "$fixed_domain$url"; //echo "rule 5<br />"; } if(!preg_match("/^(\w+.)$/siU",$parse_url)){ $fixed_url[] = "$fixed_domain$url"; //echo "rule 6<br />"; } if($parse_url == $fixed_domain) { $fixed_url[] = "http://$url"; //echo "rule 7<br />"; } if (0 !== strpos($fixed_url[0], 'http')) { $fixed_url[0] = "http://$fixed_url[0]"; //echo "rule 8<br />"; } $lower_domain = parseHOST($fixed_url[0]); $lower_url = str_ireplace($lower_domain,strtolower($lower_domain),$fixed_url[0]); $lower_url = trim($lower_url,"'"); $lower_url = trim($lower_url,"#"); return $lower_url; }//end fix relative function //try to load as xml file first @$xml = simplexml_load_file($target_url); if($xml===TRUE) { echo "<h3>Page is xml</h3>"; foreach ($xml->url as $url_list) { $raw_url_array[] = json_decode($url_list->loc,TRUE);//create array } } else {//connect with curl request to $target_url $ch = curl_init(); curl_setopt($ch, CURLOPT_USERAGENT, $userAgent); curl_setopt($ch, CURLOPT_URL,$target_url); curl_setopt($ch, CURLOPT_FAILONERROR, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_AUTOREFERER, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER,true); curl_setopt($ch, CURLOPT_TIMEOUT, 10); $html= curl_exec($ch); if (!$html) { //echo "<br />cURL error number:" .curl_errno($ch); //echo "<br />cURL error:" . curl_error($ch); die("Unable to connect to that url"); } // parse the html into a DOMDocument $dom = new DOMDocument(); @$dom->loadHTML($html); // grab all the links on the page $xpath = new DOMXPath($dom); //only looking for a href links in the body section $hrefs = $xpath->query('/html/body//a'); //loop all the found href links for ($i = 0; $i < $hrefs->length; $i++) { $href = $hrefs->item($i); $raw_url_array[] = $href->getAttribute('href');//create array }//end loop }//end if/else xml type or not //check if is array, loop through urls and clean/fix if(is_array($raw_url_array)){ foreach($raw_url_array as $url){ $url = fixRELATIVE($target_url,$url);//fix the self relative links //only show http links in array if($url != '' || substr($url,0,4) != "http:" || substr($url,0,5) != "https:"){ $url_array[] = $url;//create a url array } }//end foreach //displaying it $url_array = array_unique($url_array); foreach($url_array as $clean_url){ $clean_url = htmlentities(urldecode($clean_url)); echo "<a href='$clean_url' target='_blank'>$clean_url</a><br />"; }//end display }//end if is array }//end if $_GET['target'] set ?> </div> </body> </html>
  16. Totally agree. Create a fully working site for yourself and show what your skills can do. That first impression of your own website goes a long way with their decision to hire you. As for the design....ask a few people and I'm sure everyone will agree your choices are not what they would want. I feel you posted a bit early to get any type of positive critique.
  17. Had the Please Wait... for a while, I eventually just clicked the button and it worked. The thumbs are cool, but i think people would like an option to size the thumbs for what they need. Is many sites that don't support bmp images, even though they can be converted into another format. Site may be more appealing if users at least see the most recently uploaded images.
  18. Something a little extra. <?php $username = 'joe'; $username = ucwords(strtolower(trim($username))); $filename = 'users.txt'; if(file_exists($filename)){ $users= array_map('trim',file($filename)); if(in_array(strtolower($username), array_map('strtolower', $users))){ echo "Got $username"; } else { echo "$username not found"; } } else { echo "$filename doesn't exist."; } ?>
  19. change: $users= file('users.txt'); to: $users= array_map('trim',file('users.txt')); There is white space,new lines and the in_array() is searching for an exact match
  20. I had a little time waiting for a friend, decided to expand upon this for you. I used a stream context and file_get_contents, like I said could also use curl() Checking for valid xml Also grabbed the title,description and keywords, and made it all arrays You can work out any filtering or escaping before the mysql inserts. <?php //test url http://www.domain.com/sitemap.xml //test url http://www.phpfreaks.com/sitemap.xml if(isset($_GET['url']) && $_GET['url'] != ''){ $url = trim($_GET['url']); @$xml = simplexml_load_file($url); if($xml===FALSE) { die('not a valid xml string'); } else { foreach ($xml->url as $url_list) { $urls = $url_list->loc; if (substr($urls, 0, 4) != "http") { $urls = "http://$urls"; } $context = stream_context_create(array('http' => array('timeout' => 1))); $str = file_get_contents($urls, 0, $context); if(!$str){ die("Unable to connect"); } $tags = get_meta_tags($urls); preg_match("/<title>(.*)<\/title>/Umis", $str, $title); preg_match("/<head>(.*)<\/head>/is", $str, $head); $title = $title[1]; if($title == ''){ $title = $urls; } $description = $tags['description']; $keywords = $tags['keywords']; //make it an array each value, json decode used to remove url from being xml object $urls_array[] = array("url"=>json_decode($urls,TRUE),"title"=>$title,"description"=>$description,"keywords"=>$keywords); }//end loop //see the array //print_r($urls_array); //display the array echo "<hr>"; foreach($urls_array as $url_value){ echo "<a href=".$url_value['url'].">".$url_value['title']."</a><br />"; echo $url_value['description']."<br />"; echo $url_value['keywords']."<br />"; echo "<hr>"; } } } else { echo "No xml url inserted"; } ?> It will return an array like this for phpfreaks sitemap Array ( [0] => Array ( [url] => http://www.phpfreaks.com [title] => PHP Freaks - PHP Help Index [description] => PHP Freaks is a website dedicated to learning and teaching PHP. Here you will find a forum consisting of 128,486 members who have posted a total of 1,330,567 posts on the forums. Additionally, we have tutorials covering various aspects of PHP and you will find news syndicated from other websites so you can stay up-to-date. Along with the tutorials, the developers on the forum will be able to help you with your scripts, or you may perhaps share your knowledge so others can learn from you. [keywords] => php help, php forums, php tutorials, php tutorial, php news, php snippets, php, help, news, resources, news, snippets, tutorials, web development, programming ) [1] => Array ( [url] => http://www.phpfreaks.com/forums [title] => PHP Freaks Forums - Index [description] => PHP Freaks Forums - Index [keywords] => php, tutorials, help, tutorial, forum, free, resources, advice, oop, design ) [2] => Array ( [url] => http://www.phpfreaks.com/tutorials [title] => PHP Freaks - Tutorials [description] => Free tutorials on various PHP subjects covering basic to advanced principles. [keywords] => ) [3] => Array ( [url] => http://www.phpfreaks.com/blogs [title] => PHP Freaks - Blog posts [description] => [keywords] => ) [4] => Array ( [url] => http://www.phpfreaks.com/news [title] => PHP Freaks - PHP News [description] => [keywords] => ) )
  21. http://www.roseindia.net/tutorial/php/phpgd/About-watermark.html
  22. for something simple: simplexml() <?php //test url http://www.domain.com/sitemap.xml //test url http://www.phpfreaks.com/sitemap.xml if(isset($_GET['url']) && $_GET['url'] != ''){ $url = trim($_GET['url']); $xml = simplexml_load_file($url); foreach ($xml->url as $url_list) { $url_array[] = $url_list->loc; } //display the array foreach($url_array as $urls){ echo "<a href='$urls'>$urls</a><br />"; } } else { echo "No xml url inserted"; } ?> make the php file , use in the address bar something like http://mysite.com/script.php?url=http://www.phpfreaks.com/sitemap.xml Now that you have the array full of urls you can insert them into a database however you want, AUTO_INCREMENT per id, or serialize or implode the array into a field per each sites xml file To grab the titles can use curl() or file_get_contents() I have a script to obtain the titles for websites, it's not that easy actually to get it from every site, been there.
  23. The solution is to always open the connection first, then use mysql_real_escape_string() Note: A MySQL connection is required before using mysql_real_escape_string() otherwise an error of level E_WARNING is generated, and FALSE is returned. If link_identifier isn't defined, the last MySQL connection is used.
  24. ereg was deprecated as of php version 5.3, might be better off using preg_match instead
  25. round() $newrating = round($imageinfo['rating'],0); you had the 2 for 2 positions, is now set to zero
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.