Jump to content

QuickOldCar

Staff Alumni
  • Posts

    2,972
  • Joined

  • Last visited

  • Days Won

    28

Everything posted by QuickOldCar

  1. I made a few chats, what you plan is fine for a small amount of people, some sort of backend chat using python may be a better solution.
  2. Sure you are Samuel, the more the merrier.
  3. Welcome to the site. I've been programming since I was 8, so 34 years, and still don't consider myself an expert in anything.
  4. change this: <form id="contact-form" name="contactform" method="post" enctype="multipart/form-data" form action="html_form_send.php"> to this: <form id="contact-form" name="contactform" method="post" enctype="multipart/form-data" action="html_form_send.php">
  5. wouldn't something like this work if(@array){ print "array not empty"; } else { print "array empty"; }
  6. I can probably help you out with this. There is a lot more than meets the eye with all this, seems like a simple thing, but is many unforeseen obstacles. There are a few opensource ones out there can use http://www.sphider.eu/ http://cuab.de/ https://code.google.com/p/phpspider/ and tons more if looked for them... I used sphider quite a few years ago and seemed pretty good out of a lot of them I tried, but I wanted a lot more control and do it all different than what they do. Their system is that you add sites to a crawl list, and will keep hitting those sites looking if any new data. Which is fine if want a search for the sites you select. I wrote a few of my own crawler/scraper/spider or whatever someone wants to call it. I have a few ways to add new sites and links, is manual submission, pulling urls from lists or db, through my webcrawler or with my site or page scraper. I started out like 5 years ago and did more like what google does, even looked similar to them, but after doing it a while and seeing how long it takes to scrape entire sites...I changed it all around to pull in more data faster and simpler. But i can still scrape entire sites if wanted to. Basically I hit a url, grab any information want from it, scrape all their links from pages, and they get stored into my links search. The site itself does not get indexed into specific categories or tags, but the information of that site does get stored. I use a full text search to sort my results in the website index, and use sphinxsearch to handle my links results. The toughest part of all of this is not getting information, but to actually display it in a timely manner, once you get to a million+ results will quickly see what i mean. That's why you have to make sure you do indexing on the database so can return results faster. And is better to fetch and return exactly what you need. You can check my search engine and website index with the link in my signature, if any questions just ask. I could probably write a novel about search engines and indexing.
  7. I made some php api's, aren't really that hard to do at all. I guess the most important part is that you are using clean data. First take a look at some of the links for json, xml and html formats html json xml Basically they are all simple GET requests, I check if they are set and not empty, for some I insert default values in case is not set. Then you query your database and fetch some data.(yes did this a while ago and is mysql versus mysqli) If no format is set I default to json Use a switch or if/else statement and show different outputs. I'll paste my entire api code here, seems easier than editing it with dummy values. <?php if(isset($_GET['format']) && trim($_GET['format']) != ''){ $format = trim($_GET['format']); } else { $format = "json"; } $style_array = array("default","title","video"); if(!isset($_GET['style']) || trim($_GET['style']) == ''){ $style = "default"; } else { $style = trim(strtolower($_GET['style'])); } if(!in_array($style,$style_array)){ $style = "default"; } if(!isset($_GET['max']) || trim($_GET['max']) == ''){ $max_results = 10; } else { $max_results = (int) trim($_GET['max']); } if($max_results > 50){ $max_results = 50; } if(!isset($_GET['startrow']) || trim($_GET['startrow']) == ''){ $startrow = 0; } else { $startrow = (int) trim($_GET['startrow']); } //$startrow = $startrow - $max_results; if($startrow <= 0){ $startrow = 0; } if(!isset($_GET['display']) || trim($_GET['display']) == ''){ $display = "id"; } else { $display = trim($_GET['display']); } if(!isset($_GET['order']) || trim($_GET['order']) == ''){ $order = "desc"; } else { $order = trim($_GET['order']); } if($display !== "id" && !isset($_GET['order'])){ $order = "asc"; } if(!isset($_GET['size']) || trim($_GET['size']) == ''){ $size = 190; } else { $size = (int) trim($_GET['size']); } $format_array = array("json","xml","html"); if(!in_array($format,$format_array )){ $format = "json"; } $_GET['s'] = strtolower($_GET['s']); $var = @mysql_real_escape_string($_GET['s']); //$var = $_GET['s']; $trimmed = trim($var); //trim whitespace from the stored variable $trimmed_length = strlen($trimmed); if ($trimmed_length > 200) { //limit to 200 characters $trimmed = substr($trimmed, 0, 200); } //remove need for + $explode_trimmed = explode(" ", $trimmed); foreach ($explode_trimmed as $trim_words) { if (substr($trim_words, 0, 1) != "-" || substr($trim_words, 0, 1) != '"') { $trim_words = trim($trim_words); $trimmed_words .= " +$trim_words"; } else { $trim_words = trim($trim_words); $trimmed_words .= " $trim_words"; } } $trimmed_words = trim($trimmed_words); $trimmed_words = preg_replace('/\s+/', ' ', $trimmed_words); $trimmed_words = str_replace(array(" ", " +", "+ +", " -", "+++"), array(" ", " +", " +", " -", "++"), $trimmed_words); mysql_connect("localhost", "username", "password"); mysql_select_db("mydatabase") or die("Unable to select database"); $display = mysql_real_escape_string($display); $order = mysql_real_escape_string($order); $startrow = mysql_real_escape_string($startrow); $max_results = mysql_real_escape_string($max_results); $trimmed_words = mysql_real_escape_string($trimmed_words); if($var == ''){ $result = mysql_query("SELECT * FROM videolinks WHERE status='1' GROUP BY $display $order Limit $startrow ,$max_results"); } else { $result = mysql_query("SELECT * FROM videolinks WHERE status='1' AND MATCH (title,description) AGAINST ('$trimmed_words' IN BOOLEAN MODE) GROUP BY $display $order Limit $startrow,$max_results"); } switch ($format) { //json api case 'json': // you can uncomment it for Live version header('Content-Type: application/json; charset=utf-8'); if (count($result)) { while ($row = mysql_fetch_array($result)) { echo json_encode(array('data' => $row )); } } else { echo json_encode(array('data' => 'Nothing found')); } break; //xml api case 'xml': $sCode = ''; if (count($result)) { function convertchar($chars){ $chars = $chars = str_replace(array("&&","<",">"),array("&","&lt","&gt"),$chars); $chars = htmlspecialchars($chars,ENT_QUOTES); return $chars; } while ($row = mysql_fetch_array($result)) { $link_id = $row['id']; $link_url = convertchar($row['url']); $link_domain = convertchar($row['domain']); $link_title = convertchar($row['title']); $link_description = convertchar($row['description']); if($link_domain == "youtube.com"){ $ytid = end(explode("~v=~",$link_url)); $thumbnail = "http://img.youtube.com/vi/".$ytid."/0.jpg"; $thumbnail_href = "<a href='$yturl' target='_blank'><img src='$thumbnail' border='0'></a>"; } $video_display = @file_get_contents("http://dynainternet.com/dynavid/embed.php?video=$link_url&width=835&height=505"); $sCode .= <<<EOF <id>{$link_id}</id> <url>{$link_url}</url> <title>{$link_title}</title> <description>{$link_description}</description> <domain>{$link_domain}</domain> EOF; } } header('Content-Type: text/xml; charset=utf-8'); echo <<<EOF <?xml version="1.0" encoding="utf-8"?> <videos> {$sCode} </videos> EOF; break; //html api case 'html': ?> <style> p { color: white; background:black; } a { color: white; background:black; } a:hover { color: black; background:white; } .nav { font-size:18; text-align:center; background-color:black; } </style> <?php if (count($result)) { //pagination $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; if (!preg_match("/startrow=/i", $url)) { $url = $url . "&startrow=$startrow"; } if (!preg_match("/max=/i", $url)) { $url = $url . "&max=$max_results"; } if (!preg_match("/size=/i", $url)) { $url = $url . "&size=$size"; } } $url = preg_replace('/\s+/', ' ', $url); $url = str_replace(array("++", "+++", "+ +"), " +", $url); $url = str_replace(array(" ", " "), " ", $url); $urlparse = parse_url($url); parse_str($urlparse[query], $query); $current_startrow = $query['startrow']; $next_set = $current_startrow + $max_results; $prev_set = $current_startrow - $max_results; $next_url = str_ireplace("startrow=$current_startrow","startrow=$next_set",$url); $prev_url = str_ireplace("startrow=$current_startrow","startrow=$prev_set",$url); ?> <form name="input" action="" method="get"> <input type="text" <?php if($var != ''){echo "value='".htmlentities(stripslashes($var))."'";}else{echo "placeholder='Search'";}?> name="s"> <input type="hidden" name="format" value="html"> <input type="hidden" name="size" value="<?php echo $size;?>"> <input type="hidden" name="startrow" value="0"> <input type="hidden" name="max" value="<?php echo $max_results;?>"> <input type="hidden" name="display" value="id"> <input type="hidden" name="order" value="desc"> <input type="submit" value="Go" style="background:white;font-size:18;text-align:center;width:36;"> </form> <?php echo "<div id='nav' class='nav'><a href='http://dynainternet.com/dynavid/api/index.php?format=html&size=$size&display=id&order=desc&startrow=0&max=$max_results' style='text-decoration: none'>ALL </a> <a href='$prev_url' style='text-decoration: none'>< PREV</a> - <a href='$next_url' style='text-decoration: none'>NEXT ></a></div>"; while ($row = mysql_fetch_array($result)) { $link_id = $row['id']; $link_url = utf8_decode(urldecode($row['url'])); $link_domain = $row['domain']; $link_title = html_entity_decode($row['title']); $link_description = html_entity_decode($row['description']); switch($style){ case "default": echo "<a href='$link_url' target='_blank' style='text-decoration: none'>$link_title</a><br />"; echo $video_display = @file_get_contents("http://dynainternet.com/dynavid/api-embed.php?video=$link_url&width=$size&height=$size"); echo "<hr>"; break; case "title": echo "<a href='$link_url' target='_blank' style='text-decoration: none;font-color:white;background:black;'>$link_title</a><br />"; echo "<hr>"; break; case "video": echo $video_display = @file_get_contents("http://dynainternet.com/dynavid/api-embed.php?video=$link_url&width=$size&height=$size"); echo "<hr>"; break; } } echo "<div id='nav' class='nav'><a href='http://dynainternet.com/dynavid/api/index.php?format=html&size=190&display=id&order=desc&startrow=$startrow&max=$max_results' style='text-decoration: none'>ALL </a> <a href='$prev_url' style='text-decoration: none'>< PREV</a> - <a href='$next_url' style='text-decoration: none'>NEXT ></a></div>"; } else { echo 'Nothing found'; } break; }//end switch mysql_close(); ?>
  8. localhost isn't being seen as a valid web address, so it doing a google search instead You can modify the browsers behavior https://support.mozilla.org/en-US/kb/search-web-address-bar#w_turning-off-the-internet-keyword-search can even change in your hosts file to redirect somewhere else 127.0.0.1 localhost localhost get-a-domain-name.com
  9. mp4 should work in the popular browsers besides opera ogg and webm does not work in internet explorer or safari The sad truth is that html5 video is not a work for all solution yet all browsers. Stick to flash for now is my suggestion. Did you ever try to use jwplayer or flowplayer ?
  10. Does it work using is_user_logged_in() function?
  11. If you follow this tutorial it should work. http://ablereach.com/wordpress/wordpress-add-a-second-widget-ready-sidebar/
  12. I think just the uk bbc has feeds http://www.bbc.co.uk/news/10628494
  13. Is the file you uploaded even testcounter.php, to me it looks like a huge shopping cart script that includes all sorts of stuff including a framework. And can post the code here using the sites code tags, some don't like clicking to read them.
  14. Lots of hosts when are shared don't want you doing much, they expect simple little sites that are barely used. Maybe your next step is getting a dedicated server so you can run what you need to.
  15. Get a better host is most likely your best solution.
  16. Your script works fine for me, I added full php opening tag, <?php
  17. if (isset($_POST['subject']) && isset($_POST['post']) && trim($_POST['subject']) != '' && trim($_POST['post']) != '' ) {
  18. For the future can look here. http://codex.wordpress.org/Page_Templates The basics: Create a new file in your current themes folder named what would like, lets call it quiz.php Add the following code into quiz.php <?php /* Template Name: Quiz */ ?> <?php get_header(); ?> <style> <!-- div.quiz { width: 80%; text-decoration: none; text-align:center; margin-top:0px; margin-bottom:0px; margin-right: auto; margin-left: auto; padding:0px; } --> </style> <?php echo "<div class='quiz'>"; echo "quiz code gets added this area"; echo "</div>"; ?> <?php get_footer(); ?> In the dashboard create a new page named Quiz, select the quiz template located lower right area, publish the new page You may also add the sidebar or anything else you desire.
  19. I just tested this and worked fine, a few minor changes, you should add the ttf extension your font filename <?php if (isset($_GET['message']) && trim($_GET['message']) !='') { $message = trim($_GET['message']); // load font and image, calculate width of text $font = "times.ttf"; // does this font file exist same folder ? $size = 12; $image = imagecreatefrompng("button.png"); $tsize = imagettfbbox($size, 0, $font, $message); // center $dx = abs($tsize[2] - $tsize[0]); $dy = abs($tsize[5] - $tsize[3]); $x = (imagesx($image) - $dx) / 2; $y = (imagesy($image) - $dy) / 2 + $dy; // draw text $black = imagecolorallocate($image,0,0,0); imagettftext($image, $size, 0, $x, $y, $black, $font, $message); // return image header("Content-type: image/png"); imagepng($image); //frees image from memory imagedestroy($image); exit; } ?> <html> <head> <title>Button Form</title> </head> <body> <form action="" method="GET"> Enter message to appear on button: <input type="text" name="message" /><br /> <input type="submit" value="Create Button" /> </form> </body> </html>
  20. Do the form like this <form action="" method="GET"> leaving it blank will go to same page Removed my comment about no <?php opening tag, see it in code
×
×
  • 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.