Editorial

LolaTheriotRelease: MVC 2 Editor Template for Radio Buttons

Tuesday, June 8th, 2010

How to create an HTML helper to produce a radio button list? Here, the HTML helper was “wrapping” the FluentHtml library from MvcContrib to produce the following html output (given an IEnumerable list containing the items “Foo” and “Bar”):

   1:  <div>
   2:      <input id="Name_Foo" name="Name" type="radio" value="Foo" /><label for="Name
_Foo" id="Name_Foo_Label">Foo</label>
   3:      <input id="Name_Bar" name="Name" type="radio" value="Bar" /><label for="Name
_Bar" id="Name_Bar_Label">Bar</label>
   4:  </div>

MVC 2 has released, providing an editor template that can be used as it rely on metadata, which allow us to customize the views appropriately.  For example, for the radio buttons above, we want the “id” attribute to be differentiated and unique and we want the “name” attribute to be the same across radio buttons so the buttons will be grouped together and so model binding will work appropriately. We also want the “for” attribute in the <label> element being set to correctly point to the id of the corresponding radio button.

The default behavior of the RadioButtonFor() method that comes OOTB with MVC produces the same value for the “id” and “name” attributes so this isn’t exactly what I want out the box if I’m trying to produce the HTML mark up above.

If we use an EditorTemplate, the first gotcha that we run into is that, by default, the templates just work on your view model’s property. But in this case, we *also* was the list of items to populate all the radio buttons. It turns out that the EditorFor() methods do give you a way to pass in additional data. There is an overload of the EditorFor() method where the last parameter allows you to pass an anonymous object for “extra” data that you can use in your view – it gets put on the view data dictionary:

   1:  <%: Html.EditorFor(m => m.Name, "RadioButtonList", new { selectList = new SelectList(new[] 
{ "Foo", "Bar" }) })%>

Now we can create a file called RadioButtonList.ascx that looks like this:

   1:  <%@ Control Inherits="System.Web.Mvc.ViewUserControl" %>
   2:  <%
   3:      var list = this.ViewData["selectList"] as SelectList;
   4:  %>
   5:  <div>
   6:      <% foreach (var item in list) {
   7:             var radioId = ViewData.TemplateInfo.GetFullHtmlFieldId(item.Value);
   8:             var checkedAttr = item.Selected ? "checked=\"checked\"" : string.Empty;
   9:      %>
  10:          <input type="radio" id="<%: radioId %>" name="<%: ViewData.TemplateInfo.HtmlFieldPrefix 
%>" value="<%: item.Value %>" <%: checkedAttr %>/>
  11:          <label for="<%: radioId %>"><%: item.Text %></label>
  12:      <% } %>
  13:  </div>

IN the above code, there are several things that to be noted. First, you can see in line #3, it’s getting the SelectList out of the view data dictionary. Then on line #7 it uses the GetFullHtmlFieldId() method from the TemplateInfo class to ensure to get unique IDs. We pass the Value to this method so that it will produce IDs like “Name_Foo” and “Name_Bar” rather than just “Name” which is our property name. However, for the “name” attribute (on line #10) we can just use the normal HtmlFieldPrefix property so that we ensure all radio buttons have the same name which corresponds to the view model’s property name. We also get to leverage the fact the a SelectListItem has a Boolean Selected property so we can set the checkedAttr variable on line #8 and use it on line #10. Finally, it’s trivial to set the correct “for” attribute for the <label> on line #11 since we already produced that value.

Because the TemplateInfo class provides all the metadata for our view, we’re able to produce this view that is widely re-usable across our application. In fact, we can create a couple HTML helpers to better encapsulate this call and make it more user friendly:

   1:  public static MvcHtmlString RadioButtonList<TModel, TProperty>(this HtmlHelper<TModel> 
htmlHelper, Expression<Func<TModel, TProperty>> expression, params string[] items)
   2:  {
   3:      return htmlHelper.RadioButtonList(expression, new SelectList(items));
   4:  }
   5:
   6:  public static MvcHtmlString RadioButtonList<TModel, TProperty>(this HtmlHelper<TModel> 
htmlHelper, Expression<Func<TModel, TProperty>> expression, IEnumerable<SelectListItem> items)
   7:  {
   8:      var func = expression.Compile();
   9:      var result = func(htmlHelper.ViewData.Model);
  10:      var list = new SelectList(items, "Value", "Text", result);
  11:      return htmlHelper.EditorFor(expression, "RadioButtonList", new { selectList = list });
  12:  }

