QuickOldCar
Staff Alumni-
Posts
2,972 -
Joined
-
Last visited
-
Days Won
28
Everything posted by QuickOldCar
-
Application Which Reveals the Rank Number in Google
QuickOldCar replied to Glese's topic in Miscellaneous
you can still use the ranking api, but would need to exclude google from it and use the others -
feedburner will display similar information that your current feed does. If you want more information in your feed you must add it or allow more of it. Post your sites link so can take a look.
-
There is no advanced logic in this function. Such as ai,similar words, similar meanings or anything like that. it simply takes a bad word and if the word exists in the string it will perform the action on that word. but due to the few modifications it can now also do uppercase/lowercase/mixed case, as well as bad words that have a prefix or suffix.
-
I don't fully understand your question. This function is named and created, is not a standard php function, it's custom. The function itself can be used in any way you see fit to use it. It could be modified upon more. To sum the purpose of this function up: The function takes a string of words, cycles through all the badwords, and for the ones that match.... replaces each letter of the word with a * and returns the modified string
-
Personally I would use gd and watermark the image on display, leaving the original uploaded image untouched. http://www.roseindia.net/tutorial/php/phpgd/About-%20watermark.html If you have many of them and constantly producing them with gd, you could cache the watermarked image It all really depends if full size images are available for download or not, possibly for paying customers.
-
I think because this is a group of words in a chat message, the str_replace will not work because it will clump the words together. Look over what I did here, and can do it similar to your needs with a while loop for results, versus the array list and loop I did. <?php function filterBadWords($str) { $replacements = "*"; $bad_words_array = array("chit","poop","shat","chits"); foreach($bad_words_array as $bad_words) { $spaced_bad_words = preg_replace("/(.)/i", "\${1} ", $bad_words); $spaced_bad_words = trim($spaced_bad_words); $str = preg_replace("/$bad_words|$spaced_bad_words/i", str_repeat('*', strlen($bad_words)), $str); } return $str; } $text = "I have to deal with a whole pile of chit dealing with you. Even C H I T will work too."; echo filterBadWords($text); ?> results: I have to deal with a whole pile of **** dealing with you. Even **** will work too. The above words will now look for bad words case-insensitive as well. eregi_replace is deprecated and should use preg_replace()
-
While it's possible to write a function to do what you suggest, it may be better for you to look into opendir() or glob() Just because of what you describe as your intentions. The creating of new files and folders could be based off the value by simply appending to the end.
-
properly formatted html is the best, the page would contain additional information in the head, but it will still run without doing so you can place the php file anywhere you want, as long as know where to link to it one example would be to create a folder named contact under root, and then name this file index.php now you would be able to visit the file as http://mysite.com/contact
-
use this section of code here was your error //email subject $subject = ($_POST['subject'] <body> <?php //my email $recipient = "info@hairlosslasergroup.co.uk"; //persons name $name = htmlspecialchars($_POST['name']); //persons email $email = htmlspecialchars($_POST['email']); if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/",$email)) { die("E-mail address not valid"); } //persons phone number $phone = htmlspecialchars($_POST['phone']); //preferred date $date = htmlspecialchars($_POST['comments']); //best time $time = htmlspecialchars($_POST['time']); //check required fields $required = check_input($_POST['required'], "Please go back and complete all required fields"); //email subject $subject = $_POST['subject']; //message contains $message = "Name:$name</br>Email:$email</br>Phone:$phone</br>Preferred Date:$date</br>Best Time To Contact:$time"; //message mail($recipient, $subject, $message); //redirect to thank you page header('Location:$redirect'); ?> </body> </html>
-
I think there is a mistake. It was making a new adid only if was not blank, it should make one if it is blank if($adid == "") { $idquery = mysql_query("SELECT MAX(adid) FROM ads"); $idrow = mysql_fetch_row($idquery); $adid = $idrow[0] +1; }
-
I tried to register, but it didn't seem to do anything upon hitting the register button.
-
drawing lines, by getting coordinates from mysql database
QuickOldCar replied to jay83r's topic in PHP Coding Help
There are others can use as well http://www.php.net/manual/en/refs.utilspec.image.php -
drawing lines, by getting coordinates from mysql database
QuickOldCar replied to jay83r's topic in PHP Coding Help
as xyph said, it will not be easy gd can create lines, boxes and even fancy stuff http://www.php.net/manual/en/book.image.php to make rectangles look into imagefilledrectangle or imagerectangle http://www.php.net/manual/en/function.imagefilledrectangle.php http://php.net/manual/en/function.imagerectangle.php -
I agree mjdamato In any case, I forgot to add the mysql query, so fixed it if($adid!="") { $idquery = mysql_query("SELECT MAX(adid) FROM ads"); $idrow = mysql_fetch_row($idquery); $adid = $idrow[0] +1; }
-
$adid if not empty will make the new $adid a value of $adid +1, which to me there could always be that adid somewhere I would probably do it differently. select the highest adid in your databases, ..then add +1 to the highest one and set that as your new $adid. Also I would never make the adid a value of 1, you could have multiple 1's throughout. if($adid!="") { $adid=$adid+1; } else { $adid="1"; } something in the lines of this if($adid!="") { $idquery = "SELECT MAX(adid) FROM ads"; $idrow = mysql_fetch_row($idquery); $adid = $idrow[0] +1; }
-
Saving to a SQL Database using php and wamp
QuickOldCar replied to twinytwo's topic in PHP Coding Help
Post using the code tags <?php $Name = $_POST['Name']; $Age = $_POST['Age']; $Sex = $_POST['Sex']; $Address_1 = $_POST['Address_1']; mysql_connect("127.0.0.1","user","password") or die ('Error: ' .mysql_error()); mysql_select_db("user"); $query ="INSERT INTO users(Name,Age,Sex,Address_1) VALUES('$Name', $Age','$Sex','$Address_1')"; mysql_query($query) or die ('Error updating datadase'); mysql_close(); ?> Missed the POST and also the square brackets, must be a little tired Should the POST values be uppercased? -
Edit a PHP script to show Google search results totals
QuickOldCar replied to malone's topic in PHP Coding Help
<html> <body> <?php function my_fetch($url,$user_agent='Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)') { $ch = curl_init(); curl_setopt ($ch, CURLOPT_URL, $url); curl_setopt ($ch, CURLOPT_USERAGENT, $user_agent); curl_setopt ($ch, CURLOPT_HEADER, 0); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_REFERER, 'http://www.google.com/'); $result = curl_exec ($ch); curl_close ($ch); return $result; } $s = array(); $s = $_GET['s']; if (isset($s) && $_GET['s'] != ""){ $exploded_text = explode("\n",$s); foreach($exploded_text as $search_term){ $search_term = trim($search_term); echo "<p><i>Search for $search_term</i></p>"; $search_term = urlencode($search_term); $data = my_fetch("http://www.google.com/search?hl=en&q=" . $search_term . "&btnG=Google+Search"); $data = strip_tags($data); $find = 'Results 1 - 10 of about '; $find2 = ' for'; $data = strstr($data, $find); $pos = strpos($data, $find2); $search_number=substr($data,strlen($find), $pos-strlen($find)); echo "Total Results: $search_number"; } } else { ?> <form name="form1" id="form1" method="get" action=""> <div align="left"> <p> <textarea name="s" type="text" id="s" rows="8" style="width:60%" /></textarea><br /> <input type="submit" name="Submit" value="Results" /></p> Put "" around the string: <input type="checkbox" checked name="apos" value="true" /><br /> </div> </form> <p> <?php } ?> </p> </body> </html> -
I was just looking through the code. If was me, I would set the current ip before anything. And also use built in functions for storing ip's //gets current ip and converts incomplete ip into proper 4 position ip $ip = long2ip(ip2long($_SERVER['REMOTE_ADDR'])); echo $ip."<br />"; //ready to insert into db $save_ip = ip2long($ip); echo $save_ip."<br />"; //display from db $display_ip = long2ip($save_ip); echo $display_ip; http://php.net/manual/en/function.ip2long.php http://www.php.net/manual/en/function.long2ip.php The only times it was being set was when certain if/else conditions were met. Rethink your logic of how you check and try to make it simpler
-
<?php $message = " hi ' bye sup ' hi "; $message2 = str_replace("'", '', $message); print"$message2"; ?>
-
It's not as easy as appears to get the titles from all websites. Some chunks of the code I use for my index. <?php $url = trim("facebook.com"); //parse the url function getparsedHost($new_parse_url) { $parsedUrl = parse_url(trim($new_parse_url)); return trim($parsedUrl['host'] ? $parsedUrl['host'] : array_shift(explode('/', $parsedUrl['path'], 2))); } /*connect to the url using curl to see if exists and get the information*/ //$cookie = tempnam('tmp','cookie'); //$cookie_file_path = "tmp/"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); //curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie); //curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file_path); curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3'); curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); curl_setopt($ch, CURLOPT_TIMEOUT, 15); curl_setopt($ch, CURLOPT_MAXREDIRS, 15); curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_AUTOREFERER, true); curl_setopt ($ch, CURLOPT_FILETIME, 1); curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_ENCODING , ""); $curl_session = curl_init(); //curl_setopt($curl_session, CURLOPT_COOKIEJAR, $cookie); //curl_setopt($curl_session, CURLOPT_COOKIEFILE, $cookie_file_path); curl_setopt($curl_session, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3'); curl_setopt($curl_session, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); curl_setopt($curl_session, CURLOPT_ENCODING , ""); curl_setopt($curl_session, CURLOPT_TIMEOUT, 15); curl_setopt($curl_session, CURLOPT_HEADER, 1); curl_setopt($curl_session, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($curl_session, CURLOPT_HEADER, true); curl_setopt($curl_session, CURLOPT_MAXREDIRS, 15); curl_setopt($curl_session, CURLOPT_RETURNTRANSFER, true); curl_setopt( $curl_session, CURLOPT_AUTOREFERER, true ); curl_setopt ($curl_session, CURLOPT_HTTPGET, true); curl_setopt($curl_session, CURLOPT_URL, $url); $string = mysql_real_escape_string(curl_exec($curl_session)); $html = mysql_real_escape_string(curl_exec ($ch)); $info = curl_getinfo($ch); /*curl response check and to resolve url to the actual location*/ $response = curl_getinfo( $ch ); if ($response['http_code'] == 301 || $response['http_code'] == 302) { ini_set("user_agent", "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3"); $headers = get_headers($response['url']); $location = ""; foreach( $headers as $value ) { if ( substr( strtolower($value), 0, 9 ) == "location:" ) return get_final_url( trim( substr( $value, 9, strlen($value) ) ) ); } } if ( preg_match("/window\.location\.replace\('(.*)'\)/i", $con_addtent, $value) || preg_match("/window\.location\=[\"'](.*)[\"']/i", $con_addtent, $value) || preg_match("/location\.href\=[\"'](.*)[\"']/i", $con_addtent, $value) ) { $finalurl = get_final_url($value[1]); } else { $finalurl = $response['url']; } $html = curl_exec($ch); $header = "Location: "; if (!$html) { ?> <br /><FONT COLOR=red>No url inserted:</b></FONT> <br /><B><FONT COLOR=orange>Please try another url, that website may not exist. The url may or may not require the www.</b></FONT><br /> <?php exit; } if (curl_errno($ch)) { ?> <B><FONT COLOR=orange> <?php curl_error($ch); ?> </b></FONT><br /> <?php } else { ?> <br /> <?php $errmsg = curl_error($ch); curl_close($ch); $valid = array(200, 201, 202, 203, 204, 205, 206, 207, 300, 301, 302, 303, 304, 305, 306, 307); if (in_array($info['http_code'], $valid)) { ?> <B><FONT COLOR=lime>Connection OK</b></FONT> <?php } $invalid = array(400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 419, 420, 421, 422, 423, 424, 425, 426, 500, 501, 502, 503, 504, 505, 506, 507, 510); if (in_array($info['http_code'], $invalid)) { ?> <B><FONT COLOR=red>Connection Error</b></FONT> <?php } ?> <br /> <?php $redirected = array(300, 301, 302, 303, 307); if (in_array($info['http_code'], $redirected)) { ?> <B><FONT COLOR=orange>Redirection</b></FONT> <?php } $redirectedno = array(200, 201, 202, 203, 204, 205, 206, 207); if (in_array($info['http_code'], $redirectedno)) { ?> <B><FONT COLOR=lime> Direct Connection</b></FONT> <?php } print <<<END <br /> END; /*grabs the title description and keywords - last effort grabs any information could from head or header*/ $ok=1; //meta $title = null; if(preg_match('/<title>([^>]*)<\/title>/smiU', $html, $match)){ if (isset($match) && is_array($match) && count($match) > 0) { $title = strip_tags(trim($match[1])); } } elseif(preg_match("/<title>(.*)<\/title>/smUi",$html, $match)){ if (isset($match) && is_array($match) && count($match) > 0) { $title = strip_tags(trim($match[1])); } } elseif(preg_match("/<title>(.+?)<\/title>/msi",$html, $match)){ if (isset($match) && is_array($match) && count($match) > 0) { $title = strip_tags(trim($match[1])); } } else { preg_match('/<title>([^<]*)<\/title>/smiU', $html, $match); if (isset($match) && is_array($match) && count($match) > 0) { $title = strip_tags(trim($match[1])); } } $title = preg_replace('~\s{2,}~', ' ', $title); $charset = 'None'; $description=''; $keywords=''; preg_match("/<head.*>(.*)<\/head>/smUi",$html, $headers); if(count($headers) > 0) { if(preg_match("/<meta[^>]*http-equiv[^>]*charset=(.*)(\"|')>/Ui",$headers[1], $results)){ $charset= $results[1]; } else { $charset='None'; } } else { $ok=0; //echo 'No HEAD - Might be malformed or be a feed<br />'; } if($charset != 'None'){ $title=iconv($charset, "UTF-8", $title); } if($title == null){ $title = $finalurl; } $parsed_url = getparsedHost($finalurl); echo "Url: <a href='$finalurl'>$parsed_url</a><br />Title: $title"; } ?> If just need a title of the page there are other simpler methods to do this. But curl has more options and able to do more with it.
-
Insert data into database without waiting for it
QuickOldCar replied to IreneLing's topic in PHP Coding Help
Maybe have them upload the cvs file into a designated folder, redirect the user. For the loading of data, have a script checking for cvs file type and oldest date within a folder, then upon completion of cvs/database insert, move or delete the cvs file, then look for another file and continue. Can set a cron job to look for files, or exec the command upon their completed upload. Basically making the insert into database some type of background process. -
Here's neat script for doing as you want, can even preview images, play mp3's and a search http://www.gerd-tentler.de/tools/filemanager/
-
ftp://username:password@66.40.52.167 replace your username and password, try it oddly the forum removes the colon from the link and also adds http:// to the front for urls ftp://username:password@66.40.52.167
-
this i can see the browser, but not the http for that ip ftp://66.40.52.167"; i see the manual states can not start with ftp:// anyway, i tried your code and got the can't find a username, so it must have tried to connect at least