Saturday, December 29, 2007

What is XML-RPC?

XML-RPC is a standard network protocol that computers can use to talk to each other in a remote procedure call fashion. Remote procedure call essentially means that a program on one computer runs a program on another computer. But a simpler way of looking at this kind of network protocol is just that you have clients and servers. A client makes individual isolated requests of a server. A server sits around waiting for a request to arrive from some client, does what the request asks, and sends a response. It then goes back to waiting for the next request.

Here are some examples of remote procedure call (RPC) style communications:

There is a server that can measure atmospheric temperature. A client anywhere in the world can ask the server at any time what the temperature is. The "what temperature is it?" request and the "the temperature is..." response constitute an RPC transaction.
There is a server that can turn a light on or off. A client can tell the server to turn the light on. A request to turn the light on and the acknowledgement that the light has been turned on constitute an RPC transaction.
There is a server that knows the phone numbers of a million people. A client can supply a name and get back the phone number of the named person.
A network of 1000 computers is used to search millions of web pages. A dispatcher computer is a client and the rest are servers. The dispatcher sends each of the servers one URL at a time and some search terms. The server responds with yes or no as to whether the page with that URL contains the search terms. The dispatcher keeps a list of the URLs that match. Each of the requests to search a particular URL is an RPC transaction.
Here are some kinds of communication that are not RPC:

A long-lived connection such as an SSH login session.
A high volume transfer such as an FTP download.
A one-way transmission such as a UDP packet.
A dialogue such as an SMTP (mail) transaction.
The original RPC protocol is the ONC RPC protocol -- the one that NFS (the network fileystem protocol) uses. It's often called "Sun RPC" because Sun invented and promulgated it. The ONC RPC protocol is layered over UDP or sometimes TCP and uses a machine-friendly bits and bytes format, just like the TCP/IP layers under it.

XML-RPC differs from ONC RPC in that it encodes the information in the requests and responses in XML. That means they are human friendly -- XML is human-readable text, so a human can readily see what's going on from a network trace and quickly write code to create and decipher XML-RPC streams. Of course, the tradeoff is that XML-RPC uses way more network and computation resources than ONC RPC. Because XML-RPC is meant to be used for relatively small and infrequent transactions, this is thought not to matter.

In XML-RPC, the aforementioned XML is transported via HTTP (the protocol whose principal purpose is to implement web serving -- web browsing is a form of RPC, after all). HTTP is normally carried over TCP, which is carried over IP.

There are lots of servers in the world that use the XML-RPC protocol and lots of programs and programming libraries from which people can build XML-RPC-based servers and clients.

There are also other HTTP-based RPC protocols. SOAP and CORBA are the most famous. REST-RPC is a more recent entry.

For more information on XML-RPC, see The XML-RPC web site and The XML-RPC Howto. The latter includes information (with examples) on implementing XML-RPC clients and servers in languages other than C and C++, which is all that is covered in this document.

How Does XML-RPC For C/C++ Help with XML-RPC?
The function libraries in XML-RPC For C/C++ (Xmlrpc-c) let you write a program that makes XML-RPC calls (a client) or executes XML-RPC calls (a server program) at any of various levels of understanding of the XML-RPC protocol.

Here are some examples of client and server code.

The Xmlrpc-c Function Libraries
This is a list of the function libraries Xmlrpc-c provides, with links to the manual for each.

There are two sets of libraries -- C and C++. You can of course use the C libraries in a C++ program, but you cannot in general mix the two -- you use either the C Xmlrpc-c facilities or the C++ Xmlrpc-c facilities. The C++ libraries depend heavily on the C libraries, but apart from having to install and link to the C libraries, you won't see that from the outside.

The C++ libraries were all new in Xmlrpc-c 1.03 (June 2005).

There is an older C++ facility, which is just a thin wrapper around the C libraries. We do not document it in this manual or recommend it, but it remains part of Xmlrpc-c for backward compatibility. This library consists in the header file xmlrpc-c/oldcppwrapper.hpp (fka XmlRpcCpp.h) and the library libxmlrpc_cpp.

C Libraries
libxmlrpc - general facilities
libxmlrpc_client - facilities for implementing a client
libxmlrpc_server - facilities for implementing a server — facilities which are independent of the transport mechanism.
libxmlrpc_server_abyss - facilities for implementing a server, based on an Abyss HTTP server.
libxmlrpc_abyss - The Abyss server software.
libxmlrpc_server_cgi - facilities for implementing a server via CGI scripts under an arbitrary HTTP server (i.e. web server).
C++ Libraries
libxmlrpc++ - general facilities
libxmlrpc_client++ - facilities for implementing a client
libxmlrpc_server++ - facilities for implementing a server — facilities which are independent of the transport mechanism.
libxmlrpc_server_abyss++ - facilities for implementing a server, based on an abyss HTTP server.
libxmlrpc_server_pstream++ - facilities for implementing a pseudo-XML-RPC server that uses a packet stream in place of HTTP and has multi-RPC client/server connections.
Utility Programs
Xmlrpc-c comes with a few utility programs that you can use to diagnose problems or learn about XML-RPC or Xmlrpc-c. These programs double as examples of how to use the Xmlrpc-c function libraries.

Because the utility programs are not essential to the package, the default install tools don't install them at all. The builder does build them, though, and if you build Xmlrpc-c from source, you will find them all in the tools/ directory.

You'll also find more complete documentation there.

xmlrpc
xmlrpc is a general purpose XML-RPC client program. It performs one XML-RPC call, which you describe in its command line arguments.

Example:


$ xmlrpc http://localhost:8080/RPC2 sample.add i/3 i/5


This makes a call to the XML-RPC server at the indicated URL, for the method named "sample.add", with two arguments: the integer 3 and the integer 5.
xmlrpc prints to Standard Output the result of the call, which it gets back from the server.

You can abbreviate the URL; xmlrpc assumes "http://" and "/RPC2":


$ xmlrpc localhost:8080 sample.add i/3 i/5
Result:
Integer: 8


The port number defaults to 80, so you can abbreviate even more:


$ xmlrpc localhost sample.add i/3 i/5


String arguments look like this:


$ xmlrpc http://www.xmlrpc.com/RPC2 method_that_takes_string s/hello


If you don't include a type specifier such as "i/" or "s/", xmlrpc assumes "s/". So you can use this shortcut, equivalent to the above:


$ xmlrpc http://www.xmlrpc.com/RPC2 method_that_takes_string hello


Each argument to xmlrpc describes on XML-RPC parameter. So in a typical command shell, the following would make an XML-RPC call with two paramters: "hello" and "see you later":


$ xmlrpc http://www.xmlrpc.com/RPC2 mymethod s/hello "s/see you later"


Compound values for parameters look the following, except that these aren't implemented yet. Only "i/" and "s/" are implemented right now.

Note that this is an example of a Bourne shell command, so some of the characters (most notably the quotation marks) are part of the shell language, not the xmlrpc syntax.


$ xmlrpc http://www.oreillynet.com/meerkat/xml-rpc/server.php \
meerkat.getItems \
"struct/{search:linux,descriptions:i/76,time_period:12hour}"
Result:
Array:
Struct:
title: String: DatabaseJournal: OpenEdge-Based Finance ...
link: String: http://linuxtoday.com/news_story.php3?ltsn=...
description: String: "Finance application with embedded ...
Struct:
title: ...
link: ...
description: ...




$ xmlrpc localhost:8080 array_processing_method \
"array/(i/3,i/49,s/hello,array/(i/-10,i/-9))"


xmlrpc is implemented using the Xmlrpc-c client library, but its function is not in any way tied to Xmlrpc-c. It makes a standard XML-RPC call and does not know or care whether the server is implemented with Xmlrpc-c or not.

For extra diagnostic information, use the XMLRPC_TRACE_XML environment variable so you can see the XML that goes back and forth to perform the call. (This is not specifically xmlrpc function -- it's tracing function that's automatically there because xmlrpc uses libxmlrpc_client).

Alternatives
This section describes some alternatives to using XML-RPC For C/C++.

Other Progamming Languages
There are plenty of facilities to help you create XML-RPC clients and servers in a language other than C or C++. Search on Freshmeat.

It is worth mentioning that with some of these other-language facilities, the client or server is way slower than with XML-RPC for C/C++, due to the nature of the language. For example, I have used the Perl RPC::XML modules from CPAN and found a client program that takes 50 milliseconds to run when written with XML-RPC For C And C++ takes 2000 milliseconds to run when done with RPC::XML::Client.

In the case of Perl, there is a middle ground. The RPC::Xmlrpc_c modules from CPAN are based on Perl extensions that use the libraries of XML-RPC For C And C++. One reason RPC::XML is so slow is that it is built on top of a stack about 6 layers high, each one implemented in interpreted Perl. With RPC::Xmlrpc_c, all those layers except the top are implemented as executable machine code, efficiently compiled from C, so you have the same ease of Perl coding, without the slowness.

