Jump to content

Function eregi() is deprecated other error...


ncurran217

Recommended Posts

I have acquired a time clock script that I wanted to try and use, instead of the employees manually punching in and out, but going through it now, found that this function eregi() is old and I have tried to change it to preg_match. Here is the code:

 

elseif (!eregi ("^([0-9]?[0-9])+[-|/|.]+([0-9]?[0-9])+[-|/|.]+(([0-9]{2})|([0-9]{4}))$", $from_date, $date_regs)) {
$evil_post = '1';
if ($use_reports_password == "yes") {
include '../admin/topmain.php';
} else {
include 'topmain.php';
}
echo "<table width=100% height=89% border=0 cellpadding=0 cellspacing=1>\n";
echo " <tr valign=top>\n";
echo " <td>\n";
echo " <table width=100% height=100% border=0 cellpadding=10 cellspacing=1>\n";
echo " <tr class=right_main_text>\n";
echo " <td valign=top>\n";
echo " <table align=center class=table_border width=60% border=0 cellpadding=0 cellspacing=3>\n";
echo " <tr>\n";
echo " <td class=table_rows width=20 align=center><img src='../images/icons/cancel.png' /></td><td class=table_rows_red>
A valid From Date is required.</td></tr>\n";
echo " </table>\n";


} else {


if ($calendar_style == "amer") {
if (isset($date_regs)) {$from_month = $date_regs[1]; $from_day = $date_regs[2]; $from_year = $date_regs[3];}
if ($from_month > 12 || $from_day > 31) {
$evil_post = '1';
if ($use_reports_password == "yes") {
include '../admin/topmain.php';
} else {
include 'topmain.php';
}
echo "<table width=100% height=89% border=0 cellpadding=0 cellspacing=1>\n";
echo " <tr valign=top>\n";
echo " <td>\n";
echo " <table width=100% height=100% border=0 cellpadding=10 cellspacing=1>\n";
echo " <tr class=right_main_text>\n";
echo " <td valign=top>\n";
echo " <table align=center class=table_border width=60% border=0 cellpadding=0 cellspacing=3>\n";
echo " <tr>\n";
echo " <td class=table_rows width=20 align=center><img src='../images/icons/cancel.png' /></td><td class=table_rows_red>
A valid From Date is required.</td></tr>\n";
echo " </table>\n";
}}


elseif ($calendar_style == "euro") {
if (isset($date_regs)) {$from_month = $date_regs[2]; $from_day = $date_regs[1]; $from_year = $date_regs[3];}
if ($from_month > 12 || $from_day > 31) {
$evil_post = '1';
if ($use_reports_password == "yes") {
include '../admin/topmain.php';
} else {
include 'topmain.php';
}
echo "<table width=100% height=89% border=0 cellpadding=0 cellspacing=1>\n";
echo " <tr valign=top>\n";
echo " <td>\n";
echo " <table width=100% height=100% border=0 cellpadding=10 cellspacing=1>\n";
echo " <tr class=right_main_text>\n";
echo " <td valign=top>\n";
echo " <table align=center class=table_border width=60% border=0 cellpadding=0 cellspacing=3>\n";
echo " <tr>\n";
echo " <td class=table_rows width=20 align=center><img src='../images/icons/cancel.png' /></td><td class=table_rows_red>
A valid From Date is required.</td></tr>\n";
echo " </table>\n";
}}}}


