-
Posts
3,584 -
Joined
-
Last visited
-
Days Won
3
Everything posted by JonnoTheDev
-
That's Welsh for you. It's funny when you drive through Wales and see road signs that are both English & Welsh. The simple English lets say for Left Turn is a jumble of characters in Welsh that you would never guess what it meant. Although, this is the best one I have seen: http://www.dailymail.co.uk/news/article-1259745/Welsh-road-sign-error-Swansea-Councils-office-email-reply-ends-road-sign.html
-
Forgot password functionality doesn't work
JonnoTheDev replied to brianrlange's topic in PHPFreaks.com Website Feedback
This is the kind of stuff that makes me feel all warm and fuzzy inside. Brilliant!! Anyway, back to the original post, this login issue is doing my nut in. Have to re-login at least every other time I visit. Stupid 75 lb fat computer dorks at SMF better pull their fingers out. -
OK, the solution you opt for depends on the number of messages that you will be sending. I have mail scripts that send newsletters to thousands of users. I do not want to see this running on screen printing a message for every email sent so what I opt for is a button within the CMS that the user can click. This will start a PHP script in the background that sends the newsletter or mailer out. Part of the script will log to a database (or text file) what it is doing so I can check where it is upto. As this data is being recorded I can add code to my CMS that does not allow the user to send another batch of emails until the current message has been sent to all subscribers. Once the script has completed I get it to send an email to the administrator to say it is complete. If you are sending to a smaller number of users and do want the progress to be displayed on the screen as the script runs, there is no problem in setting the max execution time via a .htaccess file or using the set_time_limit() function. As an alternative to writing your own code to display the progress using output buffering or AJAX, I would opt for an API that already has this functionality built in. One that I have used many times is Swiftmailer http://swiftmailer.org/ One downside to this is that if a user was to close the browser window, click off the page for any reason whilst the script is running it would terminate and you may not know what emails have been sent to your users (unless you are recording in a database table). This is not the case when a script is initiated in the background. A command line script is absolutely no different to what you would write to be output in a web browser, the only difference is that you do not need any output to be displayed, the code you write just does a particluar job and that is it, no HTML, no CSS, nothing except PHP. How you implement the mail system is entirely upto you. http://www.php.net/manual/en/info.configuration.php#ini.max-execution-time /* top of script */ set_time_limit(0);
-
Fork it as a background process. You should not wait for things like that to complete in a web browser. Send it straight to the command line as follows: exec("php /path/to/mail-script.php > /dev/null &"); You could get the script to set a flag in your database once it starts to say that a mailer is being sent out. You can use this flag to display a message in the browser or disable buttons so another mailer cannot be sent until the current script has completed.
-
Of course you can. Are you telling me that you have 70 websites, some static HTML, some using Joomla CMS, and whatever else each with its own independent database (if dynamic)? If so you will need to think about changing the main structure. If each of these websites needs to be updated when you change the pricing data, this database needs to be on a central server and accessible through a URL i.e http://www.foobar.com/pricing.xml Each of your satellite websites should use a bit of PHP to read this XML (I would use simpleXML), parse it and display it as formatted HTML, easy. You will need to update the static websites so they use PHP. You can write a plugin for Joomla (there maybe one already). Any other websites that you have using PHP you will need to add the bit of code for the pricing. I am stunned if you have to update 70 websites for such a simple modification.
-
Unless you have a central server generating the HTML files & FTPing them when prices get updated you are a bit screwed. The best way to do this is to use XML feeds from a central server connected to the main database. Each site should connect to the feed to display the pricing. When prices change all websites will change.
-
How can I get a referral fee for product sales?
JonnoTheDev replied to cesarcesar's topic in Miscellaneous
You need to setup click tracking. If a user clicks on a product you can record the event in your database. Usually a tracking id is passed over in the url to the target site. When the sale gets processed the tracking id is used to determine where the user originated from and what commision is owed. This is how all affiliate systems work including Google's Adwords. If the suppliers don't have an affiliate component to their website then you will need to talk to them in regards of setting something up. Invest in some software so that the sellers can add tracking code into their website. You can host the software on your own server so you can login and check the referrals. Just Goofle affiliate tracking and speak to people. -
Simple answer. Any process that requires no output to screen and can be run on a schedule should be implemented as a command line script, whether it be in PHP, Perl, or whatever. The script should not even be accessible through a web browser, i.e stored outside of the web document root. Bad. You can still pass arguments into command line scripts. This sort of script should not even be accessible via a URL. WGET is not really used for what you are using it for. Your cron should use the path to the script, not a URL. For the sort of task that you require such as a maintenence operation, yes. As you are not using a web browser to request the script there is no overhead from the Apache web server. Nor are there any restrictions in place such as timeouts. Yes you can. If required you can fork a script to process in the background using php's exec() function. For instance I may want to send a newsletter out to lots of members when I click a button on my website. I am not going to sit there and wait for this to complete in my web browser, instead the script is run as a background process through the command line. i.e exec("php /path/to/script.php > /dev/null &"); Be aware that shared hosts do not normally allow the use of exec() for security reasons.
-
I completely understand, and I feel exactly the same way sometimes. In the end it's what pays the bills so, you are not going to learn an entirely new way of doing a task that you can already do with current methods as you will end up losing money. The difference between some of the people here and yourself is that you sound like you do this as a full time career wheras to others it is a hobby or not yet blossomed into a full time job so they can easily say do this or do that. You have to look at the big picture. What I find helps sometimes is to purchase a new book and have it on the side as I am working through a client's project. It must be a subject that may improve your current work or something that you can add to it. For example I have a jQuery book that every now and then I will take an hour from doing the client stuff and go through a chapter. Sometimes i'll hit on something that I may use in another project. A bit of mental stimulation. Also, you will get a project that requires you to use something new, an API for example. It may only be 1 out of 5 but they always come. I tend to be learning any new tools that Google produces a lot of the time such as data feeds for Google Base, shopping, etc. This is all stuff for SEO and Google tends to add or update something a lot of the time. Also, most importantly, if I can help it, I stay away from computers altogether the minute I finish work. Do some cooking, watch TV, go to the gym, etc. Spend too much time on a PC and you become a vegetable, you will get stressed (as you obviously are). Make sure you take regular breaks. If you feel this way then I would definately ask your boss (if you don't work for yourself) for a couple of days break to relax.
-
http://csscreator.com/version2/pagelayout.php
-
mmmmm. I definately think that functional code that works with popular API's is what people want the most. In the past I certainly have tried to hunt down stuff. The reason being is that API's can have a massive amount of documentation and some people just don't have the time to read or it is too complex. However if they had a complete script they may be able to see and understand how the API is used. I'll give you one that people always ask for and that is code to integrate Paypal Website Payments Pro. The documentation is complex however the complete code is not, it just seems like it should be. The code examples that they offer are rubbish, often out of date and incomplete. Another is Google Base where the API allows you to add products from your e-commerce database into their shopping results. Maybe a tool that creates a data feed from CSV, or text file would be useful. Any scripts that work with API's to help users are worth working on.
-
Best way to make a (dynamic, not content driven) website?
JonnoTheDev replied to farzher's topic in Miscellaneous
That is the same as asking, 'how long is a piece of string?' Simple. Do not use Joomla, Drupal or any other CMS. Create your own library of functions that you will require in most of the projects that you work on. These functions can be stored in a central location on your server that all your projects can access or copied into each web site. If you write a function in one project that you may use in another, simply add it to your library. Again, create a library of user management functions, authentication, privileges, etc. Make it abstract so it is not tied into one particular web site. Obviously it will require the web site that it is used in to have prerequisites such as database tables, etc. I would do this using Object Oriented techniques so you can use as an API in any web site. Store it in a central location on your server. MVC has nothing to do with web sites. It is a design pattern used in software engineering and describes the separation of the database logic, in most cases (model) from the application logic (controller) and the presentation layer i.e HTML (view). Any design pattern in it's simplest definition is a structure for code to solve a problem. In this case seperating the 3 main elements. For more info read http://en.wikipedia.org/wiki/Model%E2%80%93View%E2%80%93Controller You may want to look at the Zend framework for your projects. As discussed earlier about creating your own library of functions, classes, etc to solve common problems, a framework is essentially that. You will have to learn the syntax and the usage for each different part of the framework that you intend to use, i.e session management, database querying, MVC, etc -
I'm not sure what you mean by tools, however mashup projects are always nice to work on. Intergrating one or more API's is always a popular requirement i.e. Use the Google Maps & Flickr APIs to display photos of a location when I click on the map. Also display links to wikipedia that contain more information. Use the Google Maps API and various transport feeds to give me information on train times, add markers to specific public transport.
-
If you want the previous 5 days as oppsed to the next 5 days you simply change the following line // from $days[] = date('d/m/Y', strtotime('+'.$x.' days')); // to $days[] = date('d/m/Y', strtotime('-'.$x.' days')); There is something that you should fundementally change in your code, database, etc. That is your date formatting. PHP / MYSQL work with US formatted dates YYYY-mm-dd. If you have dates in your database you should change the field type to DATE if they are stored in VARCHAR fields. UK formatted dates are not so great for using in MYSQL or PHP functions i.e if you were to do the following: print date('Y-m-d', strtotime('+1 day', strtotime('03/02/2011'))); You would expect the next day to be 04/02/2011. PHP will actually return 03/03/2011. So we need to change your date formatting <?php // the date value to test $totest = '05/02/2011'; // convert to US date format YYYY-mm-dd $date = explode('/', $totest); $date = $date[2].'-'.$date[1].'-'.$date[0]; // the number of days before todays date we will add to our range $numdays = 5; $days = array(date('Y-m-d')); for($x = 1; $x <= $numdays; $x++) { $days[] = date('Y-m-d', strtotime('-'.$x.' days')); } if(in_array($date, $days)) { print 'This date is within my accepted range of '.$numdays.' dates'; } else { if(time() > strtotime($date)) { print 'This date has passed'; } else { print 'This date is NOT within my accepted range of dates'; } } ?>
-
Of course. What range? Do you require 5 days either side of the current date. i.e 10 future days from 5 days in the past.
-
This is incorrect. The original post is stating that the condition is met when the tested date is within 5 days of the current date. What you are doing using the strtotime function is returning the value 'Yes' to $result when the tested date is greater than 5 days in the past. This means that if the tested date is 30 days in the future then it will also return 'Yes', although the requirement states that this should return false. It will be the same with past dates if you reverse the function to use the correct +x days as opposed to -x days. What you are missing is a second condition in the if statement to say if the tested date is greater than or equal to the current day and also less than or equal to 5 days in the future. The reason I used an array containing 5 dates was to keep it simply to date values. Using strtotime without formatting the date you are dealing with timestamps (date + time). In this case you are not interested in the time which could alter the value of the output. There is nothing wrong with the way you have gone about tackling the problem, however in terms of making it simple to debug and adjust (also be able to see the values you are testing for) as opposed to the least number of lines of code I would prefer the code I posted. This is tested and works without issue as opposed the the incorrect code you are struggling with.
-
Storing an array of strings in mysql and using the IN() function on it
JonnoTheDev replied to farzher's topic in MySQL Help
Yes this is possible if you cannot do it with regular joins. ie SELECT name FROM users WHERE id IN(SELECT id FROM logins) -
Have a play with this <?php // the number of days from todays date we will add to our range $numdays = 5; $days = array(date('d/m/Y')); for($x = 1; $x <= $numdays; $x++) { $days[] = date('d/m/Y', strtotime('+'.$x.' days')); } // the date value to test $totest = '31/01/2011'; if(in_array($totest, $days)) { print 'This date is within my accepted range of dates'; } else { print 'This date is NOT within my accepted range of dates'; } ?>
-
$xml = file_get_contents('datafeed_98057.xml');
-
Have you tested any? Have you read the feature lists? http://www.joomla.org/ http://drupal.org/
-
Getting rid of cigarette smell from a computer
JonnoTheDev replied to xylex's topic in Miscellaneous
piss off, im doing really well -
We will not do the job for you. This forum is about assisting people with issues in their scripts or suggesting solutions to problems. If you want someone to do the job for you I suggest you post in the freelance board for paid help. We do expect you to at least have a go at tackling the problem before asking for help. As I have already stated, php is not used in client side technologies (unless used via AJAX, different topic..) such as flash, php is a server side technology. Video players that support flv, HTML5, etc, are controlled through Javascript API's. One of the most popular is JW Player. The documentation is clear and easy to understand. Please read if you require a video player on your website to play your flash video files. http://www.longtailvideo.com/support/jw-player/jw-player-for-flash-v5
-
What code?
-
PHP has no association with flash at all. They are 2 completely different entities. To play a flv video in a browser you require a player such as JW Player. The players are usually controlled via Javascript objects. Of course you can use a php function to create the HTML / Javascript if you wish i.e <?php function videoPlayer($flv) { $html = "<script>\n"; // javascript script code here $html .= "</script>\n"; return $html; } print videoPlayer('/path/to/test.flv'); ?> http://www.longtailvideo.com/players
-
I do not understand why you are constructing a 2nd array of keys using the key as an index when the data is available in the $styles array. Simply return the array keys if you needs them in a new array. <?php $keys = array_keys($styles); ?>