Pages

Saturday, April 5, 2014

Drupal Softaculous Installation Tutorial

The purpose of this tutorial is to show you how to install a Drupal CMS application to your site via the Softaculous auto installer. One of the great things about Softaculous is that it allows you to setup applications really fast. You don't need to go through all steps manually and with just several clicks you will have a fully functional Drupal on your account.
First, you need to access your cPanel account and find the Softaculous icon which is under the "Software/Services" section. Usually, it is located in the lower part of your cPanel page, right under the "Domains" section.
The next step is to click on the Softaculous icon. You will be redirected to a new page which is the auto installer's control panel. From here you can install new apps, create backups, import existing websites, etc. On the left side of the screen is the categories menu. To proceed with the Drupal installation find the "Portal/CMS" section and click on it to expand . You will see a list of applications that you can install. Find the Drupal link and click on it, so that Softaculous will open the Drupal installation screen.
The next page which you will see provides a brief description of the Drupal application and its features. You can also read review about the platform and rate it. Click on the blue "Install" button:
This is the most important step at which you need to provide more details about the new Drupal website. Most of the fields are automatically filled by Softaculous for your convenience. However, we strongly advise you to change the values of the following crucial configuration parameters:
  • Site Name: This is the name of your website and by default it is set to "My Drupal". You should change it to something that describes the main purpose of your new website.
  • Admin Username: By default this field is set to "admin". Many people use "admin" to access their websites and hackers can easily guess your username. That is why we advise you to change it in order to enhance your website's protection.
  • Admin Password: Softaculous automatically generates a unique password for your new website. Still, you can change the string in the field and type a new password which you can remember more easily.
Please note that by default Softaculous will install the Drupal application in the root web folder and you will be able to access the website via your domain name. If you prefer to install it in a subfolder, for example "drupal", enter its name in the "Directory" field.
The last step is to scroll down to the end of the page and click on the "Install" button.
That's it! Your Drupal application is installed and ready to use. The installer will redirect you to a new page where you will see the details for the completed installation. You can now login and create your Drupal website.

Facebook login using PHP SDK and Javascript SDK

In this article we are going to learn about facebook login using PHP and Javascript SDK. For using PHP SDK you need to check is your server is cURL enabled. PHP SDK will post the information using PHP cURL. We are using the both PHP, Javascript SDK for avoid page redirecting and stay your website user in the same page withour any redirection using popup.

First goto facebook developers account and create and app there. You will get Appid and Secret Key from there. Download the Facebook PHP SDK, from facebbok developers or github extract that save it to your folder.
Design the login page and include the facebook Javascript SDK:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
window.fbAsyncInit = function() {
    FB.init({
    appId      : 'XXXXXXXXXXXX', // replace your app id here
    channelUrl : '//WWW.YOUR_DOMAIN.COM/channel.html',
    status     : true,
    cookie     : true,
    xfbml      : true 
    });
};
(function(d){
    var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
    if (d.getElementById(id)) {return;}
    js = d.createElement('script'); js.id = id; js.async = true;
    js.src = "//connect.facebook.net/en_US/all.js";
    ref.parentNode.insertBefore(js, ref);
}(document));
include the above script in the index page inside <head> tag,
Create Javascript funtion for facebook login:
1
2
3
4
5
6
7
function FBLogin(){
    FB.login(function(response){
        if(response.authResponse){
            window.location.href = "actions.php?action=fblogin";
        }
    }, {scope: 'email,user_likes'});
}
Design the button for facebook login:
1
<img src="facebook-connect.png" alt="Fb Connect" title="Login with facebook" onclick="FBLogin();"/>
The whole index page will be like this:
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
<script type="text/javascript">
window.fbAsyncInit = function() {
    FB.init({
    appId      : 'XXXXXXXXXXX', // replace your app id here
    channelUrl : '//WWW.YOUR_DOMAIN.COM/channel.html',
    status     : true,
    cookie     : true,
    xfbml      : true 
    });
};
(function(d){
    var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
    if (d.getElementById(id)) {return;}
    js = d.createElement('script'); js.id = id; js.async = true;
    js.src = "//connect.facebook.net/en_US/all.js";
    ref.parentNode.insertBefore(js, ref);
}(document));
 
function FBLogin(){
    FB.login(function(response){
        if(response.authResponse){
            window.location.href = "actions.php?action=fblogin";
        }
    }, {scope: 'email,user_likes'});
}
</script>
<style>
body{
    font-family:Arial;
    color:#333;
    font-size:14px;
}
</style>
</head>
 
