Jump to content

JonnoTheDev

Staff Alumni
  • Posts

    3,584
  • Joined

  • Last visited

  • Days Won

    3

Everything posted by JonnoTheDev

  1. Send it to me. I've given up smoking for that past month and the cravings are a killer. I will lick it clean.
  2. This is not bizarre. It is simple. The path you have used is incorrect. You have used a relative path as opposed to an absolute path. Do the following: print $_SERVER['DOCUMENT_ROOT']; exit(); This will give you the path to your document root i.e /home/username/public_html/. Stick the xml file in this directory and use the path in the function that reads the file. Simple. Also as suggested make sure your script properly exits on error if(!$xml = file_get_contents('/path/to/file.xml')) { print 'Could not open xml file'; exit(); }
  3. Because if you want external scripts (on other servers) to include scripts from your server it must be set to on. You can see where the security issues are in this. In your case, if the file is on the server where your web script is you should not be accessing files through a url. You should use the absolute path to the file i.e $xml = file_get_contents('/path/to/file.xml'); or $handle = fopen('/path/to/file.xml','r');
  4. Your table should definately have a PRIMARY KEY. You should add indexes to fields that you are using to perform lookups on or any fields that join other tables. i.e Using a hypothetical table ' users' users ==== userid (int 10 unsigned primary key) name (varchar 30) age (tinyint 3 unsigned) Now, if I am going to be performing lookups such as: SELECT userid,age FROM users WHERE name='John' ORDER BY userid ASC I am going to be wanting to add an index to the field, 'name'. I could go one step further as it is a varchar field and add a FULLTEXT index (the field contains text values, you can add fulltext indexes to char, varchar, and text field types). You can read about this here http://devzone.zend.com/article/1304 If I am performing lookups on the field, 'age' I will wanting to be adding an index to that field also i.e SELECT userid,name FROM users WHERE age >= 25 AND age <= 30 ORDER BY userid ASC You can see the performance of a query, stating how the records have been found by using the EXPLAIN statement i.e EXPLAIN SELECT userid,name FROM users WHERE age >= 25 AND age <= 30 ORDER BY userid ASC If you ran the above before and after adding indexes you will see the difference in the result. I recommend you use EXPLAIN on the SELECT queries that you are running. To understand the results and for more information on optimising your tables & queries I suggest you read the following:
  5. php_flag allow_url_fopen on If you are on a shared hosting package then you would never have access to the php.ini configuration file. Also the host may lock down the configuration changes that you can make through your .htaccess. Shared server hosting is very restrictive.
  6. I doubt any CMS will include functionality from this API. If it did it would probably be provided by the makers of the API itself as a reseller account or such. If you are not a developer then you are in way over your head. I suggest talking to Rent Juice to see if they can assist.
  7. If the configuration change is only required for one particular website then you should set the config value via a .htaccess file, not through the php.ini file as this will set the configuration server wide and affect all websites on the box.
  8. Last line RewriteRule (.*) https://www.yourdomain.com/$1 [R=301,L]
  9. I find that the more complex and bespoke the requirements are, the more need to create a solution tailored only to those requirements. Yes it may take more time to start from scratch and build up, however in the long run, updating and adding more functionality will take less time. This is the pro/con argument. An off the shelf system that does not meet the requirements will sometimes need to be hacked to function in the way the end user wants it to. More hacks added over time lead to spaghetti code and even understanding it yourself will be a problem when you come back to it in the future. I have no problems with the likes of Drupal & Joomla. I have never opted to use them, but I do know what they can do and the functionality & addons available. However, when working for clients their requirements are often quite specific so choosing one of the many CMS to do the job is not always the best choice & leads to what I have described above.
  10. Correct. Why would I waste my time, however, if entering data into a form creates an action such as sending an email then it will get abused. If there are areas behind your login script where users can post data to your site then you will have tons of bots posting spam to obtain backlinks for blackhat SEO. It has nothing to do with what people read. This is not the point of spam containing links. Do some homework instead of jumping to conclusions.
  11. Do some research on using AJAX. This will allow you to call the php script via Javascript every second using setTimeout()
  12. You must use an absolute path, not a URL. $dir = '/home/html/images'; if(!is_dir($dir)) { mkdir($dir,0777); }
  13. This is the absolute worst kind of form protection to implement. I could break through it in five minutes no matter what the mathematical question is and how random you make it. I agree that reCaptcha is not the easiest text to read however you do not have to get it 100% correct. It is intelligent enough to know that you are human. If you do not want to use reCaptcha then implement your own. There are a plethora of captcha classes here: http://www.phpclasses.org/search.html?words=captcha&x=17&y=9&go_search=1
  14. I have a subscription to that and used to get it posted every month.
  15. I did the same however my solution was to allow the user to enter words to be stored in a database. This is not a solution if you are planning on using the entire dictionary. A simple program ran in the background that looped through each word and checked if it had a definition, synonyms, etc. If it didn't, a simple webbot would be triggered that browsed to thesaurus.com and grabbed the relevent data then inserted it into my database. A user could also trigger the bot by clicking on the word via the front-end interface. A bit of Ajax would display a timer until the bot had completed it's job. i.e http://thesaurus.com/browse/test
  16. If you want to return the values that have no associating records in other tables you must use a LEFT JOIN as opposed to an INNER JOIN. Then your if statement can be contained in the php loop when displaying the results so that if the value in a field is 0 it prints, 'vacant'
  17. I had the pleasure of working with a project that had been made entirely using the following method: <?php function foo() { global $var1; global $var2; global $var3; global $var4; global $var5; echo "<table>"; // rest of function code } function bar() { global $x; global $y; echo "</table>"; // rest of function code } $var1 = "some text"; $var2 = "some text"; $var3 = "some text"; $x = $_POST['x']; $y = $_GET['y']; foo(); bar(); ?> Too one look and said f*** this. Was easier to rewrite entire sections instead of trying to understand the logic.
  18. I was merely answering the question on how to recover session data by using the session_id() function http://uk.php.net/session_id. By no means am I suggesting to use this method. As suggested SSL is there to encrypt the data sent back and forth. Requests should be made over SSL.
  19. You can recover a session if both domains are on the same server. Pass the session ID from one url to another i.e https://www.yourdomain.com/xyz.php?sessId=123456789 You can then recover the data using the following: session_id($_GET['sessId'); session_start();
  20. It is possible that the location of php isn't available. Try adding the path to php in the cron line i.e. 01 * * * * root run-parts /usr/local/bin/php /daemons/hourly.php
  21. Simple. To send as a background process use the following: exec("php /path/to/script.php > /dev/null &");
  22. I tell you what sucks this year. Trying to quit smoking, ahhhhhhhh!
  23. Just to say Merry Christmas to everyone here. Hope you all get a well deserved rest from work. Cheers & have a good New Year.
  24. In the simplest form a simple INT field on your image database table to store a count of the number of times an image is viewed. You may want to check the users IP before incrementing the value as you do not want the same user to keep clicking and incrementing the counter. I would record the IP addresses and images clicked in another table and probably purge once a day as it will quickly fill up with lots of entries. You can then select images with the highest count as the most popular. If you want to do clicks per day then you could have another INT field to record this and have a cron job reset it to 0 at midnight.
×
×
  • 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.