GIF89a; %PDF-1.5 %���� ºaâÚÎΞ-ÌE1ÍØÄ÷{òò2ÿ ÛÖ^ÔÀá TÎ{¦?§®¥kuµùÕ5sLOšuY
Server IP : 134.29.175.74 / Your IP : 216.73.216.160 Web Server : nginx/1.10.2 System : Windows NT CST-WEBSERVER 10.0 build 19045 (Windows 10) i586 User : Administrator ( 0) PHP Version : 7.1.0 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : C:/nginx/html/Software/ |
Upload File : |
<?php // ******************************************************************************************** // 11/2009 Sandy Sund // Script is part of the Product Key program to process data // ProcessData.php is called (from ProductKeyOptions.phpinc) when user chooses to add/ email keys/checkout/check in a product key // ******************************************************************************************** $option = $_POST["f_option"]; $userID = $_POST["f_userID"]; include('../Connections/products.php'); mysql_select_db($database_products, $products); switch ($option) { case "Add": add_record($products); // send product tables connection for sql break; case "Checkout": checkout_product($userID, $products); // send user id and product tables connection for sql break; case "Import": echo "TO DO Later date- import xml file"; break; case "Resend": resend_keys($userID, $products); // send user id and product tables connection for sql break; case "Checkin": checkin_key($userID, $products); // send user id and product tables connection for sql break; default: echo "Something wrong - option $option not found ";; } // ******************************************************************************************** // ** Send all product keys that are checkout for this user id // ******************************************************************************************** function resend_keys($userID,$products) { include('../common/functions_debug.phpinc'); // get keys checked out to user and build into a table to display to user $checked_out_product_keys = get_productkeys($userID, $products); echo "<br><br>$checked_out_product_keys "; // get record from user table by user ID $Recordset_email=get_user_record($userID, $products); $userEmail= $Recordset_email['userEmail']; $userName= $Recordset_email['userFirstName'].' '.$Recordset_email['userLastName']; if ( empty($userEmail) ) { echo "<br> ** Could not find your email address so your information will not be emailed to you ** <br> userID = ".$userID ; } else { if ( empty($checked_out_product_keys) ) { echo " ** No Product Keys are Checked Out to $userName **"; } else { send_email($checked_out_product_keys,$userEmail,$userName); } } echo "<p><br><a href='index.php' >Back to Main</a> </p> " ; } // ******************************************************************************************** // ** check back in product key for re-use // ******************************************************************************************** function checkin_key($userID, $products) { // get form value $productkeyID = trim($_POST["f_productkeyID"]); $productkeyNumber = trim($_POST["f_productkeyNumber"]); // set up dates $y= date('Y'); $m= date('m'); $d= date('d'); $today=$y.$m.$d; // Update product key table change flag available flag to Y $sql_update_productkey= " UPDATE productkey set productkeyAvailable = 'Y' WHERE productkeyID='$productkeyID' and productkeyNumber='$productkeyNumber' "; $Recordset_key_update = mysql_query($sql_update_productkey, $products) or die(mysql_error()); // Update product location table add todays date for a check In date for this user ID $sql_update_productlocation= " UPDATE productlocation set productlocationDateIn='$today' WHERE productkeyID='$productkeyID' and userStudentID = '$userID' "; $Recordset_key_update2 = mysql_query($sql_update_productlocation, $products) or die(mysql_error()); redir("index.php"); } // ******************************************************************************************** // ** update the productkey record and also productlocation table with who checked out the product key // ******************************************************************************************** function checkout_product($userID, $products) { // get form value $productDescription = trim($_POST["f_productDescription"]); $y= date('Y'); $m= date('m'); $d= date('d'); $today=$y.$m.$d; $today_is=$m.'/'.$d.'/'.$y; // Get productID by product description to be used on look up on productkey table $sql_get_productID= "SELECT productID from product WHERE productDescription='$productDescription' "; $Recordset_productID = mysql_query($sql_get_productID, $products) or die(mysql_error()); $row_Recordset_productID = mysqli_fetch_assoc($Recordset_productID); $product_productID= $row_Recordset_productID['productID']; // Get available key for user by product ID $productkey_productkeyNumber= ''; $sql_get_key= " SELECT productkeyNumber,productkeyID FROM productkey WHERE productID='$product_productID' and productkeyAvailable='Y'"; $Recordset_key = mysql_query($sql_get_key, $products) or die(mysql_error()); $row_Recordset_key = mysqli_fetch_assoc($Recordset_key); $productkey_productkeyNumber= $row_Recordset_key['productkeyNumber']; $productkey_productkeyID= $row_Recordset_key['productkeyID']; if (empty($productkey_productkeyNumber) ) { echo "<br>*** ERROR - Product Key Record NOT Found in productkey table for $productDescription!! "; } else { // Update if key available using productkeyID key that was just selected $sql_update_key= " UPDATE productkey set productkeyAvailable = 'N' WHERE productkeyID='$productkey_productkeyID' and productkeyMultiUse='N' "; $Recordset_key_update = mysql_query($sql_update_key, $products) or die(mysql_error()); // add location of product key record to productlocation table $sql_location= "INSERT INTO productlocation (productkeyID,userStudentID,productlocationDateOut) VALUES ('$productkey_productkeyID','$userID','$today') "; $Recordset_location = mysql_query($sql_location, $products) or die(mysql_error()); resend_keys($userID, $products); // email user the keys redir("index.php"); } } // ******************************************************************************************** // Redirect web borwser to a location // ******************************************************************************************** function redir($url) { echo "<script language='JavaScript' type='text/javascript'>window.location='$url'</script>\n"; } // ******************************************************************************************** // ** Add a new record for the productkey table also product table if that description does not exist. // ******************************************************************************************** function add_record($products) { // get form values, lookup in product to see if description exists. If it does get productID else write record and get productID $productDescription = trim($_POST["f_productDescription"]); $productkeyNumber = trim($_POST["f_productkeyNumber"]); $productkeyMultiUse = $_POST["f_mulitUse"]; // does a product record already exist for the product description if (empty($productkeyNumber) or empty($productDescription)) {echo " *** ERROR invalid data <br> Key or Description can NOT be blank! <br> <a href='index.php' >Return to home</a> ";} else { // valid input data passed in $sql_get_productID= "SELECT productID from product WHERE productDescription='$productDescription' "; $Recordset_productID = mysql_query($sql_get_productID, $products) or die(mysql_error()); $row_Recordset_productID = mysqli_fetch_assoc($Recordset_productID); $product_productID= $row_Recordset_productID['productID']; if (empty($product_productID) ) { // Record not found in Product table for $productDescription, so insert $sql_insert1="INSERT INTO product (productDescription) VALUES ('$productDescription')"; $Recordset_inserted1 = mysql_query($sql_insert1, $products) or die(mysql_error()); // Get the new product ID that was just created with the insert $sql_get_productID2= "SELECT productID from product WHERE productDescription='$productDescription' "; $Recordset_productID2 = mysql_query($sql_get_productID2, $products) or die(mysql_error()); $row_Recordset_productID2 = mysqli_fetch_assoc($Recordset_productID2); $product_productID= $row_Recordset_productID2['productID']; } // If key does not exist in productkey table already, write the new product key / serial number to the productkey table $sql_get_productID3= "SELECT * from productkey WHERE productkeyNumber='$productkeyNumber' "; $Recordset_productID3 = mysql_query($sql_get_productID3, $products) or die(mysql_error()); $row_Recordset_productID3 = mysqli_fetch_assoc($Recordset_productID3); $key_exists= $row_Recordset_productID3['productkeyNumber']; if (!empty($key_exists)) { echo "*** ERROR-Product key ($key_exists) already exists for $productDescription <br> <a href='index.php' >Return to home</a>" ; } else { // not a duplicate product key so write the productkey record $sql_insert="INSERT INTO productkey (productID,productkeyNumber,productkeyAvailable,productkeyMultiUse) VALUES ('$product_productID','$productkeyNumber','Y','$productkeyMultiUse')"; $Recordset_inserted = mysql_query($sql_insert, $products) or die(mysql_error()); redir("index.php"); } } } // ******************************************************************************************** // ** get keys checked out to user and build into a table to display to user and return to function call // ******************************************************************************************** function get_productkeys($userID, $products) { $msg=" Product Keys that are currently assigned to you : <br><table border='0'><tr><td><b>Product Description</b> </td><td><b> Product Key Number</b> </td></tr>"; // get data $sql_get_location= "SELECT * FROM product JOIN productkey on product.productID = productkey.productID JOIN productlocation on productlocation.productkeyID =productkey.productkeyID WHERE userStudentID = '$userID' and productlocationDateIn is null "; $Recordset_location = mysql_query($sql_get_location, $products) or die(mysql_error()); $row_Recordset_location = mysqli_fetch_assoc($Recordset_location); do { $product_key_ID= $row_Recordset_location['productkeyID']; $productkey_productkeyNumber= $row_Recordset_location['productkeyNumber']; $productkey_productkeyID= $row_Recordset_location['productkeyID']; $productkey_productID= $row_Recordset_location['productID']; $description=$row_Recordset_location['productDescription']; $msg .= "<tr><td> $description </td><td> $productkey_productkeyNumber</td></tr>"; } while ($row_Recordset_location = mysqli_fetch_assoc($Recordset_location)); $msg .="</table> "; return $msg; } // ******************************************************************************************** // get data from user table by user ID // ******************************************************************************************** function get_user_record($userID, $products) { $sql_get_email=" SELECT * FROM user WHERE userStudentId='$userID' "; $Recordset_email_data = mysql_query($sql_get_email, $products) or die(mysql_error()); $Recordset_email = mysqli_fetch_assoc($Recordset_email_data); return $Recordset_email; } // ******************************************************************************************** // send the email to user email passed into function // ******************************************************************************************** function send_email($checked_out_product_keys,$userEmail,$userName) { ini_set('include_path',ini_get('include_path').PATH_SEPARATOR.$_SERVER['DOCUMENT_ROOT']."/"); // Add the DOCUMENT_ROOT to the include_path. // Start $mail. $thisFile=__FILE__; $thisLine=__LINE__; $thisLine=__LINE__; include('email/class.phpmailer.php'); // Set $mail. $mail->From = "jim.martinson@ridgewater.edu"; $mail->FromName = "Jim Martinson"; $mail->AddAddress($userEmail,$userName); // $mail->AddCC($userEmail,$userName); $mail->Subject = "CST - Product Keys"; $mail->Body =$checked_out_product_keys; // Send $mail. $thisFile=__FILE__; $thisLine=__LINE__; include('email/sendEmail.phpinc'); } //** end program ?>