<body>
<h1>Asif18 tutorial for facebook ling using php, javascript sdk dymaically</h1>
<img src="facebook-connect.png" alt="Fb Connect" title="Login with facebook" onclick="FBLogin();"/>
</body>
</html>
By the above you will get a page with dynamic facebook login dialogue box. Next  we need to save the user details using PHP SDK
Include the facebook.php file in new actions.php file:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
include 'facebook.php';
    $appid      = "XXXXXXXXXX";
    $appsecret  = "XXXXXXXXXXXXXXXXXX";
    $facebook   = new Facebook(array(
        'appId' => $appid,
        'secret' => $appsecret,
        'cookie' => TRUE,
    ));
    $fbuser = $facebook->getUser();
    if ($fbuser) {
        try {
            $user_profile = $facebook->api('/me');
        }
        catch (Exception $e) {
            echo $e->getMessage();
            exit();
        }
        $user_fbid  = $fbuser;
        $user_email = $user_profile["email"];
        $user_fnmae = $user_profile["first_name"];
        $user_image = "https://graph.facebook.com/".$user_fbid."/picture?type=large";
        /* Save the user details in your db here */
        }
    }
Create FB logout function for logout the user directly from facebook:
1
2
3
4
5
function FBLogout(){
    FB.logout(function(response) {
        window.location.href = "index.php";
    });
}
Design and view the user details here:
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
<style>
body{
    font-family:Arial;
    color:#333;
    font-size:14px;
}
.mytable{
    margin:0 auto;
    width:600px;
    border:2px dashed #17A3F7;
}
a{
    color:#0C92BE;
    cursor:pointer;
}
</style>
<table class="mytable">
<tr>
    <td colspan="2" align="left"><h2>Hi <?php echo $user_fnmae; ?>,</h2><a onClick="FBLogout();">Logout</a></td>
</tr>
<tr>
    <td><b>Fb id:<?php echo $user_fbid; ?></b></td>
    <td valign="top" rowspan="2"><img src="<?php echo $user_image; ?>" height="100"/></td>
</tr>
<tr>
    <td><b>Email:<?php echo $user_email; ?></b></td>
</tr>
</table>
Finally the actions.php file will be like this:
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
include 'facebook.php';
    $appid      = "XXXXXXXXX";
    $appsecret  = "XXXXXXXXXXXXXXXXXXXXX";
    $facebook   = new Facebook(array(
        'appId' => $appid,
        'secret' => $appsecret,
        'cookie' => TRUE,
    ));
    $fbuser = $facebook->getUser();
    if ($fbuser) {
        try {
            $user_profile = $facebook->api('/me');
        }
        catch (Exception $e) {
            echo $e->getMessage();
            exit();
        }
        $user_fbid  = $fbuser;
        $user_email = $user_profile["email"];
        $user_fnmae = $user_profile["first_name"];
        $user_image = "https://graph.facebook.com/".$user_fbid."/picture?type=large";
        $check_select = mysql_num_rows(mysql_query("SELECT * FROM `fblogin` WHERE email = '$user_email'"));
        if($check_select > 0){
            mysql_query("INSERT INTO `fblogin` (fb_id, name, email, image, postdate) VALUES ('$user_fbid', '$user_fnmae', '$user_email', '$user_image', '$now')");
        }
    }
    break;
}
?>
<!DOCTYPE html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Asif18 tutorial about facebook login for mywebsite using php sdk</title>
<script type="text/javascript">
window.fbAsyncInit = function() {
    FB.init({
    appId      : 'XXXXXXXX', // replace your app id here
    channelUrl : '//WWW.YOUR_DOMAIN.COM/channel.html',
    status     : true,
    cookie     : true,
    xfbml      : true 
    });
};
(function(d){
    var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
    if (d.getElementById(id)) {return;}
    js = d.createElement('script'); js.id = id; js.async = true;
    js.src = "//connect.facebook.net/en_US/all.js";
    ref.parentNode.insertBefore(js, ref);
}(document));
 
function FBLogout(){
    FB.logout(function(response) {
        window.location.href = "index.php";
    });
}
</script>
<style>
body{
    font-family:Arial;
    color:#333;
    font-size:14px;
}
.mytable{
    margin:0 auto;
    width:600px;
    border:2px dashed #17A3F7;
}
a{
    color:#0C92BE;
    cursor:pointer;
}
</style>
</head>
 
<body>
<h1>Asif18 tutorial for facebook ling using php, javascript sdk dymaically</h1>
<h3>here is the user details, for more details </h3>
<table class="mytable">
<tr>
    <td colspan="2" align="left"><h2>Hi <?php echo $user_fnmae; ?>,</h2><a onClick="FBLogout();">Logout</a></td>
</tr>
<tr>
    <td><b>Fb id:<?php echo $user_fbid; ?></b></td>
    <td valign="top" rowspan="2"><img src="<?php echo $user_image; ?>" height="100"/></td>
</tr>
<tr>
    <td><b>Email:<?php echo $user_email; ?></b></td>
</tr>
</table>
</body>
</html>