psalm в помощь
https://psalm.dev
Если убрать все require
<?php
error_reporting(E_ALL);
// Отклоняем запросы с IP-адресов, которые не принадлежат Payeer
//if (!in_array($_SERVER['REMOTE_ADDR'], array('185.71.65.92', '185.71.65.189','149.202.17.210'))) return;
header("Content-type: text/html; charset=windows-1251");
define('PATH_TO_LOG', dirname(__FILE__).'/');
$m_operation_id = (isset($_REQUEST["m_operation_id"])) ? htmlspecialchars(trim($_REQUEST["m_operation_id"])) : false;
$m_operation_ps = (isset($_REQUEST["m_operation_ps"])) ? htmlspecialchars(trim($_REQUEST["m_operation_ps"])) : false;
$m_operation_date = (isset($_REQUEST["m_operation_date"])) ? htmlspecialchars(trim($_REQUEST["m_operation_date"])) : false;
$m_operation_pay_date = (isset($_REQUEST["m_operation_pay_date"])) ? htmlspecialchars(trim($_REQUEST["m_operation_pay_date"])) : false;
$m_shop = (isset($_REQUEST["m_shop"])) ? htmlspecialchars(trim($_REQUEST["m_shop"])) : false;
$m_orderid = (isset($_REQUEST["m_orderid"])) ? htmlspecialchars(trim($_REQUEST["m_orderid"])) : false;
$merch_amount = (isset($_REQUEST["m_amount"])) ? htmlspecialchars(trim($_REQUEST["m_amount"])) : false;
$m_curr = (isset($_REQUEST["m_curr"])) ? htmlspecialchars(trim($_REQUEST["m_curr"])) : false;
$m_desc = (isset($_REQUEST["m_desc"])) ? htmlspecialchars(trim($_REQUEST["m_desc"])) : false;
$m_status = (isset($_REQUEST["m_status"])) ? htmlspecialchars(trim($_REQUEST["m_status"])) : false;
$m_sign = (isset($_REQUEST["m_sign"])) ? strtoupper(htmlspecialchars(trim($_REQUEST["m_sign"]))) : false;
$arHash = [$m_operation_id,$m_operation_ps,$m_operation_date,$m_operation_pay_date,$m_shop,$m_orderid,$merch_amount,$m_curr,$m_desc,$m_status,$m_key];
$sign = strtoupper(hash('sha256', implode(":", $arHash)));
if($m_orderid!=false) {
$exp = explode(":", $m_orderid);
$shp_item = $exp[0];
$merch_tran_id = $exp[1];
}else{
$merch_tran_id = 0;
$shp_item = 0;
}
$shp_item = (isset($shp_item) && preg_match("|^[\d]{1,11}$|", htmlspecialchars(trim($shp_item))) ) ? intval(htmlspecialchars(trim($shp_item))) : false;
$merch_tran_id = (isset($merch_tran_id) && preg_match("|^[\d]{1,11}$|", htmlspecialchars(trim($merch_tran_id))) ) ? intval(htmlspecialchars(trim($merch_tran_id))) : false;
$TABLE_ARR = [
1 => "tb_add_pay",
2 => "tb_ads_dlink",
3 => "tb_ads_psevdo",
4 => "tb_ads_bs",
5 => "tb_ads_auto",
6 => "tb_ads_slink",
7 => "tb_ads_kontext",
8 => "tb_ads_banner",
9 => "tb_ads_txt",
10 => "tb_ads_frm",
11 => "tb_ads_mails",
12 => "tb_ads_rc",
13 => "tb_ads_downloads",
14 => "tb_ads_questions",
15 => "tb_ads_emails",
16 => "tb_ads_packet",
20 => "tb_ads_beg_stroka",
21 => "tb_ads_tests",
22 => "tb_ads_catalog",
23 => "tb_ads_youtube"
];
$STAT_PAY_ARR = [
1 => "money_in",
2 => "dlink",
3 => "psevdo",
4 => "bserf",
5 => "autoserf",
6 => "statlink",
7 => "kontext",
8 => "banners",
9 => "txtob",
10 => "frmlink",
11 => "mails",
12 => "rekcep",
13 => "files",
14 => "quest",
15 => "sent_mails",
16 => "packet",
20 => "bstroka",
21 => "tests",
22 => "catalog",
23 => "youtube"
];
if($sign==$m_sign && $m_status=="success") {
if($shp_item!= 0 && array_key_exists($shp_item, $TABLE_ARR)) {
$sql = mysql_query("SELECT `id`,`username`,`money` FROM `".$TABLE_ARR[$shp_item]."` WHERE `status`='0' AND `merch_tran_id`='$merch_tran_id' LIMIT 1");
$row = mysql_fetch_array($sql);
$username = $row["username"];
if($shp_item==3 | $shp_item==6 | $shp_item==8 | $shp_item==9 | $shp_item==10) {
$DATE_END = ", `date_end`=`plan`*'".(24*60*60)."'+'".time()."'";
}else{
$DATE_END = false;
}
if(floatval($row["money"])!=floatval($merch_amount)) {
exit("$m_orderid|error");
}elseif($shp_item==1) {
if($username!=false) {
echo "$m_orderid|success";
$bon = mysql_query("SELECT `price` FROM `tb_config` WHERE `item`='bon_popoln' AND `howmany`='1'") or die(mysql_error());
$b = number_format(mysql_result($bon,0), 0, ".", "");
$bonus=($merch_amount/100)*$b;
$merch_amount1=$merch_amount+$bonus;
mysql_query("UPDATE `tb_users` SET `money_rb`=`money_rb`+'$merch_amount1', `money_in`=`money_in`+'$merch_amount1' WHERE `username`='$username'") or die(mysql_error());
mysql_query("INSERT INTO `tb_history` (`user`, `date`, `amount`, `method`, `status`, `tipo`) VALUES('$username', '".DATE("d.m.Y H:i")."', '$merch_amount1', 'Пополнение рекламного баланса через Payeer','Зачислено', 'popoln')") or die(mysql_error());
mysql_query("UPDATE `tb_add_pay` SET `status`='1', `date`='".time()."' WHERE `merch_tran_id`='$merch_tran_id' AND`username`='$username'") or die(mysql_error());
stat_pay($STAT_PAY_ARR[$shp_item], $merch_amount);
}elseif($shp_item==16) {
mysql_query("UPDATE `".$TABLE_ARR[$shp_item]."` SET `status`='1', `date`='".time()."' WHERE `status`='0' AND `merch_tran_id`='$merch_tran_id' ORDER BY `id` DESC LIMIT 1") or die(mysql_error());
stat_pay($STAT_PAY_ARR[$shp_item], $merch_amount);
$merch_user_wmid = false;
konkurs_ads_new($merch_user_wmid, $username, $merch_amount);
cache_stat_links();
cache_frm_links();
cache_txt_links();
cache_banners();
}elseif($shp_item==21) {
mysql_query("UPDATE `".$TABLE_ARR[$shp_item]."` SET `status`='1', `date`='".time()."',`money`='$merch_amount',`balance`='$merch_amount' WHERE `status`='0' AND `merch_tran_id`='$merch_tran_id' ORDER BY `id` DESC LIMIT 1") or die(mysql_error());
}elseif($shp_item==30) {
mysql_query("UPDATE `".$TABLE_ARR[$shp_item]."` SET `status`='2', `date`='".time()."' WHERE `status`='0' AND `merch_tran_id`='$merch_tran_id' ORDER BY `id` DESC LIMIT 1") or die(mysql_error());
}else{
mysql_query("UPDATE `".$TABLE_ARR[$shp_item]."` SET `status`='1', `date`='".time()."' $DATE_END WHERE `status`='0' AND `merch_tran_id`='$merch_tran_id' ORDER BY `id` DESC LIMIT 1") or die(mysql_error());
}
mysql_query("UPDATE `tb_users` SET `money_rek`=`money_rek`+'$merch_amount' WHERE `username`='$username'") or die(mysql_error());
echo "$m_orderid|success";
stat_pay($STAT_PAY_ARR[$shp_item], $merch_amount);
$merch_user_wmid = false;
if($shp_item!=21){ konkurs_rek_ed($merch_user_wmid, $username, $merch_amount);
konkurs_rek_ed($merch_user_wmid, $username, $merch_amount); }
if($shp_item==6 | $shp_item==7 | $shp_item==8 | $shp_item==9 | $shp_item==10 | $shp_item==12 | $shp_item==20) {
cache_stat_links();
cache_kontext();
cache_frm_links();
cache_txt_links();
cache_rek_cep();
cache_banners();
cache_beg_stroka();
}
}
}else{
exit("$m_orderid|error");
}
}else{
exit("$m_orderid|error");
}
?>
то выдаст
INFO: MixedArgument - 11:80 - Argument 1 of trim cannot be mixed, expecting string
INFO: MixedArgument - 12:80 - Argument 1 of trim cannot be mixed, expecting string
INFO: MixedArgument - 13:84 - Argument 1 of trim cannot be mixed, expecting string
INFO: MixedArgument - 14:92 - Argument 1 of trim cannot be mixed, expecting string
INFO: MixedArgument - 15:64 - Argument 1 of trim cannot be mixed, expecting string
INFO: MixedArgument - 16:70 - Argument 1 of trim cannot be mixed, expecting string
INFO: MixedArgument - 17:72 - Argument 1 of trim cannot be mixed, expecting string
INFO: MixedArgument - 18:64 - Argument 1 of trim cannot be mixed, expecting string
INFO: MixedArgument - 19:64 - Argument 1 of trim cannot be mixed, expecting string
INFO: MixedArgument - 20:68 - Argument 1 of trim cannot be mixed, expecting string
INFO: MixedArgument - 21:75 - Argument 1 of trim cannot be mixed, expecting string
ERROR: UndefinedGlobalVariable - 22:143 - Cannot find referenced variable $m_key in global scope
INFO: PossiblyUndefinedIntArrayOffset - 32:19 - Possibly undefined array offset 'int(1)' is risky given expected type 'int'. Consider using isset beforehand.
ERROR: InvalidScalarArgument - 37:85 - Argument 1 of trim expects string, int(0)|string provided
ERROR: InvalidScalarArgument - 37:131 - Argument 1 of trim expects string, int(0)|string provided
ERROR: InvalidScalarArgument - 38:95 - Argument 1 of trim expects string, int(0)|string provided
ERROR: InvalidScalarArgument - 38:146 - Argument 1 of trim expects string, int(0)|string provided
ERROR: PossiblyFalseArgument - 88:38 - Argument 1 of array_key_exists cannot be false, possibly false value provided
ERROR: UndefinedFunction - 89:8 - Function mysql_query does not exist
INFO: MixedOperand - 89:60 - Right operand cannot be mixed
INFO: MixedAssignment - 89:1 - Unable to determine the type that $sql is being assigned to
ERROR: UndefinedFunction - 91:13 - Function mysql_fetch_array does not exist
INFO: MixedAssignment - 91:6 - Unable to determine the type that $row is being assigned to
INFO: MixedArrayAccess - 92:15 - Cannot access array value on mixed variable $row
INFO: MixedAssignment - 92:3 - Unable to determine the type that $username is being assigned to
ERROR: InvalidOperand - 93:16 - Cannot perform a numeric operation with non-numeric types bool and bool
ERROR: InvalidOperand - 93:46 - Cannot perform a numeric operation with a non-numeric type bool
ERROR: InvalidOperand - 93:61 - Cannot perform a numeric operation with a non-numeric type bool
ERROR: InvalidOperand - 93:76 - Cannot perform a numeric operation with a non-numeric type bool
INFO: MixedArrayAccess - 99:14 - Cannot access array value on mixed variable $row
ERROR: UndefinedFunction - 104:16 - Function mysql_query does not exist
INFO: MixedAssignment - 104:9 - Unable to determine the type that $bon is being assigned to
ERROR: UndefinedFunction - 104:114 - Function mysql_error does not exist
ERROR: UndefinedFunction - 105:28 - Function mysql_result does not exist
INFO: MixedArgument - 105:28 - Argument 1 of number_format cannot be mixed, expecting float|int
ERROR: PossiblyFalseOperand - 106:17 - Left operand cannot be falsable, got false|string
ERROR: InvalidOperand - 106:17 - Cannot perform a numeric operation with a non-numeric type string
ERROR: InvalidOperand - 106:36 - Cannot perform a numeric operation with a non-numeric type string
ERROR: PossiblyFalseOperand - 107:24 - Left operand cannot be falsable, got false|string
ERROR: InvalidOperand - 107:24 - Cannot perform a numeric operation with a non-numeric type string
ERROR: UndefinedFunction - 109:9 - Function mysql_query does not exist
ERROR: UndefinedFunction - 109:161 - Function mysql_error does not exist
ERROR: UndefinedFunction - 110:9 - Function mysql_query does not exist
ERROR: UndefinedFunction - 110:283 - Function mysql_error does not exist
ERROR: UndefinedFunction - 111:9 - Function mysql_query does not exist
ERROR: UndefinedFunction - 111:154 - Function mysql_error does not exist
ERROR: UndefinedFunction - 112:9 - Function stat_pay does not exist
ERROR: TypeDoesNotContainType - 114:11 - Type int(1) for $shp_item is never int(16)
ERROR: UndefinedFunction - 115:7 - Function mysql_query does not exist
INFO: MixedOperand - 115:30 - Right operand cannot be mixed
ERROR: UndefinedFunction - 115:185 - Function mysql_error does not exist
ERROR: UndefinedFunction - 116:13 - Function stat_pay does not exist
ERROR: UndefinedFunction - 118:4 - Function konkurs_ads_new does not exist
ERROR: UndefinedFunction - 120:5 - Function cache_stat_links does not exist
ERROR: UndefinedFunction - 121:5 - Function cache_frm_links does not exist
ERROR: UndefinedFunction - 122:5 - Function cache_txt_links does not exist
ERROR: UndefinedFunction - 123:5 - Function cache_banners does not exist
ERROR: TypeDoesNotContainType - 124:11 - Type int(1) for $shp_item is never int(21)
ERROR: UndefinedFunction - 125:7 - Function mysql_query does not exist
INFO: MixedOperand - 125:30 - Right operand cannot be mixed
ERROR: UndefinedFunction - 125:236 - Function mysql_error does not exist
ERROR: TypeDoesNotContainType - 126:11 - Type int(1) for $shp_item is never int(30)
ERROR: UndefinedFunction - 127:10 - Function mysql_query does not exist
INFO: MixedOperand - 127:33 - Right operand cannot be mixed
ERROR: UndefinedFunction - 127:188 - Function mysql_error does not exist
ERROR: UndefinedFunction - 129:7 - Function mysql_query does not exist
INFO: MixedOperand - 129:30 - Right operand cannot be mixed
ERROR: UndefinedFunction - 129:196 - Function mysql_error does not exist
ERROR: UndefinedFunction - 131:4 - Function mysql_query does not exist
ERROR: UndefinedFunction - 131:117 - Function mysql_error does not exist
ERROR: UndefinedFunction - 134:9 - Function stat_pay does not exist
ERROR: RedundantCondition - 136:6 - Type int(1) for $shp_item is never int(21)
ERROR: UndefinedFunction - 136:22 - Function konkurs_rek_ed does not exist
ERROR: UndefinedFunction - 137:3 - Function konkurs_rek_ed does not exist
ERROR: InvalidOperand - 139:6 - Cannot perform a numeric operation with non-numeric types bool and bool
ERROR: InvalidOperand - 139:36 - Cannot perform a numeric operation with a non-numeric type bool
ERROR: InvalidOperand - 139:51 - Cannot perform a numeric operation with a non-numeric type bool
ERROR: InvalidOperand - 139:66 - Cannot perform a numeric operation with a non-numeric type bool
ERROR: InvalidOperand - 139:82 - Cannot perform a numeric operation with a non-numeric type bool
ERROR: InvalidOperand - 139:98 - Cannot perform a numeric operation with a non-numeric type bool
понятно, что не все критичны, и часть вообще про ненайденные функции (из других файлов или удаленные в РНР 7), но в идеале всех этих ошибок про несовпадение типов не должно быть.
UndefinedGlobalVariable - 22:143 - Cannot find referenced variable $m_key
Несуществующие переменные.
ERROR: TypeDoesNotContainType - 114:11 - Type int(1) for $shp_item is never int(16)
Ошибка в логике, которую видно если нормально отформатировать код:
http://beautifytools.com/php-beautifier.php
<?php
error_reporting(E_ALL);
// Отклоняем запросы с IP-адресов, которые не принадлежат Payeer
//if (!in_array($_SERVER['REMOTE_ADDR'], array('185.71.65.92', '185.71.65.189','149.202.17.210'))) return;
header("Content-type: text/html; charset=windows-1251");
define('PATH_TO_LOG', dirname(__FILE__) . '/');
$m_operation_id = (isset($_REQUEST["m_operation_id"])) ? htmlspecialchars(trim($_REQUEST["m_operation_id"])) : false;
$m_operation_ps = (isset($_REQUEST["m_operation_ps"])) ? htmlspecialchars(trim($_REQUEST["m_operation_ps"])) : false;
$m_operation_date = (isset($_REQUEST["m_operation_date"])) ? htmlspecialchars(trim($_REQUEST["m_operation_date"])) : false;
$m_operation_pay_date = (isset($_REQUEST["m_operation_pay_date"])) ? htmlspecialchars(trim($_REQUEST["m_operation_pay_date"])) : false;
$m_shop = (isset($_REQUEST["m_shop"])) ? htmlspecialchars(trim($_REQUEST["m_shop"])) : false;
$m_orderid = (isset($_REQUEST["m_orderid"])) ? htmlspecialchars(trim($_REQUEST["m_orderid"])) : false;
$merch_amount = (isset($_REQUEST["m_amount"])) ? htmlspecialchars(trim($_REQUEST["m_amount"])) : false;
$m_curr = (isset($_REQUEST["m_curr"])) ? htmlspecialchars(trim($_REQUEST["m_curr"])) : false;
$m_desc = (isset($_REQUEST["m_desc"])) ? htmlspecialchars(trim($_REQUEST["m_desc"])) : false;
$m_status = (isset($_REQUEST["m_status"])) ? htmlspecialchars(trim($_REQUEST["m_status"])) : false;
$m_sign = (isset($_REQUEST["m_sign"])) ? strtoupper(htmlspecialchars(trim($_REQUEST["m_sign"]))) : false;
$arHash = [$m_operation_id, $m_operation_ps, $m_operation_date, $m_operation_pay_date, $m_shop, $m_orderid, $merch_amount, $m_curr, $m_desc, $m_status, $m_key];
$sign = strtoupper(hash('sha256', implode(":", $arHash)));
if ($m_orderid != false) {
$exp = explode(":", $m_orderid);
$shp_item = $exp[0];
$merch_tran_id = $exp[1];
}
else {
$merch_tran_id = 0;
$shp_item = 0;
}
$shp_item = (isset($shp_item) && preg_match("|^[\d]{1,11}$|", htmlspecialchars(trim($shp_item)))) ? intval(htmlspecialchars(trim($shp_item))) : false;
$merch_tran_id = (isset($merch_tran_id) && preg_match("|^[\d]{1,11}$|", htmlspecialchars(trim($merch_tran_id)))) ? intval(htmlspecialchars(trim($merch_tran_id))) : false;
$TABLE_ARR = [1 => "tb_add_pay", 2 => "tb_ads_dlink", 3 => "tb_ads_psevdo", 4 => "tb_ads_bs", 5 => "tb_ads_auto", 6 => "tb_ads_slink", 7 => "tb_ads_kontext", 8 => "tb_ads_banner", 9 => "tb_ads_txt", 10 => "tb_ads_frm", 11 => "tb_ads_mails", 12 => "tb_ads_rc", 13 => "tb_ads_downloads", 14 => "tb_ads_questions", 15 => "tb_ads_emails", 16 => "tb_ads_packet", 20 => "tb_ads_beg_stroka", 21 => "tb_ads_tests", 22 => "tb_ads_catalog", 23 => "tb_ads_youtube"];
$STAT_PAY_ARR = [1 => "money_in", 2 => "dlink", 3 => "psevdo", 4 => "bserf", 5 => "autoserf", 6 => "statlink", 7 => "kontext", 8 => "banners", 9 => "txtob", 10 => "frmlink", 11 => "mails", 12 => "rekcep", 13 => "files", 14 => "quest", 15 => "sent_mails", 16 => "packet", 20 => "bstroka", 21 => "tests", 22 => "catalog", 23 => "youtube"];
if ($sign == $m_sign && $m_status == "success") {
if ($shp_item != 0 && array_key_exists($shp_item, $TABLE_ARR)) {
$sql = mysql_query("SELECT `id`,`username`,`money` FROM `" . $TABLE_ARR[$shp_item] . "` WHERE `status`='0' AND `merch_tran_id`='$merch_tran_id' LIMIT 1");
$row = mysql_fetch_array($sql);
$username = $row["username"];
if ($shp_item == 3 | $shp_item == 6 | $shp_item == 8 | $shp_item == 9 | $shp_item == 10) {
$DATE_END = ", `date_end`=`plan`*'" . (24 * 60 * 60) . "'+'" . time() . "'";
}
else {
$DATE_END = false;
}
if (floatval($row["money"]) != floatval($merch_amount)) {
exit("$m_orderid|error");
}
elseif ($shp_item == 1) {
if ($username != false) {
echo "$m_orderid|success";
$bon = mysql_query("SELECT `price` FROM `tb_config` WHERE `item`='bon_popoln' AND `howmany`='1'") or die(mysql_error());
$b = number_format(mysql_result($bon, 0) , 0, ".", "");
$bonus = ($merch_amount / 100) * $b;
$merch_amount1 = $merch_amount + $bonus;
mysql_query("UPDATE `tb_users` SET `money_rb`=`money_rb`+'$merch_amount1', `money_in`=`money_in`+'$merch_amount1' WHERE `username`='$username'") or die(mysql_error());
mysql_query("INSERT INTO `tb_history` (`user`, `date`, `amount`, `method`, `status`, `tipo`) VALUES('$username', '" . DATE("d.m.Y H:i") . "', '$merch_amount1', 'Пополнение рекламного баланса через Payeer','Зачислено', 'popoln')") or die(mysql_error());
mysql_query("UPDATE `tb_add_pay` SET `status`='1', `date`='" . time() . "' WHERE `merch_tran_id`='$merch_tran_id' AND`username`='$username'") or die(mysql_error());
stat_pay($STAT_PAY_ARR[$shp_item], $merch_amount);
}
elseif ($shp_item == 16) {
mysql_query("UPDATE `" . $TABLE_ARR[$shp_item] . "` SET `status`='1', `date`='" . time() . "' WHERE `status`='0' AND `merch_tran_id`='$merch_tran_id' ORDER BY `id` DESC LIMIT 1") or die(mysql_error());
stat_pay($STAT_PAY_ARR[$shp_item], $merch_amount);
$merch_user_wmid = false;
konkurs_ads_new($merch_user_wmid, $username, $merch_amount);
cache_stat_links();
cache_frm_links();
cache_txt_links();
cache_banners();
}
elseif ($shp_item == 21) {
mysql_query("UPDATE `" . $TABLE_ARR[$shp_item] . "` SET `status`='1', `date`='" . time() . "',`money`='$merch_amount',`balance`='$merch_amount' WHERE `status`='0' AND `merch_tran_id`='$merch_tran_id' ORDER BY `id` DESC LIMIT 1") or die(mysql_error());
}
elseif ($shp_item == 30) {
mysql_query("UPDATE `" . $TABLE_ARR[$shp_item] . "` SET `status`='2', `date`='" . time() . "' WHERE `status`='0' AND `merch_tran_id`='$merch_tran_id' ORDER BY `id` DESC LIMIT 1") or die(mysql_error());
}
else {
mysql_query("UPDATE `" . $TABLE_ARR[$shp_item] . "` SET `status`='1', `date`='" . time() . "' $DATE_END WHERE `status`='0' AND `merch_tran_id`='$merch_tran_id' ORDER BY `id` DESC LIMIT 1") or die(mysql_error());
}
mysql_query("UPDATE `tb_users` SET `money_rek`=`money_rek`+'$merch_amount' WHERE `username`='$username'") or die(mysql_error());
echo "$m_orderid|success";
stat_pay($STAT_PAY_ARR[$shp_item], $merch_amount);
$merch_user_wmid = false;
if ($shp_item != 21) {
konkurs_rek_ed($merch_user_wmid, $username, $merch_amount);
konkurs_rek_ed($merch_user_wmid, $username, $merch_amount);
}
if ($shp_item == 6 | $shp_item == 7 | $shp_item == 8 | $shp_item == 9 | $shp_item == 10 | $shp_item == 12 | $shp_item == 20) {
cache_stat_links();
cache_kontext();
cache_frm_links();
cache_txt_links();
cache_rek_cep();
cache_banners();
cache_beg_stroka();
}
}
}
else {
exit("$m_orderid|error");
}
}
else {
exit("$m_orderid|error");
}
?>
elseif ($shp_item == 1) {
...
elseif ($shp_item == 16) {
Еще тут наверняка SQL инъекции возможны потому что значения в запрос вставляются через конкатенацию и нет эскейпинга для SQL, только для HTML.
В целом код конечно лучше выкинуть и переписать нормально пользуясь современными способами/методологиями/библиотеками/инструментами