| | |
Create a script that checks if "file.txt" is chmoded 777, and if mod_rewrite = on
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
Create a script that checks if "file.txt" is chmoded 777, and if mod_rewrite = on
0
#1 Jan 4th, 2009
•
•
Join Date: Jan 2009
Posts: 4
Reputation:
Solved Threads: 0
Re: Create a script that checks if "file.txt" is chmoded 777, and if mod_rewrite = on
0
#2 Jan 5th, 2009
•
•
•
•
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
Create a file called test.php
add the code below to test.php
PHP Syntax (Toggle Plain Text)
<?php echo substr(sprintf('%o', fileperms('latest.txt')), -4); echo '<br>'; echo substr(sprintf('%o', fileperms('count.txt')), -4); echo '<br>'; echo substr(sprintf('%o', fileperms('comments.txt')), -4); ?>
To check if Check if mod_rewrite is enabled
You have to do this.
PHP Syntax (Toggle Plain Text)
1. Create a php file called "rewrite.php" with your text editor (notepad) 2. Copy and paste the following code into rewrite.php Code/Command: <h2 align=center> <? if($_GET['link']==1){echo"You are not using mod_rewrite";} elseif($_GET['link']==2){echo"Congratulations!! You are using Apache mod_rewrite";} else{echo"Linux Apache mod_rewrte Test Tutorial";} ?> </h2> <hr> <head> <title>How To Test mod_rewrite in Apache Linux Server</title> </head> <body> <br><p><ahref="rewrite.php?link=1">LINK1</a>= rewrite.php?link=1</p> <p><a href="link2.html">LINK2</a> = link2.html</p> <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> </body> </html> 3. Save rewrite.php 4. Now create a file called .htaccess with your text editor like notepad 5. Copy and paster the following code into the .htaccess file: Code/Command: RewriteEngine On RewriteRule ^link([^/]*).html$ rewrite.php?link=$1 [L] 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) 7. Now upload these two file into a new directory in your site. for example: test 8. Pull the rewrite.php file with your browser to the location you just upoaded. 9. you should see two links, LINK1 and LINK2 Click on LINK1 and the same page will display. 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. 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.
Re: Create a script that checks if "file.txt" is chmoded 777, and if mod_rewrite = on
0
#3 Jan 5th, 2009
•
•
•
•
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)
<?php echo substr(sprintf('%o', fileperms('latest.txt')), -4); echo '<br>'; echo substr(sprintf('%o', fileperms('count.txt')), -4); echo '<br>'; echo substr(sprintf('%o', fileperms('comments.txt')), -4); ?>
I found the cURL check function:
•
•
•
•
<?php
if (!function_exists('curl_init'))
echo "OK";
elseif (function_exists('curl_init'))
echo "Curl is installed";
?>
![]() |
Other Threads in the PHP Forum
- Previous Thread: Help for MySQl display
- Next Thread: Website rating!!!
| Thread Tools | Search this Thread |
.htaccess alerts apache api archive array autocomplete beginner binary broken cakephp checkbox class cms code convert cron curl database date display duplicates dynamic echo email emptydisplayvalue error errors explodefunction file files folder form forms function functions google hack href htaccess html htmlspecialchars image include insert ip javasciptvalidation javascript joomla keywords limit link login loop mail menu methods mlm multiple mysql network object oop paypal pdf php problem query radio random recursion recursive redirect regex remote script search securephp server sessions shot sms soap source space sql subscription syntax system table tutorial update upload url validator variable video web xml youtube





