Example #1
0
function json_encode($value)
{
    function _is_array($array)
    {
        $keys = array_keys($array);
        for ($i = 0; $i < count($array); $i++) {
            if ($i !== $keys[$i]) {
                return false;
            }
        }
        return true;
    }
    $is_array = _is_array($value);
    $res = $is_array ? '[' : '{';
    foreach ($value as $key => $val) {
        if (!$is_array) {
            if (is_numeric($key)) {
                $res .= $key . ":";
            } else {
                if (is_string($key)) {
                    $res .= string_escape($key) . ":";
                }
            }
        }
        if (is_numeric($val)) {
            $res .= $val . ",";
        } else {
            if (is_string($val)) {
                $res .= string_escape($val) . ",";
            } else {
                if ($val === NULL) {
                    $res .= 'null,';
                } else {
                    if ($val === TRUE) {
                        $res .= 'true,';
                    } else {
                        if ($val === FALSE) {
                            $res .= 'false,';
                        } else {
                            if (is_array($val)) {
                                $res .= json_encode($val) . ',';
                            } else {
                                $res .= 'undefined,';
                            }
                        }
                    }
                }
            }
        }
    }
    return substr($res, 0, -1) . ($is_array ? ']' : '}');
}
Example #2
0
$json = json_decode($services, TRUE);
$hostname = $json['p-rabbitmq'][0]['credentials']['protocols']['amqp']['host'];
$user = $json['p-rabbitmq'][0]['credentials']['protocols']['amqp']['username'];
$password = $json['p-rabbitmq'][0]['credentials']['protocols']['amqp']['password'];
$port = $json['p-rabbitmq'][0]['credentials']['protocols']['amqp']['port'];
$vhost = $json['p-rabbitmq'][0]['credentials']['protocols']['amqp']['vhost'];
$db = new DB_Connect();
$db->connect();
$system_id = string_escape(util_aiod($_POST, 'ID', ""));
$name = string_escape(util_aiod($_POST, 'name', ""));
$type = 'Thin';
$capacity = string_escape(util_aiod($_POST, 'capacity', ""));
$offset = 0;
$sq = 'gb';
$pool_id = '0';
$sp = string_escape(util_aiod($_POST, 'sp', ""));
$auto_assignment = '1';
$tiering_policy = 'autoTier';
$initial_tier = 'highestAvailable';
$cmd = "naviseccli lun -create -type  " . $type . " -capacity " . $capacity . " -sq " . $sq . " -poolId " . $pool_id . " -sp " . $sp . "  -aa " . $auto_assignment . " -name " . $name . " -offset " . $offset . " -tieringPolicy " . $tiering_policy . " -initialTier " . $initial_tier;
$result = mysql_query("INSERT INTO `requests` (system_id, cmd, type, status) values ('{$system_id}', '{$cmd}', 'create_lun', 'N');");
$tuple_id = mysql_insert_id();
$connection = new AMQPConnection($hostname, $port, $user, $password, $vhost);
$channel = $connection->channel();
$channel->exchange_declare('direct_logs', 'direct', false, false, false);
$data = "(capacity=" . $capacity . ",name=\"" . $name . "\",update_id=" . $tuple_id . ")";
$msg = new AMQPMessage($data);
$channel->basic_publish($msg, 'direct_logs', "create_lun");
$channel->close();
$connection->close();
$db->close();
Example #3
0
<?php

/*##############################################
# Hawkeye POC Portal                          #
# Author: Ankita Pawar (ankita.pawar@emc.com) #
###############################################*/
require_once __DIR__ . '/include/util.inc';
require_once __DIR__ . '/include/db_connect.php';
//header('Content-type: text/html');
header('Access-Control-Allow-Origin: *');
//print_r($_POST);
$db = new DB_Connect();
$db->connect();
// Define $username and $password
$username = string_escape(util_aiod($_POST, 'username', ""));
$password = string_escape(util_aiod($_POST, 'password', ""));
$query = mysql_query("select * from user where password='******' AND name='{$username}'");
$rows = mysql_num_rows($query);
echo $rows;
$db->close();
?>

Example #4
0
<?php

/*##############################################
# Hawkeye POC Portal                          #
# Author: Ankita Pawar (ankita.pawar@emc.com) #
###############################################*/
require_once __DIR__ . '/include/util.inc';
require_once __DIR__ . '/include/db_connect.php';
//header('Content-type: text/html');
header('Access-Control-Allow-Origin: *');
//print_r($_POST);
$db = new DB_Connect();
$db->connect();
// Define $username and $password
$username = string_escape(util_aiod($_POST, 'username', ""));
$password = string_escape(util_aiod($_POST, 'password', ""));
$email = string_escape(util_aiod($_POST, 'email', ""));
$query = mysql_query("INSERT INTO `user` (name, email, password) values ('{$username}', '{$email}', '{$password}');");
echo $query;
$db->close();
?>

Example #5
0
<?php

require_once __DIR__ . '/include/util.inc';
require_once __DIR__ . '/include/db_connect.php';
//header('Content-type: text/html');
header('Access-Control-Allow-Origin: *');
$db = new DB_Connect();
$db->connect();
$update_id = string_escape(util_aiod($_POST, "update_id", ""));
$status = string_escape(util_aiod($_POST, "status", ""));
$cmd = "UPDATE `requests` SET status='{$status}' WHERE ID ={$update_id};";
echo "{$update_id}:{$status}";
echo $cmd;
$result = mysql_query($cmd);
$db->close();