Thursday, 28 February 2013

Lesson 2


SEO techniques are classified into two broad categories:
  1. Techniques that search engines recommend as part of good design referred to as White Hat SEO, and
  2. Techniques that search engines do not approve and attempt to minimize the effect of referred to as Black Hat or spamdexing.
White Hat SEO:
An SEO tactic, technique or method is considered as White Hat if it follows the followings
  • If it conforms to the search engine's guidelines.
  • If it does not involves any deception.
  • It ensures that the content a search engine indexes and subsequently ranks is the same content a user will see.
  • It ensures that a Web Page content should have been created for the users and not just for the search engines.
  • It ensures the good quality of the web pages
  • It ensures the useful content available on the web pages
Always follow a White Hat SEO tactic and don't try to fool your site visitors. Be honest and definitely you will get something more.
Next chapter onward we will put light on White Hap SEO techniques. The WHST are very simple and can be done without investing much cost.
Black Hat or Spamdexing:
An SEO tactic, technique or method is considered as Black Hat or Spamdexing if it follows the followings
  • Try to improve rankings that are disapproved of by the search engines and/or involve deception.
  • Redirecting users from a page that is built for search engines to one that is more human friendly.
  • Redirecting users to a page that was different from the page the search engine ranked.
  • Serving one version of a page to search engine spiders/bots and another version to human visitors. This is called Cloaking SEO tactic.
  • Using Hidden or invisible text or with the page background color, using a tiny font size or hiding them within the HTML code such as "no frame" sections.
  • Repeating keywords in the Meta tags, and using keywords that are unrelated to the site's content. This is called Meta tag stuffing.
  • Calculated placement of keywords within a page to raise the keyword count, variety, and density of the page. This is called Keyword stuffing .
  • Creating low-quality web pages that contain very little content but are instead stuffed with very similar key words and phrases. These pages are called Doorway or Gateway Pages
  • Mirror web sites by hosting multiple web sites all with conceptually similar content but using different URLs.
  • Creating a rogue copy of a popular web site which shows contents similar to the original to a web crawler, but redirects web surfers to unrelated or malicious web sites. This is called Page hijacking.
Always be away to adopt any of the above Black Hat tactic to improve the rank of your site. Search engines are smart enough to identify all the above proprieties of your site and ultimately you are not going to get anything.

Sending SMS from the webpage

Introduction

In this article we will see an example of sending sms through the way2sms account. There are two pages in the demo

1. login.aspx 
2. Sms.aspx

This is the login.aspx where you have to provide your way2sms username and password

NOTE: If you don't have account in way2sms, before using this demo you have to create account in way2sms.com

1.gif

protected
void btnconnect_Click(object sender, EventArgs e){    Session["id"] = txtmobileno.Text;    Session["pw"] = txtpw.Text;    Response.Redirect("send.aspx");}
Send.aspx

In this page two functions are created

1. Connect() this function will connect and authenticate your id and password
2. Sendsms(): If you are successfully connected they you will get the following page and you can send sms now


2.gif
Send.aspx.cs