if (!isset($evil_post)) {
if (empty($to_date)) {
$evil_post = '1';
if ($use_reports_password == "yes") {
include '../admin/topmain.php';
} else {
include 'topmain.php';
}
echo "<table width=100% height=89% border=0 cellpadding=0 cellspacing=1>\n";
echo " <tr valign=top>\n";
echo " <td>\n";
echo " <table width=100% height=100% border=0 cellpadding=10 cellspacing=1>\n";
echo " <tr class=right_main_text>\n";
echo " <td valign=top>\n";
echo " <table align=center class=table_border width=60% border=0 cellpadding=0 cellspacing=3>\n";
echo " <tr>\n";
echo " <td class=table_rows width=20 align=center><img src='../images/icons/cancel.png' /></td><td class=table_rows_red>
A valid To Date is required.</td></tr>\n";
echo " </table>\n";
}
elseif (!eregi ("^([0-9]?[0-9])+[-|/|.]+([0-9]?[0-9])+[-|/|.]+(([0-9]{2})|([0-9]{4}))$", $to_date, $date_regs)) {
$evil_post = '1';
if ($use_reports_password == "yes") {
include '../admin/topmain.php';
} else {
include 'topmain.php';
}
echo "<table width=100% height=89% border=0 cellpadding=0 cellspacing=1>\n";
echo " <tr valign=top>\n";
echo " <td>\n";
echo " <table width=100% height=100% border=0 cellpadding=10 cellspacing=1>\n";
echo " <tr class=right_main_text>\n";
echo " <td valign=top>\n";
echo " <table align=center class=table_border width=60% border=0 cellpadding=0 cellspacing=3>\n";
echo " <tr>\n";
echo " <td class=table_rows width=20 align=center><img src='../images/icons/cancel.png' /></td><td class=table_rows_red>
A valid To Date is required.</td></tr>\n";
echo " </table>\n";


} else {


if ($calendar_style == "amer") {
if (isset($date_regs)) {$to_month = $date_regs[1]; $to_day = $date_regs[2]; $to_year = $date_regs[3];}
if ($to_month > 12 || $to_day > 31) {
$evil_post = '1';
if ($use_reports_password == "yes") {
include '../admin/topmain.php';
} else {
include 'topmain.php';
}
echo "<table width=100% height=89% border=0 cellpadding=0 cellspacing=1>\n";
echo " <tr valign=top>\n";
echo " <td>\n";
echo " <table width=100% height=100% border=0 cellpadding=10 cellspacing=1>\n";
echo " <tr class=right_main_text>\n";
echo " <td valign=top>\n";
echo " <table align=center class=table_border width=60% border=0 cellpadding=0 cellspacing=3>\n";
echo " <tr>\n";
echo " <td class=table_rows width=20 align=center><img src='../images/icons/cancel.png' /></td><td class=table_rows_red>
A valid To Date is required.</td></tr>\n";
echo " </table>\n";
}}


elseif ($calendar_style == "euro") {
if (isset($date_regs)) {$to_month = $date_regs[2]; $to_day = $date_regs[1]; $to_year = $date_regs[3];}
if ($to_month > 12 || $to_day > 31) {
$evil_post = '1';
if ($use_reports_password == "yes") {
include '../admin/topmain.php';
} else {
include 'topmain.php';
}
echo "<table width=100% height=89% border=0 cellpadding=0 cellspacing=1>\n";
echo " <tr valign=top>\n";
echo " <td>\n";
echo " <table width=100% height=100% border=0 cellpadding=10 cellspacing=1>\n";
echo " <tr class=right_main_text>\n";
echo " <td valign=top>\n";
echo " <table align=center class=table_border width=60% border=0 cellpadding=0 cellspacing=3>\n";
echo " <tr>\n";
echo " <td class=table_rows width=20 align=center><img src='../images/icons/cancel.png' /></td><td class=table_rows_red>
A valid To Date is required.</td></tr>\n";
echo " </table>\n";
}}}}


if (isset($evil_post)) {
echo " <br />\n";
echo " <form name='form' action='$self' method='post' onsubmit=\"return isFromOrToDate();\">\n";
echo " <table align=center class=table_border width=60% border=0 cellpadding=3 cellspacing=0>\n";
echo " <tr>\n";
echo " <th class=rightside_heading nowrap halign=left colspan=3><img src='../images/icons/report.png' />   Daily
Time Report</th></tr>\n";
echo " <tr><td height=15></td></tr>\n";
echo " <input type='hidden' name='date_format' value='$js_datefmt'>\n";

 

 

When I change the two lines:

 

!eregi ("^([0-9]?[0-9])+[-|/|.]+([0-9]?[0-9])+[-|/|.]+(([0-9]{2})|([0-9]{4}))$", $from_date, $date_regs)

 

to this:

 

!preg_match("^([0-9]?[0-9])+[-|/|.]+([0-9]?[0-9])+[-|/|.]+(([0-9]{2})|([0-9]{4}))$", $from_date, $date_regs)

 

I get an error saying this:

 

preg_match() [<a href='function.preg-match'>function.preg-match</a>]: No ending delimiter '^'

 

I also get an error within it saying:

 

A valid From Date is required.

 

The calendar style is "amer", so you can ignore the "euro" part of the code, as I did not want to delete anything. Hopefully this is enough information.

Link to comment
Share on other sites

PCRE (preg_* functions) expressions require delimiters around the expression while POSIX (ereg* functions) do not. It's complaining that you haven't added delimiters.

 

The expression needs fixing anyways: it allows stuff I'm sure you don't want, like "9999||||9999||||9999".

#^(\d?\d)[-/.](\d?\d)[-/.](\d\d(?:\d\d)?)$#

Edited by requinix
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.