Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: Testing Scripts

  1. #1
    Join Date
    Jun 2004
    Posts
    102

    Default

    MySQL connection script using MySQLPP

    Code:

    #!/usr/bin/perl

    print "Content-type: text/html\n\n";
    use DBI;

    my $database;
    $database = 'ecakti';
    $option1 = 'localhost';
    $option2 = 'ecakti';
    $option3 = 3306;

    my $password;
    $password = 'tjm2244';

    my $dbh = eval {
    DBI->connect(
    "dbi:mysqlPP:database=$database;hostname=&#03 6;option1;port=$option3",
    $option2, $password, {
    RaiseError => 1, PrintError => 0
    });
    };
    die $DBI::errstr if $@;
    print "Connected to database sucessfully";

  2. #2
    Join Date
    Jun 2004
    Posts
    102

    Default

    CGI script for testing MySQL connection

    Code:

    #! /usr/bin/perl

    use DBI;
    use strict;
    my $dbh;

    print "Content-type: text/html \n\n";

    $dbh = DBI->connect('DBI:mysql:genepilotReg','bre ttm','ba35se&#39||print "Cannot Connect" . $dbh->errstr . "&br&";

    $dbh->disconnect;

    print "done";

  3. #3
    Join Date
    Jun 2004
    Posts
    102

    Default

    Test JSP script

    Place the following code in the html folder with the permissions 0640 and as hello.jsp:

    Requirements

    File: /hello.jsp
    Permissions: 0640

    Code:

    <%
    String title = "hello.jsp";
    %>
    <HTML>
    <HEAD>
    <TITLE><%= title %></TITLE>
    </HEAD>
    <BODY>
    <H1><%= title %></H1>

    JSP example
    </BODY>
    </HTML>



    The Output should be as follows:
    hello.jsp in the Title bar and body section
    and
    JSP example in the body section

  4. #4
    Join Date
    Jun 2004
    Posts
    102

    Default

    PHP Mail

    Mail
    (PHP 3, PHP 4 )
    Mail -- send mail

    Description
    bool mail ( string to, string subject, string message [, string additional_headers [, string additional_parameters]])

    mail() automatically mails the message specified in message to the receiver specified in to. Multiple recipients can be specified by putting a comma between each address in to. Email with attachments and special types of content can be sent using this function.

    mail() returns TRUE if the mail was successfully accepted for delivery, FALSE otherwise.

    Example 1: Sending mail.

    Code:
    mail("joecool@example.com", "My Subject", "Line 1&#092;nLine 2&#092;nLine 3");



    If a fourth string argument is passed, this string is inserted at the end of the header. This is typically used to add extra headers. Multiple extra headers are separated with a carriage return and newline.

    Note: You must use &#092;r&#092;n to seperate headers, although some Unix mail transfer agents may work with just a single newline (&#092;n).


    Example 2 : Sending mail with extra headers.


    Code:
    mail ("nobody@example.com", "the subject", &#036;message,
    "From: webmaster@&#036;SERVER_NAME&#092;r&#092;n"
    "Reply-To: webmaster@&#036;SERVER_NAME&#092;r&#092;n"
    "X-Mailer: PHP/" . phpversion());


    The additional_parameters parameter can be used to pass an additional parameter to the program configured to use when sending mail using the sendmail_path configuration setting. For example, this can be used to set the envelope sender address when using sendmail. You may need to add the user that your web server runs as to your sendmail configuration to prevent a &#39;X-Warning&#39; header from being added to the message when you set the envelope sender using this method.


    Example 3 : Sending mail with extra headers and setting an additional command line parameter.


    Code:
    Mail( "nobody@example.com", "the subject", &#036;message,
    "From: webmaster@&#036;SERVER_NAME", "-
    fwebmaster@&#036;SERVER_NAME" );



    Note: This fifth parameter was added in PHP 4.0.5. Since PHP 4.2.3 this parameter is disabled in safe_mode and the mail() function will expose a warning message and return FALSE if you&#39;re trying to use it.


    You can also use simple string building techniques to build complex email messages.

    Example 4 : Sending complex email.


    Code:
    /* recipients */
    &#036;to = "Mary <mary@example.com>" . ", " ; // note the comma
    &#036;to .= "Kelly <kelly@example.com>";

    /* subject */
    &#036;subject = "Birthday Reminders for August";

    /* message */
    &#036;message = &#39;
    <html>
    <head>
    <title>Birthday Reminders for August</title>
    </head>
    <body>


    Here are the birthdays upcoming in August&#33;</p>
    <table>
    <tr>
    <th>Person</th><th>Day</th><th>Month</th><th>Year</th>
    </tr>
    <tr>
    <td>Joe</td><td>3rd</td><td>August</td><td>2004</td>
    </tr>
    <tr>
    <td>Sally</td><td>17th</td><td>August</td><td>1973</td>
    </tr>
    </table>
    </body>
    </html> &#39;;

    /* To send HTML mail, you can set the Content-type header. */
    &#036;headers = "MIME-Version: 1.0&#092;r&#092;n";
    &#036;headers = "Content-type: text/html; charset=iso-8859-1&#092;r&#092;n";

    /* additional headers */
    &#036;headers = "From: Birthday Reminder <birthday@example.com>&#092;r&#092;n";

    &#036;headers = "Cc: birthdayarchive@example.com&#092;r&#092;n";
    &#036;headers = "Bcc: birthdaycheck@example.com&#092;r&#092;n";

    /* and now mail it */
    mail(&#036;to, &#036;subject, &#036;message, &#036;headers);



    Note: Make sure you do not have any newline characters in the to or subject, or the mail may not be sent properly.

    Note: The to parameter cannot be an address in the form of "Something <someone@example.com>". The mail command will not parse this properly while talking with the MTA.

  5. #5
    Join Date
    Jun 2004
    Posts
    102

    Default

    PHP-Mysql for localhost


    Code:
    <?php
    &#036;host=?localhost?; // You can use IP address instead of localhost
    &#036;user=?Your Username?;
    &#036;password=?Your Password?;
    &#036;database=?Your Databasename?;

    &#036;Link_ID=mysql_pconnect(&#036;host, &#036;user, &#036;password);
    if (&#33;&#036;Link_ID)
    {
    echo "Failed to connect to Server=".&#036;host;
    return 0;
    }
    else
    {
    echo "Successfully to connected to Server=".&#036;host;
    }


    if (&#33;@mysql_select_db(&#036;database,&#036;Link_I D))
    {
    echo "
    Cannot use database=".&#036;database;
    }
    else
    {
    echo "
    Successfully connected to database=".&#036;database;
    }
    ?>

  6. #6
    Join Date
    Jun 2004
    Posts
    102

    Default

    To test the perl modules installed on the server you can use the following code and place it in the cgi-bin of the domain.

    Code:

    #&#33;/usr/bin/perl -w
    #
    #************************************************* **********************
    # PURPOSE: Freeware Perl script to display some server-side information
    # including environment variables and installed modules.
    #
    # DATE: 21 August, 2002
    # VERSION: 0.2.1
    #
    # LICENSE:
    # Copyright &copy; Shashank Tripathi (shanx@shanx.com)
    #
    # This program is free software; you can redistribute it and/or
    # modify it under the terms of the GNU General Public License
    # as published by the Free Software Foundation; either version 2
    # of the License, or (at your option) any later version.
    #
    # This program is distributed in the hope that it will be useful,
    # but WITHOUT ANY WARRANTY; without even the implied warranty of
    # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    # GNU General Public License for more details.
    #
    # You should have received a copy of the GNU General Public License
    # along with this program; if not, write to the Free Software
    # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
    # 02111-1307, USA.
    #
    #================================================= ======================
    # I N S T A L L A T I O N:
    #-----------------------------------------------------------------------
    #
    # 1. Copy and paste all this text into a file, e.g., perldigger.cgi
    # 2. Upload this file into your CGI-BIN or an equivalent CGI directory.
    # 3. CHMOD the file to 755 so it can be executed.
    # 4. It is common for Perl to reside on most servers at "/usr/bin/perl"
    # but if it doesn&#39;t, please replace the first line of this program
    # with the appropriate path (e.g., "/usr/local/bin/perl").
    #
    # That should be all. If you have any problems, please feel free to
    # write to me at shanx@shanx.com.
    #
    #************************************************* **********************
    use CGI qw(:standard);
    use CGI::Carp qw(fatalsToBrowser);
    print "Content-type: text/html&#092;n&#092;n";


    # You can set the page title here
    &#036;PAGE_TITLE = "PERL DIGGER &deg;| Free CGI script to list environment information and installed Perl modules";


    #-----------------------------------------------------------------------
    # NO NEED TO TOUCH ANYTHING BEYOND THIS POINT
    #================================================= ======================

    #Location of Perl
    &#036;whereperl = join("
    ", split(/&#092;s+/, qx/whereis perl/));

    #Location of Sendmail
    &#036;wheresendmail = join("
    ", split(/&#092;s+/, qx/whereis sendmail/));

    #Location of Current Directory
    &#036;currentdirectory = `pwd`;

    # List of processes
    &#036;processes = qx/ps aux/;
    &#036;processes =~ s/
    /&#092;n/gi;
    &#036;processes =~ s/
    /&#092;n&#092;n/gi;
    &#036;processes =~ s/<(?:[^>&#39;"]*|([&#39;"]).*?&#092;1)*>//gs;

    #Perl Variables
    &#036;perlversion = &#036;];

    &#036;path_tar = join("
    ", split(/&#092;s+/, qx/whereis tar/));
    &#036;path_gzip = join("
    ", split(/&#092;s+/, qx/whereis gzip/));
    &#036;path_apache = join("
    ", split(/&#092;s+/, qx/whereis apache/));
    &#036;path_httpd = join("
    ", split(/&#092;s+/, qx/whereis httpd/));
    &#036;path_php = join("
    ", split(/&#092;s+/, qx/whereis php/));
    &#036;path_mysql = join("
    ", split(/&#092;s+/, qx/whereis mysql/));
    &#036;path_man = join("
    ", split(/&#092;s+/, qx/whereis man/));
    &#036;path_perldoc = join("
    ", split(/&#092;s+/, qx/whereis perldoc/));


    #Perl Os
    &#036;perlos = &#036;^O;
    &#036;perlos_version = get_server(&#39;version&#39;
    &#036;perlos_version =~ s/#/
    #/s;
    &#036;perlos_version =~ s/&#092;(/
    (/s;

    &#036;perlos_cpu = get_server_detail(&#39;cpuinfo&#39;
    &#036;perlos_mem = get_server_detail(&#39;meminfo&#39;
    &#036;perlos_mem =~ s/^.*?&#092;n.*?&#092;n.*?&#092;n//s;
    &#036;perlos_dsk = `df`;

    sub get_server
    {
    open PROC, "</proc/&#036;_[0]" || &error("Cannot read proc [/proc/&#036;_[0]]", &#036;&#33;
    my &#036;res = join("
    ", <PROC>);
    close PROC;
    return &#036;res ? &#036;res : undef;
    }
    sub get_server_detail
    {
    open PROC, "</proc/&#036;_[0]" || &error("Cannot read proc [/proc/&#036;_[0]]", &#036;&#33;
    my &#036;res = join("", <PROC>);
    close PROC;
    return &#036;res ? &#036;res : undef;
    }


    #Module Paths
    foreach &#036;line (@INC)
    {
    &#036;modulepaths .= "&#036;line
    ";
    }

    #Environment Variables
    &#036;environment = qq~
    <table width="69%" align="center" cellspacing="0" cellpadding="4" bordercolor="#c5c5c5">
    <tr>
    <td colspan="2" bgcolor="#efefef" class="tabletitle">ENVIRONMENT VARIABLES <font style="font-family: Webdings; font-size: 15px; text-decoration: none">5</font> </td>
    </tr>
    ~;

    &#036;PAGE_FOOTER = "Powered by | Copyright &copy; <a href=&#39;http://shanx.com&#39;>Shashank Tripathi ";

    @allkeys = keys(%ENV);
    foreach &#036;key (@allkeys)
    {
    &#036;value = &#036;ENV{&#036;key};
    if (&#036;value eq "") {&#036;value = "-";}
    &#036;environment .= qq~
    <tr>
    <td width="168" class="tableitems">&#036;key</td>
    <td class="tablevalue">&#036;value</td>
    </tr>
    ~;
    }
    &#036;environment .= qq~
    </table>
    ~;


    &#036;documentroot = &#036;ENV{&#39;DOCUMENT_ROOT&#39;};
    if (&#036;documentroot ne "")
    {
    @lines = `du -c -k &#036;documentroot`;
    &#036;lastline = @lines-1;
    (&#036;diskusage) = split/[&#092;t| ]/,&#036;lines[&#036;lastline];
    }

    #Server Software
    &#036;serverip = &#036;ENV{&#39;SERVER_ADDR&#39;};
    &#036;servername = &#036;ENV{&#39;SERVER_NAME&#39;};
    &#036;serverport = &#036;ENV{&#39;SERVER_PORT&#39;};

    &#036;serversoftware = &#036;ENV{&#39;SERVER_SOFTWARE&#39;};

    &#036;serveruptime =`uptime`;


    #Localtime
    (&#036;sec,&#036;min,&#036;hour,&#036;mday,&#036;m on,&#036;year,&#036;wday,&#036;yday,&#036;isdst) = localtime(time);
    @months = ("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug"," Sep","Oct","Nov","Dec");
    &#036;date = sprintf("%02d-%s-%04d",&#036;mday,&#036;months[&#036;mon],&#036;year+1900);
    &#036;time = sprintf("%02d:%02d:%02d",&#036;hour,&#036;min,&#03 6;sec);
    &#036;localtime = "&#036;date, &#036;time";

    #GMTtime
    (&#036;sec,&#036;min,&#036;hour,&#036;mday,&#036;m on,&#036;year,&#036;wday,&#036;yday,&#036;isdst) = gmtime(time);
    @months = ("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug"," Sep","Oct","Nov","Dec");
    &#036;date = sprintf("%02d-%s-%04d",&#036;mday,&#036;months[&#036;mon],&#036;year+1900);
    &#036;time = sprintf("%02d:%02d:%02d",&#036;hour,&#036;min,&#03 6;sec);
    &#036;gmttime = "&#036;date, &#036;time";


    print qq~
    <&#33;DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>

    <title>&#036;PAGE_TITLE</title>

    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <meta http-equiv="PICS-Label" content=&#39; (PICS-1.1 "http://www.gcf.org/v2.5" labels on "2001.11.05T08:15-0500" until "1995.12.31T23:59-0000" for "http://w3.org/PICS/Overview.html" ratings (suds 0.5 density 0 color/hue 1))&#39;>
    <meta name="author" lang="en" content="Shashank Tripathi">
    <meta name="title" content="&#036;PAGE_TITLE">
    <meta name="copyright" content="&copy; Shashank Tripathi, 1998 - 2010. All rights reserved.">
    <meta name="revisit-after" content="1 week">
    <meta name="description" content="Perl Digger is a freeware Perl script to dig for information about the server-side environment including a list of all installed Perl modules with a handy link to their documentation at CPAN">
    <meta name="keywords" content="Perl digger, Perl info, server-side free Perl / CGI script to show environment variables and all installed Perl modules, Shashank Tripathi">

    <style type="text/css">
    &#60;&#33;--
    h1 {font-family: Arial, Helvetica, sans-serif; font-size: 18px; font-weight: bold; }
    .tabletitle { font-family: Arial, Helvetica, sans-serif; font-size: 12px; font-weight: bold; height: 22px; }
    .tableitems { font-family: Arial, Helvetica, sans-serif; font-weight: bold; font-size: 11px; border-bottom: 1px #efefef solid;}
    .tablevalue { font-family: Arial, Helvetica, sans-serif; font-size: 11px; border-bottom: 1px #efefef solid;}
    a { color: #3366ff; }
    a:hover { text-decoration: none; color: #ff6600;}
    td { font-family: Arial, Helvetica, sans-serif; font-size: 11px }
    table { border: 1px #c5c5c5 solid; background-color: #fff }
    --&#62;
    </style>
    </head>

    <body bgcolor="#FFFFFF" text="#000000" background="http://sniptools.com/av/bg.gif"><a name="top"></a>

    <table width="69%" align="center" cellpadding="4" cellspacing="0">
    <tr><td height="51" width="168" valign="top" background="http://sniptools.com/av/bg_grey.gif"><h1 style="margin-bottom: 3px">Perl Digger</h1>
    Get Perl code here</td>
    <td valign="middle" background="http://sniptools.com/av/bg_grey.gif"><b style="font-size: 12px">Perl Digger is a freeware Perl script to dig for information
    about the server-side environment including a list of all installed Perl modules
    with a handy link to their documentation at CPAN. This page is based on easy CSS so you can easily change
    the look if you wish.
    [/b] </tr>
    <tr>
    <td colspan="2" height="60" align="center" valign="middle">
    PERL INFORMATION
    | SERVER INFORMATION
    | ENVIRONMENT VARIABLES
    | INSTALLED PERL MODULES
    </td>
    </tr>
    </table>



    <a name="perlinfo"></a>


    <table width="69%" align="center" cellpadding="4" cellspacing="0">
    <tr bgcolor="#efefef">
    <td colspan="2" class="tabletitle">

    PERL INFORMATION <font style="font-family: Webdings; font-size: 15px; text-decoration: none">5</font>

    </td>
    </tr>
    <tr>
    <td class="tableitems" width="168" valign="top">Perl version</td>
    <td class="tablevalue">&#036;perlversion</td>
    </tr>
    <tr>
    <td class="tableitems" width="168" valign="top">Perl</td>
    <td class="tablevalue">&#036;whereperl</td>
    </tr>
    <tr>
    <td class="tableitems" width="168" valign="top">Sendmail</td>
    <td class="tablevalue">&#036;wheresendmail</td>
    </tr>
    </table>


    <a name="serverinfo"></a>


    <table width="69%" align="center" cellspacing="0" cellpadding="4" bordercolor="#c5c5c5">
    <tr bgcolor="#efefef">
    <td colspan="2" class="tabletitle">

    SERVER INFORMATION <font style="font-family: Webdings; font-size: 15px; text-decoration: none">5</font>

    </td>
    </tr>
    <tr>
    <td class="tableitems" width="168" valign="top">Name</td>
    <td class="tablevalue">&#036;servername</td>
    </tr>
    <tr>
    <td class="tableitems" width="168" valign="top">IP</td>
    <td class="tablevalue">&#036;serverip</td>
    </tr>
    <tr>
    <td class="tableitems" width="168" valign="top">Listing Port</td>
    <td class="tablevalue">&#036;serverport</td>
    </tr>
    <tr>
    <td class="tableitems" width="168" valign="top">Document Root</td>
    <td class="tablevalue">&#036;documentroot</td>
    </tr>
    <tr>
    <td class="tableitems" width="168" valign="top">Disk Usage by Root</td>
    <td class="tablevalue">&#036;diskusage KB</td>
    </tr>
    <tr>
    <td class="tableitems" width="168" valign="top">Server stamp</td>
    <td class="tablevalue">&#036;serversoftware</td>
    </tr>
    <tr>
    <td class="tableitems" width="168" valign="top">Server Time (Local)</td>
    <td class="tablevalue">&#036;localtime</td>
    </tr>
    <tr>
    <td class="tableitems" width="168" valign="top">Server Time (GMT)</td>
    <td class="tablevalue">&#036;gmttime</td>
    </tr>
    <tr>
    <td class="tableitems" width="168" valign="top">Server Details </td>
    <td class="tablevalue">


    OPERATING SYSTEM:
    &#036;perlos_version


    CPU UTILIZATION:
    <textarea rows=10 cols=60>&#036;perlos_cpu</textarea>


    MEMORY UTILIZATION:
    <textarea rows=10 cols=60>&#036;perlos_mem</textarea>


    DISK UTILIZATION:
    <textarea rows=10 cols=60 wrap="OFF">TOTAL DISK USAGE:&#092;n&#036;diskusage KB &#092;n&#092;n&#036;perlos_dsk</textarea>
    </td>
    </tr>
    <tr>
    <td class="tableitems" width="168" valign="top">Module Paths</td>
    <td class="tablevalue">&#036;modulepaths</td>
    </tr>
    <tr>
    <td class="tableitems" width="168" valign="top">Path(s) to TAR</td>
    <td class="tablevalue">&#036;path_tar</td>
    </tr>
    <tr>
    <td class="tableitems" width="168" valign="top">Path(s) to GZIP</td>
    <td class="tablevalue">&#036;path_gzip</td>
    </tr>
    <tr>
    <td class="tableitems" width="168" valign="top">Path to APACHE/HTTPD</td>
    <td class="tablevalue">&#036;path_apache

    &#036;path_httpd</td>
    </tr>
    <tr>
    <td class="tableitems" width="168" valign="top">Path to PHP</td>
    <td class="tablevalue">&#036;path_php</td>
    </tr>
    <tr>
    <td class="tableitems" width="168" valign="top">Path to MYSQL</td>
    <td class="tablevalue">&#036;path_mysql</td>
    </tr>
    <tr>
    <td class="tableitems" width="168" valign="top">Path to MAN (Unix manual)</td>
    <td class="tablevalue">&#036;path_man</td>
    </tr>
    <tr>
    <td class="tableitems" width="168" valign="top">Path to PERLDOC</td>
    <td class="tablevalue">&#036;path_perldoc</td>
    </tr>
    <tr>
    <td class="tableitems" width="168" valign="top">Processes currently on the server</td>
    <td class="tablevalue"><textarea rows=10 cols=60 wrap="OFF">&#036;processes</textarea> </td>
    </tr>
    </table>



    <a name="env"></a>

    &#036;environment

    &#60;&#33;-- ALL MODULES --&#62;
    <a name="modules"></a>

    <table width="69%" align="center" cellspacing="0" cellpadding="4" bordercolor="#c5c5c5">
    <tr bgcolor="#efefef">
    <td colspan="2" class="tabletitle">
    LIST OF ALL INSTALLED PERL MODULES <font style="font-family: Webdings; font-size: 15px; text-decoration: none">5</font>
    </td>
    </tr>
    <tr>
    <td>

    ~;

    &vars;
    find(&#092;&wanted,@INC);
    &#036;modcount = 0;
    foreach &#036;line(@foundmods)
    {
    &#036;match = lc(&#036;line);
    if (&#036;found{&#036;line}[0] >0)
    {&#036;found{&#036;line} = [&#036;found{&#036;line}[0]+1,&#036;match]}
    else
    {&#036;found{&#036;line} = ["1",&#036;match];&#036;modcount++}
    }
    @foundmods = sort count keys(%found);

    sub count
    {
    return &#036;found{&#036;a}[1] cmp &#036;found{&#036;b}[1]

    }
    &#036;third = &#036;modcount/3;
    &#036;count=0;
    &#036;firstroundtotal = 0;

    foreach &#036;mod(@foundmods)
    {
    chomp &#036;mod;
    &#036;count++;
    if (&#036;count <= &#036;third)
    {
    &#036;firstroundtotal++;
    print qq~
    &#036;firstroundtotal. &#036;mod


    ~;
    }
    else
    {
    push (@mod1,&#036;mod)
    }
    }

    &#036;count = 0;
    print qq~ </td><td>~;
    foreach &#036;mod1(@mod1)
    {
    chomp &#036;mod1;
    &#036;count++;
    if (&#036;count <= &#036;third){}
    else {

    push (@mod2,&#036;mod1)}}&#036;count = 0;
    foreach &#036;mod2(@mod2)
    { chomp &#036;mod2; &#036;count++; if (&#036;count <= &#036;third)
    {
    &#036;firstroundtotal++;
    print qq~
    &#036;firstroundtotal. &#036;mod2
    ~; }};
    sub vars {use File::Find;}
    sub wanted { &#036;count = 0; if (&#036;File::Find::name =~ /&#092;.pm&#036;/) { open(MODFILE,&#036;File::Find::name) || return;
    while(<MODFILE>){ if (/^ *package +(&#092;S+);/){
    push (@foundmods, &#036;1); last; } } } }
    print qq~
    </td>
    </tr>
    </table>

    <p class="tablevalue"></p>
    <p class="tablevalue" align="center"><font style="font-family: Webdings; font-size: 15px; text-decoration: none">5</font> &#036;PAGE_FOOTER</p>



    </body>
    </html>

  7. #7
    Join Date
    Jun 2004
    Posts
    102

    Default

    php redirect

    <?php
    header("Location: redirected.php");
    exit;
    ?>

  8. #8
    Join Date
    Jun 2004
    Posts
    102

    Default

    PhpInfo.php

    <?php
    echo phpinfo();
    ?>

  9. #9
    Join Date
    Jun 2004
    Posts
    102

    Default

    File Upload Using Php


    <?
    //file_upload.php
    //The dirctory in which you are uploading files must have 777 permissions
    //&#036;archive_dir is the location where you want to upload the files or imgaes
    &#036;archive_dir = "/home/username/uploadfiles";
    function upload_form() {
    global &#036;PHP_SELF;
    ?>
    <FORM METHOD="POST" ENCTYPE="MULTIPART/FORM-DATA" ACTION="<? echo &#036;PHP_SELF ?>">
    <INPUT TYPE="HIDDEN" NAME="action" VALUE="upload">
    Upload file&#33;
    <INPUT TYPE="FILE" NAME="userfile">
    <INPUT TYPE="SUBMIT" NAME="SUBMIT" VALUE="upload">
    </FORM>
    <?
    }

    function upload_file() {
    global &#036;userfile, &#036;userfile_name, &#036;userfile_size,
    &#036;userfile_type, &#036;archive_dir, &#036;WINDIR;

    if(isset(&#036;WINDIR)) &#036;userfile = str_replace("&#092;&#092;&#092;&#092;","&#092;&#09 2;", &#036;userfile);

    &#036;filename = basename(&#036;userfile_name);

    if(&#036;userfile_size <= 0) die ("&#036;filename is empty.");

    if(&#33;@copy(&#036;userfile, "&#036;archive_dir/&#036;filename"))
    die("Can&#39;t copy &#036;userfile_name to &#036;filename.");

    if(&#33;isset(&#036;WINDIR) && &#33;@unlink(&#036;userfile))
    die ("Can&#39;t delete the file &#036;userfile_name.");

    echo "&#036;filename has been successfully uploaded.
    ";
    echo "Filesize: " . number_format(&#036;userfile_size) . "
    ";
    echo "Filetype: &#036;userfile_type
    ";
    }
    ?>
    <HTML>
    <HEAD><TITLE>FILE UPLOAD</TITLE></HEAD>
    <BODY>
    <?
    if(&#036;action == &#39;upload&#39 upload_file();
    else upload_form();
    ?>
    </BODY>
    </HTML>

  10. #10
    Join Date
    Jun 2004
    Posts
    102

    Default

    Perl Script to send an email

    Below is the perl script to send an email.
    Save the script as test.pl
    Change the permissions of test.pl as 755 and test it.
    --------------------------------------------------------------

    #&#33;/usr/bin/perl

    &#036;fromemail = "sami&#092;@abc.com";
    &#036;toemail = "sachin&#092;@test.com";

    open(SENDMAIL,"|/usr/sbin/sendmail -t");
    print SENDMAIL "From : &#036;fromemail&#092;n";
    print SENDMAIL "To : &#036;toemail&#092;n";
    print SENDMAIL "Subject : This is a test mail.&#092;n";
    print SENDMAIL <<EOM;
    Hello,
    This is a test mail.
    EOM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •