
Max
Members-
Content Count
104 -
Joined
-
Last visited
Everything posted by Max
-
...and I am killing off any emails in the first category as I don't want to receive them anyway.... $very_bad = array('to:' , 'cc:', 'bcc:', 'content-type:', 'mime-version', 'multipart-mixed', 'content-transfer-encoding:', 'sex', 'bitcoin', 'resource', '$', 'city', 'money', 'traffic', 'GetaBusinessLoan', 'bitcoin', 'ProFunding', 'BusinessLoan', 'einfac'); foreach ($very_bad as $v) { if (stripos($value, $v) !== false) { die(); } } I don't know it that is bad programming practice to kill a program in mid-flow
- 3 replies
-
- spamscrubber
-
(and 1 more)
Tagged with:
-
I have also changed the criteria so: $very_bad = array('to:' , 'cc:', 'bcc:', 'content-type:', 'mime-version', 'multipart-mixed', 'content-transfer-encoding:', 'sex', 'bitcoin', 'resource', '$', 'city', 'money', 'traffic', 'GetaBusinessLoan', 'bitcoin', 'ProFunding', 'BusinessLoan', 'einfac'); which has cut downthe deluge of spam that I used to get.
- 3 replies
-
- spamscrubber
-
(and 1 more)
Tagged with:
-
Hi there I hope you are well, Larry. I decided to re-visit my 'Contact us' page and review the spamscrubber. I was having trouble getting the spamscrubber to fish out the '\n's and '\r's to the extent that I changed the blank spaces to letters: function spam_scrubber($value) { //Create spam scrubber array.............. $very_bad = array('to:' , 'cc:' , 'bcc:' , 'content-type:' , 'mime-version' , 'multipart-mixed' , 'content-transfer-encoding:'); //For loop comparing email text to bad words....... foreach ($very_bad as $v) {
- 3 replies
-
- spamscrubber
-
(and 1 more)
Tagged with:
-
Hi Larry and everyone, I have really painted myself into a corner with this one. Above is the database that I created for a timeline. The issue is that not all of the dates at my disposition have days and months. Some are just years. Hence, I had to make a separate column for years only. What I want to do is create a timeline using tables so that any year that has either a YYYY date and/or a YYYY-MM-DD date appears in chronological order. I tried it with a for loop starting at $i = 1700 - 2000 which works for the first year but the while ($enquiry3 = @mysqli_fetch_arr
-
Hi all, Well, finally solved it. What really complicated matters was that my browser was converting the (correct) answer from php back to html entities! This led me to believe that php wasn't actually doing anything. So, it has all come down to two lines of code:.... $search = trim($_POST['Search']); $search = htmlentities($search); Now, php can do the MySQL search and now finds matches. To get round the problem on the test script I added as the first line: header('Content-Type: text/plain'); .....so now m
-
Hi Larry, html : <meta charset="utf-8"> <!--[if lt IE 9]> <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> MySQL: Collation on all relevant columns and tables are utf-8_unicode_ci When I use phpMyAdmin the accented characters show as ASCII entities (i.e. á = á), which is what I want. It all works fine: Inauguración. Bendición de las locomotoras - Águilas. Marzo 1890. - from phpMyAdmin becomes..... Inauguración. Bendición de las
-
I have come across htmlentities and htmlspecialchars but neither seems to work. Here is a Q&D test: <?php if(isset($_POST['char'])) { $char = $_POST['char']; $char2 = htmlentities($char); echo 'Answer: ' . $char . '<br /><br />'; echo $char2; } echo '<form action = "char_test.php" method = "post"> <input type = "text" name = "char" size = "6"> <input type = "submit" name = "submit" value = "Search!" /> </form>'; if I entered á then I would expect the answer to be: Answer: á
-
Hi Larry and everyone, I'm still using your book as php is still reducing me to tears. Here is the problem: I have created a large database in English and Spanish. In spite of setting the MySQL db to UTF-8 it still returns nonsense characters with eg accented 'a', so I have been entering all of the text with accents as for example á = á, Ú = Ú, ñ = ñ as the only way to guarantee that they print correctly when called. The problem is that when a Spaniosh speaker does a search, then they will search for eg 'Estación' not 'Estació
-
File Handling
Max replied to Max's topic in PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (4th Edition)
The words are fact. I will look at including regular exressions in the glob(). Regards Max -
File Handling
Max replied to Max's topic in PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (4th Edition)
Further to the above comment, I have stumbled across something called 'imagick' which is part of the PHP domain. The PHP manual says something like this: bool Imagick::resizeImage ( int $columns , int $rows , int $filter , float $blur [, bool $bestfit = false ] ) ..and gives examples like this: <?php function resizeImage($imagePath, $width, $height, $filterType, $blur, $bestFit, $cropZoom) { //The blur factor where > 1 is blurry, < 1 is sharp. $imagick = new \Imagick(realpath($imagePath)); $imagick->resizeImage($width, $height, $filterType, $blur, $bestFit) -
File Handling
Max replied to Max's topic in PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (4th Edition)
Another question for Larry. I would like to offer a library of all of the thousands of images that I have in my raw data directory by displaying thumbnails. I know I can use: <a href = "images/raw/yadayada.jpg" target = "_blank"><img style = "width: 100px;" src = "images/raw/yadayada.jpg" .... /> </a> but this will involve huge overheads as it will mean downloading approx 1Mb images and then resizing them in the browser, so I would prefer to resize the images in PHP before downloading them, but I can't find any reference to this in the PHP manual, or the PHP GD -
File Handling
Max replied to Max's topic in PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (4th Edition)
Just spotted a problem with the script - it is only checking files with the extension .jpg, not .JPG. Have changed: //Now create a variable ($getlisting) to be able to call only the category that we are interested in... $getlisting = 'images/' . $category . '/*.jpg'; to: //Now create a variable ($getlisting) to be able to call only the category that we are interested in... $getlisting = 'images/' . $category . '/*.*'; - can't really see any neat way around it. I suppose I could run it twice, once with .jpg and then with .JPG, then run the .JPGs through strtolower and then comb -
Hi Larry I thought that I'd post this as it might help other php-ers. I have a website which has many images. To facilitate the download of images, I save a reduced image under a directory name e.g. images/activities/P3451098.jpg for thumbnails and slideshows as well as the full size in e.g. images/raw/P3451098.jpg. Then I can offer an enlarged image using <a href = ***><img src...... target = "_blank"> etc. The problem is that as I send the images up using FTP (Filezilla) I can't be sure if all of the reduced images have the corresponding full sized images thanks to
-
STOP PRESS!! Darn it! I have just found a much easier way, thanks to your book (Chapter 2):.... Create array of all jpg files on server in the images/activities/activities directory: $listing = glob("images/activities/activities/*.jpg"); Use 'shuffle() to change the order of the jpg files in the array: shuffle($listing); Use 'foreach()' to trawl through the array to extract the filenames: foreach($listing as $key => $value) { This is a bit of js: echo '<div class="mySlides fade"> <img src = "' . $value . '" style=" display: block; margin: auto; width:80%; border-styl
-
Hi Larry. I am sure that this has been done elsewhere, but I thought I would share it with you anyway. I have a website that displays a slideshow of images of where I live ( www.beautifulcastril.com ). To make things cleaner and quicker, I just upload the jpgs to the server via Filezilla and then, in the program use glob() to bring their filenames into an array. I then used to pass through the array using foreach() to display the images automatically using js and CSS as per your book Chapter 2. The irritating thing was that they always came out in the same order so I have changed
-
Charachter Encoding
Max replied to Max's topic in PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (4th Edition)
Thanks, Larry - I think I have my head round it now - that one apostrophe entered through a textarea caused me a lot of chaos. Keep up the great work. -
Charachter Encoding
Max replied to Max's topic in PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (4th Edition)
Following your book, I have now added mysqli_real_escape_string() to the php which actually works for everything except `` and ´´ which it doesn't escape, but I will take the risk of those never being used by the people who are uploading data. They are not the standard apostrophes but Hex 60. To get to the root of the problem, what I did was to comment out the steps whereby I uploaded the data to MySQL and instead did an 'echo' instead: e.g. $update = "UPDATE blah SET Name = '$name', Address = '$address', Description = '$desc' WHERE Ref = $ref LIMIT 1"; echo $update; I then -
Charachter Encoding
Max replied to Max's topic in PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (4th Edition)
In addition, I have been caught out with uploading text to MySQL from a textarea - when people use an apostrophe - as in "I've" - then the MySQL sees that apostrophe as the end of a data set as in - UPDATE blah SET Comments = 'blah blah it's blah blah' you find that MySQL has thrown it all out because it has seen the " ' " as a termination character. The problem is that there are so many apostrophes on a keyboard - ' , ` , ´ , " etc - so I have included a str_replace routine to turn these into spaces as \' doesn't seem to work in all circumstances. -
Charachter Encoding
Max replied to Max's topic in PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (4th Edition)
Hi Larry Comments genuinely meant - and if I am mad enough to scramble my brains by learning something new I will always look for your books on that subject. Regarding the character encoding, I am referring to a textarea such as this one. Head is set to: <meta charset="utf-8"> and the MySQL "utf8_unicode_ci". On my keyboard are characters such as an "enye" - the n with a tilde on top. Also, it would be nice for people to have a way of writing m2 as for 'square metres'. When I put the 'enye' into MySQL using phpMyAdmin it works and reads correctly, but when read by html in my w -
Hi again Larry, Character encoding....Hmmmm If I write HTML, and want to include an ampersand -> & - or a euro sign -> € or alternatively € I type exactly those characters. The question is when one is using php to write text to mySQL. For example, if you have a web page which invites a customer to upload text to the database. If they use a keyboard that has unusual characters such as a half, which I would type in HTML as ½ it is not saved as such even though the DB has UTF-8 encoding. So...what happens when the text is retrieved from the DM and sent to the browser is
-
Killing A Php Program
Max replied to Max's topic in PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (4th Edition)
Hi Abigail Thanks for that. My provider doesn't offer e-mail help - you have to phone them and I was hoping to avoid the embarrassment of admitting that I'd done something stoopid !! The web site will be back tomorrow (did before when I screwed up). I would be nice to be able to kill it through php some way. I have tried most things - logging out, uploading (FTP) a safe version of the program. Regards Max -
Larry, what would we do without you??? How about something like this??: //We'll call the variable that contains the text '$my_text' // html elements are not all the same size, eg <h1>, </strong>, <small> // Do a 'while...'....then.... //Find the first opening tag (<) $first = strpos("<") //Find first closing tag (>) $second = strpos('>',$my_text) $length_of_string = $second - $first; //Remove the offending element substr_replace($my_text, "", $first, $length_of_string) //end while Unfortunately, this removes all of the HTM
-
Killing A Php Program
Max replied to Max's topic in PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (4th Edition)
Hi Larry Thanks for that, but the php seems to be running in the server - I still get hundreds of e-mails per minute with the same error (the error is just a notice, not related to the problem. Eventually the server blocks the website for a day and just gives a 'Website not available' message. I guess they're waiting for the server to cool down after whizzing round in circles . The worst of it is that I feel so bally FOOLISH!!