function obfuscate($filename) { global $conf; global $parser, $traverser, $prettyPrinter; global $debug_mode; try { $source = php_strip_whitespace($filename); fprintf(STDERR, "Obfuscating %s%s", $filename, PHP_EOL); //var_dump( token_get_all($source)); exit; if ($source === '') { throw new Exception("Error obfuscating [{$filename}]: php_strip_whitespace returned an empty string!"); } try { $stmts = $parser->parse($source . PHP_EOL . PHP_EOL); // PHP-Parser returns the syntax tree } catch (PhpParser\Error $e) { $source = file_get_contents($filename); $stmts = $parser->parse($source . PHP_EOL . PHP_EOL); } if ($debug_mode === 2) { $source = file_get_contents($filename); $stmts = $parser->parse($source . PHP_EOL . PHP_EOL); } if ($debug_mode) { var_dump($stmts); } $stmts = $traverser->traverse($stmts); // Use PHP-Parser function to traverse the syntax tree and obfuscate names if ($conf->shuffle_stmts) { $last_inst = array_pop($stmts); $stmts = shuffle_statements($stmts); $stmts[] = $last_inst; } $code = $prettyPrinter->prettyPrintFile($stmts); // Use PHP-Parser function to output the obfuscated source, taking the modified obfuscated syntax tree as input $code = trim($code); // var_dump($stmts); if (isset($conf->strip_indentation) && $conf->strip_indentation) { $code = remove_whitespaces($code); } $endcode = substr($code, 6); $code = '<?php' . PHP_EOL; $code .= $conf->get_comment(); // comment obfuscated source if (isset($conf->extract_comment_from_line) && isset($conf->extract_comment_to_line)) { $t_source = file($filename); for ($i = $conf->extract_comment_from_line - 1; $i < $conf->extract_comment_to_line; ++$i) { $code .= $t_source[$i]; } } if (isset($conf->user_comment)) { $code .= '/*' . PHP_EOL . $conf->user_comment . PHP_EOL . '*/' . PHP_EOL; } $code .= $endcode; return $code; } catch (Exception $e) { fprintf(STDERR, "Obfuscator Parse Error [%s]:%s\t%s%s", $filename, PHP_EOL, $e->getMessage(), PHP_EOL); return null; } }
} } elseif ($card_type == "Visa") { $pattern = "/^([4]{1})([0-9]{12,15})\$/"; //Visa if (preg_match($pattern, $cardnumber)) { $verified = true; } else { $verified = false; } } if ($verified == false) { //Do something here in case the validation fails $cardno_err = "Credit card invalid. Please make sure that you entered a valid credit card number "; $no_error = 1; } $cardId = remove_whitespaces($_POST["cardId"]); if (!preg_match("/^[0-9]{3}\$/", $cardId)) { $cardId_err = "Invalid card ID. Please enter 3 digit number located on the back of your credit card "; $no_error = 1; } // echo $fname . $lname . $address . $city . $zipcode . $phone . $cardnumber . $cardId. $card_type; if ($no_error == 0) { if (isset($_SESSION['name'])) { $conn = mysqli_connect('localhost', 'root', '', 'winestore'); if ($conn->connect_error) { die("Connection failed!" . $conn->connect_error); } else { $username = $_SESSION['name']; $p = ""; $subtotal = 0; $totalprice = 0;