RPC::Xmlrpc_c is much younger than RPC::XML, so doesn't have many features, and in fact does not include any server facilities. But you could add missing features yourself (and, ideally, submit them for inclusion in the RPC::Xmlrpc_c package on CPAN, so others can use them).

RPC::Xmlrpc_c was new in December 2006 and needs XML-RPC For C And C++ Release 1.08 or better.

In other interpreted languages, the same hybrid may be possible -- replacing slow interpreted code with executable XML-RPC libraries.

Apache Module
You can make a nice XML-RPC server based on an Apache HTTP server (which may or may not simultaneously be a regular web server) using an Apache module. mod_xmlrpc is one such module. mod_xmlrpc is actually built on Xmlrpc-c, so you can use the same method code as you do for other Xmlrpc-c-based implementations

An even simpler, though less efficient and more limited way to make an XML-RPC server out of an Apache server is to do it via a CGI script. That script can be written in a variety of languages, but if you write it in C, you can use Xmlrpc-c's libxmlrpc_server_cgi library.

Other RPC Protocols
SOAP and CORBA are common alternatives to XML-RPC. Lots of expensive commercial software helps you use those. There is more to know and more you can do with them.

REST-RPC was invented in 2006 and was meant to be superior to XML-RPC for at least some things. It is easier to use in many ways than XML-RPC. Like XML-RPC, it uses HTTP, and like XML-RPC an RPC's result is XML. But unlike XML-RPC, a call is not XML. It is encoded entirely in the query part of a URL. (Example: http:/test.rest-rpc.org/?_function=GetCart&cart=1563). In the result, there are no inherent data types; server and client agree on those separately. The Xins project has more information.

Appendices
Introductory Examples
Here, to show you what Xmlrpc-c is, we present example code (almost an entire C program) for a simple XML-RPC client that exploits the Xmlrpc-c libraries, and a corresponding simple XML-RPC server.

You can find complete working versions of these, and lots of other examples in the examples/ directory in the Xmlrpc-c source tree.

In these examples, the service to be provided is adding of two numbers. You wouldn't do this with RPC in real life, of course, because a program can add two numbers without the help of a remote server. This is just to demonstrate the concept.

Table Of Contents
Small C Client Example
Small C Server Example
CGI C Server Example
Small C++ Server Example
Small C++ Client Example
Small C Client Example
Here is an example of C code that implements an XML-RPC client using the highest level facilities of Xmlrpc-c. This client sends a request to add 5 and 7 together to an XMLRPC-C server that is designed to provide the service of adding numbers.


#include
#include

#include "config.h" /* information about this build environment */

#define NAME "XML-RPC C Test Client"
#define VERSION "1.0"

int
main(int const argc,
const char ** const argv) {

xmlrpc_env env;
xmlrpc_value * resultP;
int sum;
char * const url = "http://localhost:8080/RPC2";
char * const methodName = "sample.add";

/* Initialize our error-handling environment. */
xmlrpc_env_init(&env);

/* Start up our XML-RPC client library. */
xmlrpc_client_init2(&env, XMLRPC_CLIENT_NO_FLAGS, NAME, VERSION, NULL, 0);
die_if_fault_occurred(&env);

/* Make the remote procedure call */
resultP = xmlrpc_client_call(&env, url, methodName,
"(ii)", (xmlrpc_int32) 5, (xmlrpc_int32) 7);
die_if_fault_occurred(&env);

/* Get our state name and print it out. */
xmlrpc_parse_value(&env, resultP, "i", &sum);
die_if_fault_occurred(&env);
printf("The sum is %d\n", sum);

/* Dispose of our result value. */
xmlrpc_DECREF(resultP);

/* Clean up our error-handling environment. */
xmlrpc_env_clean(&env);

/* Shutdown our XML-RPC client library. */
xmlrpc_client_cleanup();

return 0;
}



Small C Server Example
Now, here is code that implements an XML-RPC server that provides the number-adding service from the previous section.


#include
#include
#include

static xmlrpc_value *
sample_add(xmlrpc_env * const envP,
xmlrpc_value * const paramArrayP,
void * const serverContext) {

xmlrpc_int32 x, y, z;

/* Parse our argument array. */
xmlrpc_parse_value(envP, paramArrayP, "(ii)", &x, &y);
if (env->fault_occurred)
return NULL;

/* Add our two numbers. */
z = x + y;

/* Return our result. */
return xmlrpc_build_value(envP, "i", z);
}



int
main (int const argc,
const char ** const argv) {

xmlrpc_server_abyss_parms serverparm;
xmlrpc_registry * registryP;
xmlrpc_env env;

if (argc-1 != 1) {
fprintf(stderr, "You must specify 1 argument: The Abyss "
"configuration file name. You specified %d.\n", argc-1);
exit(1);
}

xmlrpc_env_init(&env);

registryP = xmlrpc_registry_new(&env);

xmlrpc_registry_add_method(
&env, registryP, NULL, "sample.add", &sample_add, NULL);

serverparm.config_file_name = argv[1];
serverparm.registryP = registryP;

printf("Starting XML-RPC server...\n");

xmlrpc_server_abyss(&env, &serverparm, XMLRPC_APSIZE(registryP));

return 0;
}


There's a lot going on under the covers of this example server. What the xmlrpc_server_abyss() statement does is run a whole HTTP server. The function doesn't normally return. The HTTP server runs the abyss web server (i.e. HTTP server) program. abyss is like the more serious web server program apache, but on a much smaller scale. An XML-RPC call is just an HTTP POST request, so while abyss was not designed specifically for XML-RPC, it provides much of the function an XML-RPC server needs.

The only way this Abyss web server differs from one you would run to do traditional web serving is that it contains a special handler to call Xmlrpc-c functions to handle an XML-RPC POST request. The server calls that handler for any URI that starts with "/RPC2", which is what XML-RPC URIs conventionally have.

While abyss is distributed independently of Xmlrpc-c, Xmlrpc-c contains an old copy of it, somewhat modified. So you don't need to install abyss separately.

In this example, you have to provide an example abyss configuration file as a program argument. The main thing you need that file for is to specify on which TCP port the server will listen. A single "Port 8080" statement is probably enough. (I say 8080, because in the example client code above, I hardcoded 8080 as the port in the URI the client uses).

There are lots of other ways to use Xmlrpc-c libraries to build XML-RPC clients and servers. The more code you're willing to write, and the more involved in the guts of the protocol you want to get, the more control you can have.

CGI Server Example

/* A simple CGI-based XML-RPC server written in C. */

#include
#include

static xmlrpc_value *
sample_add(xmlrpc_env * const env,
xmlrpc_value * const param_array,
void * const user_data) {

xmlrpc_int32 x, y, z;

/* Parse our argument array. */
xmlrpc_decompose_value(env, param_array, "(ii)", &x, &y);
if (env->fault_occurred)
return NULL;

/* Add our two numbers. */
z = x + y;

/* Return our result. */
return xmlrpc_int_new(env, z);
}



int
main(int const argc,
const char ** const argv) {

/* Process our request. */
xmlrpc_cgi_init(XMLRPC_CGI_NO_FLAGS);
xmlrpc_cgi_add_method_w_doc("sample.add", &sample_add, NULL,
"i:ii", "Add two integers.");
xmlrpc_cgi_process_call();
xmlrpc_cgi_cleanup();

return 0;
}



Small C++ Client Example
Here is an example of C++ code that implements an XML-RPC client using the highest level facilities of Xmlrpc-c. This client sends a request to add 5 and 7 together to an XMLRPC-C server that is designed to provide the service of adding numbers.

The example server above would be a suitable server for this client.


#include
#include
#include
#include

using namespace std;

int
main(int argc, char **argv) {

if (argc-1 > 0) {
if (argv) {}
cerr << "This program has no arguments" << endl;
exit(1);
}

string const serverUrl("http://localhost:8080/RPC2");
string const methodName("sample.add");

xmlrpc_c::clientSimple myClient;
xmlrpc_c::value result;

myClient.call(serverUrl, methodName, "ii", &result, 5, 7);

int const sum((xmlrpc_c::value_int(result)));
// Assume the method returned an integer; throws error if not

cout << "Result of RPC (sum of 5 and 7): " << sum << endl;

return 0;
}


To keep it brief, we don't catch any thrown errors, though various parts of this program can throw them.

Small C++ Server Example
Here is C++ code that implements the same kind of XML-RPC server shown in C above.


#include

#include
#include
#include

using namespace std;

class sampleAddMethod : public xmlrpc_c::method {
public:
sampleAddMethod() {}

void
execute(xmlrpc_c::paramList const& paramList,
xmlrpc_c::value * const retvalP) {

int const addend(paramList.getInt(0));
int const adder(paramList.getInt(1));

paramList.verifyEnd(2);

*retvalP = xmlrpc_c::value_int(addend + adder);
}
};



