I Build Web Sites

Do you need to take your dull website and make it shine? That's what SLiK INTERACTIVE is here to do, offering a range of web design services to meet your internet needs.

  • Mizu
  • Flow Go Riding Center
  • TW's Grille and Bar

Archive for July, 2010

So I know in Wordpress there are several built-in functions for checking what page the user is currently viewing, but I needed to be able to check what page when not using Wordpress. After some searching I found this really simple PHP snippet for doing just that. Add this code somewhere in your PHP file so you can perform an action depending on the current URL:

 

1
2
3
4
5
6
7
8
9
10
<?php
 
$uri = $_SERVER['REQUEST_URI'];
if ($uri == "/") {
      echo "You're on the homepage";
} else {
     echo "You're on an internal page";
}
 
?>

Joomla CHMOD Trick when Installing Extensions


Are you getting Joomla an error like it can’t create a new directory when you try to install an extension? I can’t remember where I found it but this little PHP script will allow you to change the permissions for all of theĀ  necessary folders in one shot when run in a browser. It will save you much time and headache trying to do it one by one. Thanks to the original creator! This is how to use it:


  1. Copy and paste the text into a new text file. Save it as “chmod.php”
  2. Upload the file to the root of your site and go to the following URL in your browser: http://www.yoursite.com/chmod.php?chmod=0777
  3. Upon hitting return, you should get a screen indicating success listing all of the directories of which it has changed the permissions. If something went wrong then you will get a different screen indicating it failed. Usually this is because the base path is wrong in chmod.php. ( The base path is usually something like “httpdocs/” )
  4. Install your extensions
  5. Once you’ve installed your extensions, go to: http://www.yoursite.com/chmod.php?chmod=0755 to change the permissions back to 755 so your files aren’t vulnerable.



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
 
<?php
 
// your ftp credentials
$ftp_server='your_server';
$ftp_user='ftp username';
$ftp_pass='ftp password';
 
// where is Joomla installed? (trailing slash required)
 
$base = 'httpdocs/';
 
// what files or directories need chmod applied? (trailing slash optional)
$dirs = array( 'administrator/backups',
               'administrator/components',
               'administrator/language',
               'administrator/language/en-GB',
               'administrator/modules',
               'administrator/templates',
               'administrator/cache',
               'components',
               'images',
               'images/banners',
               'images/stories',
               'media',
               'language',
               'language/en-GB',
               'language/pdf_fonts',
               'modules',
               'plugins',
               'plugins/content',
               'plugins/editors',
               'plugins/editors-xtd',
               'plugins/search',
               'plugins/system',
               'plugins/user',
               'plugins/xmlrpc',
               'tmp',
               'templates',
               'cache'
             );
 
// default to safe 0755 setting
if ($_GET['chmod']) {
    $ftp_chmod = $_GET['chmod'];
} else {
    $ftp_chmod = "0755";
}
echo "chmod=".$ftp_chmod.'<br/>';
 
// connect via ftp and apply chmod
$conn_id = ftp_connect("$ftp_server");
ftp_login($conn_id, $ftp_user, $ftp_pass);
foreach( $dirs as $dir ){
    if (ftp_site($conn_id, 'CHMOD '.$ftp_chmod.' '.$base.$dir)) {
        echo "success ";
    } else {
        echo "failed ";
    }
    echo $base.$dir.'<br/>';
}
ftp_close($conn_id);
 
echo 'DONE';
?>