kolaz |
Advanced user |
|
|
Joined: May 06, 2015 |
Posts: 53 |
|
|
|
|
|
|
|
add_client.php
=========
<?php include("db.php"); $_SESSION["main_menu"]=1; $_SESSION["sub_menu"]=0; include("header.php"); $grant=true; if ($_USER_ACCESS>1) { $grant=false; } $id=(int)$_POST['id']; $port=(int)$_POST['port']; $ip=pg_escape_string($_POST['iplist']); $name=pg_escape_string($_POST['name']); $address=pg_escape_string($_POST['address']); $street=(int)$_POST['street']; $phone=pg_escape_string($_POST['phone']); $mac=pg_escape_string($_POST['mac']); $note=pg_escape_string($_POST['note']); $paid=pg_escape_string($_POST['paid']); $delete=isset($_POST['delete']); $level=(int)$_POST['level']; $status=(int)$_POST['status']; $maccontrol=pg_escape_string($_POST['nomaccontrol']); $platil=pg_escape_string($_POST['platil']); $plant=pg_escape_string($_POST['plant']); $bulstat=pg_escape_string($_POST['bulstat']); $mol=pg_escape_string($_POST['mol']); $ddsid=pg_escape_string($_POST['ddsid']); $money=floatval($_POST['money']); $bank=pg_escape_string($_POST['bank']); $otkazal=pg_escape_string($_POST['otkazal']); $smokeping=pg_escape_string($_POST['smokeping']); if ($maccontrol != "TRUE") $maccontrol="FALSE"; if ($bank != "TRUE") $bank="FALSE"; if ($otkazal != "TRUE") $otkazal="FALSE"; if ($smokeping != "TRUE") $smokeping="FALSE"; $old_paid=$_SESSION["old_paid"]; $username=$_SERVER['PHP_AUTH_USER']; if (($_USER_ACCESS>0)&&($money==floatval("0"))&&($old_paid!=$paid)) { echo "<br><h3>За нулево плащане се обърнете към администратор!</h3>"; include("footer.php"); exit; } if (isset($_POST['searched'])) $redirectto="index.php"; else $redirectto="clients.php"; $invoice=true; $inv="T"; if ((strtotime($old_paid)==strtotime($paid)) || ($bank=="TRUE")) { $money=0; $invoice=false; $inv="F"; } if ($id!="") { if ($delete) { $sql="BEGIN;
UPDATE clients SET last_editor='$username' WHERE id='$id';
DELETE FROM clients WHERE id='$id';
COMMIT;"; if (!db_query($sql,"host=$dbhost dbname=$dbname user=$dbusername password=$dbpass", $db, $result)) return; db_free($db, $result); if (!$grant) { echo "<br>".$noacc_msg; include("footer.php"); exit; } echo "<br>".$delete_msg."<meta http-equiv='refresh' content='1; url=".$redirectto."?otkazali=".$_POST['otkazali']."&sort=".$_POST['sort']."&port_select=".$_POST['port_select']."&level_select=".$_POST['level_select']."&search_name=".$_POST['search_name']."&search_mac=".$_POST['search_mac']."'>"; } else { $sql="BEGIN;"; $sql.="INSERT INTO paid_log (client_id,old_paid,new_paid,invoice) VALUES('$id','$old_paid','$paid','$inv');"; if ($invoice) { $sql.="INSERT INTO invoices (name, address, phone, bulstat, paid, plan, money, username, ddsid, mol) VALUES('$name', '$address', '$phone', '$bulstat', '$paid', '$plant', '$money', '$username', '$ddsid', '$mol') RETURNING id;"; if ((!db_query($sql,"host=$dbhost dbname=$dbname user=$dbusername password=$dbpass", $db, $result)) || (!($iid=pg_fetch_result($result, 0, "id")))) return; $sql=""; } $sql.="UPDATE clients SET ip='$ip', name='$name', address='$address', phone='$phone', mac='$mac', note='$note', paid='$paid', level='$level', port='$port', status='$status', nomaccontrol='$maccontrol', bulstat='$bulstat', ddsid='$ddsid', mol='$mol', bank='$bank', otkazal='$otkazal', smokeping='$smokeping', street='$street', last_editor='$username', extended=false WHERE id='$id';
COMMIT;"; if (!db_query($sql,"host=$dbhost dbname=$dbname user=$dbusername password=$dbpass", $db, $result)) return; db_free($db, $result); if (!$grant) { echo "<br>".$noacc_msg; include("footer.php"); exit; } if (isset($_POST['B1'])) echo "<br>".$update_msg."<meta http-equiv='refresh' content='1; url=".$redirectto."?otkazali=".$_POST['otkazali']."&sort=".$_POST['sort']."&port_select=".$_POST['port_select']."&level_select=".$_POST['level_select']."&search_name=".$_POST['search_name']."&search_mac=".$_POST['search_mac']."'>"; else echo "<br>".$update_msg."<meta http-equiv='refresh' content='1; url=".$redirectto."?print=".$iid."&otkazali=".$_POST['otkazali']."&sort=".$_POST['sort']."&port_select=".$_POST['port_select']."&level_select=".$_POST['level_select']."&search_name=".$_POST['search_name']."&search_mac=".$_POST['search_mac']."'>"; } } else { $sql = "BEGIN;"; if ($invoice) { $sql.="INSERT INTO invoices (name, address, phone, bulstat, paid, plan, money, username, ddsid, mol) VALUES('$name', '$address', '$phone', '$bulstat', '$paid', '$plant', '$money', '$username', '$ddsid', '$mol') RETURNING id;"; if((!db_query($sql,"host=$dbhost dbname=$dbname user=$dbusername password=$dbpass", $db, $result)) || (!($iid=pg_fetch_result($result, 0, "id")))) return; $sql=""; } $sql .= "INSERT INTO clients (ip, name, address, phone, mac, note, paid, port, level, status, nomaccontrol, bulstat, ddsid, mol, bank, otkazal, smokeping, street, last_editor)
VALUES('$ip', '$name', '$address', '$phone', '$mac', '$note', '$paid', '$port', '$level', '$status', '$maccontrol', '$bulstat', '$ddsid', '$mol', '$bank', '$otkazal', '$smokeping', '$street', '$username');
COMMIT;"; if (!db_query($sql,"host=$dbhost dbname=$dbname user=$dbusername password=$dbpass", $db, $result)) { return; } db_free($db, $result); if (!$grant) { echo "<br>".$noacc_msg; include("footer.php"); exit; } if ((isset($_POST['B1'])) || (!$invoice)) echo "<br>".$update_msg."<meta http-equiv='refresh' content='1;
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Contact me if you want full decoding. |
|