This allows us to simply the call like this:

   1:  <%: Html.RadioButtonList(m => m.Name, "Foo", "Bar" ) %>

In that example, the values for the radio button are hard-coded and being passed in directly. But if you had a view model that contained a property for the collection of items you could call the second overload like this:

   1:  <%: Html.RadioButtonList(m => m.Name, Model.FooBarList ) %>

The Editor templates introduced in MVC 2 definitely allow for much more flexible views/editors than previously available.

Source: http://geekswithblogs.net/

http://get-a-designer.com

http://www.all1sourcetech.com

Tags: , , ,
Posted in Editorial, Purely Technical

LolaTheriotHow to overcome after Blackmal virus- Hard Drive Data Lost?

Wednesday, May 26th, 2010

For the data to be deleted fro the hard drive, concerns the computer virus as one of the most common factor. Each and every computer virus is different and designed to harm a particular set of files.

Some of the common ways through which a computer virus can enter your system are downloading files from the Internet, attaching a virus-infected external storage media, and e-mails. Though the consequences of a virus attack vary from situation to situation, the most common outcome is permanent deletion of files.

In order to overcome the after-effects of any virus attack and access the files, the user needs to restore the files from an up-to-date backup. However, if in case no backup is available or backup is unable to restore required files, the user needs to opt for a commercial Hard Drive Recovery Software that can perform recovery of deleted files.

The list of computer virus is too long but the most common one is ‘Blackmal’ virus. This virus has till now infected more than 6,00,000 computer systems and resulted in huge data loss. The virus is competent enough to permanently delete eleven varied file types on the third of every month.

The virus is programmed to delete files not only from the system’s hard drive, but also from network-attached storage.

Prevention: To prevent the attack of Blackmal virus, you will need to follow the below mentioned prevention tips:

1.Always keeps an updated anti-virus installed on your system.

2. Always scan the external storage media before attaching it to your system.

3. Always scan an e-mail (specifically with an attachment) using an anti-virus application.

In case, the above prevention tips are not followed and your different file types have been deleted, then you will need to follow the below steps:

Restore the files from an adequate backup.

In case of failure of the restoration process, you will need to recover the files using an effective third-party Hard Drive Recovery Software.

A Hard Drive Recovery utility is a powerful utility that can scan virus infected media and recovers all lost files after virus attack. The tool is built with self-explanatory user-interface and needs no prior technical knowledge to perform recovery.

http://get-a-designer.com

http://www.all1sourcetech.com

Tags: , , , , ,
Posted in Editorial, Expert's Opinions

SteveManorHow to Avert and Resolve Oracle Database Corruption

Friday, April 16th, 2010

A database administrator needs to perform various operations like performing incremental backups, identifying and resolving network issues, viewing archive log destination, error generation in alert log, etc. in order to ensure that the database always remains in a running state. However, the possibility of database corruption exists due to human mistakes, virus attacks, and hardware corruption.

Database remains unmountable in most cases after it is corrupted, further rendering to inaccessibility of all its records. In such situations, if the administrator wants to access the Oracle database records, then he/she will need to use a cold backup to restore the database. However, if the administrator has not created any backup or the backup is not sufficient to meet all his/her requirements, then he/she needs to use an advanced third-party Oracle Recovery utility to repair the database.

Let’s consider a practical case, where you, as a database administrator, perform below steps:

1.You copy your database file when your database is alive.
2. Then you update the table stored in the data file.
3. After this, you shutdown the database using ‘shutdown immediate’ command and change the datafile with its ‘alive’ copy.

After this, when you try to mount your Oracle database, it does not mount. The reason is-

The fundamental reason for unmountability of the database is corruption in datafile. To prevent the corruption of datafile, you should never follow the above steps sequentially.

Resolution:

