Search Results

Search found 22 results on 1 pages for 'zerobu'.

Page 1/1 | 1 

  • Matching a date in perl

    - by Zerobu
    Hello, I want to match a date in the format day/month/year. where day is two digits month is two digits and year is four digits. Also, I want to check see if it is a valid date, for example knows when is leap year, and know which month has 30days, 31days and 28, or 29 days for Februrary.

    Read the article

  • Ignoring Whitespace with Regex(perl)

    - by Zerobu
    Hello, I am using Perl Regular expressions. How would i go about ignoring white space and still perform a test to see if a string match. For example. $var = " hello "; #I want var to igonore whitespace and still match if($var =~ m/hello/) { }

    Read the article

  • Regular expression for a phone number

    - by Zerobu
    Hello, I would like a regular expression in this format. It Must match one of the following formats: * (###)###-#### * ###-###-#### * ###.###.#### * ########## Strip all whitespace. Make sure it's a valid phone number, then (if necessary) translate it to the first format listed above.

    Read the article

  • Performing an http redirect in Perl

    - by Zerobu
    Hello, I want to perform an http redirect, but the way i am currently doing it isn't working. When i try redirect it just prints the status code, and the location header my $q = new CGI; q->redirect(" http://www.google.com ");

    Read the article

  • Sending the contents of a file to a client

    - by Zerobu
    Hello, I am writing a C++ server side application called quote of the day. I am using the winsock2 library. I want to send the contents of a file back to the client, including newlines by using the send function. The way i tried it doesn't work. How would i go about doing this?

    Read the article

  • How can my CGI program access non-browseable files?

    - by Zerobu
    I was wondering if it was possible to read a text file that was located in a directory called "/home/user/files" I wanted to read it from my cgi-bin which is located in /home/user/cgi-bi/ Below is my code, #!/usr/bin/perl use strict; use CGI; #Virtual Directory #Steffan Harris eval { use constant PASSWORD => 'perl'; use constant UPLOAD_DIR => '/home/sharris2/files'; sub mapToFile { print chdir UPLOAD_DIR; } #This function will list all files in a directory. sub listDirectoryFiles { chdir UPLOAD_DIR; my @files = <*>; mapToFile; print<<LIST; <h2>Current Files</h2> <ul> LIST if(!$files[0]) { print" </ul>\n<em>No files in directory</em>"; } foreach(@files) { print" <li>$_</li>"; } print " </ul>\n"; } #This function generates a 404 Not Found error sub generate404 { print<<RESPONSE; Status: 404 Not Found Content-Type: text/html <html> <head><title>404 Not Found</title></head> <body> <p> <h1>404 - Not Found</h1> </p> The requested URL <b>$ENV{"HTTP_HOST"}$ENV{"REQUEST_URI"}</b> was not found on the server. </body> </html> RESPONSE exit; } #This function checks the path info to see if it matches a file in the UPLOAD_DIR directory, If it does not, then it returns a 404 error sub checkExsistence { if($ENV{"PATH_INFO"}) { chdir UPLOAD_DIR; my @files = <*>; if(!$files[0] and $ENV{"PATH_INFO"} eq "/") { return; } foreach(@files) { if($ENV{"PATH_INFO"} eq "/".$_ || $ENV{"PATH_INFO"} eq "/") { print "yes"; return; } } generate404; } } sub checkPassword { my ($password, $cgi); $cgi = new CGI; $password = $cgi->param('passwd'); unless($password eq PASSWORD) { print<<RESPONSE; Status: 200 OK Content-Type: text/html <html> <head> <title>Incorrect Password</title> </head> <body> <h1>Invalid password entered.</h1> <h3><a href="/~sharris2/cgi-bin/files/">Go Back</a></h3> </body> RESPONSE exit; } } sub upLoadFile { checkPassword; my ($uploadfile, $cgi); $cgi = new CGI; $uploadfile = $cgi->upload('uploadfile'); chdir UPLOAD_DIR; $uploadfile or die "Did not receive a file to upload"; open my $FILE, '>', UPLOAD_DIR."/$uploadfile" or die "$!"; while(<$uploadfile>) { print $FILE $_; } } #Start of main part of program my $cgi = new CGI; if(!$ENV{"PATH_INFO"}) { print $cgi->redirect('/~sharris2/cgi-bin/files/'); } checkExsistence; if($ENV{"REQUEST_METHOD"} eq "POST") { upLoadFile; } print <<"HEADERS"; Status: 200 OK Content-Type: text/html HEADERS print <<"HTML"; <html> <head> <title>Virtual Directory</title> </head> <body> HTML listDirectoryFiles; print<<HTML; <h2>Upload a new file</h2> <form method = "POST" enctype = "multipart/form-data" action = "/~sharris2/cgi-bin/files/" /> File:<input type = "file" name="uploadfile"/> <p>Password: <input type = "password" name ="passwd"/></p> <p><input type = "submit" value= "Submit File" /></p> </form> </body> </html> HTML };

    Read the article

  • How can I match a phone number with a regex? [closed]

    - by Zerobu
    Possible Duplicate: A comprehensive regex for phone number validation I would like a regular expression in this format. It Must match one of the following formats: (###)###-#### ###-###-#### ###.###.#### ########## Strip all whitespace. Make sure it's a valid phone number, then (if necessary) translate it to the first format listed above.

    Read the article

  • Error with connection in my database servlet

    - by Zerobu
    Hello, I am writing a Database servlet, all seems well except that there seems to be an error in my connection import java.io.IOException; import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.util.ArrayList; import javax.servlet.RequestDispatcher; import javax.servlet.ServletContext; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; public class DBServlet3 extends HttpServlet { private static final long serialVersionUID = 1L; @Override public void init() throws ServletException { super.init(); try { String jdbcDriverClass= getServletContext().getInitParameter( "jdbcDriverClass" ); if (jdbcDriverClass == null) throw new ServletException( "Could not find jdbcDriverClass initialization parameter" ); Class.forName( jdbcDriverClass ); } catch (ClassNotFoundException e) { throw new ServletException( "Could not load JDBC driver class", e ); } } @Override protected void doGet( HttpServletRequest request, HttpServletResponse response ) throws ServletException, IOException { RequestDispatcher dispatcher= request.getRequestDispatcher( "/db.jsp" ); ServletContext application= getServletContext(); ArrayList<String> names= new ArrayList<String>(); try { Connection connection= null; Statement statement= null; ResultSet results= null; try { String jdbcUrl= application.getInitParameter( "jdbcUrl" ); String jdbcUser= application.getInitParameter( "jdbcUser" ); String jdbcPassword= application.getInitParameter( "jdbcPassword" ); connection= DriverManager.getConnection( jdbcUrl, jdbcUser, jdbcPassword ); statement= connection.createStatement(); results= statement.executeQuery( "SELECT * FROM students" ); while (results.next()) { String name= results.getString( "name" ); names.add( name ); } } finally { if (results != null) results.close(); if (statement != null) statement.close(); if (connection != null) connection.close(); } } catch (SQLException e) { throw new ServletException( e ); } request.setAttribute( "names", names ); dispatcher.forward( request, response ); } @Override protected void doPost( HttpServletRequest request, HttpServletResponse response ) throws ServletException, IOException { String sql= "INSERT INTO students VALUES (" + request.getParameter( "id" ) + ", '" + request.getParameter( "name" ) + "')"; sql= "INSERT INTO students VALUES (?, ?, ?, ?)"; PreparedStatement statement= connection.prepareStatement( sql ); //error on this line statement.setString( 1, request.getParameter( "id" ) ); statement.setString( 2, request.getParameter( "name" ) ); } }

    Read the article

  • Using HTML::Template within a value attribute

    - by Zerobu
    Hello, my question is how would I use an HTML::Template tag inside a value of form to change that form. For example <table border="0" cellpadding="8" cellspacing="1"> <tr> <td align="right">File:</td> <td> <input type="file" name="upload" value= style="width:400px"> </td> </tr> <tr> <td align="right">File Name:</td> <td> <input type="text" name="filename" style="width:400px" value="" > </td> </tr> <tr> <td align="right">Title:</td> <td> <input type="text" name="title" style="width:400px" value="" /> </td> </tr> <tr> <td align="right">Date:</td> <td> <input type="text" name="date" style="width:400px" value="" /> </td> </tr> <tr> <td colspan="2" align="right"> <input type="button" value="Cancel"> <input type="submit" name="action" value="Upload" /> </td> </tr> </table> I want the value to have a variable in it.

    Read the article

1