int
main(int const argc,
const char ** const argv) {

xmlrpc_c::registry myRegistry;

xmlrpc_c::methodPtr const sampleAddMethodP(new sampleAddMethod);

myRegistry.addMethod("sample.add", sampleAddMethodP);

xmlrpc_c::serverAbyss myAbyssServer(
myRegistry,
8080, // TCP port on which to listen
"/tmp/xmlrpc_log" // Log file
);

myAbyssServer.run();
// xmlrpc_c::serverAbyss.run() never returns
assert(false);

return 0;
}



About This Document
This document is part of the XML-RPC For C/C++ project. It is the main user documentation for the project.

The master copy of this document lives at http://xmlrpc-c.sourceforge.net/doc/. The HTML copy there is the original source -- it is hand edited.

This is a living document. It gets updated continuously, both to document changes in Xmlrpc-c and to improve the documentation. It documents all current and past, and, where possible, future releases of Xmlrpc-c. There is no benefit to keeping an old copy of the document to use with an old copy of the code.

Bryan Henderson wrote and published the first draft of this document in November 2004, as an entirely original work. Bryan placed it in the public domain.

LEARN C/C++ TODAY (A list of resources/tutorials)

Introduction:
-------------
This is a list of a few C and C++ language tutorials available to a
user. This list includes interactive tutorials, public-domain code
collections, books etc. I've developed this FAQ purely as a volunteer
effort as a service to the Internet community. Although every effort
has been made to insure that all the information here is as accurate as
possible, no guarantee is implied or intended.

I welcome comments, suggestions or criticism for all the people out
there on the net that read this. If you can help me make this list a
little better, you will be helping a lot of people out there on the
net. I am a horrible writer and an even worse speller. If you find
any errors or would like to suggest any additions please feel free to
email me at the address below:
carpenterv@vms.csd.mu.edu
What's new in this issue:
-------------------------