It is advisable to restore the database from a standby database in order to resolve datafile corruption and to mount your Oracle database. However, if no such database exists, then you will need to repair the database. To effectively do so, you will need to search for a commercial dbf recovery application that can repair your corrupted database.

A repair tool to recover Oracle database and to bring it back to a reusable state can be easily downloaded from the Internet. Such tools can Recover Oracle Database after any logical corruption scenario using powerful recovery algorithms. Moreover, these tools do not make any change in the original database, making them completely non-destructive in nature.

For most of the Oracle database administrators, Oracle Recovery Software is a utility that they use to recover Oracle database after all kinds of logical crashes. The tool supports recovery of Oracle 9i databases. Designed for Windows XP and 2003, the read only software leaves the original database untouched and unmodified.

Tags: , , , , , ,
Posted in Editorial, Purely Technical

LolaTheriotUse JavaMail to Automate Email Distribution

Saturday, March 6th, 2010

Every action can possibly be automated with software, then why not automate the email distribution to end-users/customers. In this case, the JavaMail API, currently in version 1.4.3, can support this development in a protocol-independent manner and remain platform independent as always.

Here’s the JavaMail code for sending the email:

import javax.mail.*;
import javax.mail.internet.*;
import java.util.*;
import java.io.*;

class EmailClient
{
    final String emailInfo = "EmailInfo.properties";
    Properties properties = new Properties();

    public static void main(String args[])
    {
        EmailClient emailClient = new EmailClient ();
        emailClient.sendEmail();
    }

    private void sendEmail()
    {
       try{
            //This is required to load all the properties
           FileInputStream fileInputStream = new FileInputStream(emailInfo);
           properties.load(fileInputStream);
           fileInputStream.close();
        }catch(IOException ioe)
       {
            //throw IOException of your choice.
            //can end here
       }
        System.out.println("Email properties read successfully.");

       String smtpAddress = properties.getProperty("smtpAddress");
       String fromAddress = properties.getProperty("fromAddress");
       String toAddress = properties.getProperty("toAddress");
       String emailSubject = properties.getProperty("emailSubject");
       String emailBody = properties.getProperty("emailBody");

       Properties props = new Properties();
        props.put("mail.smtp.host", smtpAddress);
        props.put("mail.from", fromAddress);
       Session session = Session.getInstance(props, null);

       try
       {
           MimeMessage mimeMessage = new MimeMessage(session);
           mimeMessage.setRecipients(Message.RecipientType.TO,toAddress);
           mimeMessage.setSentDate(new Date());
           mimeMessage.setSubject(emailSubject);
           mimeMessage.setText(emailBody);
           System.out.println("Sending e-mail...");
           Transport.send(mimeMessage);
           System.out.println("e-mail sent.");
       }
        catch(MessagingException me)
       {
           System.out.println("e-mail send failed.");
           me.getMessage();
       }
    }
}

The code is fairly simple to understand:

  • The properties have been loaded for the email to be sent from a properties file. This could come from any other source, such as hardcoded values, a database, a user interface, etc.
  • The processed information is updated to the MimeMessage object, which is the actual email object. (The MIME, or Multipurpose Internet Mail Extensions, is an Internet standard that specifies how messages must be formatted for interoperability.)
  • MimeMessage takes a session argument, which can either be created or refer to the default session.
  • The session—important in any context and used here for the email—is established using the properties mail.smtp.host and mail.from.
  • Other details such as the date, subject, and the body of the email, which will be used when the email is sent, are being set out.
  • Finally, the email is dispatched using the send() method of the Transport class.
  • The entire email information is made available in a properties file. Here are the contents of the properties file for this application:

smtpAddress=smtp.server.address
fromAddress=myself@me.com
toAddress=someone@you.com
emailSubject=First email
emailBody=My first email

It’s stated previously that the source of the required information can vary, so we can modify the entries at will without recompiling the code to experiment. By the way, holding configurable information in properties files is a standard programming practice.

It seems to be simple right, and now let’s add more advanced features to the application. Don’t you think, you need attachments with email? The following code creates that-

import javax.mail.*;
import javax.mail.internet.*;
import javax.activation.*;
import java.util.*;
import java.io.*;

