- Timestamp:
- 06/04/08 01:37:02
(6 months ago)
- Author:
- rats
- Message:
* Updated net2ftp to version 0.97
* Updated SquirrelMail to version 1.4.15
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r910 |
r1198 |
|
| 3 | 3 | // ------------------------------------------------------------------------------- |
|---|
| 4 | 4 | // | net2ftp: a web based FTP client | |
|---|
| 5 | | // | Copyright (c) 2003-2007 by David Gartner | |
|---|
| | 5 | // | Copyright (c) 2003-2008 by David Gartner | |
|---|
| 6 | 6 | // | | |
|---|
| 7 | 7 | // | This program is free software; you can redistribute it and/or | |
|---|
| … | … | |
| 23 | 23 | |
|---|
| 24 | 24 | // -------------- |
|---|
| 25 | | // This function takes a clear-text password and returns an encrypted password |
|---|
| 26 | | // Written by Jakub |
|---|
| 27 | | // -------------- |
|---|
| 28 | | |
|---|
| 29 | | global $net2ftp_globals; |
|---|
| 30 | | |
|---|
| 31 | | // XOR with random string (which is set in settings.inc.php) |
|---|
| 32 | | $password_encrypted = ""; |
|---|
| 33 | | $encryption_string = sha1($net2ftp_globals["REMOTE_ADDR"]); |
|---|
| 34 | | if ($encryption_string % 2 == 1) { // we need even number of characters |
|---|
| 35 | | $encryption_string .= $encryption_string{0}; |
|---|
| 36 | | } |
|---|
| 37 | | for ($i=0; $i < strlen($password); $i++) { // encrypts one character - two bytes at once |
|---|
| 38 | | $password_encrypted .= sprintf("%02X", hexdec(substr($encryption_string, 2*$i % strlen($encryption_string), 2)) ^ ord($password{$i})); |
|---|
| 39 | | } |
|---|
| 40 | | return $password_encrypted; |
|---|
| | 25 | // Stone PHP SafeCrypt |
|---|
| | 26 | // http://blog.sc.tri-bit.com/archives/101 |
|---|
| | 27 | // -------------- |
|---|
| | 28 | |
|---|
| | 29 | $packed = PackCrypt($password, "Replace this by your own salt to improve security! 229450455034058679120494"); |
|---|
| | 30 | |
|---|
| | 31 | if ($packed["success"] == true) { |
|---|
| | 32 | return $packed["output"]; |
|---|
| | 33 | } |
|---|
| | 34 | else { |
|---|
| | 35 | setErrorVars(false, "An error occured when trying to encrypt the password: " . $packed["reason"], debug_backtrace(), __FILE__, __LINE__); |
|---|
| | 36 | } |
|---|
| 41 | 37 | |
|---|
| 42 | 38 | } // End function encryptPassword |
|---|
| … | … | |
| 59 | 55 | |
|---|
| 60 | 56 | // -------------- |
|---|
| 61 | | // This function takes an encrypted password and returns the clear-text password |
|---|
| 62 | | // Written by Jakub |
|---|
| 63 | | // -------------- |
|---|
| 64 | | |
|---|
| 65 | | global $net2ftp_globals; |
|---|
| 66 | | |
|---|
| 67 | | // XOR with random string (which is set in settings.inc.php) |
|---|
| 68 | | $password = ""; |
|---|
| 69 | | $encryption_string = sha1($net2ftp_globals["REMOTE_ADDR"]); |
|---|
| 70 | | if ($encryption_string % 2 == 1) { // we need even number of characters |
|---|
| 71 | | $encryption_string .= $encryption_string{0}; |
|---|
| 72 | | } |
|---|
| 73 | | for ($i=0; $i < strlen($password_encrypted); $i += 2) { // decrypts two bytes - one character at once |
|---|
| 74 | | $password .= chr(hexdec(substr($encryption_string, $i % strlen($encryption_string), 2)) ^ hexdec(substr($password_encrypted, $i, 2))); |
|---|
| 75 | | } |
|---|
| 76 | | return $password; |
|---|
| | 57 | // Stone PHP SafeCrypt |
|---|
| | 58 | // http://blog.sc.tri-bit.com/archives/101 |
|---|
| | 59 | // -------------- |
|---|
| | 60 | |
|---|
| | 61 | $unpacked = UnpackCrypt($password_encrypted, "Replace this by your own salt to improve security! 229450455034058679120494"); |
|---|
| | 62 | |
|---|
| | 63 | if ($unpacked["success"] == true) { |
|---|
| | 64 | return $unpacked["output"]; |
|---|
| | 65 | } |
|---|
| | 66 | else { |
|---|
| | 67 | setErrorVars(false, "An error occured when trying to decrypt the password: " . $unpacked["reason"], debug_backtrace(), __FILE__, __LINE__); |
|---|
| | 68 | } |
|---|
| 77 | 69 | |
|---|
| 78 | 70 | } // End function decryptPassword |
|---|
| … | … | |
| 318 | 310 | // ------------------------------------------------------------------------- |
|---|
| 319 | 311 | if ($net2ftp_settings["allowed_addresses"][1] != "ALL") { |
|---|
| 320 | | $result3 = array_search($net2ftp_globals["REMOTE_ADDR"], $net2ftp_settings["allowed_addresses"]); |
|---|
| | 312 | // Old way of searching |
|---|
| | 313 | // Does not work with IP address ranges in $net2ftp_settings["allowed_addresses"] |
|---|
| | 314 | // $result3 = array_search($net2ftp_globals["REMOTE_ADDR"], $net2ftp_settings["allowed_addresses"]); |
|---|
| | 315 | // New way of searching |
|---|
| | 316 | $result3 = false; |
|---|
| | 317 | for ($i=1; $i<=sizeof($net2ftp_settings["allowed_addresses"]); $i++) { |
|---|
| | 318 | if (substr($net2ftp_globals["REMOTE_ADDR"], 0, strlen($net2ftp_settings["allowed_addresses"][$i])) == $net2ftp_settings["allowed_addresses"][$i]) { $result3 = true; } |
|---|
| | 319 | } |
|---|
| 321 | 320 | if ($result3 == false) { |
|---|
| 322 | 321 | $errormessage = __("Your IP address (%1\$s) is not in the list of allowed IP addresses.", $net2ftp_globals["REMOTE_ADDR"]); |
|---|
| … | … | |
| 331 | 330 | // ------------------------------------------------------------------------- |
|---|
| 332 | 331 | if (isset($net2ftp_settings["banned_addresses"][1]) == true && $net2ftp_settings["banned_addresses"][1] != "NONE") { |
|---|
| 333 | | $result4 = array_search($net2ftp_globals["REMOTE_ADDR"], $net2ftp_settings["banned_addresses"]); |
|---|
| | 332 | // Old way of searching |
|---|
| | 333 | // Does not work with IP address ranges in $net2ftp_settings["banned_addresses"] |
|---|
| | 334 | // $result4 = array_search($net2ftp_globals["REMOTE_ADDR"], $net2ftp_settings["banned_addresses"]); |
|---|
| | 335 | // New way of searching |
|---|
| | 336 | $result4 = false; |
|---|
| | 337 | for ($i=1; $i<=sizeof($net2ftp_settings["banned_addresses"]); $i++) { |
|---|
| | 338 | if (substr($net2ftp_globals["REMOTE_ADDR"], 0, strlen($net2ftp_settings["banned_addresses"][$i])) == $net2ftp_settings["banned_addresses"][$i]) { $result4 = true; } |
|---|
| | 339 | } |
|---|
| 334 | 340 | if ($result4 != false) { |
|---|
| 335 | 341 | $errormessage = __("Your IP address (%1\$s) is in the list of banned IP addresses.", $net2ftp_globals["REMOTE_ADDR"]); |
|---|
| … | … | |
| 618 | 624 | global $net2ftp_globals, $net2ftp_settings, $net2ftp_result; |
|---|
| 619 | 625 | |
|---|
| 620 | | // ------------------------------------------------------------------------- |
|---|
| 621 | | // Check if the logging of Errors is ON or OFF |
|---|
| 622 | | // ------------------------------------------------------------------------- |
|---|
| 623 | | if ($net2ftp_settings["log_access"] == "yes" && $net2ftp_settings["use_database"] == "yes") { |
|---|
| 624 | | |
|---|
| 625 | | // ------------------------------------------------------------------------- |
|---|
| | 626 | if ($net2ftp_settings["log_access"] == "yes") { |
|---|
| | 627 | |
|---|
| | 628 | // ------------------------------------------------------------------------- |
|---|
| | 629 | // Date and time |
|---|
| | 630 | // ------------------------------------------------------------------------- |
|---|
| | 631 | $date = date("Y-m-d"); |
|---|
| | 632 | $time = date("H:i:s"); |
|---|
| | 633 | |
|---|
| | 634 | // ------------------------------------------------------------------------- |
|---|
| | 635 | // Logging to the database |
|---|
| | 636 | // ------------------------------------------------------------------------- |
|---|
| | 637 | |
|---|
| | 638 | if ($net2ftp_settings["use_database"] == "yes") { |
|---|
| | 639 | |
|---|
| | 640 | // ---------------------------------------------- |
|---|
| 626 | 641 | // Input checks |
|---|
| 627 | | // ------------------------------------------------------------------------- |
|---|
| | 642 | // ---------------------------------------------- |
|---|
| 628 | 643 | // Add slashes to variables which are used in a SQL query, and which are |
|---|
| 629 | 644 | // potentially unsafe (supplied by the user). |
|---|
| 630 | | // $date is calculated in this function |
|---|
| 631 | | // $time is calculated in this function |
|---|
| 632 | | $REMOTE_ADDR_safe = addslashes($net2ftp_globals["REMOTE_ADDR"]); |
|---|
| 633 | | $REMOTE_PORT_safe = addslashes($net2ftp_globals["REMOTE_PORT"]); |
|---|
| 634 | | $HTTP_USER_AGENT_safe = addslashes($net2ftp_globals["HTTP_USER_AGENT"]); |
|---|
| 635 | | $PHP_SELF_safe = addslashes($net2ftp_globals["PHP_SELF"]); |
|---|
| 636 | | if (isset($net2ftp_globals["consumption_datatransfer"]) == true) { |
|---|
| 637 | | $consumption_datatransfer_safe = addslashes($net2ftp_globals["consumption_datatransfer"]); |
|---|
| 638 | | } |
|---|
| 639 | | else { |
|---|
| 640 | | $consumption_datatransfer_safe = "0"; |
|---|
| 641 | | } |
|---|
| 642 | | if (isset($net2ftp_globals["consumption_executiontime"]) == true) { |
|---|
| 643 | | $consumption_executiontime_safe = addslashes($net2ftp_globals["consumption_executiontime"]); |
|---|
| 644 | | } |
|---|
| 645 | | else { |
|---|
| 646 | | $consumption_executiontime_safe = "0"; |
|---|
| 647 | | } |
|---|
| 648 | | $net2ftp_ftpserver_safe = addslashes($net2ftp_globals["ftpserver"]); |
|---|
| 649 | | $net2ftp_username_safe = addslashes($net2ftp_globals["username"]); |
|---|
| 650 | | $state_safe = addslashes($net2ftp_globals["state"]); |
|---|
| 651 | | $state2_safe = addslashes($net2ftp_globals["state2"]); |
|---|
| 652 | | $screen_safe = addslashes($net2ftp_globals["screen"]); |
|---|
| 653 | | $directory_safe = addslashes($net2ftp_globals["directory"]); |
|---|
| 654 | | $entry_safe = addslashes($net2ftp_globals["entry"]); |
|---|
| 655 | | $HTTP_REFERER_safe = addslashes($net2ftp_globals["HTTP_REFERER"]); |
|---|
| 656 | | |
|---|
| 657 | | // ------------------------------------------------------------------------- |
|---|
| | 645 | // $date is calculated in this function |
|---|
| | 646 | // $time is calculated in this function |
|---|
| | 647 | $REMOTE_ADDR_safe = addslashes($net2ftp_globals["REMOTE_ADDR"]); |
|---|
| | 648 | $REMOTE_PORT_safe = addslashes($net2ftp_globals["REMOTE_PORT"]); |
|---|
| | 649 | $HTTP_USER_AGENT_safe = addslashes($net2ftp_globals["HTTP_USER_AGENT"]); |
|---|
| | 650 | $PHP_SELF_safe = addslashes($net2ftp_globals["PHP_SELF"]); |
|---|
| | 651 | if (isset($net2ftp_globals["consumption_datatransfer"]) == true) { |
|---|
| | 652 | $consumption_datatransfer_safe = addslashes($net2ftp_globals["consumption_datatransfer"]); |
|---|
| | 653 | } |
|---|
| | 654 | else { |
|---|
| | 655 | $consumption_datatransfer_safe = "0"; |
|---|
| | 656 | } |
|---|
| | 657 | if (isset($net2ftp_globals["consumption_executiontime"]) == true) { |
|---|
| | 658 | $consumption_executiontime_safe = addslashes($net2ftp_globals["consumption_executiontime"]); |
|---|
| | 659 | } |
|---|
| | 660 | else { |
|---|
| | 661 | $consumption_executiontime_safe = "0"; |
|---|
| | 662 | } |
|---|
| | 663 | $net2ftp_ftpserver_safe = addslashes($net2ftp_globals["ftpserver"]); |
|---|
| | 664 | $net2ftp_username_safe = addslashes($net2ftp_globals["username"]); |
|---|
| | 665 | $state_safe = addslashes($net2ftp_globals["state"]); |
|---|
| | 666 | $state2_safe = addslashes($net2ftp_globals["state2"]); |
|---|
| | 667 | $screen_safe = addslashes($net2ftp_globals["screen"]); |
|---|
| | 668 | $directory_safe = addslashes($net2ftp_globals["directory"]); |
|---|
| | 669 | $entry_safe = addslashes($net2ftp_globals["entry"]); |
|---|
| | 670 | $HTTP_REFERER_safe = addslashes($net2ftp_globals["HTTP_REFERER"]); |
|---|
| | 671 | |
|---|
| | 672 | // ---------------------------------------------- |
|---|
| 658 | 673 | // Connect to the DB |
|---|
| 659 | | // ------------------------------------------------------------------------- |
|---|
| 660 | | $mydb = connect2db(); |
|---|
| 661 | | if ($net2ftp_result["success"] == false) { return false; } |
|---|
| 662 | | |
|---|
| 663 | | // ------------------------------------------------------------------------- |
|---|
| 664 | | // Log the accesses |
|---|
| 665 | | // ------------------------------------------------------------------------- |
|---|
| 666 | | $date = date("Y-m-d"); |
|---|
| 667 | | $time = date("H:i:s"); |
|---|
| 668 | | $sqlquery1 = "INSERT INTO net2ftp_log_access VALUES(null, '$date', '$time', '$REMOTE_ADDR_safe', '$REMOTE_PORT_safe', '$HTTP_USER_AGENT_safe', '$PHP_SELF_safe', '$consumption_datatransfer_safe', '$consumption_executiontime_safe', '$net2ftp_ftpserver_safe', '$net2ftp_username_safe', '$state_safe', '$state2_safe', '$screen_safe', '$directory_safe', '$entry_safe', '$HTTP_REFERER_safe')"; |
|---|
| 669 | | $result1 = @mysql_query($sqlquery1); |
|---|
| 670 | | if ($result1 == false) { |
|---|
| 671 | | $errormessage = __("Unable to execute the SQL query."); |
|---|
| 672 | | setErrorVars(false, $errormessage, debug_backtrace(), __FILE__, __LINE__); |
|---|
| 673 | | return false; |
|---|
| 674 | | } |
|---|
| 675 | | |
|---|
| 676 | | $nrofrows1 = @mysql_affected_rows($mydb); |
|---|
| 677 | | |
|---|
| 678 | | $net2ftp_globals["log_access_id"] = mysql_insert_id(); |
|---|
| 679 | | |
|---|
| 680 | | } // end if logAccesses |
|---|
| | 674 | // ---------------------------------------------- |
|---|
| | 675 | $mydb = connect2db(); |
|---|
| | 676 | if ($net2ftp_result["success"] == false) { return false; } |
|---|
| | 677 | |
|---|
| | 678 | // ---------------------------------------------- |
|---|
| | 679 | // Add record to the database table |
|---|
| | 680 | // ---------------------------------------------- |
|---|
| | 681 | $sqlquery1 = "INSERT INTO net2ftp_log_access VALUES(null, '$date', '$time', '$REMOTE_ADDR_safe', '$REMOTE_PORT_safe', '$HTTP_USER_AGENT_safe', '$PHP_SELF_safe', '$consumption_datatransfer_safe', '$consumption_executiontime_safe', '$net2ftp_ftpserver_safe', '$net2ftp_username_safe', '$state_safe', '$state2_safe', '$screen_safe', '$directory_safe', '$entry_safe', '$HTTP_REFERER_safe')"; |
|---|
| | 682 | $result1 = @mysql_query($sqlquery1); |
|---|
| | 683 | if ($result1 == false) { |
|---|
| | 684 | $errormessage = __("Unable to execute the SQL query."); |
|---|
| | 685 | setErrorVars(false, $errormessage, debug_backtrace(), __FILE__, __LINE__); |
|---|
| | 686 | return false; |
|---|
| | 687 | } |
|---|
| | 688 | |
|---|
| | 689 | $nrofrows1 = @mysql_affected_rows($mydb); |
|---|
| | 690 | |
|---|
| | 691 | $net2ftp_globals["log_access_id"] = mysql_insert_id(); |
|---|
| | 692 | |
|---|
| | 693 | } // end if use_database |
|---|
| | 694 | |
|---|
| | 695 | // ------------------------------------------------------------------------- |
|---|
| | 696 | // Logging to the system log |
|---|
| | 697 | // ------------------------------------------------------------------------- |
|---|
| | 698 | |
|---|
| | 699 | if ($net2ftp_settings["use_syslog"] == "yes") { |
|---|
| | 700 | |
|---|
| | 701 | // ---------------------------------------------- |
|---|
| | 702 | // Get consumption values |
|---|
| | 703 | // ---------------------------------------------- |
|---|
| | 704 | if (isset($net2ftp_globals["consumption_datatransfer"]) == true) { |
|---|
| | 705 | $consumption_datatransfer = $net2ftp_globals["consumption_datatransfer"]; |
|---|
| | 706 | } |
|---|
| | 707 | else { |
|---|
| | 708 | $consumption_datatransfer = "0"; |
|---|
| | 709 | } |
|---|
| | 710 | if (isset($net2ftp_globals["consumption_executiontime"]) == true) { |
|---|
| | 711 | $consumption_executiontime = $net2ftp_globals["consumption_executiontime"]; |
|---|
| | 712 | } |
|---|
| | 713 | else { |
|---|
| | 714 | $consumption_executiontime = "0"; |
|---|
| | 715 | } |
|---|
| | 716 | |
|---|
| | 717 | // ---------------------------------------------- |
|---|
| | 718 | // Create message |
|---|
| | 719 | // ---------------------------------------------- |
|---|
| | 720 | $message2log = "$date $time " . $net2ftp_globals["REMOTE_ADDR"] . " " . $net2ftp_globals["REMOTE_PORT"] . " " . $net2ftp_globals["PHP_SELF"] . " " . $consumption_datatransfer . " " . $consumption_executiontime . " " . $net2ftp_globals["ftpserver"] . " " . $net2ftp_globals["username"] . " " . $net2ftp_globals["state"] . " " . $net2ftp_globals["state2"] . " " . $net2ftp_globals["screen"] . " " . $net2ftp_globals["directory"] . " " . $net2ftp_globals["entry"]; |
|---|
| | 721 | $result2 = openlog($net2ftp_settings["syslog_ident"], 0, $net2ftp_settings["syslog_facility"]); |
|---|
| | 722 | if ($result2 == false) { |
|---|
| | 723 | $errormessage = __("Unable to open the system log."); |
|---|
| | 724 | setErrorVars(false, $errormessage, debug_backtrace(), __FILE__, __LINE__); |
|---|
| | 725 | return false; |
|---|
| | 726 | } |
|---|
| | 727 | |
|---|
| | 728 | // ---------------------------------------------- |
|---|
| | 729 | // Write message to system logger |
|---|
| | 730 | // ---------------------------------------------- |
|---|
| | 731 | $result3 = syslog($net2ftp_settings["syslog_priority"], $message2log); |
|---|
| | 732 | if ($result3 == false) { |
|---|
| | 733 | $errormessage = __("Unable to write a message to the system log."); |
|---|
| | 734 | setErrorVars(false, $errormessage, debug_backtrace(), __FILE__, __LINE__); |
|---|
| | 735 | return false; |
|---|
| | 736 | } |
|---|
| | 737 | |
|---|
| | 738 | } // end if use_syslog |
|---|
| | 739 | |
|---|
| | 740 | } // end if log_access |
|---|
| 681 | 741 | |
|---|
| 682 | 742 | } // end logAccess() |
|---|
| … | … | |
| 710 | 770 | global $net2ftp_globals, $net2ftp_settings, $net2ftp_result; |
|---|
| 711 | 771 | |
|---|
| 712 | | // ------------------------------------------------------------------------- |
|---|
| 713 | | // Check if the logging of Errors is ON or OFF |
|---|
| 714 | | // ------------------------------------------------------------------------- |
|---|
| 715 | | if ($net2ftp_settings["log_error"] == "yes" && $net2ftp_settings["use_database"] == "yes") { |
|---|
| | 772 | if ($net2ftp_settings["log_error"] == "yes") { |
|---|
| 716 | 773 | |
|---|
| 717 | 774 | // ------------------------------------------------------------------------- |
|---|
| … | … | |
| 719 | 776 | // If an error occurs within logError, logError will return false and reset the |
|---|
| 720 | 777 | // $net2ftp_result variable to it's original value |
|---|
| | 778 | // Also if no error occurs logError will return the variable to it's original value |
|---|
| 721 | 779 | // ------------------------------------------------------------------------- |
|---|
| 722 | 780 | $net2ftp_result_original = $net2ftp_result; |
|---|
| … | … | |
| 724 | 782 | |
|---|
| 725 | 783 | // ------------------------------------------------------------------------- |
|---|
| | 784 | // Errormessage and debug backtrace |
|---|
| | 785 | // ------------------------------------------------------------------------- |
|---|
| | 786 | $errormessage = addslashes($net2ftp_result_original["errormessage"]); |
|---|
| | 787 | |
|---|
| | 788 | $debug_backtrace = ""; |
|---|
| | 789 | $i = sizeof($net2ftp_result_original["debug_backtrace"])-1; |
|---|
| | 790 | if ($i > 0) { |
|---|
| | 791 | $debug_backtrace .= addslashes("function " . $net2ftp_result_original["debug_backtrace"][$i]["function"] . " (" . $net2ftp_result_original["debug_backtrace"][$i]["file"] . " on line " . $net2ftp_result_original["debug_backtrace"][$i]["line"] . ")\n"); |
|---|
| | 792 | for ($j=0; $j<sizeof($net2ftp_result_original["debug_backtrace"][$i]["args"]); $j++) { |
|---|
| | 793 | $debug_backtrace .= addslashes("argument $j: " . $net2ftp_result_original["debug_backtrace"][$i]["args"][$j] . "\n"); |
|---|
| | 794 | } |
|---|
| | 795 | } |
|---|
| | 796 | |
|---|
| | 797 | // ------------------------------------------------------------------------- |
|---|
| | 798 | // Date and time |
|---|
| | 799 | // ------------------------------------------------------------------------- |
|---|
| | 800 | $date = date("Y-m-d"); |
|---|
| | 801 | $time = date("H:i:s"); |
|---|
| | 802 | |
|---|
| | 803 | // ------------------------------------------------------------------------- |
|---|
| | 804 | // Logging to the database |
|---|
| | 805 | // ------------------------------------------------------------------------- |
|---|
| | 806 | if ($net2ftp_settings["use_database"] == "yes") { |
|---|
| | 807 | |
|---|
| | 808 | // ---------------------------------------------- |
|---|
| 726 | 809 | // Input checks |
|---|
| 727 | | // ------------------------------------------------------------------------- |
|---|
| | 810 | // ---------------------------------------------- |
|---|
| 728 | 811 | // Add slashes to variables which are used in a SQL query, and which are |
|---|
| 729 | 812 | // potentially unsafe (supplied by the user). |
|---|
| 730 | | // $date is calculated in this function |
|---|
| 731 | | // $time is calculated in this function |
|---|
| 732 | | $net2ftp_ftpserver_safe = addslashes($net2ftp_globals["ftpserver"]); |
|---|
| 733 | | $net2ftp_username_safe = addslashes($net2ftp_globals["username"]); |
|---|
| 734 | | $state_safe = addslashes($net2ftp_globals["state"]); |
|---|
| 735 | | $state2_safe = addslashes($net2ftp_globals["state2"]); |
|---|
| 736 | | $directory_safe = addslashes($net2ftp_globals["directory"]); |
|---|
| 737 | | $REMOTE_ADDR_safe = addslashes($net2ftp_globals["REMOTE_ADDR"]); |
|---|
| 738 | | $REMOTE_PORT_safe = addslashes($net2ftp_globals["REMOTE_PORT"]); |
|---|
| 739 | | $HTTP_USER_AGENT_safe = addslashes($net2ftp_globals["HTTP_USER_AGENT"]); |
|---|
| 740 | | |
|---|
| 741 | | // ------------------------------------------------------------------------- |
|---|
| 742 | | // Errormessage and debug backtrace |
|---|
| 743 | | // ------------------------------------------------------------------------- |
|---|
| 744 | | $errormessage = addslashes($net2ftp_result["errormessage"]); |
|---|
| 745 | | |
|---|
| 746 | | $debug_backtrace = ""; |
|---|
| 747 | | $i = sizeof($net2ftp_result["debug_backtrace"])-1; |
|---|
| 748 | | |
|---|
| 749 | | if ($i > 0) { |
|---|
| 750 | | $debug_backtrace .= addslashes("function " . $net2ftp_result["debug_backtrace"][$i]["function"] . " (" . $net2ftp_result["debug_backtrace"][$i]["file"] . " on line " . $net2ftp_result["debug_backtrace"][$i]["line"] . ")\n"); |
|---|
| 751 | | for ($j=0; $j<sizeof($net2ftp_result["debug_backtrace"][$i]["args"]); $j++) { |
|---|
| 752 | | $debug_backtrace .= addslashes("argument $j: " . $net2ftp_result["debug_backtrace"][$i]["args"][$j] . "\n"); |
|---|
| 753 | | } |
|---|
| 754 | | } |
|---|
| 755 | | |
|---|
| 756 | | // ------------------------------------------------------------------------- |
|---|
| | 813 | // $date is calculated in this function |
|---|
| | 814 | // $time is calculated in this function |
|---|
| | 815 | $net2ftp_ftpserver_safe = addslashes($net2ftp_globals["ftpserver"]); |
|---|
| | 816 | $net2ftp_username_safe = addslashes($net2ftp_globals["username"]); |
|---|
| | 817 | $state_safe = addslashes($net2ftp_globals["state"]); |
|---|
| | 818 | $state2_safe = addslashes($net2ftp_globals["state2"]); |
|---|
| | 819 | $directory_safe = addslashes($net2ftp_globals["directory"]); |
|---|
| | 820 | $REMOTE_ADDR_safe = addslashes($net2ftp_globals["REMOTE_ADDR"]); |
|---|
| | 821 | $REMOTE_PORT_safe = addslashes($net2ftp_globals["REMOTE_PORT"]); |
|---|
| | 822 | $HTTP_USER_AGENT_safe = addslashes($net2ftp_globals["HTTP_USER_AGENT"]); |
|---|
| | 823 | |
|---|
| | 824 | // ---------------------------------------------- |
|---|
| 757 | 825 | // Connect to the DB |
|---|
| 758 | | // ------------------------------------------------------------------------- |
|---|
| 759 | | $mydb = connect2db(); |
|---|
| 760 | | if ($net2ftp_result["success"] == false) { |
|---|
| 761 | | setErrorVars($net2ftp_result_original["success"], $net2ftp_result_original["errormessage"], $net2ftp_result_original["debug_backtrace"], $net2ftp_result_original["file"], $net2ftp_result_original["line"]); |
|---|
| 762 | | return false; |
|---|
| 763 | | } |
|---|
| 764 | | |
|---|
| 765 | | // ------------------------------------------------------------------------- |
|---|
| 766 | | // Log the Errors |
|---|
| 767 | | // ------------------------------------------------------------------------- |
|---|
| 768 | | $date = date("Y-m-d"); |
|---|
| 769 | | $time = date("H:i:s"); |
|---|
| 770 | | $sqlquerystring = "INSERT INTO net2ftp_log_error VALUES('$date', '$time', '$net2ftp_ftpserver_safe', '$net2ftp_username_safe', '$errormessage', '$debug_backtrace', '$state_safe', '$state2_safe', '$directory_safe', '$REMOTE_ADDR_safe', '$REMOTE_PORT_safe', '$HTTP_USER_AGENT_safe')"; |
|---|
| 771 | | $result_mysql_query = @mysql_query($sqlquerystring); |
|---|
| 772 | | if ($result_mysql_query == false) { |
|---|
| 773 | | setErrorVars($net2ftp_result_original["success"], $net2ftp_result_original["errormessage"], $net2ftp_result_original["debug_backtrace"], $net2ftp_result_original["file"], $net2ftp_result_original["line"]); |
|---|
| 774 | | return false; |
|---|
| 775 | | } |
|---|
| | 826 | // ---------------------------------------------- |
|---|
| | 827 | $mydb = connect2db(); |
|---|
| | 828 | if ($net2ftp_result["success"] == false) { |
|---|
| | 829 | setErrorVars($net2ftp_result_original["success"], $net2ftp_result_original["errormessage"], $net2ftp_result_original["debug_backtrace"], $net2ftp_result_original["file"], $net2ftp_result_original["line"]); |
|---|
| | 830 | return false; |
|---|
| | 831 | } |
|---|
| | 832 | |
|---|
| | 833 | // ---------------------------------------------- |
|---|
| | 834 | // Add record to the database table |
|---|
| | 835 | // ---------------------------------------------- |
|---|
| | 836 | $sqlquerystring = "INSERT INTO net2ftp_log_error VALUES('$date', '$time', '$net2ftp_ftpserver_safe', '$net2ftp_username_safe', '$errormessage', '$debug_backtrace', '$state_safe', '$state2_safe', '$directory_safe', '$REMOTE_ADDR_safe', '$REMOTE_PORT_safe', '$HTTP_USER_AGENT_safe')"; |
|---|
| | 837 | $result_mysql_query = @mysql_query($sqlquerystring); |
|---|
| | 838 | if ($result_mysql_query == false) { |
|---|
| | 839 | setErrorVars($net2ftp_result_original["success"], $net2ftp_result_original["errormessage"], $net2ftp_result_original["debug_backtrace"], $net2ftp_result_original["file"], $net2ftp_result_original["line"]); |
|---|
| | 840 | return false; |
|---|
| | 841 | } |
|---|
| | 842 | |
|---|
| | 843 | } // end if use_database |
|---|
| | 844 | |
|---|
| | 845 | // ------------------------------------------------------------------------- |
|---|
| | 846 | // Logging to the system log |
|---|
| | 847 | // ------------------------------------------------------------------------- |
|---|
| | 848 | if ($net2ftp_settings["use_syslog"] == "yes") { |
|---|
| | 849 | |
|---|
| | 850 | // ---------------------------------------------- |
|---|
| | 851 | // Get consumption values |
|---|
| | 852 | // ---------------------------------------------- |
|---|
| | 853 | if (isset($net2ftp_globals["consumption_datatransfer"]) == true) { |
|---|
| | 854 | $consumption_datatransfer = $net2ftp_globals["consumption_datatransfer"]; |
|---|
| | 855 | } |
|---|
| | 856 | else { |
|---|
| | 857 | $consumption_datatransfer = "0"; |
|---|
| | 858 | } |
|---|
| | 859 | if (isset($net2ftp_globals["consumption_executiontime"]) == true) { |
|---|
| | 860 | $consumption_executiontime = $net2ftp_globals["consumption_executiontime"]; |
|---|
| | 861 | } |
|---|
| | 862 | else { |
|---|
| | 863 | $consumption_executiontime = "0"; |
|---|
| | 864 | } |
|---|
| | 865 | |
|---|
| | 866 | // ---------------------------------------------- |
|---|
| | 867 | // Create message |
|---|
| | 868 | // ---------------------------------------------- |
|---|
| | 869 | $message2log = "$date $time " . $net2ftp_globals["ftpserver"] . " " . $net2ftp_globals["username"] . " " . $net2ftp_result["errormessage"] . " $debug_backtrace " . $net2ftp_globals["state"] . " " . $net2ftp_globals["state2"] . " " . $net2ftp_globals["directory"] . " " . $net2ftp_globals["REMOTE_ADDR"] . " " . $net2ftp_globals["HTTP_USER_AGENT"]; |
|---|
| | 870 | $result2 = openlog($net2ftp_settings["syslog_ident"], 0, $net2ftp_settings["syslog_facility"]); |
|---|
| | 871 | if ($result2 == false) { |
|---|
| | 872 | $errormessage = __("Unable to open the system log."); |
|---|
| | 873 | setErrorVars(false, $errormessage, debug_backtrace(), __FILE__, __LINE__); |
|---|
| | 874 | return false; |
|---|
| | 875 | } |
|---|
| | 876 | |
|---|
| | 877 | // ---------------------------------------------- |
|---|
| | 878 | // Write message to system logger |
|---|
| | 879 | // ---------------------------------------------- |
|---|
| | 880 | $result3 = syslog($net2ftp_settings["syslog_priority"], $message2log); |
|---|
| | 881 | if ($result3 == false) { |
|---|
| | 882 | $errormessage = __("Unable to write a message to the system log."); |
|---|
| | 883 | setErrorVars(false, $errormessage, debug_backtrace(), __FILE__, __LINE__); |
|---|
| | 884 | return false; |
|---|
| | 885 | } |
|---|
| | 886 | |
|---|
| | 887 | } // end if use_syslog |
|---|
| | 888 | |
|---|
| | 889 | // ------------------------------------------------------------------------- |
|---|
| | 890 | // Reset the variable to it's original value |
|---|
| | 891 | // ------------------------------------------------------------------------- |
|---|
| | 892 | setErrorVars($net2ftp_result_original["success"], $net2ftp_result_original["errormessage"], $net2ftp_result_original["debug_backtrace"], $net2ftp_result_original["file"], $net2ftp_result_original["line"]); |
|---|
| 776 | 893 | |
|---|
| 777 | 894 | } // end if logErrors |
|---|
|