<?php session_start(); $user = $_SESSION['username']; include "MyLogPHP.class.php"; $log = new MyLogPHP('log.csv'); if (session_destroy()) { $log->info("{$user} has successfully logged out"); header("Location: index.php"); // Redirecting To Home Page }
function runMyFunction() { //include 'global_variables.php'; $flask_server = 'localhost:9999/'; $mysqlServerName = "localhost"; $username = "******"; $password = "******"; $dbname = "mysql"; $user = $_SESSION['username']; $log = new MyLogPHP('log.csv'); $long_host_name = $_GET['serverName']; $instance_type = $_GET['type']; //echo 'I just ran a php function'.$long_host_name; // Create connection $conn = new mysqli($mysqlServerName, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $epoch = time(); $dt = new DateTime("@{$epoch}"); // convert UNIX timestamp to PHP DateTime $current_GMT_time = $dt->format('Y-m-d H:i:s') . " GMT"; //echo $current_GMT_time; //echo "<br><br><br>"; $sql = "UPDATE server_upgrade SET Last_Upgrade_Time='" . $current_GMT_time . "' WHERE Longname='" . $long_host_name . "';"; $conn->query($sql); $url = $flask_server . "upgrade_server/" . $long_host_name; $log->info("{$long_host_name} of type {$instance_type} is set to upgrade by {$user}"); $log->info("{$long_host_name} upgrade started at {$current_GMT_time}"); $server_query = "UPDATE server_upgrade SET upgrade_status='1' WHERE Longname='" . $long_host_name . "';"; $server_list_query = "UPDATE server_upgrade SET Installed_SW_Version='setforupgrade' WHERE Longname='" . $long_host_name . "' and Instance_Type='" . $instance_type . "';"; $conn->query($server_list_query); $conn->query($server_query); try { $curl = curl_init($url); curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($curl, CURLOPT_TIMEOUT, 60); //timeout in seconds $output = curl_exec($curl); } catch (Exception $e) { echo 'Caught exception: ', $e->getMessage(), "\n"; } $conn->close(); }
<?php //session_start session_start(); //inicia o autoload do composer require 'vendor/autoload.php'; //log init $log = new MyLogPHP('./log/debug.log.csv'); //log info $log->info('The log starts here.'); // Timezone date_default_timezone_set('America/Sao_paulo'); //db congig // require 'db/DB.php'; // require 'db/config.php'; require 'config/configActiveRecord.php'; require 'config/authenticate.php'; //app start $app = new \Slim\Slim(array('debug' => false)); // header $app->contentType("application/json"); //Tratamento de erros $app->error(function (Exception $e = null) use($app) { $response["success"] = "false"; $response["code"] = "0"; $response["message"] = $e->getMessage(); echo json_encode($response); ##echo '{"error":[{"text":"'. $e->getMessage() . '"}]}'; }); $app->notFound(function () use($app) { $response["success"] = "false";
<?php session_start(); include "global_variables.php"; include "MyLogPHP.class.php"; $log = new MyLogPHP('log.csv'); $user = $_SESSION['username']; $conn = new mysqli($mysqlServerName, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $tag = $_GET['q']; $server = $_GET['r']; $type = $_GET['s']; //echo $tag; //echo $server; //echo $type; $log->info("{$user} has selected tag version of {$tag} for {$server} of Type {$type} for upgrade"); $sql = "UPDATE server_upgrade set Scheduled_Upgrade_Tag='" . $tag . "'where Longname='" . $server . "' and Instance_Type='" . $type . "'"; //$sql = "UPDATE server_upgrade set Scheduled_Upgrade_Tag='" . $tag . "'where Host_Id='".$index."'"; $result = $conn->query($sql);
<?php session_start(); include 'MyLogPHP.class.php'; $log = new MyLogPHP('log.csv'); if (isset($_POST['username']) && isset($_POST['password'])) { if (empty($_POST['username']) || empty($_POST['password'])) { echo "invalid username and password"; $log->error("Login for {$username} failed"); exit; } $adServer = "ldap://svl-ldap.arubanetworks.com"; $ldapport = 389; $ldap = ldap_connect($adServer, $ldapport); $username = $_POST['username']; $password = $_POST['password']; $ldaprdn = 'arubanetworks' . "\\" . $username; ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 3); ldap_set_option($ldap, LDAP_OPT_REFERRALS, 0); $bind = @ldap_bind($ldap, $ldaprdn, $password); if ($bind) { $filter = "(sAMAccountName={$username})"; $result = ldap_search($ldap, "dc=arubanetworks,dc=com", $filter); ldap_sort($ldap, $result, "sn"); $info = ldap_get_entries($ldap, $result); $log->info("{$username} has successfully logged in"); //echo "Hi"; //print_r($info); //echo "bye"; for ($i = 0; $i < $info["count"]; $i++) { if ($info['count'] > 1) {