943,741 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 1291
  • PHP RSS
Jan 4th, 2009
0

Create a script that checks if "file.txt" is chmoded 777, and if mod_rewrite = on

Expand Post »
Can someone help me creating a script that can check these things:
if latest.txt is chmoded 777
if count.txt is chmoded 777
if comments.txt is chmoded 777

Check if cURL is enabled
Check if mod_rewrite is enabled
Reputation Points: 7
Solved Threads: 14
Junior Poster
smartness is offline Offline
103 posts
since Aug 2007
Jan 5th, 2009
0

Re: Create a script that checks if "file.txt" is chmoded 777, and if mod_rewrite = on

Click to Expand / Collapse  Quote originally posted by smartness ...
Can someone help me creating a script that can check these things:
if latest.txt is chmoded 777
if count.txt is chmoded 777
if comments.txt is chmoded 777

Check if cURL is enabled
Check if mod_rewrite is enabled
You can check the Permissions of a file like this
Create a file called test.php
add the code below to test.php
PHP Syntax (Toggle Plain Text)
  1. <?php
  2. echo substr(sprintf('%o', fileperms('latest.txt')), -4);
  3. echo '<br>';
  4. echo substr(sprintf('%o', fileperms('count.txt')), -4);
  5. echo '<br>';
  6. echo substr(sprintf('%o', fileperms('comments.txt')), -4);
  7. ?>

To check if Check if mod_rewrite is enabled
You have to do this.
PHP Syntax (Toggle Plain Text)
  1. 1. Create a php file called "rewrite.php" with your text editor (notepad)
  2. 2. Copy and paste the following code into rewrite.php
  3. Code/Command:
  4. <h2 align=center>
  5. <?
  6.  
  7. if($_GET['link']==1){echo"You are not using mod_rewrite";}
  8. elseif($_GET['link']==2){echo"Congratulations!! You are using Apache mod_rewrite";}
  9. else{echo"Linux Apache mod_rewrte Test Tutorial";}
  10. ?>
  11. </h2>
  12.  
  13. <hr>
  14.  
  15. <head>
  16. <title>How To Test mod_rewrite in Apache Linux Server</title>
  17. </head>
  18.  
  19. <body>
  20. <br><p><ahref="rewrite.php?link=1">LINK1</a>= rewrite.php?link=1</p>
  21. <p><a href="link2.html">LINK2</a> = link2.html</p>
  22. <p>How this works: both links are for this same page, except they both are different. link one is without the mod_rewrite and link2 is using mod_rewrite. Link1 show the php file, with with mod_rewrite we are mascarading the php file into a html file. you can use whatever type of extension you want, you can change it to .htm or .shtml etc... all you have to do is to make sure you also chang it in the .htaccess file</p>
  23.  
  24. </body>
  25. </html>
  26.  
  27.  
  28. 3. Save rewrite.php
  29. 4. Now create a file called .htaccess with your text editor like notepad
  30. 5. Copy and paster the following code into the .htaccess file:
  31. Code/Command:
  32. RewriteEngine On
  33. RewriteRule ^link([^/]*).html$ rewrite.php?link=$1 [L]
  34.  
  35. 6. Save as .htaccess (if you are using notepad as I am, make sure to put quotes in between. example: ".htaccess" otherwise, notepad will create a file called .htacces.txt and we don't need the .txt at the end only .htaccess)
  36. 7. Now upload these two file into a new directory in your site. for example: test
  37. 8. Pull the rewrite.php file with your browser to the location you just upoaded.
  38. 9. you should see two links, LINK1 and LINK2 Click on LINK1 and the same page will display.
  39. 10. Now click on LINK2 and the same page will display with the a mod_rewrite message. If it doesnt you either did something wrong. Check your steps. If you checked your steps, refresh your browser, and if refreshing doesnt work, then you dont have mod_rewrite enabled.
  40.  
  41. If you get a 500 Error, then you do not have mod_rewrite enabled in your server. Or if mod_rewrite is not working for you and you are a Smedia customer, please contact our support team to assist you.
  42.  
Reputation Points: 10
Solved Threads: 0
Newbie Poster
wxflint is offline Offline
15 posts
since Jan 2009
Jan 5th, 2009
0

Re: Create a script that checks if "file.txt" is chmoded 777, and if mod_rewrite = on

Quote ...
You can check the Permissions of a file like this
Create a file called test.php
add the code below to test.php
PHP Syntax (Toggle Plain Text)
  1. <?php
  2. echo substr(sprintf('%o', fileperms('latest.txt')), -4);
  3. echo '<br>';
  4. echo substr(sprintf('%o', fileperms('count.txt')), -4);
  5. echo '<br>';
  6. echo substr(sprintf('%o', fileperms('comments.txt')), -4);
  7. ?>
Can you help me on Echoing error message for each file if not writeable, or echo a Other Message if writeable

I found the cURL check function:
Quote ...
<?php

if (!function_exists('curl_init'))
echo "OK";


elseif (function_exists('curl_init'))
echo "Curl is installed";


?>
Reputation Points: 7
Solved Threads: 14
Junior Poster
smartness is offline Offline
103 posts
since Aug 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: Help for MySQl display
Next Thread in PHP Forum Timeline: Website rating!!!





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC