QuickOldCar
Staff Alumni-
Posts
2,972 -
Joined
-
Last visited
-
Days Won
28
Everything posted by QuickOldCar
-
I'm not a fan of the stripes for the background, makes my eyes go buggy. Maybe a bit darker text could help as well.
-
How to make a web crawler/scraper is a lot of information to tell someone how to do it. Basic concept: Designate a url either by input,a list or from a database. Connect to it by using curl, file_get-contents or other. Obtain desired information, could be header info, meta info, some content that matches within that page. Preg_match using regular expressions is a common way to find the related content. Dom or something like simple html dom could also find specific areas in the content. Once links are found you could then insert them into a database, those same links later on could be used to visit that page and acquire more links. You could make yourself a system that knows pages already visited or just don't insert duplicate urls into the database. Have your scraper keep running and visiting these pages in loops. I have seen some example scraper scripts on the net, they could give you an idea of how to do it, but not one of them is a complete solution, you must do lots of work to them for your needs. Consider using this already made search spider or something similar if do not want to invest the time to make your own. http://www.sphider.eu/
-
From what I see it's just posts and the weeks are categories. You can install wordpress and do something similar. It could look and run numerous free themes and plugins out there and even do more.
-
Taking screenshot of currently open webpage
QuickOldCar replied to G.kanojiya's topic in PHP Coding Help
You may need to go into services and allow apache to "interact with desktop" if getting a black screen. It needs something to actually render the image, like x-server, xvfb, a browser. If you just needed a few images done, or not planning doing a thumbserver, it may be easier to just use many of the thumbnail services available. Be aware many of the free services usually just do the domain links and not actual pages, many have limits on them and most have a pro version for more features. Just to name a few. http://wimg.ca/ http://www.thumboo.com/ www.shrinktheweb.com/ http://www.thumbalizr.com/ http://thumbnails.iwebtool.com/ http://webshotspro.com/ http://thumbnailspro.com/ http://www.sitethumbshot.com/ and there are more if searched for them... Or use an application to get them done single url or from a list. http://www.websitescreenshots.com/ If you want to spend some time and create your own, here are some helpful links. https://github.com/coderholic/PyWebShot http://www.mysql-apache-php.com/website_screenshot.htm http://www.zubrag.com/scripts/website-thumbnail-generator.php http://www.zubrag.com/forum/index.php?topic=55.0 http://www.boutell.com/webthumb/ http://www.semicomplete.com/blog/geekery/xvfb-firefox.html http://www.initsix.co.uk/headless-screenshot-server-ubuntu http://stackoverflow.com/questions/125951/command-line-program-to-create-website-screenshots-on-linux/143148#143148 http://code.google.com/p/wkhtmltopdf/ http://iecapt.sourceforge.net/ http://cutycapt.sourceforge.net/ A plugin I've used to take screenshots http://pearlcrescent.com/products/pagesaver/ follow their documentation, but use this for taking the thumbs as png -savepng -
Here's an ajax based search with dropdown. http://www.dynamicajax.com/fr/AJAX_Suggest_Tutorial-.html
-
Need help with php mysql database - maintenance?
QuickOldCar replied to andy_b_1502's topic in PHP Coding Help
Sorry I had an error in the naming of my query. You can prob move the mail function lower under the if($check) as well, work out your end bracket and message. <?php if(isset($_POST['username']) && $_POST['username'] != ""){ $username = $_POST['username']; } else { $username = ""; } if(isset($_POST['email']) && $_POST['email'] != ""){ $email = $_POST['email']; } else { $email = ""; } if(isset($_POST['upassword']) && $_POST['upassword'] != ""){ $upassword = $_POST['upassword']; } else { $upassword = ""; } function isValidEmail($email){ return preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/", $email); } if($username != "" || $email != "" || $upassword != ""){ if(isValidEmail($email) == False){ header("refresh:5;url=register.php"); echo "Try again and use a valid email."; } else { $to = $_POST['email']; $subject = "Welcome!"; $body = "Welcome to website.co.uk,\n\nYour are now registered with website.com. Here are your details: \n\n Username: " .$_POST['username']. " \n\n Password: " .$_POST['upassword']. " \n\n You can now use these to log-in at http://www.website.com. Thank you!"; $mailheader = "From:'mail@website.com'"; if (mail($to, $subject, $body, $mailheader)){ $user_name = "***"; $password = "***";$database = "***"; $server = "***"; $db_handle = mysql_connect($server, $user_name, $password); $db_found = mysql_select_db($database,$db_handle);//escaped variables before database insert $username = mysql_real_escape_string($_POST['username']); $upassword = md5(strtolower(trim($_POST['upassword'])));//this should be encrypted and not a regular password $email = mysql_real_escape_string($_POST['email']); if ($db_found) { $query = mysql_query("SELECT username FROM users WHERE username='".$username."'"); $check = mysql_num_rows($query); if($check <= 0) { $SQL = "INSERT INTO users (username, upassword, email) VALUES ('" .$username. "', '" .$upassword. "', '" .$email. "')"; $result = mysql_query($SQL); //$sql = mysql_query("SELECT * FROM users WHERE Email = $email");//this query is never used to display any results header( "refresh:5;url=login.php" );//or index.php with a login echo "You are now registered, redirecting to login in about 5 secs. If not, click <a href='login.php'>here</a>."; exit(); } else { echo "User name is taken, try a different one. <br />"; } } else { print "Database NOT Found "; } } } } else { echo "Please insert a user name, email and password"; } ?> <br /> <form action="" method="post"> Name: <input type="text" name="username" value="<?php echo $username;?>" placeholder="Your user name"/> Password: <input type="text" name="upassword" value="<?php echo $upassword;?>" placeholder="Your password"/> Email: <input type="text" name="email" value="<?php echo $email;?>" placeholder="Your email"/> <input type="submit" value="Submit" /> </form> -
Need help with php mysql database - maintenance?
QuickOldCar replied to andy_b_1502's topic in PHP Coding Help
I played around and added what I think you need. For the redirect I have a message with a refresh delay, they lead to register.php(this script name), or if success login.php, or an index.php with a login. Hope this helps you. <?php if(isset($_POST['username']) && $_POST['username'] != ""){ $username = $_POST['username']; } else { $username = ""; } if(isset($_POST['email']) && $_POST['email'] != ""){ $email = $_POST['email']; } else { $email = ""; } if(isset($_POST['upassword']) && $_POST['upassword'] != ""){ $upassword = $_POST['upassword']; } else { $upassword = ""; } function isValidEmail($email){ return preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/", $email); } if($username != "" || $email != "" || $upassword != ""){ if(isValidEmail($email) == False){ header("refresh:5;url=register.php"); echo "Try again and use a valid email."; } else { $to = $_POST['email']; $subject = "Welcome!"; $body = "Welcome to website.co.uk,\n\nYour are now registered with website.com. Here are your details: \n\n Username: " .$_POST['username']. " \n\n Password: " .$_POST['upassword']. " \n\n You can now use these to log-in at http://www.website.com. Thank you!"; $mailheader = "From:'mail@website.com'"; if (mail($to, $subject, $body, $mailheader)){ $user_name = "***"; $password = "***";$database = "***"; $server = "***"; $db_handle = mysql_connect($server, $user_name, $password); $db_found = mysql_select_db($database,$db_handle);//escaped variables before database insert $username = mysql_real_escape_string($_POST['username']); $upassword = md5(strtolower(trim($_POST['upassword'])));//this should be encrypted and not a regular password $email = mysql_real_escape_string($_POST['email']); if ($db_found) { $query = mysql_query("SELECT username FROM users WHERE username='".$username."'"); $check = mysql_num_rows($query_add); if($check <= 0) { $SQL = "INSERT INTO users (username, upassword, email) VALUES ('" .$username. "', '" .$upassword. "', '" .$email. "')"; $result = mysql_query($SQL); //$sql = mysql_query("SELECT * FROM users WHERE Email = $email");//this query is never used to display any results header( "refresh:5;url=login.php" );//or index.php with a login echo "You are now registered, redirecting to login in about 5 secs. If not, click <a href='login.php'>here</a>."; exit(); } else { echo "User name is taken, try a different one. <br />"; } } else { print "Database NOT Found "; } } } } else { echo "Please insert a user name, email and password"; } ?> <br /> <form action="" method="post"> Name: <input type="text" name="username" value="<?php echo $username;?>" placeholder="Your user name"/> Password: <input type="text" name="upassword" value="<?php echo $upassword;?>" placeholder="Your password"/> Email: <input type="text" name="email" value="<?php echo $email;?>" placeholder="Your email"/> <input type="submit" value="Submit" /> </form> -
Need help with php mysql database - maintenance?
QuickOldCar replied to andy_b_1502's topic in PHP Coding Help
You have to query the user name first and see if it exists first, then if does not exist, do the mysql insert. -
Need help with php mysql database - maintenance?
QuickOldCar replied to andy_b_1502's topic in PHP Coding Help
You can try what paulryan suggested, but I tried this out and seemed to work, I fixed some errors with it, and added a form to test it. <?php if(isset($_POST['email']) && $_POST['email'] != ""){ $email = $_POST['email']; } else { $email = ""; } if(isset($_POST['upassword']) && $_POST['upassword'] != ""){ $upassword = $_POST['upassword']; } else { $upassword = ""; } ?> <form action="" method="post"> Name: <input type="text" name="email" value="<?php echo $email;?>" placeholder="Your email"/> Password: <input type="text" name="upassword" value="<?php echo $upassword;?>" placeholder="Your password"/> <input type="submit" value="Submit" /> </form> <?php function isValidEmail($email){ return preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/", $email); } if($email != "" || $upassword != ""){ if(isValidEmail($email) == False){ die("$email is no good"); } else { $to = $_POST['email']; $subject = "Welcome!"; $body = "Welcome to website.co.uk,\n\nYour are now registered with website.com. Here are your details: \n\n Username: " .$_POST['username']. " \n\n Password: " .$_POST['upassword']. " \n\n You can now use these to log-in at http://www.website.com. Thank you!"; $mailheader = "From:'mail@website.com'"; if (mail($to, $subject, $body, $mailheader)){ $user_name = "***"; $password = "***";$database = "***"; $server = "***"; $db_handle = mysql_connect($server, $user_name, $password); $db_found = mysql_select_db($database,$db_handle);//escaped variables before database insert $username = mysql_real_escape_string($_POST['username']); $upassword = md5(strtolower(trim($_POST['upassword'])));//this should be encrypted and not a regular password $email = mysql_real_escape_string($_POST['email']); if ($db_found) { $SQL = "INSERT INTO users (username, upassword, email) VALUES ('" .$username. "', '" .$upassword. "', '" .$email. "')"; $result = mysql_query($SQL); $sql = mysql_query("SELECT * FROM users WHERE Email = $email"); header('Location: http://www.***.com'); exit(); } else { print "Database NOT Found "; } } } } else { echo "Please insert an email and password"; } ?> -
I totally agree PFMaBiSmAd, my multi-upload form does that, but would be too much for someone to adapt to their use. and as an example of how i do my error checking while(list($key,$value) = @each($_FILES["file"]["name"])) { if(!empty($value)){ if ($_FILES["file"]["error"][$key] > 0) { echo "Error: " . $_FILES["file"]["error"][$key] . "<br/>" ; } else { //continue with upload }
-
ahh, i see so the != is the way Here's how I handle them, I use allowed arrays, if is the array allow it. Is an example upload showing for types and extensions <html> <body> <form action="" method="post" enctype="multipart/form-data"> <label for="file">Filename:</label> <input type="file" name="file" id="file" /> <br /> <input type="submit" name="submit" value="Submit" /> </form> </body> </html> <?php if(isset($_POST['submit']) && !empty($_FILES["file"]["name"])) { $timestamp = time(); $target = "upload/"; $target = $target . basename($_FILES['uploaded']['name']) ; $ok=1; $allowed_types = array("image/gif","image/jpeg","image/pjpeg","image/png","image/bmp"); $allowed_extensions = array("gif","png","jpg","bmp"); if ($_FILES['file']['size'] > 350000) { $max_size = round(350000 / 1024); echo "Your file is too large. Maximum $max_size Kb is allowed. <br>"; $ok=0; } if ($_FILES["file"]["error"] > 0) { echo "Error: " . $_FILES["file"]["error"] . "<br />"; $ok=0; } else { $path_parts = pathinfo(strtolower($_FILES["file"]["name"])); if(in_array($_FILES["file"]["type"],$allowed_types) && in_array($path_parts["extension"],$allowed_extensions)){ $filename = $timestamp."-".$_FILES["file"]["name"]; echo "Name: " . $filename . "<br />"; echo "Type: " . $_FILES["file"]["type"] . "<br />"; $path_parts = pathinfo($_FILES["file"]["name"]); echo "Extension: " . $path_parts["extension"] . "<br />"; echo "Size: " . round($_FILES["file"]["size"] / 1024) . " Kb<br />"; //echo "Stored in: " . $_FILES["file"]["tmp_name"]. " <br />"; } else { echo "Type " . $_FILES["file"]["type"] . " with extension " . $path_parts["extension"] . " not allowed <br />"; $ok=0; } } if($ok == 1){ @move_uploaded_file($_FILES["file"]["tmp_name"], $target . $filename); $file_location = $target . $filename; if(file_exists($file_location)){ echo "Uploaded to <a href='$file_location'>$filename</a> <br />"; } else { echo "There was a problem saving the file. <br />"; } } } else { echo "Select your file to upload."; } ?>
-
From what I see, you are trying to detect if any compressed type files, like zip or rar, and if it is, redirect them to a page telling them no zip files. if ($_FILES['file']['type'] == "application/zip" || $_FILES['file']['type'] == "application/octet-stream" || $_FILES['file']['type'] == "application/rar" || $_FILES['file']['type'] == "application/x-rar-compressed" || $_FILES['file']['type'] == "application/x-compressed") { header('Location: scontrol.php?alert=notzip'); } You might consider doing an extension check,
-
if ($_FILES['file']['type'] == 'application/zip' || $_FILES['file']['type'] == 'application/x-zip-compressed' || $_FILES['file']['type'] == 'application/x-zip') { header('location: scontrol.php?alert=notzip'); }
-
$name would be an empty value if $_POST['name'] is empty <?php if(isset($_POST['name']) && $_POST['name'] != ""){ $name = $_POST['name']; } else { $name = ""; } ?> <form action="" method="post"> Name: <input type="text" name="name" value="<?php echo $name;?>" placeholder="Your name"/> <input type="submit" value="Submit" /> </form> <?php if($name != ""){ echo $name; } ?>
-
You confused me a bit about the domain2.com and domain3.com If they are actual different domain names, it won't matter because each is it's own domain and will be treated seperately. If you are talking something like site1.domain.com, site2.domain.com, those also are treated as individual sites, since many subdomains are usually unique. If did your sites as domain.com/site1 or domain.com/site2, they usually get associated with the main domain, considered more of a page/folder/section of a website, they have value still, are just considered differently even if they are set up like websites.
-
You mean something like this? <?php if(isset($_POST['name']) && $_POST['name'] != ""){ $name = $_POST['name']; } else { echo "Please insert your name"; } ?> <form action="" method="post"> Name: <input type="text" name="name" value="<?php echo $name;?>" placeholder="Your name"/> <input type="submit" value="Submit" /> </form> <?php if($name != ""){ echo $name; } ?>
-
I think it should be if (!isset($_POST['name']) || ($_POST['name'] == '')){ $name = 'Bob'; } else { $name = $_POST['name']; }
-
<?php $file_array = file('http://www.weatherserver.net/text/CWTO/WOCN11.txt'); $subject1_words = explode(" ",$file_array[2]); $subject1 = $subject1_words[0] . " " . $subject1_words[1]; $subject2 = $file_array[3]; echo $subject1 . "<br />"; echo $subject2 . "<br />"; ?> Results: WOCN11 CWTO SPECIAL WEATHER STATEMENT
-
As AyKay47 pointed out already. Here's a pagination script and demo I did, might be able to see the process better. http://get.blogdns.com/paginate/ As can see there is a startrow(mysql starting row begins at zero) and a posts_per_page(how many results are displayed each page) in the query. It uses math to determine what the mysql starting row will be depending on the page number and how many posts per page are displaying. $result = mysql_query("SELECT * FROM table ORDER BY id DESC LIMIT $startrow,$posts_per_page"); It would be better to have the $startrow dynamic in the query, not checking with multiple if's and setting the values for each page like you are. There's a complete pagination tutorial at phpfreaks. http://www.phpfreaks.com/tutorial/basic-pagination
-
Need help with php mysql database - maintenance?
QuickOldCar replied to andy_b_1502's topic in PHP Coding Help
I always like to trim and lower the POST password as well. $upassword = md5(strtolower(trim($_POST['upassword']))); -
bicycle parts related page- need critique about layout
QuickOldCar replied to supercaliber's topic in Website Critique
Can see for yourself how it looks in many browsers. http://browsershots.org/http://absoluteblack.cc/ -
Need help with php mysql database - maintenance?
QuickOldCar replied to andy_b_1502's topic in PHP Coding Help
Yeah, that was an example of how to use the function, not an exact paste it in and would work. Need to use your POST email info and use that with the function, placing your mysql and mail functions within it..only if it passes with a 1. I just got home, I threw this together as best from what I think might work. <?php function isValidEmail($email){ return preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/", $email); } $to = $_POST['email']; $subject = "Welcome!"; $body = "Welcome to Removalspace.co.uk,\n\nYour are now registered with website.com. Here are your details: \n\n Username: '$_POST['username']' \n\n Password: '$_POST['upassword']' \n\n You can now use these to log-in at http://www.website.com. Thank you!"; $mailheader = "From:'mail@website.com'"; if(isValidEmail($_POST['email']) == 0){ die("email is no good"); } else { if (mail($to, $subject, $body, $mailheader)){ $user_name = "****"; $password = "****"; $database = "*********"; $server = "**********.com"; $db_handle = mysql_connect($server, $user_name, $password); $db_found = mysql_select_db($database, $db_handle); //escaped variables before database insert $username = mysql_real_escape_string($_POST['username']); $upassword = mysql_real_escape_string($_POST['upassword']);//this should be encrypted and not a regular password $email = mysql_real_escape_string($_POST['email']); if ($db_found) { $SQL = "INSERT INTO users (username, upassword, email) VALUES ('" .$username. "', '" .$upassword. "', '" .$email. "')"; $result = mysql_query($SQL); $sql = mysql_query("SELECT * FROM users WHERE Email = $email"); header( 'Location: http://www.website.com/index.php' ); exit(); } else { print "Database NOT Found "; } } ?> -
Need help with php mysql database - maintenance?
QuickOldCar replied to andy_b_1502's topic in PHP Coding Help
I have to go work now, but here is a simple example using the filter check and using preg_match. The function returns a 0 or a 1, false/true <?php $post_email = "somename@mail.com"; //$post_email = "1"; function isValidEmail($email){ return preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/", $email); } if(isValidEmail($post_email) == 0){ die("email is no good"); } else { echo "good email $post_email"; } ?> -
Need help with php mysql database - maintenance?
QuickOldCar replied to andy_b_1502's topic in PHP Coding Help
Use preg_match versus eregi, eregi is a deprecated function. http://php.net/manual/en/function.preg-match.php -
Need help with php mysql database - maintenance?
QuickOldCar replied to andy_b_1502's topic in PHP Coding Help
http://php.net/manual/en/filter.examples.validation.php I guess you can call it checking/validation/filtering/sanitizing If there is something you do not want to happen, should write a code to handle it. Could be a type, certain values, no empty fields, if something is set, so on. Simple example to stop them registering with a 1 if($username == 1 || $password == 1){ die("That's not allowed"); } For emails you can have them email back for verification before becoming active.