Archive for the ‘progrmming’ category

How to use Chmod

September 29th, 2011

The chmod command is used in Linux-based systems to set permissions on a file or folder. This can be very important in making your website hosted with us function as it should when served to the public.

FTP Usage

If you’re not a Linux guru, this is generally the easiest way to change chmod settings. You can generally modify chmod settings in any FTP client by right clicking on a file or folder and choosing chmod. Generally multiple files or folders can be selected by using the shift or CTRL keys. This feature is also available in the web-based file manager located in your control panel.

CHMOD and File Permission Settings
400 r——– files (won’t let you accidently erase)
444 r–r–r– files (lets everyone read)
600 rw——- files (no one else can read or see files)
644 rw-r–r– files
664 rw-rw-r– files
666 rw-rw-rw- files (note: this could allow serious havoc)
700 rwx—— Programs and Directories
750 rwxr-x— Programs and Directories
755 rwxr-xr-x Programs and Directories
777 rwxrwxrwx Programs and Directories
Note: 777 will produce a wide open executable script, this is dangerous!

SSH Usage

This can also be done via SSH if you’re more familiar with this interface. The chmod command options are specified like this:

$ chmod [options] mode[,mode] file1 [file2 ...]

To view what the permissions currently are, type:

$ ls -l file 
Command line examples
chmod +r file    read is added for all
chmod -x file    execute permission is removed for all
chmod u=rw,go= file    read and write is set for the owner, all permissions are cleared for the group and others
chmod +rw file    change the permissions of the file file to read and write for all.
chmod -R u+w,go-w docs/    change the permissions of the directory docs and all its contents to add write access for the user, and deny write access for everybody else.
chmod file    removes all privileges for all
chmod 664 file    sets read and write access for the owner, the group, and not for all others.
chmod 0755 file    equivalent to u=rwx (4+2+1),go=rx (4+1 & 4+1). The 0 specifies no special modes.
chmod 4755 file    the 4 specifies set user ID and the rest is equivalent to u=rwx (4+2+1),go=rx (4+1 & 4+1).
find path/ -type d -exec chmod a-x {} \;    removes execute permission for all directories (cannot list files) in tree starting from path/ (use ‘-type f’ to match files only).
find path/ -type d -exec chmod a+x {} \;    allows directory browsing (ls for example) for all users if you’ve reset permissions for Samba write access.
chmod -R u+rwX,g-rwx,o-rwx directory    set a directory tree to rwx for owner directories, rw for owner files, — for group and others.
chmod -R a-x+X directory    remove the execute permission on all files in a directory tree, while allowing for directory browsing.

			

Send Email from a PHP Script Using SMTP Authentication

March 30th, 2011

This post about “Sending Mail using SMTP and PHP“. Now you can send emails with SMTP authentication using this script. Every mail needed server authentication, So you have to buy mail server. It’s very useful you can implement this on your web projects.

This tutorial contains three files.

- Index.php //Run Mail Form
- SMTPconfig.php // SMTP Server Cofiguration
- SMTPClass.php // SMTP Mail Sending Class

SMTPconfig.php
You have to change SMTP server details.

<?php
//Server Address

$SmtpServer=”127.0.0.1″;
$SmtpPort=”25″; //default
$SmtpUser=”username”;
$SmtpPass=”password”;
?>

 

SMTPclass.php
SMTP mail sending class.

<?php

class SMTPClient
{

function SMTPClient ($SmtpServer, $SmtpPort, $SmtpUser, $SmtpPass, $from, $to, $subject, $body)
{

$this->SmtpServer = $SmtpServer;
$this->SmtpUser = base64_encode ($SmtpUser);
$this->SmtpPass = base64_encode ($SmtpPass);
$this->from = $from;
$this->to = $to;
$this->subject = $subject;
$this->body = $body;

if ($SmtpPort == “”)
{
$this->PortSMTP = 25;
}

else

{
$this->PortSMTP = $SmtpPort;
}
}

function SendMail ()
{
if ($SMTPIN = fsockopen ($this->SmtpServer, $this->PortSMTP))
{
fputs ($SMTPIN, “EHLO “.$HTTP_HOST.”\r\n”);
$talk["hello"] = fgets ( $SMTPIN, 1024 );
fputs($SMTPIN, “auth login\r\n”);
$talk["res"]=fgets($SMTPIN,1024);
fputs($SMTPIN, $this->SmtpUser.”\r\n”);
$talk["user"]=fgets($SMTPIN,1024);
fputs($SMTPIN, $this->SmtpPass.”\r\n”);
$talk["pass"]=fgets($SMTPIN,256);
fputs ($SMTPIN, “MAIL FROM: <”.$this->from.”>\r\n”);
$talk["From"] = fgets ( $SMTPIN, 1024 );
fputs ($SMTPIN, “RCPT TO: <”.$this->to.”>\r\n”);
$talk["To"] = fgets ($SMTPIN, 1024);
fputs($SMTPIN, “DATA\r\n”);
$talk["data"]=fgets( $SMTPIN,1024 );
fputs($SMTPIN, “To: <”.$this->to.”>\r\nFrom: <”.$this->from.”>\r\nSubject:”.$this->subject.”\r\n\r\n\r\n”.$this->body.”\r\n.\r\n”);
$talk["send"]=fgets($SMTPIN,256);
//CLOSE CONNECTION AND EXIT …
fputs ($SMTPIN, “QUIT\r\n”);
fclose($SMTPIN);

//

}
return $talk;
}
}
?>

 

index.php

<?php

include(‘SMTPconfig.php’);
include(‘SMTPClass.php’);
if($_SERVER["REQUEST_METHOD"] == “POST”)
{
$to = $_POST['to'];
$from = $_POST['from'];
$subject = $_POST['sub'];
$body = $_POST['message'];
$SMTPMail = new SMTPClient ($SmtpServer, $SmtpPort, $SmtpUser, $SmtpPass, $from, $to, $subject, $body);
$SMTPChat = $SMTPMail->SendMail();
}

?>
<form method=”post” action=”">

To:<input type=”text” name=”to” />
From :<input type=’text’ name=”from” />
Subject :<input type=’text’ name=”sub” />
Message :<textarea name=”message”></textarea>
<input type=”submit” value=” Send ” />
</form>

 

Download Source Code

 

What are some of the basic steps to Optimizing your web site?

April 19th, 2010

1.  Meta Research!!!!  The keywords used to describe your web site will be thoroughly researched to insure that you are using the right words – meta tags should contain 10 to 15 of the carefully selected key words and phrases for each page you are submitting to the search engines.

2.  Meta Rich Content! Each page should contain approximately 2,000 words describing your service/product.  We will enrich your text to include the keywords and phrases insuring they are used a minimum of 5% of the content.

3.  Page Techniques: In order to prove to the search engine spiders that your web site is relevant to the meta tags you’ve submitted, several techniques will be applied to your pages.  The quality graphics that make your page visually appealing will not only interest & entice the visitors, but they will entice the search engines after they are encoded with alternate image tags. Heading tags made up of your keywords/phrases will be added to your content.

4.  Doorway/Content Pages: These keyword/key phrase specific optimized pages are designed to rank well with the Search Engines. The goal of doorway pages is utilizing more valuable content within the crawlable pages of a Web site. The idea is to create the page that looks as if it is the main entry page of your web site, but the doorway page only features a particular type of product or service.  It is richly designed with graphics valuable information and an irresistible sales pitch.  It must make high usage of the keywords and key phrases.  It will serve as an introduction to your product/services and thereby entice the visitor to continue viewing your other products & services from text links at the bottom of the page.

PHP Freelancer