class SendAdvancedEmail
{
    final String emailInfo = "EmailInfo.properties";
    Properties properties = new Properties();

    public static void main(String args[])
    {
        SendAdvancedEmail sendAdvancedEmail = new SendAdvancedEmail ();
        sendAdvancedEmail.sendEmail();
    }

    private void sendEmail()
    {
       try{
            //This is required to load all the properties
           FileInputStream fileInputStream = new FileInputStream(emailInfo);
           properties.load(fileInputStream);
           fileInputStream.close();
        }catch(IOException ioe)
       {
            //throw IOException of your choice.
            //can end here
       }
        System.out.println("Email properties read successfully.");

       String smtpAddress = properties.getProperty("smtpAddress");
       String fromAddress = properties.getProperty("fromAddress");
       String toAddress = properties.getProperty("toAddress");
       String emailSubject = properties.getProperty("emailSubject");
       String emailBody = properties.getProperty("emailBody");

       Properties props = new Properties();
        props.put("mail.smtp.host", smtpAddress);
        props.put("mail.from", fromAddress);
       Session session = Session.getInstance(props, null);

       try
       {
           MimeMessage mimeMessage = new MimeMessage(session);
           mimeMessage.setRecipients(Message.RecipientType.TO,toAddress);
           mimeMessage.setSentDate(new Date());
           mimeMessage.setSubject(emailSubject);
            //The following is required to add attachments
           MimeMultipart multipart = new MimeMultipart();
           //Creating the text part of the email message
           BodyPart bodyPart = new MimeBodyPart();
            //The type is set to "text/plain"
           bodyPart.setText(emailBody);
           //Creating the attachment part of the email message
           BodyPart attachment = new MimeBodyPart();
           DataSource source = new FileDataSource(emailInfo);
           attachment.setDataHandler(new DataHandler(source));
           attachment.setFileName(emailInfo);
           //attachment.setContent(properties, "text/html");
            //Now combining the email message and the attachment
           multipart.addBodyPart(bodyPart);
           multipart.addBodyPart(attachment);
           //Setting the message with the multipart just created
           mimeMessage.setContent(multipart);

           System.out.println("Sending e-mail...");
           Transport.send(mimeMessage);
           System.out.println("e-mail sent.");
       }
        catch(MessagingException me)
       {
           System.out.println("e-mail send failed."+me);
           me.getMessage();
       }
    }
}

The important difference between this code listing and the one for sending email in the previous section is the process of building the message body, which is now capable of adding a file as an attachment. The Multipart class is actually split into two sections, the message part and the attachment. The properties are actually the same as for the previous code listing.

You could use Multipart instead of MimeMultipart, but be aware that Multipart is an abstract class and hence requires you to create an instance of MimeMultipart. It’s a similar case with MimeMessage. You can use Message, which also is an abstract class. Understanding all the classes used here will help you familiarize yourself with the mail package.

The article has provided enough information for you to experiment with sending and receiving emails. But you need to know-

  • The details in the properties file must be accurate to achieve the desired results.
  • Ensure that you have mail.jar and activation.jar in your classpath.

http://www.all1martpro.com
http://www.all1sourcetech.com

Tags: , , , , , , ,
Posted in Editorial, Purely Technical

BobbyeM71hxwHow to build a PHP Link Scraper with cURL?

Thursday, March 4th, 2010

Let’s build a robot, which scrapes links from web pages and dumps them in a database, and then it read those links from the database and follows them, scraping up the links on those pages, and so on ad infinitum.

To begin, let’s have a look at the groundwork.

The cURL Component-

cURL (or “client for URLS”) is a command-line tool for getting or sending files using URL syntax. It was first used in 2007 by Daniel Stenberg as a way to transfer files via protocols such as HTTP, FTP, Gopher, and many others, via a command-line interface. Since then, many more contributors has participated in further developing cURL, and the tool is used widely today.

Using cURL with PHP-

PHP is one of the languages that provide full support for cURL. (Find a listing of all the PHP functions you can use for cURL.) Luckily, PHP also enables you to use cURL without invoking the command line, making it much easier to use cURL while the server is executing. The example below demonstrates how to retrieve a page called example.com using cURL and PHP.

