Wednesday, September 9, 2015

Goolge Plus Merge Pages with Places Page

Follow the instructions bellow to merge your places page with a normal google plus page.

Situation in brief: I created a very new places page for my company in google plus and our company already having a google plus page.

In your Company / Places Page Account:
  1. Go to Dashboard
  2. Right Top side, there is a Gear Icon click on there and go to settings.
  3. Under the Profile section find "Connect Different Page" button.


Add next and finish your final steps.

Monday, January 26, 2015

PHP Clean URL for SEO

function seo_uri($phrase, $maxLength=50){
  $result = strtolower($phrase);
  $result = preg_replace("/[^a-z0-9\s-]/", "", $result);
  $result = trim(preg_replace("/[\s-]+/", " ", $result));
  $result = trim(substr($result, 0, $maxLength));
  $result = preg_replace("/\s/", "-", $result);
  return $result;
}

Wednesday, April 30, 2014

Installing PHPUnit On Windows

I wanted to start contributing to the WordPress unit tests so I needed to install PHPUnit. Turned out it was harder than it might seem (I had a tough time getting it all working) so I thought I’d blog what finally ended up working for me to help save some people some time.
Assuming you already have PHP and MySQL installed, here’s the steps you need to take:
  1. Install PEAR, a dependency for PHPUnit:
    1. Visit http://pear.php.net/go-pear.phar in your browser and save the file into your PHP directory. This is the folder where you can find php.exe.
    2. Open an administrator command prompt. On Vista or Windows 7, hit your Windows key, type “cmd”, right-click the resulting “cmd.exe” search result, and select “Run as administrator”. Navigate to the folder where you have PHP installed, the same folder where you saved the file in the previous step.
    3. Type the following command to execute the file you just downloaded: php go-pear.phar
    4. After a moment, you should start being prompted for some things. The installer is pretty self-explanatory and I think you want a system installation rather than a local one.
    5. Open the folder where PHP is installed and double-click the PEAR_ENV.reg file that has been created. This allows you to run the pear command from any folder.
    6. Verify PEAR is working by running the command pear version
  2. Install PHPUnit:
    1. Turn on auto_discover in PEAR by typing the following command at the command line: pear config-set auto_discover 1
    2. Download and install PHPUnit by running the following command: pear install pear.phpunit.de/PHPUnit
    3. In order to be able to run the phpunit command from any folder, you need to add it to your Windows Path value. Right-click My Computer → Properties → Advanced system settings → Environmental Variables → select “Path” under “System Variables” → Edit → Add a semi-colon (;) and then the full path to your PHP folder onto the end of the value, for example like this: ;D:\Webserver\php
    4. Verify PHPUnit is working by running the command phpunit --version
  3. Set up the WordPress unit tests by following the rest of the steps on the WordPress Core Contributor Handbook now that you have PHPUnit installed.
Done!

Monday, January 13, 2014

Simple PHP PDO Class Implementation

Simple PHP PDO Class Implementation

$host = "127.0.0.1";
$db = "sample";
$username = "root";
$password = "";

$database = new PDO("mysql:host=" . $host . ";dbname=" . $db, $username, $password);

function find_user($username) {
 global $database;
 $p = $database->prepare("SELECT * FROM member WHERE username = ?");
 $p->execute(array($username));
 return $p->fetchObject();
}

$results = find_user("admin");
var_dump($results);

Out put of this function will be like bellow.
object(stdClass)[3]
  public 'id' => string '4' (length=1)
  public 'username' => string 'admin' (length=5)
  public 'password' => string '240824aa0487bca3bdd4deb847954b76' (length=32)
  public 'email' => string 'bthssssiban@gmail.com' (length=17)
  public 'postcode' => string 'Q2Z23S' (length=6)
  public 'status' => string 'Inactive' (length=8)
  public 'code' => string '4172f3101212a2009c74b547b6ddf935' (length=32)
  public '_date' => string '2011-02-17' (length=10)


echo $results->username; will prints the output of the username of value from the database.

Friday, January 10, 2014

Create htaccess folder password with htpasswd

Create htaccess folder password with htpasswd

Lets create the .htaccess file first

<IfModule mod_rewrite.c>
RewriteEngine off
</IfModule>
AuthName "Are You Real User"
AuthType Basic
AuthUserFile "/home/apweb/www/yourfolder/xo/.htpasswd"
require valid-user

Now we create the .htpasswd file, we have to generate the password so it will look like this

root:$apr1$2mMeQzaz$577FZ5p/E8EpdrsoVWFRg0

Please use the following URL to generate the username and the password



Finally copy and paste the generated code to your .htpasswd file and uplaod in to the server
Good Luck!

Thursday, November 21, 2013

Disable directory browsing in CentOs 6.4 apache/httpd

How to Disable directory browsing in apache httpd.conf ?


Answer: Actually you are totally right that you wish to disable this feature. One of the “must do’s” on setting a secure apache web server is to disable directory browsing. Usually apache comes with this feature enabled but its always a good idea to get it disabled unless you really need it.

First of all find where is the main apache’s config file httpd.conf is located. If you use Debian, it should be here: /etc/apache/httpd.conf. Using some file editor like Vim or Nano open this file and find the line that looks as follows:

Options Includes Indexes FollowSymLinks MultiViews

then remove word Indexes and save the file. The line should look like this one:

Options Includes FollowSymLinks MultiViews

for the subdomains:

To allow directory browsing for sub-domains and blocked in the main domain as become as follow.
Options Includes FollowSymLinks MultiViews
<VirtualHost *:80>
DocumentRoot "/var/www/downloads"
ServerName downloads.facebook.com
ErrorLog "logs/facebook"
CustomLog "logs/facebook_custom" common
<Directory "/var/www/downloads">
allow from all
Options +Indexes
</Directory>
</VirtualHost>

If no file from the DirectoryIndex directive can be located in the directory, then mod_autoindex can generate a listing of the directory contents. This is turned on and off using the Options directive. For example, to turn on directory listings for a particular directory, you can use:

<Directory /usr/local/apache2/htdocs/listme>
  Options +Indexes
</Directory>

To prevent directory listings (for security purposes, for example), you should remove the Indexes keyword from every Options directive in your configuration file. Or to prevent them only for a single directory, you can use:
<Directory /usr/local/apache2/htdocs/dontlistme>
  Options -Indexes
</Directory>

CentOS 6.4 Create FTP Users

How to Create FTP Users in CentOs 6.4?

- Add a user called "bira"
# useradd bira

Add a password for the user "bira"
# passwd bira (Enter)

New password: (enter your password)

Retype new password: (enter the same password again)
passwd: all authentication tokens updated successfully.

Now give the directory access for the user.
Change the ownership for the "html" directory 
# chown bira /var/www/html

Change the group for this "html" directory .
#chgrp bira /var/www/html

list the directories and check
# ls -l
drwxr-xr-x. 3 bira bira 4096 Nov 21 13:23 html

Finally re-start the vsfptd server.
# service vsftpd restart

All done! just trying to connect with your FileZilla ftp client.

if not:

Do you have SELinux enabled?

To check: # sestatus

If SELinuxstatus = on & Current mode = enforcing, it's all enabled... 
so lets turn it to permissive mode.

Permissive mode: # setenforce 0

Check sestatus again, and it should be Current mode = permissive. This basically leaves SELinux on, but in a log only manner.

All done! just trying to connect with your FileZilla ftp client.

If you still having issues please let me know my self.