This section of the document will point out all the new additions,
corrections, updates etc. If there is enough interest, I will start
producing a 'diff' version.
1. Added a second web server that has the HTML and PS version of this
document.
2. Updated the information on the 'C++ on the WWW'. The address has
of the web server has changes. The author also converted Dordill's
C++ course to HTML which is online.
3. Updated the information in the MSDOS/Windows compiler section.
4. Added a new item called `Programming in C' that contains a great
collection of C and programming items.
5. Updated the information on the C++ FAQ.
6. Added a lot of information on OS/2. (Joe Dougherty)
7. Added more information about Scott Meyers new book titled "More
Effective C++".
8. Updated the oak.oakland.edu info and the directory structure has
been changed.
9. Update the information on the C Snippets packages. The author
released a new package that includes 400+ files.
I am switching to URL in place of the standard ftp and filename format.
URL stands for "Uniform Resource Locator". Think of it as a networked
extension of the standard filename concept: not only can you point to a
file in a directory, but that file and that directory can exist on any
machine on the network, can be served via any of several different
methods, and might not even be something as simple as a file: URLs can
also point to queries, documents stored deep within databases, the
results of a finger or archie command, or whatever.

File URL:
---------
file://oak.oakland.edu/simtel/msdos/c/00_index.txt

Gopher URL:
-----------
To connect to a particular gopher server, use this URL:

gopher://gopher.tc.umn.edu/

News URL:
---------
To point to a Usenet Newsgroups, the URL is simply:

news:comp.lang.c

HTTP URL:
---------
HTTP stands for HyperText Transport Protocol. HTTP servers are
commonly used for serving hypertext documents

http://vinny.csd.mu.edu

This file is posted on the 1st and the 15th of each month to the Usenet
Newsgroups COMP.LANG.C, COMP.LANG.C.MODERATED, COMP.LANG.C++,
NEWS.ANSWERS & COMP.ANSWERS. The HTML and postscript version of this
documents are available. Here's the URL:

http://vinny.csd.mu.edu

NOTE: This is my Linux PC that does get inundated with request. The
last time I checked the stats, there were about 27 connections every
minute. If you get timed out, please try again. The most recently
posted version of this document is kept on the news.answers archive on
rtfm.mit.edu. You can receive it via anonymous ftp. The URL is listed
below.
ftp://rtfm.mit.edu/pub/usenet/news.answers/C-faq/learn-c-cpp-today
If you don't have access to ftp, you can also receive this file via
e-mail by sending mail to mail-server@rtfm.mit.edu with:
send /pub/usenet/news.answers/C-faq/learn-c-cpp-today

in the body (not subject line) of your message. You can also receive
the latest version via electronic mail by e-mailing me.
To: learncpp@vinny.csd.mu.edu
Subject: send learn-c-cpp-today
Body: ignored. Can be blank.

A lot of tutorials discussed here are available via anonymous ftp. If
you don't have ftp, you can also retrieve these files via a ftp-email
gateway. To retrieve files via e-mail, send mail to
ftpmail@decwrl.dec.com with the command HELP in the body of the message
to receive a complete list of all commands. A typical message would
look something like this:

connect oak.oakland.edu
chdir /simtel/msdos/c
binary
uuencode
get xxx.zip
quit

Some of the items discussed here are platform-dependent, but most of
the items are applicable across all platforms (portable). If you have
any comments, suggestions, complaints, additions, etc, please feel free
to e-mail me at the following address:

carpenterv@vms.csd.mu.edu

If you are working on a tutorial or would like something added to this
list, please e-mail me at the address given above.

The Origins of C and C++:
-------------------------

The 'C' programming language was originally developed for and
implemented on the UNIX operating system, on a DEC PDP-11 by Dennis
Ritchie. One of the best features of C is that it is not tied to any
particular hardware or system. This makes it easy for a user to write
programs that will run without any changes on practically all machines.
C is often called a middle-level computer language as it combines the
elements of high-level languages with the functionalism of assembly
language.

C allows the manipulation of bits, bytes and addresses- the basic
elements with which the computer functions. Another good point about C
is its portability which makes it possible to adapt software written
for one type of computer to another. C was created, influenced, and
field tested by working programmers. The end result is that C gives
the programmer what the programmer wants. C offers the speed of
assembly language and the extensibility of FORTH, but few of the
restrictions of Pascal and Modula-2.

C++ is an enhanced version of the C language. C++ includes everything
that is part of C and adds support for object-oriented programming
(OOP). In addition, C++ also contains many improvements and features
that make it a "better C", independent of object oriented programming.
C++ is actually an extendible language since we can define new types in
such a way that they act just like the predefined types which are part
of the standard language.

If you just use C++ as a better C, you will not be using all of its
power. Like any quality tool, C++ must be used the way it was designed
to be used to exploit its richness. Some of the new features include
encapsulation, inline function calls, overloading operators,
inheritance and polymorphism. I am not going to explain what they mean
here as that would simply take me away from my purpose here, but you
can refer to any good C++ book or the C++ FAQ (Item 7) for more
information.


What do you need to get started?
--------------------------------

The first thing you need is a compiler. A compiler reads the entire
program and converts it into object code, which is a translation of the
program source code into a form that the computer can execute directly.


UNIX SYSTEM:

Type cc at the % prompt. If you don't get any error messages, you
probably have a C compiler . If you get an error message, try acc, gcc
or g++. If any of these don't work, contact your local system
administrator and ask him/her to get you a C/C++ compiler. GNU C/C++
compiler is available from a lot of anonymous ftp sites free of charge.
Look into it. (I've got g++ running on my Linux box without any
problems)

MSDOS/Windows/OS2/Linux (IBM COMPATIBLES):

There are a lot of good compilers available to you. Microsoft Quick C
and Borland Turbo C/C++ are both good products for beginners. You can
buy both of them for under $50.00. I use Microsoft Quick C and
MS-Visual C/C++, and I prefer Quick-C for all my DOS programs as it is
small, and yet very powerful. Most of my programming is now on my
Linux PC with gcc/g++. (If you want a great 32 bit operating system,
you should look into Linux. E-mail me for details). You can also get
the DOS port of GNU C/C++ called DJGPP from oak.oakland.edu
/simtel/vendors/djgpp.

The increased popularity of OS/2 and it's latest incarnation Warp, has
provided programmers with a wider selection of compilers and
programming tools. Still available for free is the GNU gcc package
under the name emx. Emx integrates nicely with the Extended Editor
included with OS/2. It's available on ftp.cdrom.com, hobbes.nmsu.edu,
and other sites. IBM provides the CSet++ 2.x, as well as a smaller,
less-expensive package on CD-ROM called CSet++ First Step. Other
popular compilers include Borland C++ 1.0 for OS/2, and Watcom C/C++
for OS/2 10.0, and CA-C++ for OS/2 from Computer Associates.


OpenVMS (VAX & AXP)

If you're on a VAX, type in CC to check and see if you have a C
compiler. VAX C is not the best compiler around, but it certainly does
the job. If you don't have a C compiler, look into the GNU C/C++
compiler GCC. You can get the VAX version of GCC from ftp.spc.edu via
anonymous ftp. If on a AXP system, you should have access to DEC
C/C++. Please contact your local system administrator or computer
consultant for more site specific questions.

Macintosh (Apple/PowerMac)

There are three main players in the Mac compiler market: MPW (from
Apple), THINK C / Symantec C++ (both from Symantec), or CodeWarrior
(from Metrowerks): THINK C is $225 (only a C compiler), while Symantec
C++ is $375 (includes C and C++ compilers). CodeWarrior comes in two
versions: bronze and gold, at $199/299/399, respectively. The Symantec
C++ compiler (ver 8.0) is PowerMac native. Symantec and Metrowerks
offer academic pricing on their products which are substantially less
than the commercial prices.

There have been two attempts at freeware/shareware Mac C compilers:
Sesame C and Harvest. Harvest C was an ambitious attempt at a
production-quality freeware compiler which was later abandoned by the
author.

Friday, December 28, 2007

Creating the SimpleSample XML Expansion Pack Manifest File (Visual C++ Tutorial)

Start Notepad or another text editor.
Open the Manifest.xml file included in the supporting files for the SimpleSample smart document. For more information about the schema for the XML expansion pack manifest file, see the XML Expansion Pack Manifest Schema Reference.

Determine the location where you will deploy the SimpleSample smart document. This may be a network share (for example, \\sharedfolder), an intranet path (for example, http://mysmartdocument), or an Internet address (for example, http://www.microsoft.com).
You can also use a relative path. For example, if your smart document is located in the same folder as your supporting files, you can use a relative address to the file by entering only the file name into the filePath element.

Note The file names referenced in the Manifest.xml file are relative addresses, so you can copy the file into most folders without modification. However, if you store your SimpleSample smart document on a network share or Web server, you may need to provide the absolute path to the smart document dynamic-link library (DLL) and supporting files in the filePath element.

Locate the class identifier (CLSID) for the SimpleSample DLL that you compiled earlier, and paste it into the CLSID element in the Manifest.xml file. You can locate the CLSID by opening the registry and searching for "SimpleSample.clsActions." For more information, see Locating the CLSID.
Change the value of the solutionID element to a globally unique identifier (GUID). You can generate a GUID by using the Uuidgen.exe utility included with Microsoft Visual Studio.
Change the value of the alias element to "SimpleSmart Document Sample - C++".
Save the Manifest.xml file.

Basic PHP

Basic PHP
A PHP scripting block always starts with "" . A PHP scripting block can be placed anywhere in the document.

Variables in PHP

$txt = "Hello World!";
$number = 16;

Strings in PHP

$txt="Hello World";
echo $txt;

The output of the code above will be:
Hello World

$txt1="Hello World";
$txt2="1234";
echo $txt1 . " " . $txt2;

The output of the code above will be:
Hello World 1234

echo strlen("Hello world!");

The output of the code above will be:
12

echo strpos("Hello world!","world");

The output of the code above will be:
6

Conditional Statements

$d=date("D");
if ($d=="Fri")
echo "Have a nice weekend!";
elseif ($d=="Sun")
echo "Have a nice Sunday!";
else
echo "Have a nice day!";

The Switch Statement

switch ($x)
{
case 1:
echo "Number 1";
break;
case 2:
echo "Number 2";
break;
case 3:
echo "Number 3";
break;
default:
echo "No number between 1 and 3";
}

PHP Arrays
a.Numeric array - An array with a numeric ID key
b.Associative array - An array where each ID key is associated with a value
c.Multidimensional array - An array containing one or more arrays

$names[0] = "Peter";
$names[1] = "Quagmire";
$names[2] = "Joe";

The ID keys can be used in a script:

$names[0] = "Peter";
$names[1] = "Quagmire";
$names[2] = "Joe";echo $names[1] . " and " . $names[2] .
" are ". $names[0] . "'s neighbors";

Looping
a.
$i=1;
while($i<=5)
{
echo "The number is " . $i . "
";
$i++;
}
b.
$i=0;
do
{
$i++;
echo "The number is " . $i . "
";
}
while ($i<5);
c.
for ($i=1; $i<=5; $i++)
{
echo "Hello World!
";
}

d.
$arr=array("one", "two", "three");foreach ($arr as $value)
{
echo "Value: " . $value . "
";
}

PHP Functions
1.
function writeMyName($fname)
{
echo $fname . " Refsnes.
";
}echo "My name is ";
writeMyName("Kai Jim");echo "My name is ";
writeMyName("Hege");echo "My name is ";
writeMyName("Stale");

2.
function writeMyName($fname,$punctuation)
{
echo $fname . " Refsnes" . $punctuation . "
";
}echo "My name is ";
writeMyName("Kai Jim",".");echo "My name is ";
writeMyName("Hege","!");echo "My name is ";
writeMyName("StĂĄle","...");

The output of the code above will be:
My name is Kai Jim Refsnes.
My name is Hege Refsnes!
My name is StĂĄle Refsnes...
3.
function add($x,$y)
{
$total = $x + $y;
return $total;
}echo "1 + 16 = " . add(1,16);

The output of the code above will be:
1 + 16 = 17

tutorial from http://www.w3schools.com/php/

Thursday, December 27, 2007

Apa itu CakePHP ?

Yeah, apa sich CakePHP itu ? Sejenis script PHP kah ? Atau CMS (Content Management System), atau apaan ? Emm, secara singkat barangkali CakePHP bisa diterangkan sebagai berikut :

Cake PHP atau orang lebih mengenalnya dengan nama CakePHP, adalah sebuah framework atau kerangka kerja untuk membuat aplikasi CRUD (Create, Read, Update, Delete) berbasis bahasa pemrograman PHP. CakePHP juga menjadi salah satu framework pilihan

yang memungkinkan seorang developer web untuk membuat sebuah aplikasi dengan karakter pengembangan RAD (Rapid Application Development), yang memungkinkan untuk digunakan dan dikembangkan menjadi aplikasi lain yang lebih kompleks. CakePHP masih satu keturunan dan mempunyai hubungan darah yang cukup erat dengan Ruby on Rails, sebuah framework pemrograman Ruby. Artikel kali ini akan menjelaskan sedikit mengenai CakePHP. Harapannya, sebagai developer web kita tidak hanya terpaku pada satu metode konvensional saja, akan tetapi cobalah untuk meningkatkan kemampuan kita dalam mengembangkan aplikasi, seiring dengan semakin mudah dan berkembangnya bahasa pemrograman PHP itu sendiri.

Menurut pengalaman penulis (halah), CakePHP lumayan lengkap untuk disebut sebagai sebuah framework berbasis PHP. Selain mendukung penggunaan dan pengembangan web service, CakePHP juga sudah mendukung penggunaan AJAX secara built in. Tinggal di-include-kan saja component dari Class nya. Beres !

Beberapa keuntungan menggunakan CakePHP adalah :

1. Ringan . Ya, CakePHP adalah salah satu framework paling ringan yang ada di dunia, dengan ukuran 300 Kb dalam satu file .zip . Salah satu prinsip yang dijunjung tinggi oleh para programmer CakePHP adalah “no we-might-need-it code”, atau dengan kata lain, semua code dalam CakePHP adalah bermanfaat dan selalu digunakan dalam pembuatan aplikasi. Tidak ada code-code sampah yang tidak berguna dan memperbesar ukuran framework secara keseluruhan.

2. Kompatibel dengan PHP 4 dan PHP 5.

3. Scaffolding feature. CakePHP mempunyai fitur yang mampu men-generate prototype aplikasi kita, sebelum kita menyusun source code nya secara lengkap. Cukup tambahkan variabel $scaffold di controller anda, dan zapp ! Aplikasi anda sudah bisa anda nikmati ..

4. Mendukung AJAX. Buat kamu-kamu yang suka mainan animasi real time pake AJAX, CakePHP sudah mendukung AJAX. Yang pasti aplikasi Web 2.0 AJAX yang kamu buat akan berjalan dengan cepat dan mudah.

5. Komunitas developer yang luas. Yah, bagi Anda yang memang sudah siap terjun untuk menjadi pengembang CakePHP, silahkan sambangi komunitas-komunitas yang ada, di irc.cakephp.org, atau di channel #cakephp

6. Yang jelas, CakePHP yang dikembangkan oleh Cake Software Foundation ini sangat cocok untuk diterapkan dalam berbagai project Anda.

Ada beberapa kelemahan juga, sih. Tapi sedang dalam proses perbaikan koq :

1. Dokumentasi yang belum lengkap. CakePHP adalah framework yang selalu berkembang, demikian pula dokumentasinya. Maka dari itu, komunitas pengembang CakePHP selalu meng-update dokumentasi CakePHP, sesuai dengan perkembangan CakePHP itu sendiri

2. Belum ada dukungan internasionalisasi. Ya, sampai saat ini, release terbaru dari CakePHP belum support i18n, alias internasionalisasi bahasa-bahasa yang ada di dunia. Tapi sekali lagi, ini adalah bagian dari proses pengembangan, yang akan disempurnakan di release-release terbaru.
Tertarik?
http://idcake.web.id/ or http://www.cakephp.org/

The Cake Blog Tutorial

Introduction
Welcome to Cake! You're probably checking out this tutorial because you want to learn more about how Cake works. Its our aim to increase productivity and make coding more enjoyable: we hope you'll see this as you dive into the code.

This tutorial will walk you through the creation of a simple blog application. We'll be getting and installing Cake, creating and configuring a database, and creating enough application logic to list, add, edit, and delete blog posts.
Here's what you'll need:

A running web server. We're going to assume you're using Apache, though the instructions for using other servers should be very similar. We might have to play a little with the server configuration, but most folks can get Cake up and running without any configuration at all.

A database server. We're going to be using mySQL in this tutorial. You'll need to know enough about SQL in order to create a database: Cake will be taking the reigns from there.

Basic PHP knowledge. The more object-oriented programming you've done, the better: but fear not if you're a procedural fan.

Finally, you'll need a basic knowledge of the MVC programming pattern. A quick overview can be found in Chapter "Basic Concepts", Section 2: The MVC Pattern. Don't worry: its only a half a page or so.

Let's get started!

Section 2
Getting Cake
First, let's get a copy of fresh Cake code.

To get a fresh download, visit the CakePHP project at Cakeforge: http://cakeforge.org/projects/cakephp/ and download the stable release.

You can also checkout/export a fresh copy of our trunk code at: https://svn.cakephp.org/repo/trunk/cake/1.x.x.x/

Regardless of how you downloaded it, place the code inside of your DocumentRoot. Once finished, your directory setup should look something like the following:

/path_to_document_root
/app
/cake
/vendors
.htaccess
index.php
VERSION.txtNow might be a good time to learn a bit about how Cake's directory structure works: check out Chapter "Basic Concepts", Section 3: Overview of the Cake File Layout.

Section 3
Creating the Blog Database
Next, lets set up the underlying database for our blog. Right now, we'll just create a single table to store our posts. We'll also throw in a few posts right now to use for testing purposes. Execute the following SQL statements into your database:

/* First, create our posts table: */
CREATE TABLE posts (
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
title VARCHAR(50),
body TEXT,
created DATETIME DEFAULT NULL,
modified DATETIME DEFAULT NULL
);

/* Then insert some posts for testing: */
INSERT INTO posts (title,body,created)
VALUES ('The title', 'This is the post body.', NOW());
INSERT INTO posts (title,body,created)
VALUES ('A title once again', 'And the post body follows.', NOW());
INSERT INTO posts (title,body,created)
VALUES ('Title strikes back', 'This is really exciting! Not.', NOW());

The choices on table and column names are not arbitrary. If you follow Cake's database naming conventions, and Cake's class naming conventions (both outlined in Appendix "Cake Conventions"), you'll be able to take advantage of a lot of free functionality and avoid configuration. Cake is flexible enough to accomodate even the worst legacy database schema, but adhering to convention will save you time.

Check out Appendix "Cake Conventions" for more information, but suffice it to say that naming our table 'posts' automatically hooks it to our Post model, and having fields called 'modified' and 'created' will be automagically managed by Cake.

Section 4
Cake Database Configuration
Onward and upward: let's tell Cake where our database is and how to connect to it. This will be the first and last time you configure anything.

A copy of Cake's database configuration file is found in /app/config/database.php.default. Make a copy of this file in the same directory, but name it database.php.

The config file should be pretty straightforward: just replace the values in the $default array with those that apply to your setup. A sample completed configuration array might look something like the following:

var $default = array('driver' => 'mysql',
'connect' => 'mysql_pconnect',
'host' => 'localhost',
'login' => 'cakeBlog',
'password' => 'c4k3-rUl3Z',
'database' => 'cake_blog_tutorial' );
Once you've saved your new database.php file, you should be able to open your browser and see the Cake welcome page. It should also tell you that your database connection file was found, and that Cake can successfully connect to the database.

Section 5
A Note On mod_rewrite
Occasionally a new user will run in to mod_rewrite issues, so I'll mention them marginally here. If the Cake welcome page looks a little funny (no images or css styles), it probably means mod_rewrite isn't functioning on your system. Here are some tips to help get you up and running:

Make sure that an .htaccess override is allowed: in your httpd.conf, you should have a section that defines a section for each Directory on your server. Make sure the AllowOverride is set to All for the correct Directory.

Make sure you are editing the system httpd.conf rather than a user- or site-specific httpd.conf.

For some reason or another, you might have obtained a copy of CakePHP without the needed .htaccess files. This sometimes happens because some operating systems treat files that start with '.' as hidden, and don't copy them. Make sure your copy of CakePHP is from the downloads section of the site or our SVN repository.

Make sure you are loading up mod_rewrite correctly! You should see something like LoadModule rewrite_module libexec/httpd/mod_rewrite.so and AddModule mod_rewrite.c in your httpd.conf.


If you don't want or can't get mod_rewrite (or some other compatible module) up and running on your server, you'll need to use Cake's built in pretty URLs. In /app/config/core.php, uncomment the line that looks like:

define ('BASE_URL', env('SCRIPT_NAME'));
This will make your URLs look like www.example.com/index.php/controllername/actionname/param rather than www.example.com/controllername/actionname/param.

Section 6
Create a Post Model
The model class is the bread and butter of CakePHP applications. By creating a Cake model that will interact with our database, we'll have the foundation in place needed to do our view, add, edit, and delete operations later.

Cake's model class files go in /app/models, and the file we will be creating will be saved to /app/models/post.php. The completed file should look like this:

/app/models/post.php

Because of the way the class and file are named, this tells Cake that you want a Post model available in your PostsController that is tied to a table in your default database called 'posts'.

The $name variable is always a good idea to add, and is used to overcome some class name oddness in PHP4.

For more on models, such as table prefixes, callbacks, and validation, check out Chapter "Models".

Section 7
Create a Posts Controller
Next we'll create a controller for our posts. The controller is where all the logic for post interaction will happen, and its also where all the actions for this model will be found. You should place this new controller in a file called posts_controller.php inside your /app/controllers directory. Here's what the basic controller should look like:

/app/controllers/posts_controller.php

Now, lets add an action to our controller. When users request www.example.com/posts, this is the same as requesting www.example.com/posts/index. Since we want our readers to view a list of posts when they access that URL, the index action would look something like this:

/app/controllers/posts_controller.php (index action added)
set('posts', $this->Post->findAll());
}
}

?>
Let me explain the action a bit. By defining function index() in our PostsController, users can now access the logic there by requesting www.example.com/posts/index. Similarly, if we were to define a function called foobar(), users would be able to access that at www.example.com/posts/foobar.

The single instruction in the action uses set() to pass data to the view (which we'll create next). The line sets the view variable called 'posts' equal to the return value of the findAll() method of the Post model. Our Post model is automatically available at $this->Post because we've followed Cake's naming conventions.

To learn more about Cake's controllers, check out Chapter "Controllers".

Section 8
Creating Post Views
Now that we have our database connected using our model, and our application logic and flow defined by our controller, let's create a view for the index action we defined above.

Cake views are just HTML and PHP flavored fragments that fit inside an application's layout. Layouts can be defined and switched between, but for now, let's just use the default.

Remember in the last section how we assigned the 'posts' variable to the view using the set() method? That would hand down data to the view that would look something like this:

// print_r($posts) output:

Array
(
[0] => Array
(
[Post] => Array
(
[id] => 1
[title] => The title
[body] => This is the post body.
[created] => 2006-03-08 14:42:22
[modified] =>
)
)
[1] => Array
(
[Post] => Array
(
[id] => 2
[title] => A title once again
[body] => And the post body follows.
[created] => 2006-03-08 14:42:23
[modified] =>
)
)
[2] => Array
(
[Post] => Array
(
[id] => 3
[title] => Title strikes back
[body] => This is really exciting! Not.
[created] => 2006-03-08 14:42:24
[modified] =>
)
)
)
Cake's view files are stored in /app/views inside a folder named after the controller they correspond to (we'll have to create a folder named 'posts' in this case). To format this post data in a nice table, our view code might look something like this:

/app/views/posts/index.thtml

Blog posts



















IdTitleCreated

link($post['Post']['title'], "/posts/view/".$post['Post']['id']); ?>

Hopefully this should look somewhat simple.

You might have noticed the use of an object called $html. This is an instance of the HtmlHelper class. Cake comes with a set of view 'helpers' that make things like linking, form output, JavaScript and Ajax a snap. You can learn more about how to use them in Chapter "Helpers", but what's important to note here is that the link() method will generate an HTML link with the given title (the first parameter) and URL (the second parameter).

When specifying URL's in Cake, you simply give a path relative to the base of the application, and Cake fills in the rest. As such, your URL's will typically take the form of /controller/action/id.

Now you should be able to point your browser to http://www.example.com/posts/index. You should see your view, correctly formatted with the title and table listing of the posts.

If you happened to have clicked on one of the links we created in this view (that link a post's title to a URL /posts/view/some_id), you were probably informed by Cake that the action hasn't yet been defined. If you were not so informed, either something has gone wrong, or you actually did define it already, in which case you are very sneaky. Otherwise, we'll create it now:

/app/controllers/posts_controller.php (view action added)
set('posts', $this->Post->findAll());
}

function view($id = null)
{
$this->Post->id = $id;
$this->set('post', $this->Post->read());
}
}

?>
The set() call should look familiar. Notice we're using read() rather than findAll() because we only really want a single post's information.

Notice that our view action takes a parameter. This parameter is handed to the action by the URL called. If a user requests /posts/view/3, then the value '3' is passed as $id.

Now let's create the view for our new 'view' action and place it in /app/views/posts/view.thtml.

/app/views/posts/view.thtml



Created:




Verify that this is working by trying the links at /posts/index or manually requesting a post by accessing /posts/view/1.

Section 9
Adding Posts
reading from the database and showing us the posts is fine and dandy, but let's allow for the adding of new posts.

First, start with the add() action in the PostsController:

/app/controllers/posts_controller.php (add action added)
set('posts', $this->Post->findAll());
}

function view($id)
{
$this->Post->id = $id;
$this->set('post', $this->Post->read());

}

function add()
{
if (!empty($this->data))
{
if ($this->Post->save($this->data))
{
$this->flash('Your post has been saved.','/posts');
}
}
}
}

?>
Let me read the add() action for you in plain English: if the form data isn't empty, try to save the post model using that data. If for some reason it doesn't save, give me the data validation errors and render the view showing those errors.

When a user uses a form to POST data to your application, that information is available in $this->params. You can pr() that out if you want to see what it looks like. $this->data is an alias for $this->params['data'].

The $this->flash() function called is a controller function that flashes a message to the user for a second (using the flash layout) then forwards the user on to another URL (/posts, in this case). If DEBUG is set to 0 $this->flash() will redirect automatically, however, if DEBUG > 0 then you will be able to see the flash layout and click on the message to handle the redirect.

Calling the save() method will check for validation errors and will not save if any occur. There are several methods available so you can check for validation errors, but we talk about the validateErrors() call in a bit, so keep that on the back burner for a moment while I show you what the view looks like when we move on to the section about data validation.

Section 10
Data Validation
Cake goes a long way in taking the monotony out of form input validation. Everyone hates coding up endless forms and their validation routines, and Cake makes it easier and faster.

To take advantage of the validation features, you'll need to use Cake's HtmlHelper in your views. The HtmlHelper is available by default to all views at $html.

Here's our add view:

/app/views/posts/add.thtml

Add Post


url('/posts/add')?>" method=post>


Title:
input('Post/title', array('size' => '40'))?>
tagErrorMsg('Post/title', 'Title is required.') ?>



Body:
textarea('Post/body', array('rows'=>'10')) ?>
tagErrorMsg('Post/body', 'Body is required.') ?>



submit('Save') ?>



As with $html->link(), $html->url() will generate a proper URL from the controller and action we have given it. By default, it prints out a POST form tag, but this can be modified by the second parameter. The $html->input() and $html->textarea() functions spit out form elements of the same name. The first parameter tells Cake which model/field they correspond to, and the second param is for extra HTML attributes (like the size of the input field). Again, refer to Chapter "Helpers" for more on helpers.

The tagErrorMsg() function calls will output the error messages in case there is a validation problem.

If you'd like, you can update your /app/views/posts/index.thtml view to include a new "Add Post" link that points to www.example.com/posts/add.

That seems cool enough, but how do I tell Cake about my validation requirements? This is where we come back to the model.

/app/models/post.php (validation array added)
VALID_NOT_EMPTY,
'body' => VALID_NOT_EMPTY

);
}

?>
The $validate array tells Cake how to validate your data when the save() method is called. The values for those keys are just constants set by Cake that translate to regex matches (see /cake/libs/validators.php). Right now Cake's validation is regex based, but you can also use Model::invalidate() to set your own validation dynamically.

Now that you have your validation in place, use the app to try to add a post without a title or body to see how it works.

Section 11
Deleting Posts
Next, let's make a way for users to delete posts. Start with a delete() action in the PostsController:

/app/controllers/posts_controller.php (delete action only)
function delete($id)
{
$this->Post->del($id);
$this->flash('The post with id: '.$id.' has been deleted.', '/posts');
}
This logic deletes the post specified by $id, and uses flash() to show the user a confirmation message before redirecting them on to /posts.

Because we're just executing some logic and redirecting, this action has no view. You might want to update your index view to allow users to delete posts, however.

/app/views/posts/index.thtml (add and delete links added)

Blog posts


link('Add Post', '/posts/add'); ?>




















IdTitleCreated

link($post['Post']['title'], '/posts/view/'.$post['Post']['id']);?>
link(
'Delete',
"/posts/delete/{$post['Post']['id']}",
null,
'Are you sure?'
)?>

This view code also uses the HtmlHelper to prompt the user with a JavaScript confirmation dialog before they attempt to delete a post.

Section 12
Editing Posts
So... post editing: here we go. You're a Cake pro by now, so you should have picked up a pattern. Make the action, then the view. Here's what the edit action of the Posts Controller would look like:

/app/controllers/posts_controller.php (edit action only)
function edit($id = null)
{
if (empty($this->data))
{
$this->Post->id = $id;
$this->data = $this->Post->read();
}
else
{
if ($this->Post->save($this->data['Post']))
{
$this->flash('Your post has been updated.','/posts');
}
}
}
This checks for submitted form data. If nothing was submitted, go find the Post and hand it to the view. If some data has been submitted, try to save the Post model (or kick back and show the user the validation errors).

The edit view might look something like this:

/app/views/posts/edit.thtml

Edit Post


url('/posts/edit')?>" method=post>
hidden('Post/id'); ?>


Title:
input('Post/title', array('size' => '40'))?>
tagErrorMsg('Post/title', 'Title is required.') ?>



Body:
textarea('Post/body', array('rows'=>'10')) ?>
tagErrorMsg('Post/body', 'Body is required.') ?>



submit('Save') ?>



This view ouputs the edit form (with the values populated), and the necessary error messages (if present). One thing to note here: Cake will assume that you are edititing a model if the 'id' field is present and exists in a currently stored model. If no 'id' is present (look back at our add view), Cake will assume that you are inserting a new model when save() is called.

You can now update your index view with links to edit specific posts:

/app/views/posts/index.thtml (edit links added)

Blog posts


link("Add Post", "/posts/add"); ?>



















IdTitleCreated

link($post['Post']['title'], '/posts/view/'.$post['Post']['id']);?>
link(
'Delete',
"/posts/delete/{$post['Post']['id']}",
null,
'Are you sure?'
)?>
link('Edit', '/posts/edit/'.$post['Post']['id']);?>


Section 13
Routes
This part is optional, but helpful in understanding how URLs map to specific function calls in Cake. We're only going to make a quick change to routes in this tutorial. For more information, see Chapter "Configuration", Section 3: Routes Configuration.

Cake's default route will take a person visiting the root of your site (i.e. http://www.example.com) to the PagesController, and render a view called home. Rather than do that, we'll want users of our blog application to go to our soon-to-be-created PostsController.

Cake's routing is found in /app/config/routes.php. You'll want to comment out or remove the line that looks like this:

$Route->connect ('/', array('controller'=>'pages', 'action'=>'display', 'home'));
This line connects the URL / with the default Cake home page. We want it to connect with our own controller, so add a line that looks like this:

$Route->connect ('/', array('controller'=>'posts', 'action'=>'index'));
This should connect users requesting '/' to the index() action of our soon-to-be-created PostsController.

Section 14
Conclusion
Creating applications this way will win you peace, honor, women, and money beyond even your wildest fantasies. Simple, isn't it? Keep in mind that this tutorial was very basic. Cake has many more features to offer, and is flexible in ways we didn't wish to cover here. Use the rest of this manual as a guide for building more feature-rich applications.

Now that you've created a basic Cake application you're ready for the real thing. Start your own project, read the rest of the Manual and API.

Comparing VPN Options

Virtual private networking has become necessity for business users who need to remotely access their files. Of course, they could dial in directly to a remote access server, but that solution has a couple of significant drawbacks. The solution, of course, is a VPN connection. This article will discuss the different VPN options available

Virtual private networking has become more of a necessity than a luxury for business users who need a way to access files on an office network when they’re on the road, working from home or otherwise physically separated from the network. Of course, they could dial in directly to a remote access server, but that solution has a couple of significant drawbacks:

If your remote location is not in the same calling area as the remote access server, you’ll have to pay long distance charges – and those can add up fast if you need to spend much time connected to the network.
The remote access server will need multiple phone lines and modems in order to accommodate more than one incoming connection at a time – that cost, too, can add up if many.
The solution, of course, is a VPN connection. If the remote computer has Internet connectivity (via modem, broadband or through a LAN) and the office network has a permanent connection to the Internet such as T-1 or business-class broadband, the most cost effective way for remote users to connect is by tunneling through the public network. VPN technologies use tunneling protocols to create the connection and encryption protocols to provide the “private” part, allowing you to securely access a VPN server on the company network and through it (if the VPN server is set up to allow it), other computers on the company LAN.

So the question today is not whether to use VPN technology, but which VPN technology to use. There are four popular VPN protocols in use, and each has advantages and disadvantages. In this article, we’ll take a look at each and discuss how they compare, depending on your purpose.

Four Favorite Flavors of VPN
Because a VPN creates a secure “tunnel” through the public network, the protocols used to establish this tunneled connection are called tunneling protocols. If you ask the typical Windows administrator to name five VPN tunneling protocols, he/she is apt to get be stumped, having dealt only with the two VPN methods for which Windows provides built-in support. The five most common methods of creating a virtual private network include:

PPTP
L2TP
IPSec
SSL
The first two, of course, are familiar to Windows admins. The last two may be less so. Unfortunately, there is no clear cut one-size-fits-all solution. The best choice for your organization depends on a number of factors: server and client operating systems deployed, network resources to which access is needed, level of security required, performance issues, administrative overhead, and so forth.

PPTP
The Point-to-Point Tunneling Protocol (PPTP), developed by Microsoft in conjunction with other technology companies, is the most widely supported VPN method among Windows clients, and it is the only VPN protocol built into Windows 9x and NT operating systems. PPTP is an extension of the Internet standard Point-to-Point protocol (PPP), the link layer protocol used to transmit IP packets over serial links. PPTP uses the same types of authentication as PPP (PAP, SPAP, CHAP, MS-CHAP, EAP).

PPTP establishes the tunnel but does not provide encryption. It is used in conjunction with the Microsoft Point-to-Point Encryption (MPPE) protocol to create a secure VPN. PPTP has relatively low overhead, making it faster than some other VPN methods.

Because the client software is built into most Microsoft operating systems, PPTP servers can be deployed without having to worry about installing client software on those systems. PPTP clients are also available for Linux (see http://pptpclient.sourceforge.net/) and Macintosh OS 9.x (see http://www.rochester.edu/its/vpn/tunnelbuilder.html). Mac OS X 10.2 comes with built-in support for PPTP, and there are also third-party clients available for OS X (see http://www.gracion.com/vpn/). PPTP VPNs are supported by many major firewall appliances and enterprise level software firewalls, including ISA Server, Cisco PIX, SonicWall and some models of WatchGuard.

PPTP has been criticized in the past for various security flaws; many of these problems have been addressed in current versions of the protocol. Using EAP authentication greatly enhances the security of PPTP VPNs. One advantage of using PPTP is that there is no requirement for a Public Key Infrastructure; however EAP does use digital certificates for mutual authentication (both client and server) and highest security.

L2TP
The Layer 2 Tunneling Protocol (L2TP) was developed in cooperation between Cisco and Microsoft, combining features of PPTP with those of Cisco’s proprietary Layer 2 Forwarding (L2F) protocol. One advantage of L2TP over PPTP is that it can be used on non-IP networks such as ATM, frame relay and X.25. Like PPTP (and as its name implies), L2TP operates at the data link layer of the OSI networking model. L2TP VPNs are supported by many major firewall products, including ISA Server, CheckPoint, Cisco PIX, and WatchGuard.

The L2TP client is built into Windows 2000, XP and 2003, but you can download client software for most pre-Windows 2000 operating systems (Windows 98, ME and NT 4.0).

IP Security (IPSec), and more specifically its Encapsulating Security Payload (ESP) protocol, provides the encryption for L2TP tunnels.

L2TP requires the use of digital certificates. User authentication can be performed via the same PPP authentication mechanisms as PPTP, but L2TP also provides computer authentication. This adds an extra level of security.

L2TP has several advantages over PPTP. PPTP gives you data confidentiality, but L2TP goes further and also provides data integrity (protection against modification of the data between the time it left the sender and the time it reached the recipient), authentication of origin (confirmation that the user who claims to have sent the data really did), and replay protection (which keeps a hacker from being able to capture data that is sent, such as the sending of credentials, and then “replay” it to “trick” the server). On the other hand, the overhead involved in providing this extra security can result in slightly slower performance than PPTP.

IPSec
Windows administrators know IPSec as the protocol used for encryption in conjunction with the L2TP tunneling protocol. However, IPSec can itself be used as a tunneling protocol, and is in fact considered by many to be the “standard” VPN solution, especially for gateway-to-gateway (site-to-site) VPNs that connect two LANs. IPSec operates at a higher level of the OSI model, the network layer (Layer 3).

Many hardware VPN appliances use an implementation of IPSec. For example, Cisco’s VPN Concentrators and PIX firewalls support IPSec, as do NetScreen, SonicWall, and WatchGuard appliances. Enterprise level software firewalls such as ISA Server, CheckPoint and Symantec Enterprise Firewall also support IPSec VPNs.

IPSec in tunnel mode secures packets that are transmitted between two gateways or between a client computer and a gateway. As its name implies, an IPSec VPN works only with IP-based networks and applications. Like PPTP and L2TP, IPSec requires that the VPN client computers have client software installed.

Authentication is accomplished via the Internet Key Exchange (IKE) protocol with either digital certificates (which is the more secure method) or with a preshared key. IPSec VPNs can protect against many of the most common attack methods, including Denial of Service (DoS), replay, and “man-in-the-middle” attacks.

Many vendors include “managed client” features in their VPN client software, which make it possible for you to establish policies regarding such things as a requirement that the client machine have anti-virus software or personal firewall software installed in order to be allowed to connect to the VPN gateway.

IPSec support is included in Windows 2000/XP/2003, but not in older Windows operating systems. VPN gateway vendors, such as Cisco and CheckPoint, provide client software for their IPSec-based VPNs. Note that you may have to purchase licenses for the client software.

SSL
A VPN technology that has been growing in popularity is the Secure Sockets Layer (SSL) VPN. A big advantage of SSL VPNs is that you don’t need special VPN client software on the VPN clients. That’s because the SSL VPN uses the Web browser as the client application. Thus, SSL VPNs are known as “clientless” solutions. This also means the protocols that can be handled by an SSL VPN are more limited. However, this can also be a security advantage. With SSL VPNs, instead of giving VPN clients access to the whole network or subnet as with IPSec, you can restrict them to specific applications. If the applications to which you want to give them access are not browser-based, however, custom programming might be necessary to create Java or Active-X plug-ins to make the application accessible through the browser. A disadvantage of this is that in order to use such plug-ins, the client’s browser settings will have to be opened up to allow active content – thus exposing the browser to malicious applets unless you set it to block unsigned active content and ensure that the plug-ins are digitally signed.

SSL VPNs operate at an even higher layer of the OSI model than IPSec VPNs: the session layer. This gives them the ability to control access more granularly. SSL VPNs use digital certificates for server authentication. Other methods can be used for client authentication, but certificates are preferred as the most secure.

Even though there is no client software installed (other than the Web browser), SSL VPN gateways can still provide the advantages of “managed clients” by forcing the browser to run applets, for example, to verify that anti-virus software is in place before the VPN connection can be established.

Summary
Virtual private networking is often the best and most cost effective way to provide remote access to your company network. The first step in deploying a VPN server/gateway is selecting the type of VPN technology to use. The four most common VPN technologies in use are PPTP, L2TP, IPSec and SSL. Each has advantages and disadvantages, so it is important to familiarize yourself with the characteristics of each, and with your users’ needs, before making a decision. In this article, we’ve provide a brief overview of each of these VPN protocols.

Scan Effectively with Anti-Virus

This procedure can remove common threat on your computer using only your installed Anti-Virus software.
Author:
PreciseSecurity
Operating System:
Windows ME/2000/XP

Requirements:
1. Installed Anti-Virus Software
2. Internet connection
3. Administrative privilege
Procedure:
1. Temporarily Disable System Restore in Windows XP. For Windows ME user, please click here.
Note: You must have an Administrator Privilege to be able to disable System Restore on Windows XP. It is advised to enable it after this procedure.
a) On the Desktop, Right Click on My Computer
b) Select the System Restore Tab
c) Mark the “Turn Off System Restore” to disable and UnMark to Enable
d) Click Apply on the Bottom of the Dialog Box to save the settings.
e) A message “This deletes all existing restore points” will appear, click Yes to disable.
f) Click OK.
2. Connect to internet and update your Anti-Virus software
3. Reboot computer in SafeMode
a) During BootUp process Press F8 continuously until selection appears
b) Use Arrow Up+Down to select SafeMode on the selections menu.
c) Hit Enter to proceed.
4. Thoroughly scan your computer with Anti-Virus installed and clean/delete all infected files.
5. Reboot computer and start it normally.
6. Do another scan to make sure that there are no threats present on your computer.

Wednesday, December 26, 2007

NEW FOLDER.EXE Dangerous

versions of an executable program.
The most common file size is 107,520 bytes. But the following file sizes have also been seen:
172,032 bytes
222,461 bytes
272,131 bytes
197,120 bytes
106,496 bytes

The filename NEW FOLDER.EXE refers to many The unsafe files using this name are associated with the malware group WORM.VB.NLJ.Some files using the name NEW FOLDER.EXE are also associated with the malware groups:
WORM.SOHANAT.AB
SystemPoser:Trojan-c
These files have no vendor, product or version information specified in the file header.
NEW FOLDER.EXE has been seen to perform the following behavior(s):
The Process is packed and/or encrypted using a software packing process
Disables Access to the Windows Registry Editior
Modifies Windows Security Policies to restrict/expand User Privlidges on the machine
Disables Access to the Task Manager built into Windows
Adds a Registry Key (RUN) to auto start Programs on system start up
Disables the built in Windows File Protection System
This Process Creates Other Processes On Disk
This Process Deletes Other Processes From Disk
Executes a Process
Terminates Processes
Writes to another Process's Virtual Memory (Process Hijacking)
Can communicate with other computer systems using HTTP protocols
Registers a Dynamic Link Library File
Changes the Internet Explorer Home Page Settings
Changes of IE options including home page, security tab, colour, font, advanced, menu
Disables the Built in Windows System Restore Feature
Adds a Link in the Start Menu
NEW FOLDER.EXE has been the subject of the following behavior(s):
Created as a process on disk
Executed as a Process
Added as a Registry auto start to load Program on Boot up
Writes to another Process's Virtual Memory (Process Hijacking)
Executed by Internet Explorer
Deleted as a process from disk
Terminated as a Process
Added as a Link in the Start Menu
NEW FOLDER.EXE can also use the following file names:

SVICHOSSST.EXE
JSA CO2 AREA.EXE
WORKING.EXE
DEHYDRATION SKID TESTING.EXE
10.31.38.03 FIRST AID PRESENTATION.EXE
WORK RELATED INJURIES.EXE
ELECTRICITY.EXE
AFZAL DATA.EXE
AFZAL CV NEW.EXE
FIRST AID PRESENTATION.EXE
TOTAL POSTER.EXE
LEVEL 2 - SOP.EXE
FALLS & FALLING OBJECTS.EXE
ACCESS.EXE
CHEMICALS.EXE
SUPERVISOR SKILPATH.EXE
FIRE.EXE
PPE.EXE
NEW SIGNS.EXE
TOOLBOX TOPICS.EXE
SUPERVISION WORKSHOP.EXE
SOP-FORMET.EXE
SUP TRAINING PPTA.EXE
FORMATS.EXE
RIGGING MANUAL.EXE
SAFETY LEADERSHIP.EXE
PRESENTATIONS.EXE
PLAN-METHOD STATEMENT.EXE
HSE PLANE.EXE
MSDS.EXE
OSHA.DOMENO THEORY.EXE
TERRENSFIN.EXE
DOMINO THEORY.EXE
T&J SAFETY & QUALITY PLAN.EXE
SST.EXE
OSHA 10 HOUR.EXE
SUPERVISOR 40 HOUR TRAINING.EXE
OSHA 10 HOURS.EXE
OSHA FILE.EXE
PMT STANDERED.EXE
OSHA GUIDE.EXE
JCP SAFETY MANUAL.EXE
ERGONOMICS FACT SHEET_FILES.EXE
NET SAFETY.EXE
EMERGENCY RESPONSE PLAN_FILES.EXE
HIGHLY REACTIVE CHEMICALS_FILES.EXE
INDEX - TRAINING - SAFETY SESSIONS_FILES.EXE
PROCESS SAFETY MANAGEMENT - INTRODUCTION_FILES.EXE
URDU.EXE
FIRE EXTINGUISHER TRAING OUTLINE_FILES.EXE
GENERAL SAFETY INSPECTION_FILES.EXE
IAQ - SICK BUILDING SYNDROME_FILES.EXE
FLEET MANAGEMENT - ACCIDENT PREVENTION_FILES.EXE
EYE WASH AND EMERGENCY SHOWERS_FILES.EXE
M A J.EXE
KSAJEEL.EXE
ISO.EXE
JSA MECH.EXE
INCIDENT REPORTS.EXE
CERTIFICATE.EXE
2007-09 (SEP).EXE
DEL DOC. TRANING.EXE
RVHOST.EXE
MSTAN.EXE
RICOH.EXE
DD1.EXE
WEEKLY SCHEDULE 07.EXE
POCKETGUIDE.EXE
JULY DAILY REPORT.EXE
JULY07.EXE
EXPLORE.EXE
WORM2007[1].EXE
LSASS.EXE
SVCHOST32.EXE
PPQ5A.TMP
BOOT.EXE
MSCONFIG.EXE
CALENDARS.EXE
WINDOWS EXPLORER.EXE
TOP PICTURES.EXE
DC3.EXE
DC4.EXE

Windows Defender helps protect your computer from spyware and other unwanted software

Windows Defender detects and removes known spyware from your computer, which helps make your Internet browsing safer.

The software uses automatic definition updates provided by Microsoft analysts to help detect and remove new threats as the threats are identified.

Improvements in Windows Defender
• Enhanced performance through a new scanning engine.

• Streamlined, simplified user interface and alerts.

• Improved control over programs on your computer using enhanced Software Explorer.

• Multiple language support with globalization and localization features.

• Protection technologies for all users, whether or not they have administrator rights on the computer.

• Support for assistive technology for individuals who have physical or cognitive difficulties, impairments, and disabilities.

• Support for Microsoft Windows XP Professional x64 Edition.

• Automatic cleaning according to your settings during regularly scheduled scans.


Benefits of Windows Defender
Helps detect and remove spyware

• Spyware detection. Quickly and easily finds spyware and other unwanted programs that can slow down your computer, display annoying pop-up ads, change Internet settings, or use your private information without your consent.

• Straightforward operation and thorough removal technology. Eliminates detected spyware easily at your direction. If you inadvertently remove programs that you actually want, it's easy to get them back.

• Scheduled scanning and removal. Runs these processes when it's convenient for you, whether it's on-demand or on a schedule that you set.


Improves Internet browsing safety

• Helps stop spyware before it infiltrates your computer. Offers a continuous safeguard designed to target all the ways that spyware can infiltrate your computer.

• Works without distracting you. Runs in the background and automatically handles spyware based on preferences that you set. You can use your computer with minimal interruption.


Helps stop the latest threats

• Expertise you can rely on. A dedicated team of Microsoft researchers continuously searches the Internet to discover new spyware and develop methods to counteract it.

• Stops new threats quickly. A voluntary, worldwide network of Windows Defender users helps Microsoft determine which suspicious programs to classify as spyware. Participants help discover new threats quickly and notify Microsoft analysts, so that everyone is better protected. Anyone who uses Windows Defender can join this network and help report potential spyware to Microsoft.

• Automatically stays up to date. To help protect your computer from the latest threats, you can choose to have updates that counteract new spyware automatically downloaded to your computer.


Windows Defender detects and removes known spyware from your computer, which helps make your Internet browsing safer.

The software uses automatic definition updates provided by Microsoft analysts to help detect and remove new threats as the threats are identified.

Basic Computer Tutorial

This basic computer tutorial is written for those who do not know very much about computers. The purpose of this basic computer tutorial is to help the reader better understand how to use their computer more effectively and safely. It will help the reader understand:

What files and file types are.
How to copy files.
Where your files are stored.
What the parts of your computer are.
What an operating system is.
What a computer program is.
Security and Performance
With the above basic information, this tutorial will explain methods that you can do to make your system more secure, keep your data safe by backing it up, and avoid most performance degredation caused to bad applications and SPAM.

How some file types can be used by third parties to gain control of your computer.
How to modify your file view settings so you are not as easily fooled by e-mails containing viruses.
How to prevent viruses and worms.
How to reduce SPAM.
How to back up your files.
How to reduce or eliminate unwanted programs that could reduce your system performance.
What to do if you receive a virus or worm.
What to do if you receive an e-mail telling you that an e-mail you sent contained a virus.


This basic computer tutorial gives some basic information about hardware, operating systems, and programs in the first half to help the reader understand later information about files, e-mail and computer security practices. Depending on the reader's level of knowledge, some of the basic information may be skipped and the reader may refer to the terms page if they do not understand some of the terms.