<body>
<center>
<b>Could not include SQL library functions. Aborting</b>
</body>
</html>
EOM;
    exit;
}
$date = strftime('%A, %e %B %Y, %T %Z');
$sql_extra_query = '';
if ($config[sql_accounting_extra_query] != '') {
    $sql_extra_query = xlat($config[sql_accounting_extra_query], $login, $config);
    $sql_extra_query = da_sql_escape_string($sql_extra_query);
}
$link = @da_sql_pconnect($config);
$link2 = connect2db($config);
$tot_in = $tot_rem = 0;
if ($link) {
    $h = 21;
    $servers_num = 0;
    if ($config[general_ld_library_path] != '') {
        putenv("LD_LIBRARY_PATH={$config['general_ld_library_path']}");
    }
    foreach ($nas_list as $nas) {
        $j = 0;
        $num = 0;
        if ($server != '') {
            if ($nas[name] == $server) {
                $servers_num++;
            } else {
                continue;
Esempio n. 2
0
function putConsumption()
{
    // --------------
    // This function writes the consumption to the database.
    // It is run at the end of the script.
    // --------------
    // -------------------------------------------------------------------------
    // Global variables
    // -------------------------------------------------------------------------
    global $net2ftp_globals, $net2ftp_settings, $net2ftp_result;
    // -------------------------------------------------------------------------
    // Initial checks
    // -------------------------------------------------------------------------
    // Verify if a database is used, and if consumption checking is turned on. If not: don't continue.
    if ($net2ftp_settings["use_database"] != "yes" || $net2ftp_settings["check_consumption"] != "yes") {
        return true;
    }
    // When user is not logged in, the FTP server is not set
    if ($net2ftp_globals["ftpserver"] == "") {
        return true;
    }
    // If the REMOTE_ADDR is not filled in, then there is a problem (IP spoofing), so return an error
    if ($net2ftp_globals["REMOTE_ADDR"] == "") {
        setErrorVars(false, __("Unable to determine your IP address."), debug_backtrace(), __FILE__, __LINE__);
        return false;
    }
    // If the database has already been updated, don't do it a second time.
    // This is to avoid updating the database twice. The putConsumption() function
    // is called from index.php and from shutdown() in filesystem.inc.php. On Windows
    // the shutdown() function is called after *every* script execution.
    if ($net2ftp_globals["consumption_database_updated"] == 1) {
        return true;
    }
    // Add slashes to variables which are used in a SQL query, and which are
    // potentially unsafe (supplied by the user).
    // $date is calculated in this function
    // $time is calculated in this function
    $REMOTE_ADDR_safe = addslashes($net2ftp_globals["REMOTE_ADDR"]);
    $net2ftp_ftpserver_safe = addslashes($net2ftp_globals["ftpserver"]);
    // -------------------------------------------------------------------------
    // Check the input
    // -------------------------------------------------------------------------
    //	if (preg_match("/^[0-9]+$/", $net2ftp_globals["consumption_ipaddress_datatransfer) == FALSE) {
    //			setErrorVars(false, __("The variable <b>consumption_ipaddress_datatransfer</b> is not numeric."), debug_backtrace(), __FILE__, __LINE__);
    //			return false;
    //	}
    // -------------------------------------------------------------------------
    // Connect
    // -------------------------------------------------------------------------
    $mydb = connect2db();
    if ($net2ftp_result["success"] == false) {
        return false;
    }
    // -------------------------------------------------------------------------
    // Get date
    // -------------------------------------------------------------------------
    $date = date("Y-m-d");
    // -------------------------------------------------------------------------
    // Put consumed data volume and execution time by the current IP address
    // -------------------------------------------------------------------------
    $sqlquery1 = "SELECT * FROM net2ftp_log_consumption_ipaddress WHERE date = '{$date}' AND ipaddress = '{$REMOTE_ADDR_safe}';";
    $result1 = mysql_query("{$sqlquery1}");
    $nrofrows1 = mysql_num_rows($result1);
    if ($nrofrows1 == 1) {
        $sqlquery2 = "UPDATE net2ftp_log_consumption_ipaddress SET datatransfer = '" . $net2ftp_globals["consumption_ipaddress_datatransfer"] . "', executiontime = '" . round($net2ftp_globals["consumption_ipaddress_executiontime"]) . "' WHERE date = '{$date}' AND ipaddress = '{$REMOTE_ADDR_safe}';";
        $result2 = mysql_query("{$sqlquery2}");
        $nrofrows2 = mysql_affected_rows($mydb);
        // Don't check on the UPDATE nr of rows, because when the values in the variables and in the table are the same,
        // the $nrofrows2 is set to 0. (This happens on the Browse screen, when the loading is fast: the datatransfer is 0
        // and the executiontime is the same as in the table.)
        //		if ($nrofrows2 != 1) {
        //			setErrorVars(false, __("Table net2ftp_log_consumption_ipaddress could not be updated."), debug_backtrace(), __FILE__, __LINE__);
        //			return false;
        //		}
    } elseif ($nrofrows1 == 0) {
        $sqlquery3 = "INSERT INTO net2ftp_log_consumption_ipaddress VALUES('{$date}', '{$REMOTE_ADDR_safe}', '" . $net2ftp_globals["consumption_ipaddress_datatransfer"] . "', '" . round($net2ftp_globals["consumption_ipaddress_executiontime"]) . "');";
        $result3 = mysql_query("{$sqlquery3}");
        $nrofrows3 = mysql_affected_rows($mydb);
        if ($nrofrows3 != 1) {
            setErrorVars(false, __("Table net2ftp_log_consumption_ipaddress could not be updated."), debug_backtrace(), __FILE__, __LINE__);
            return false;
        }
    } else {
        setErrorVars(false, __("Table net2ftp_log_consumption_ipaddress contains duplicate entries."), debug_backtrace(), __FILE__, __LINE__);
        return false;
    }
    // MySQL > 4.1.0
    //	$sqlquery1 = "INSERT INTO net2ftp_log_consumption_ipaddress VALUES('$date', '$REMOTE_ADDR_safe', '" . $net2ftp_globals["consumption_ipaddress_datatransfer"] . "', '" . round($net2ftp_globals["consumption_ipaddress_executiontime"])  . "') ON DUPLICATE KEY UPDATE datatransfer = '" . $net2ftp_globals["consumption_ipaddress_datatransfer"] . "', executiontime = '" . round($net2ftp_globals["consumption_ipaddress_executiontime"]) . "';";
    // -------------------------------------------------------------------------
    // Put consumed data volume and execution time to the current FTP server
    // -------------------------------------------------------------------------
    $sqlquery4 = "SELECT * FROM net2ftp_log_consumption_ftpserver WHERE date = '{$date}' AND ftpserver = '{$net2ftp_ftpserver_safe}';";
    $result4 = mysql_query("{$sqlquery4}");
    $nrofrows4 = mysql_num_rows($result4);
    if ($nrofrows4 == 1) {
        $sqlquery5 = "UPDATE net2ftp_log_consumption_ftpserver SET datatransfer = '" . $net2ftp_globals["consumption_ftpserver_datatransfer"] . "', executiontime = '" . round($net2ftp_globals["consumption_ftpserver_executiontime"]) . "' WHERE date = '{$date}' AND ftpserver = '{$net2ftp_ftpserver_safe}';";
        $result5 = mysql_query("{$sqlquery5}");
        $nrofrows5 = mysql_affected_rows($mydb);
        // Don't check on the UPDATE nr of rows, because when the values in the variables and in the table are the same,
        // the $nrofrows2 is set to 0. (This happens on the Browse screen, when the loading is fast: the datatransfer is 0
        // and the executiontime is the same as in the table.)
        //		if ($nrofrows5 != 1) {
        //			setErrorVars(false, __("Table net2ftp_log_consumption_ftpserver could not be updated."), debug_backtrace(), __FILE__, __LINE__);
        //			return false;
        //		}
    } elseif ($nrofrows4 == 0) {
        $sqlquery6 = "INSERT INTO net2ftp_log_consumption_ftpserver VALUES('{$date}', '{$net2ftp_ftpserver_safe}', '" . $net2ftp_globals["consumption_ftpserver_datatransfer"] . "', '" . round($net2ftp_globals["consumption_ftpserver_executiontime"]) . "');";
        $result6 = mysql_query("{$sqlquery6}");
        $nrofrows6 = mysql_affected_rows($mydb);
        if ($nrofrows6 != 1) {
            setErrorVars(false, __("Table net2ftp_log_consumption_ftpserver could not be updated."), debug_backtrace(), __FILE__, __LINE__);
            return false;
        }
    } else {
        setErrorVars(false, __("Table net2ftp_log_consumption_ftpserver contains duplicate entries."), debug_backtrace(), __FILE__, __LINE__);
        return false;
    }
    // -------------------------------------------------------------------------
    // Update the net2ftp_log_access record with the consumed data volume and execution time
    // -------------------------------------------------------------------------
    $sqlquery7 = "SELECT * FROM net2ftp_log_access WHERE id = '" . $net2ftp_globals["log_access_id"] . "';";
    $result7 = mysql_query("{$sqlquery7}");
    $nrofrows7 = mysql_num_rows($result7);
    if ($nrofrows7 == 1) {
        $sqlquery8 = "UPDATE net2ftp_log_access SET datatransfer = '" . $net2ftp_globals["consumption_datatransfer"] . "', executiontime = '" . round($net2ftp_globals["consumption_executiontime"]) . "' WHERE id = '" . $net2ftp_globals["log_access_id"] . "'";
        $result8 = mysql_query("{$sqlquery8}");
        $nrofrows8 = mysql_affected_rows($mydb);
        // Don't check on the UPDATE nr of rows, because when the values in the variables and in the table are the same,
        // the $nrofrows2 is set to 0. (This happens on the Browse screen, when the loading is fast: the datatransfer is 0
        // and the executiontime is the same as in the table.)
        //		if ($nrofrows8 != 1) {
        //			setErrorVars(false, __("Table net2ftp_log_access could not be updated."), debug_backtrace(), __FILE__, __LINE__);
        //			return false;
        //		}
    } elseif ($nrofrows7 == 0) {
        $sqlquery9 = "INSERT INTO net2ftp_log_access VALUES('{$date}', '{$REMOTE_ADDR_safe}', '" . $net2ftp_globals["consumption_ipaddress_datatransfer"] . "', '" . round($net2ftp_globals["consumption_ipaddress_executiontime"]) . "');";
        $result9 = mysql_query("{$sqlquery9}");
        $nrofrows9 = mysql_affected_rows($mydb);
        if ($nrofrows9 != 1) {
            setErrorVars(false, __("Table net2ftp_log_access could not be updated."), debug_backtrace(), __FILE__, __LINE__);
            return false;
        }
    } else {
        setErrorVars(false, __("Table net2ftp_log_access contains duplicate entries."), debug_backtrace(), __FILE__, __LINE__);
        return false;
    }
    // -------------------------------------------------------------------------
    // If all 3 tables have been updated, set the flag to 1
    // -------------------------------------------------------------------------
    $net2ftp_globals["consumption_database_updated"] = 1;
    // Return true
    return true;
}
function getRootdirectory()
{
    // --------------
    // This function gets the user's root directory from the database and
    // stores it in $net2ftp_globals["homedirectory"].
    //
    // If $net2ftp_globals["homedirectory"] is already filled in (cache), no connection
    // is made to the DB and this value is returned.
    // --------------
    // -------------------------------------------------------------------------
    // Global variables
    // -------------------------------------------------------------------------
    global $net2ftp_globals, $net2ftp_settings, $net2ftp_result;
    // -------------------------------------------------------------------------
    // Initial checks
    // -------------------------------------------------------------------------
    if ($net2ftp_settings["use_database"] != "yes" || $net2ftp_settings["check_homedirectory"] != "yes") {
        $net2ftp_globals["homedirectory"] = "/";
    }
    // -------------------------------------------------------------------------
    // Get the homedirectory from the database, then store it in a global
    // variable, and from then on, don't access the database any more
    // -------------------------------------------------------------------------
    if (isset($net2ftp_globals["homedirectory"]) == false) {
        // -------------------------------------------------------------------------
        // Add slashes to variables which are used in a SQL query, and which are
        // potentially unsafe (supplied by the user)
        // -------------------------------------------------------------------------
        $net2ftp_ftpserver_safe = addslashes($net2ftp_globals["ftpserver"]);
        $net2ftp_username_safe = addslashes($net2ftp_globals["username"]);
        // -------------------------------------------------------------------------
        // Connect
        // -------------------------------------------------------------------------
        $mydb = connect2db();
        if ($net2ftp_result["success"] == false) {
            return false;
        }
        // -------------------------------------------------------------------------
        // Get user's home directory
        // -------------------------------------------------------------------------
        $sqlquery1 = "SELECT homedirectory FROM net2ftp_users WHERE ftpserver = '{$net2ftp_ftpserver_safe}' AND username = '******';";
        $result1 = mysql_query("{$sqlquery1}") or die("Unable to execute SQL SELECT query (isAuthorizedDirectory > sqlquery1) <br /> {$sqlquery1}");
        $nrofrows1 = mysql_num_rows($result1);
        if ($nrofrows1 == 0) {
            $net2ftp_globals["homedirectory"] = "/";
        } elseif ($nrofrows1 == 1) {
            $resultRow1 = mysql_fetch_row($result1);
            $net2ftp_globals["homedirectory"] = $resultRow1[0];
        } else {
            setErrorVars(false, __("Table net2ftp_users contains duplicate rows."), debug_backtrace(), __FILE__, __LINE__);
            return false;
        }
    }
    return $net2ftp_globals["homedirectory"];
}
Esempio n. 4
0
function rotateLogs()
{
    // --------------
    // Rotate the tables
    // net2ftp_log_access          = active table
    // net2ftp_log_access_YYYYMM   = archive table with information of month MM and year YYYY
    // net2ftp_log_access_template = template table (empty table)
    //
    // To avoid that the log rotation actions would be executed multiple times at
    // the end of the period, a "log rotation status" is used:
    // 0 = no rotation needed
    // 1 = step 1 not yet started (renaming active tables to archived tables)
    // 2 = step 1 in progress
    // 3 = step 2 not yet started (copying template tables to the active tables)
    // 4 = step 2 in progress
    // 5 = step 3 not yet started (dropping oldest archive tables)
    // 6 = step 3 in progress
    // --------------
    // -------------------------------------------------------------------------
    // Global variables
    // -------------------------------------------------------------------------
    global $net2ftp_globals, $net2ftp_settings, $net2ftp_result, $net2ftp_output;
    $toreturn = true;
    // -------------------------------------------------------------------------
    // Verify if a database is used. If not: don't continue.
    // -------------------------------------------------------------------------
    if ($net2ftp_settings["use_database"] != "yes") {
        return true;
    }
    // -------------------------------------------------------------------------
    // Check if the setting is within the allowed range; if not, set it to 12 months
    // -------------------------------------------------------------------------
    if (!($net2ftp_settings["log_length_months"] > 1 && $net2ftp_settings["log_length_months"] < 99)) {
        $net2ftp_settings["log_length_months"] = 12;
    }
    // -------------------------------------------------------------------------
    // Current month, next month, previous month
    // -------------------------------------------------------------------------
    $currentmonth = date("Ym");
    // e.g. 201207
    $lastmonth = date("Ym", mktime(0, 0, 0, date("m") - 1, date("d"), date("Y")));
    $nextmonth = date("Ym", mktime(0, 0, 0, date("m") + 1, date("d"), date("Y")));
    $dropmonth = date("Ym", mktime(0, 0, 0, date("m") - $net2ftp_settings["log_length_months"] - 1, date("d"), date("Y")));
    // -------------------------------------------------------------------------
    // Connect to the database
    // -------------------------------------------------------------------------
    $mydb = connect2db();
    if ($net2ftp_result["success"] == false) {
        return false;
    }
    // -------------------------------------------------------------------------
    // Get the log rotation status
    // -------------------------------------------------------------------------
    $logStatus = getLogStatus();
    if ($net2ftp_result["success"] == false) {
        return false;
    }
    // No log rotation needed
    if ($logStatus === 0) {
        return true;
    }
    // -------------------------------------------------------------------------
    // Table names and SQL queries to create the tables
    // -------------------------------------------------------------------------
    $tables[1]["name"] = "net2ftp_log_access";
    $tables[2]["name"] = "net2ftp_log_error";
    $tables[3]["name"] = "net2ftp_log_consumption_ftpserver";
    $tables[4]["name"] = "net2ftp_log_consumption_ipaddress";
    // -------------------------------------------------------------------------
    // step 1 of rotation: rename active tables to archived tables
    // -------------------------------------------------------------------------
    if ($logStatus == 1) {
        // Set the log status to indicate this step is in progress
        putLogStatus(2);
        if ($net2ftp_result["success"] == false) {
            return false;
        }
        // Execute the step
        for ($i = 1; $i <= sizeof($tables); $i++) {
            $table = $tables[$i]["name"];
            // Example: net2ftp_log_access
            $table_archive = $table . "_" . $lastmonth;
            // Example: net2ftp_log_access_201206
            $table_archive_drop = $table . "_" . $dropmonth;
            // Example: net2ftp_log_access_201106
            $sqlquery_rename = "RENAME TABLE {$table} TO {$table_archive}";
            $result_rename[$i] = mysql_query("{$sqlquery_rename}");
            if ($result_rename[$i] == true) {
                $net2ftp_output["rotateLogs"][] = __("The log tables were renamed successfully.");
            } else {
                $toreturn = false;
                $net2ftp_output["rotateLogs"][] = __("The log tables could not be renamed.");
            }
        }
        // end for
        // Set the log status to indicate this step is in done and the next can start
        putLogStatus(3);
        if ($net2ftp_result["success"] == false) {
            return false;
        }
    } elseif ($logStatus == 3) {
        // Set the log status to indicate this step is in progress
        putLogStatus(4);
        if ($net2ftp_result["success"] == false) {
            return false;
        }
        // Execute the step
        for ($i = 1; $i <= sizeof($tables); $i++) {
            $table = $tables[$i]["name"];
            // Example: net2ftp_log_access
            $table_archive = $table . "_" . $lastmonth;
            // Example: net2ftp_log_access_201206
            $table_archive_drop = $table . "_" . $dropmonth;
            // Example: net2ftp_log_access_201106
            $sqlquery_copy = "CREATE TABLE {$table} LIKE {$table_archive}";
            $result_copy[$i] = mysql_query("{$sqlquery_copy}");
            if ($result_copy[$i] == true) {
                $net2ftp_output["rotateLogs"][] = __("The log tables were copied successfully.");
            } else {
                $toreturn = false;
                $net2ftp_output["rotateLogs"][] = __("The log tables could not be copied.");
            }
        }
        // end for
        // Set the log status to indicate this step is in done and the next can start
        putLogStatus(5);
        if ($net2ftp_result["success"] == false) {
            return false;
        }
    } elseif ($logStatus == 5) {
        // Set the log status to indicate this step is in progress
        putLogStatus(6);
        if ($net2ftp_result["success"] == false) {
            return false;
        }
        // Execute the step
        for ($i = 1; $i <= sizeof($tables); $i++) {
            $table = $tables[$i]["name"];
            // Example: net2ftp_log_access
            $table_archive = $table . "_" . $lastmonth;
            // Example: net2ftp_log_access_201206
            $table_archive_drop = $table . "_" . $dropmonth;
            // Example: net2ftp_log_access_201106
            $sqlquery_drop = "DROP TABLE IF EXISTS {$table_archive_drop};";
            $result_drop[$i] = mysql_query("{$sqlquery_drop}");
            if ($result_drop[$i] == true) {
                $net2ftp_output["rotateLogs"][] = __("The oldest log table was dropped successfully.");
            } else {
                $toreturn = false;
                $net2ftp_output["rotateLogs"][] = __("The oldest log table could not be dropped.");
            }
        }
        // end for
        // Set the log status to indicate this step is in done and the rotation is over
        putLogStatus(0);
        if ($net2ftp_result["success"] == false) {
            return false;
        }
    }
    return $toreturn;
}
function net2ftp_module_printBody()
{
    // --------------
    // This function prints the login screen
    // --------------
    // -------------------------------------------------------------------------
    // Global variables
    // -------------------------------------------------------------------------
    global $net2ftp_settings, $net2ftp_globals, $net2ftp_messages, $net2ftp_result;
    if (isset($_POST["input_admin_username"]) == true) {
        $input_admin_username = htmlEncode2(validateGenericInput($_POST["input_admin_username"]));
    } else {
        $input_admin_username = "";
    }
    if (isset($_POST["input_admin_password"]) == true) {
        $input_admin_password = htmlEncode2(validateGenericInput($_POST["input_admin_password"]));
    } else {
        $input_admin_password = "";
    }
    if (isset($_POST["datefrom"]) == true) {
        $datefrom = addslashes(validateGenericInput($_POST["datefrom"]));
    } else {
        $datefrom = "";
    }
    if (isset($_POST["dateto"]) == true) {
        $dateto = addslashes(validateGenericInput($_POST["dateto"]));
    } else {
        $dateto = "";
    }
    // -------------------------------------------------------------------------
    // Variables for all screens
    // -------------------------------------------------------------------------
    // Output variable
    $net2ftp_output["admin_viewlogs"][] = "";
    // Title
    $title = __("Admin functions");
    // Form name, back and forward buttons
    $formname = "AdminForm";
    $back_onclick = "document.forms['" . $formname . "'].state.value='admin';document.forms['" . $formname . "'].submit();";
    $forward_onclick = "document.forms['" . $formname . "'].submit();";
    // -------------------------------------------------------------------------
    // Variables for screen 1
    // -------------------------------------------------------------------------
    // ------------------------------------
    // Connect to the database
    // ------------------------------------
    $mydb = connect2db();
    if ($net2ftp_result["success"] == false) {
        return false;
    }
    // ------------------------------------
    // Execute the SQL query and print the data
    // ------------------------------------
    // Query 1
    $sqlquery1 = "SELECT * FROM net2ftp_log_access WHERE date BETWEEN '{$datefrom}' AND '{$dateto}' ORDER BY date DESC, time DESC;";
    $table1 = printTable($sqlquery1);
    if ($net2ftp_result["success"] == false) {
        return false;
    }
    // Query 2
    $sqlquery2 = "SELECT * FROM net2ftp_log_error WHERE date BETWEEN '{$datefrom}' AND '{$dateto}' ORDER BY date DESC, time DESC;";
    $table2 = printTable($sqlquery2);
    if ($net2ftp_result["success"] == false) {
        return false;
    }
    // Query 3
    $sqlquery3 = "SELECT * FROM net2ftp_log_consumption_ftpserver WHERE date BETWEEN '{$datefrom}' AND '{$dateto}' ORDER BY datatransfer DESC, date DESC;";
    $table3 = printTable($sqlquery3);
    if ($net2ftp_result["success"] == false) {
        return false;
    }
    // Query 4
    $sqlquery4 = "SELECT * FROM net2ftp_log_consumption_ipaddress WHERE date BETWEEN '{$datefrom}' AND '{$dateto}' ORDER BY datatransfer DESC, date DESC;";
    $table4 = printTable($sqlquery4);
    if ($net2ftp_result["success"] == false) {
        return false;
    }
    // -------------------------------------------------------------------------
    // Print the output
    // -------------------------------------------------------------------------
    require_once $net2ftp_globals["application_skinsdir"] . "/" . $net2ftp_globals["skin"] . "/manage.template.php";
}
Esempio n. 6
0
<?php

require_once "include/gpsvars.php";
require_once "include/configure.php";
require_once "include/db_func.php";
date_default_timezone_set('Asia/Taipei');
session_start();
if (!isset($_SESSION['LoginID']) || empty($_SESSION['LoginID'])) {
    header("Location:{$WebHost}");
    exit;
}
$db_conn = connect2db($DBMS, $dbhost, $dbuser, $dbpwd, $dbname);
if (isset($trandel)) {
    $sqlcmd = "SELECT * FROM Transaction WHERE tno={$trandel}";
    $rs = querydb($sqlcmd, $db_conn);
    if (count($rs) > 0 && $rs[0]['state'] == 'G') {
        $sqlcmd = "UPDATE Transaction SET state='C' WHERE tno={$trandel}";
        $rs = updatedb($sqlcmd, $db_conn);
        $sqlcmd = "SELECT COUNT(*) AS C FROM Orders WHERE tno={$trandel}";
        $rs = querydb($sqlcmd, $db_conn);
        $RecoverCount = $rs[0]['c'];
        for ($i = 0; $i < $RecoverCount; $i++) {
            $sqlcmd = "SELECT * FROM Orders WHERE tno={$trandel}";
            $rs = querydb($sqlcmd, $db_conn);
            $RecoverPno = $rs[$i]['pno'];
            $RecoverNumber = $rs[$i]['amount'];
            $sqlcmd = "UPDATE Product SET stock=stock+{$RecoverNumber} WHERE pno={$RecoverPno}";
            $rs = updatedb($sqlcmd, $db_conn);
        }
    }
    header("Location:info.php");
Esempio n. 7
0
<?php

header("Content-type:text/html;charset=utf-8");
require "lib/MaterialDesign.Avatars.class.php";
require "lib/function.php";
$username = $_POST["id"];
$user_info_conn = connect2db($host, $op_username, $op_password, $op_dbname);
$user_info_query = "SELECT `name`, `portrait` FROM `user` WHERE `username` = '{$username}'";
$result = mysqli_query($user_info_conn, $user_info_query);
if (!$result) {
    echo "error";
} else {
    $return_info = mysqli_fetch_row($result);
    $name = $return_info[0];
    $portrait = $return_info[1];
    $Avatar = new MDAvtars($name, 128);
    $Avatar->Save('../img/avatar.png', 128);
    $Avatar->Free();
    echo '{"name":"' . $name . '","portrait":"' . $portrait . '"}';
}
function emptyLogs($datefrom, $dateto)
{
    // --------------
    // This function deletes the log records for the dates between $datefrom
    // and $dateto.
    // The global variable $net2ftp_output["emptyLogs"] is filled with result messages.
    // The function returns true on success, false on failure.
    // --------------
    // -------------------------------------------------------------------------
    // Global variables
    // -------------------------------------------------------------------------
    global $net2ftp_globals, $net2ftp_result, $net2ftp_output;
    $toreturn = true;
    // -------------------------------------------------------------------------
    // Connect to the DB
    // -------------------------------------------------------------------------
    $mydb = connect2db();
    if ($net2ftp_result["success"] == false) {
        return false;
    }
    $tables[1] = "net2ftp_log_access";
    $tables[2] = "net2ftp_log_error";
    $tables[3] = "net2ftp_log_consumption_ftpserver";
    $tables[4] = "net2ftp_log_consumption_ipaddress";
    // -------------------------------------------------------------------------
    // Execute the queries
    // -------------------------------------------------------------------------
    for ($i = 1; $i <= sizeof($tables); $i++) {
        $sqlquery_empty = "DELETE FROM {$tables[$i]} WHERE date BETWEEN '{$datefrom}' AND '{$dateto}';";
        $result_empty[$i] = mysql_query("{$sqlquery_empty}");
        $sqlquery_optimize = "OPTIMIZE TABLE `" . $tables[$i] . "`;";
        $result_optimize[$i] = mysql_query("{$sqlquery_optimize}");
        if ($result_empty[$i] == true) {
            $net2ftp_output["emptyLogs"][] = __("The table <b>%1\$s</b> was emptied successfully.", $tables[$i]);
        } else {
            $toreturn = false;
            $net2ftp_output["emptyLogs"][] = __("The table <b>%1\$s</b> could not be emptied.", $tables[$i]);
        }
        if ($result_optimize[$i] == true) {
            $net2ftp_output["emptyLogs"][] = __("The table <b>%1\$s</b> was optimized successfully.", $tables[$i]);
        } else {
            $toreturn = false;
            $net2ftp_output["emptyLogs"][] = __("The table <b>%1\$s</b> could not be optimized.", $tables[$i]);
        }
    }
    // end for
    return $toreturn;
}
Esempio n. 9
0
</HEAD>
<BODY bgcolor="#000000" text="#C5C0B7" link="#ADBCCD" vlink="#B39595">
<span class="iheader">
<?php 
// tm 000809
$vardas = stripslashes($vardas);
echo "{$vardas} PIEÐINIØ GALERIJA";
?>
</span><br>
<span class="ilink"><a href="http://art.scene.lt" class="ilink">art.scene</a> &gt;&gt; senoji pieðiniø galerija</span><br><br>

<?php 
// hirezpiesiniubuferio browsinimas su thumbnailais
include "include/config.inc";
include "include/code.inc";
connect2db();
if (!$vardas) {
    exit;
}
$result = mysql_query("select * from hirez where author='{$vardas}' order by id desc");
?>
<a href="/i_galerija.php">galerija</a> 
<br><br>


<?php 
//didelis foras kiekvienai lentelei
while ($row = mysql_fetch_array($result)) {
    ?>
<table cellspacing="0" cellpadding="0" width="100%" border="0"><tr><td bgcolor="#A6A090"><!--baltas krastas-->
<table width="100%" cellspacing="1" cellpadding="1" border="0">
Esempio n. 10
0
function checkLinks($links)
{
    //clean up links to remove duplicate
    $links = array_unique($links);
    $urls = array();
    list($db_connection, $table_name) = connect2db();
    foreach ($links as $link) {
        $stmt = $db_connection->prepare("SELECT url_source FROM {$table_name} WHERE url_source = :link ");
        $stmt->bindParam(":link", $link);
        $stmt->execute();
        $results = $stmt->fetch(PDO::FETCH_ASSOC);
        if (!$results) {
            $urls[] .= $link;
        }
    }
    return $urls;
}
Esempio n. 11
0
<?php

header("Content-type:text/html;charset=utf-8");
require "lib/function.php";
$uid = 0;
$main_conn = connect2db($host, $op_username, $op_password, $op_dbname);
$time = date('Y-m-d', time());
$work_info = json_decode($_POST["work_info"], true);
$type = $work_info[0]["type"];
$username = $work_info[1]["username"];
$task_query = "SELECT `user_key` FROM `user` WHERE `username` = '{$username}'";
$result = mysqli_query($main_conn, $task_query);
$uid = mysqli_fetch_row($result);
$uid = $uid[0];
switch ($type) {
    case 1:
        $task_name = $work_info[2]["name"];
        $start_date = $work_info[3]["start_time"];
        $end_date = $work_info[4]["end_time"];
        $content = $work_info[5]["content"];
        $task_query = "INSERT INTO `coop`.`task` (`task_client`,`task_startdate`,`task_enddate`,`task_title`,`task_content`)VALUES('{$uid}','{$start_date}','{$end_date}','{$task_name}','{$content}')";
        $result = mysqli_query($main_conn, $task_query);
        if (!$result) {
            echo "error";
        } else {
            echo "ok";
        }
        break;
    case 11:
        $task_id = $work_info[2]["task_id"];
        $delete_task = "UPDATE `task` SET `task_end?` = '1' WHERE `task`.`task_id` = {$task_id}";