using
System;using System.Data;using System.Configuration;using System.Collections;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;using System.IO;using System.Net;using System.Text;using System.Text.RegularExpressions;
public
partial class send : System.Web.UI.Page{    string mbno, mseg, ckuser, ckpass;    private HttpWebRequest req;    private CookieContainer cookieCntr;    private string strNewValue;    public static string responseee;    private HttpWebResponse response; 
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["id"] == null && Session["pw"] == null)
        {
            Server.Transfer("login.aspx");
        }
        connect();
 
        try
        {
            lblError.Text = "";
            lblError.Visible = false;
            if (!(IsPostBack))
            {
                btnSend.Attributes.Add("onclick", "return Validate('" + txtTo.ClientID + "','" + txtMessage.ClientID + "');");
                txtMessage.Attributes.Add("onchange", "TextChange('" + txtMessage.ClientID + "','" + lblLeft.ClientID + "');");
                txtMessage.Attributes.Add("onkeyup", "TextChange('" + txtMessage.ClientID + "','" + lblLeft.ClientID + "');");
            }
        }
        catch (Exception ex)
        {
            lblError.Text = ex.Message;
            lblError.Visible = true;
        }
       
    }
    protected void btnSend_Click(object sender, EventArgs e)
    {
        try
        {
            mbno = txtTo.Text;
            mseg = txtMessage.Text;
 
            sendSms(mbno, mseg);
            txtTo.Text = "";
            txtMessage.Text = "";
        }
        catch (Exception ex)
        {
            lblError.Text = ex.Message;
            lblError.Visible = true;
        }
    }
    public void connect()
    {
        ckuser = Session["id"].ToString();
        ckpass = Session["pw"].ToString();
 
        try
        {
            this.req = (HttpWebRequest)WebRequest.Create("http://wwwd.way2sms.com/auth.cl");
 
            this.req.CookieContainer = new CookieContainer();
            this.req.AllowAutoRedirect = false;
            this.req.Method = "POST";
            this.req.ContentType = "application/x-www-form-urlencoded";
            this.strNewValue = "username=" + ckuser + "&password=" + ckpass;
            this.req.ContentLength = this.strNewValue.Length;
            StreamWriter writer = new StreamWriter(this.req.GetRequestStream(), Encoding.ASCII);
            writer.Write(this.strNewValue);
            writer.Close();
            this.response = (HttpWebResponse)this.req.GetResponse();
            this.cookieCntr = this.req.CookieContainer;
            this.response.Close();
            this.req = (HttpWebRequest)WebRequest.Create("http://wwwd.way2sms.com//jsp/InstantSMS.jsp?val=0");
            this.req.CookieContainer = this.cookieCntr;
            this.req.Method = "GET";
            this.response = (HttpWebResponse)this.req.GetResponse();
            responseee = new StreamReader(this.response.GetResponseStream()).ReadToEnd();
            int index = Regex.Match(responseee, "custf").Index;
            responseee = responseee.Substring(index, 0x12);
            responseee = responseee.Replace("\"", "").Replace(">", "").Trim();
            this.response.Close();
 
            pnlsend.Visible = true;
            lblErrormsg.Text = "connected";
        }
        catch (Exception)
        {
            lblErrormsg.Text = "Error connecting to the server...";
            Session["error"] = "Error connecting to the server...";
            Server.Transfer("login.aspx"); 
        }
    }
    public void sendSms(string mbno, string mseg)
    {
        if ((mbno != "") && (mseg != ""))
        {
            try
            {
                this.req = (HttpWebRequest)WebRequest.Create("http://wwwd.way2sms.com//FirstServletsms?custid=");
                this.req.AllowAutoRedirect = false;
                this.req.CookieContainer = this.cookieCntr;
                this.req.Method = "POST";
                this.req.ContentType = "application/x-www-form-urlencoded";
                this.strNewValue = "custid=undefined&HiddenAction=instantsms&Action=" + responseee + "&login=&pass=&MobNo=" + this.mbno + "&textArea=" + this.mseg;
 
                string msg = this.mseg;
                string mbeno = this.mbno;
 
                this.req.ContentLength = this.strNewValue.Length;
                StreamWriter writer = new StreamWriter(this.req.GetRequestStream(), Encoding.ASCII);
                writer.Write(this.strNewValue);
                writer.Close();
                this.response = (HttpWebResponse)this.req.GetResponse(); 
                this.response.Close();
                lblErrormsg.Text = "Message Sent..... " + mbeno + ": " + msg;
            }
            catch (Exception)
            {
                lblErrormsg.Text = "Error Sending msg....check your connection...";
            }
        }
        else
        {
            lblErrormsg.Text = "Mob no or msg missing";
        }
    }
 
    protected void logout_Click(object sender, EventArgs e)
    {
        //logout
        Session["id"] = null;
        Session["pw"] = null;
        Session["error"] = null;
        Server.Transfer("login.aspx");
    }
}

Friday, 15 February 2013

Date Time Formate

-->


In SQL Server used Cast or Convert function to Format DateTime value or column into a specific date format.Both function are used to convert datetime to varchar or string.

CAST function Syntax: CAST(expression as data_type)

Let's convert current date time to varchar

select cast(getdate() as varchar)

CONVERT function is used to change or convert the DateTime formats.By using convert
function you can get only Date part or only Time part from the datetime.

CONVERT Function Syntax- 
 CONVERT(data_type,expression,date Format style)

Let's take Sql Server DateTtime styles example:



Format

Query


USA mm/dd/yy


select convert(varchar, getdate(), 1)

ANSI yy.mm.dd


select convert(varchar, getdate(), 2)

British/French dd/mm/yy

select convert(varchar, getdate(), 3)


German dd.mm.yy

select convert(varchar, getdate(), 4)


Italian dd-mm-yy


select convert(varchar, getdate(), 5)

dd mon yy


select convert(varchar, getdate(), 6)

Mon dd, yy

select convert(varchar, getdate(), 7)


USA mm-dd-yy


select convert(varchar, getdate(), 10)

JAPAN yy/mm/dd


select convert(varchar, getdate(), 11)

ISO yymmdd

select convert(varchar, getdate(), 12)


mon dd yyyy hh:miAM

(or PM)

select convert(varchar, getdate(), 100)

mm/dd/yyyy

select convert(varchar, getdate(), 101)


yyyy.mm.dd

select convert(varchar, getdate(), 102)


dd/mm/yyyy


select convert(varchar, getdate(), 103)

dd.mm.yyyy


select convert(varchar, getdate(), 104)

dd-mm-yyyy

select convert(varchar, getdate(), 105)


dd mon yyyy

select convert(varchar, getdate(), 106)


Mon dd, yyyy

select convert(varchar, getdate(), 107)


hh:mm:ss

select convert(varchar, getdate(), 108)


Default +
milliseconds mon dd yyyy hh:mi:ss:mmmAM (or PM)


select convert(varchar, getdate(), 109)

mm-dd-yyyy

select convert(varchar, getdate(), 110)


yyyy/mm/dd


select convert(varchar, getdate(), 111)

yyyymmdd


select convert(varchar, getdate(), 112)

Europe default +
milliseconds dd mon yyyy hh:mm:ss:mmm(24h)


select convert(varchar, getdate(), 113) or
select convert(varchar, getdate(),
13)

hh:mi:ss:mmm(24h)

select convert(varchar, getdate(), 114)