<?php
$ch = curl_init(“http://www.example.com/”);
$fp = fopen(“example_homepage.txt”, “w”);
curl_setopt($ch, cURLOPT_FILE, $fp);
curl_setopt($ch, cURLOPT_HEADER, 0);
curl_exec($ch);
curl_close($ch);
fclose($fp);
?>

<?php


$ch = curl_init(“http://www.example.com/”);
$fp = fopen(“example_homepage.txt”, “w”);


curl_setopt($ch, cURLOPT_FILE, $fp);
curl_setopt($ch, cURLOPT_HEADER, 0);


curl_exec($ch);
curl_close($ch);
fclose($fp);
?>

The Link Scraper-

For the link scraper, you will use cURL to get the content of the page you are looking for, and then you will use some DOM to grab the links and insert them into your database. You can build the database from the information below; it is really simple stuff.

$query = mysql_query(“select URL from links where visited != 1);
if($query)
{

 	while($query = mysql_fetch_array($result))
 	{

$target_url = $query[‘url’];
$userAgent = ‘ScraperBot’;

Next, grab the URL from the database table inside a simple while loop.

$ch = curl_init();
curl_setopt($ch, cURLOPT_USERAGENT, $userAgent);
curl_setopt($ch, cURLOPT_URL,$target_url);

After instantiating cURL, you use curl_setopt() to set the USER AGENT in the HTTP_REQUEST, and then tell cURL which page you are hoping to retrieve.

curl_setopt($qw, cURLOPT_FAILONERROR, true);
curl_setopt($qw, cURLOPT_FOLLOWLOCATION, true);
curl_setopt($qw, cURLOPT_AUTOREFERER, true);
curl_setopt($qw, cURLOPT_RETURNTRANSFER,true);
curl_setopt($qw, cURLOPT_TIMEOUT, 20);

You’ve set a few more HEADERS with curl_setopt(). This time, you made sure that when an error occurs the script will return a failed result, and you set the timeout of each page followed to 20 seconds. Usually, a standard server will time-out at 30 seconds, but if you run this from your localhost you should be able to set up a no-timeout server.

$html= curl_exec($qw);
if (!$html)
{

 	echo "ERROR NUMBER: ".curl_errno($ch);
 	echo "ERROR: ".curl_error($ch);
 	exit;

}

Grab the actual page by sending the HEADERS along while executing the cURL request using curl_exec(). If an error occurs, it will be reported to PHP by the number and description inside curl_errno() and curl_error, respectively. Obviously, if such an error exists, you exit the script.

$dom = new DOMDocument();
@$dom->loadHTML($html);

Next, you create a document model of your HTML (that you grabbed from the remote server) and set it up as a DOM object.

$xpath = new DOMXPath($dom);
$href = $xpath->evaluate(“/html/body//a”);

Use XPATH to grab all the links on the page.

for ($i = 0; $i < $href->length; $i++) {

 	$data = $href->item($i);
        $url = $data->getAttribute('href');
 	$query = "INSERT INTO links (url, gathered_from) VALUES ('$url', '$gathered_from')";
 	mysql_query($query) or die('Error, insert query failed');
        echo "Successful Link Harvest: ".$url;
 	}

}

Dump all the links into the database, as well as the URL they are gathered from, just so you never go back there again. A more intelligent system might have a separate table for URLs already visited, as well as a normalized relationship between the two.

Going a step further than just grabbing the links enables you to harvest images or entire HTML documents as well. This is kind of where you start when building a search engine. Creating your own search engine may seem naively ambitious, and this little bit of code may inspire you a bit.

Source:- http://www.developer.com

http://www.all1social.com

http://www.all1martpro.com

Tags: , , , , ,
Posted in Editorial, Expert's Opinions, Purely Technical

BobbyeM71hxwConverting HTML to PDF Using Java and Qt

Thursday, March 4th, 2010

Here is the code:

import com.trolltech.qt.core.*;
import com.trolltech.qt.gui.*;
import com.trolltech.qt.webkit.*;
class html2pdf extends QWebView
{
private QPrinter printer = new QPrinter();
public html2pdf()
{
loadFinished.connect(this, \”loadDone()\”);
setHtml(\”This is <b>HTML</b>\”);
// Or use load() to convert html page from url to pdf
}
public void loadDone()
{
printer.setPageSize(QPrinter.PageSize.A4);
printer.setOutputFormat(QPrinter.OutputFormat.PdfFormat);
printer.setOutputFileName(\”test.pdf\”);
print(printer);
System.out.println(\”Done\”);
QApplication.exit();
}
public static void main(String args[])
{
QApplication.initialize(args);
html2pdf h2p = new html2pdf();
h2p.show();
QApplication.exec();
}
}

import com.trolltech.qt.core.*;
import com.trolltech.qt.gui.*;
import com.trolltech.qt.webkit.*;
class html2pdf extends QWebView
{
private QPrinter printer = new QPrinter();
public html2pdf()
{
loadFinished.connect(this, \”loadDone()\”);
setHtml(\”This is <b>HTML</b>\”);
// Or use load() to convert html page from url to pdf
}
public void loadDone()
{
printer.setPageSize(QPrinter.PageSize.A4);
printer.setOutputFormat(QPrinter.OutputFormat.PdfFormat);
printer.setOutputFileName(\”test.pdf\”);
print(printer);
System.out.println(\”Done\”);
QApplication.exit();
}
public static void main(String args[])
{
QApplication.initialize(args);
html2pdf h2p = new html2pdf();
h2p.show();
QApplication.exec();
}
}

http://www.all1social.com

http://www.all1martpro.com

Tags: , ,
Posted in Editorial, Purely Technical

SteveManorHow to restart a windows service using VBScript

Thursday, March 4th, 2010

You can restart a windows service with the use of VBScript as shown in the below code snippet:

Set oshell = createobject(“Wscript.Shell“)
oshell.run”
cmd.exe
wscript.sleep
500
oshell.sendkeys “
net stop “”Your service name here“””+(“{Enter}”)
wscript.sleep
5000
oshell.sendkeys “
net start “”Your service name here“””+(“{Enter}”)
wscript.sleep
5000
oshell.sendkeys “
exit“+(“{Enter}”)

set oshell = nothing

WScript.Quit

`
http://www.all1press.com

http://www.all1tunes.com

Tags: , , ,
Posted in Editorial, Purely Technical

LolaTheriotHow to restart a GSM Modem using VBScript-

Wednesday, March 3rd, 2010

Now you can restart a GSM Modem with the use of VBScript-

1. Copy the script code and save as a .vbs file.
2. Open hyperterminal and setup the modem settings, for this example save the hyperterminal file as c:\example\example.ht
3. Add the below vbs file to your c:\program Files\Windows NT directory and execute.

Important: If you saved the .ht as anything other than example.ht in c:\example rename the file in script below as well.

Set oshell = createobject(“Wscript.Shell”)
oshell.run”cmd.exe”
wscript.sleep 500
oshell.sendkeys “hypertrm.exe c:\example\example.ht”+(“{Enter}”)
wscript.sleep 1500
oshell.sendkeys “at{+}cfun=1” + (“{Enter}”)
wscript.sleep 4000
oshell.sendkeys”at” + (“{Enter}”)
wscript.sleep 1500
oshell.sendkeys “at{+}cfun=1” + (“{Enter}”)
wscript.sleep 4000
oshell.sendkeys”at” + (“{Enter}”)
wscript.sleep 1500
oshell.sendkeys”%f”
wscript.sleep 1500
oshell.sendkeys”x”
wscript.sleep 1500
oshell.sendkeys(“{Enter}”)
wscript.sleep 1500
oshell.sendkeys”exit”+(“{Enter}”)
set oshell = nothing

Set oshell = createobject(“Wscript.Shell”)
oshell.run”cmd.exe”
wscript.sleep 500
oshell.sendkeys “hypertrm.exe c:\example\example.ht”+(“{Enter}”)
wscript.sleep 1500
oshell.sendkeys “at{+}cfun=1” + (“{Enter}”)
wscript.sleep 4000
oshell.sendkeys”at” + (“{Enter}”)
wscript.sleep 1500
oshell.sendkeys “at{+}cfun=1” + (“{Enter}”)
wscript.sleep 4000
oshell.sendkeys”at” + (“{Enter}”)
wscript.sleep 1500
oshell.sendkeys”%f”
wscript.sleep 1500
oshell.sendkeys”x”
wscript.sleep 1500
oshell.sendkeys(“{Enter}”)
wscript.sleep 1500
oshell.sendkeys”exit”+(“{Enter}”)
set oshell = nothing

http://www.all1social.com
http://www.all1martpro.com

Tags: , , , , ,
Posted in Editorial, Purely Technical

BobbyeM71hxwHow to Make an Image Map

Wednesday, March 3rd, 2010

An image map is a picture in which areas within the picture are links. Creating an image involves using the <img alt=”” />,<map>, and <area /> tags. </map>

Steps to creating an image map-

  • Select the image on which you would like to make multiple links. Click on the rectangular hotspot tool found in the Properties Inspector. Select the rectangle tool and drag the pointer over the image to create a rectangular hotspot. You can also choose the oval or polygon hotspot tool to make an oval or polygon selection.
  • In the hotspot Property inspector’s Link field, click the folder icon to browse to the file you want opened when the hotspot is clicked. Alternatively, type the file name.
  • Repeat the above steps to define additional hotspots in the image map.
  • That’s it! You have now successfully created an image map.

For example-

<div>
<map name=”map1″>
<area title=”Contacts” shape=”RECT” coords=”6,116,97,184″ href=”contacts.html” alt=”Contacts” />
<area title=”Products” shape=”CIRCLE” coords=”251,143,47″ href=”products.html” alt=”Products” />
<area title=”New!” shape=”POLY” coords=”150,217, 190,257, 150,297,110,257″ href=”new.html” alt=”New!” />
</map>
<img usemap=”#map1″ src=”testmap.gif” border=”0″ alt=”map of GH site” width=”300″ height=”300″ />
[ <a href=”contacts.html”>Contacts</a> ]
[ <a href=”products.html”>Products</a> ]
[ <a href=”new.html”>New!</a> ]</div>

<DIV ALIGN=CENTER>

<MAP NAME=”map1″>

<AREA

HREF=”contacts.html” ALT=”Contacts” TITLE=”Contacts”

SHAPE=RECT COORDS=”6,116,97,184″>

<AREA

HREF=”products.html” ALT=”Products” TITLE=”Products”

SHAPE=CIRCLE COORDS=”251,143,47″>

<AREA

HREF=”new.html” ALT=”New!” TITLE=”New!”

SHAPE=POLY COORDS=”150,217, 190,257, 150,297,110,257″>

</MAP>

<IMG SRC=”testmap.gif”

ALT=”map of GH site” BORDER=0 WIDTH=300 HEIGHT=300

USEMAP=”#map1″><BR>

[ <A HREF=”contacts.html” ALT=”Contacts”>Contacts</A> ]

[ <A HREF=”products.html” ALT=”Products”>Products</A> ]

[ <A HREF=”new.html”      ALT=”New!”>New!</A> ]

</DIV>

Using this, you can create an image map.

http://www.all1social.com
http://www.all1martpro.com

Tags: , , , , ,
Posted in Editorial, Purely Technical

LolaTheriot[PHP]Sending MySQL data.

Saturday, February 27th, 2010
<?Php
$db_host = "1.3.3.7"; // mySQL database host
$db_user = "dbplz"; // mySQL database user
$db_password = "rofl"; // mySQL database password
$db_name = "dbplz"; // the name of your mySQL database

//connect to our database.
  mysql_connect($db_host,$db_user,$db_password) or die(mysql_error());
// Select the database.
  mysql_select_db($db_name) or die(mysql_error());
//Define the data as $query
$query = "INSERT INTO tablename (row1, row2, row3, row4)
VALUES ('$variable1','$variable2','$variable3','$variable4')";
  mysql_query($query);
  mysql_close();

// it's almost always imperative to strip tags or the data usually doesn't send properly.
$variable = strip_tags($_POST['variable'], '');
//and now send the data
  mysql_query($query);
  mysql_close();
?>

http://www.all1martpro.com

http://www.all1sourcetech.com

Tags: , , , ,
Posted in Editorial, Purely Technical