Beispiel #1
0
function parseText($message_body)
{
    $message_body = strtolower($message_body);
    $action = 0;
    // if $action is unchanged, it's not one of the commands
    if (strpos($message_body, 'send') !== false) {
        $action = 1;
    }
    if (strpos($message_body, 'request') !== false) {
        $action = 2;
    }
    if (strpos($message_body, 'balance') !== false) {
        $action = 3;
    }
    if (strpos($message_body, 'reset') !== false) {
        send_text(0, resetDemo());
        $action = 999;
    }
    logToFile("parseText", "action = {$action}");
    return $action;
}
Beispiel #2
0
/**
*
*/
function saveConfig($config)
{
    if ($config == null || empty($config)) {
        return array("error" => "no configuration to save");
    }
    global $mysql_link;
    $token = $config->token;
    $tokenValid = false;
    // true when token is valid
    $copyConfig = false;
    // true when config is marked as readOnly
    $userEmail = $config->general->userEmail;
    $configName = $config->general->demoName;
    $configDesc = $config->general->demoDescription;
    $userIP = gethostbyaddr($_SERVER['REMOTE_ADDR']);
    $config->message = "";
    if (!empty($token)) {
        // check if token is valid.
        $configFromDB = getConfigFromDatabase($token);
        if ($configFromDB != null) {
            $tokenValid = true;
        }
        $copyConfig = @$configFromDB->readOnly != null;
        if ($tokenValid && !$copyConfig) {
            // update existing configuration
            $configString = $mysql_link->real_escape_string(json_encode($config));
            $updateConfigSql = "UPDATE `omnichanneldemo`.`demo_config` SET  `config_name` = '" . $configName . "',  `config_desc` = '" . $configDesc . "', `config_json` = '" . $configString . "', `email_to` = '" . $userEmail . "', `modify_by` = '" . $userIP . "', `modify_dttm` = CURRENT_TIMESTAMP WHERE `demo_config`.`token` = '" . $token . "' ;";
            $mysql_link->query($updateConfigSql);
            $config->message = "Configuration saved successfully.";
        }
    }
    if (empty($token) || !$tokenValid || $copyConfig) {
        // save new configuration
        $oldToken = $token;
        $token = generateRandomToken();
        $config->token = $token;
        $configString = $mysql_link->real_escape_string(json_encode($config));
        $createConfigSql = "INSERT INTO `omnichanneldemo`.`demo_config` (`id`, `token`, `config_name`, `config_desc`, `config_json`, `create_dttm`, `modify_dttm`, `modify_by`, `email_to`) VALUES (NULL, '" . $token . "', '" . $configName . "', '" . $configDesc . "', '" . $configString . "', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, '" . $userIP . "', '" . $userEmail . "');";
        $createConfigResult = $mysql_link->query($createConfigSql);
        $config->message = "Configuration saved successfully - with new Token: " . $token;
        if ($copyConfig) {
            $copyWebsiteSql = "INSERT INTO demo_website SELECT '" . $token . "', site, content, NOW(), NOW(), '" . $userIP . "' FROM demo_website WHERE token = '" . $oldToken . "';";
            $mysql_link->query($copyWebsiteSql);
            $config->message = $config->message . " & migrating website.";
        }
    }
    resetDemo($token);
    return $config;
}
Beispiel #3
0
    $returnVal = $result->num_rows == 0 ? false : true;
    logToFile($sql, $returnVal);
    return $returnVal;
}
function getBalance($user_phone_num)
{
    checkConn();
    if (!doesUserExist($user_phone_num)) {
        return -1;
    }
    $sql = "SELECT balance from `akshhhlt_blupay`.`users` where user_phone_num={$user_phone_num}";
    $result = mysqli_query($GLOBALS['sqli_conn'], $sql);
    $row = mysqli_fetch_assoc($result);
    logToFile("getBalance for {$user_phone_num}", "balance = {$balance}");
    return $row['balance'];
}
/*** unsets session vars, empties user information from db ***/
function resetDemo()
{
    checkConn();
    unset($_SESSION['lastTextTime']);
    unset($_SESSION['lastAction']);
    $sql = "TRUNCATE TABLE `akshhhlt_blupay`.`users`";
    $result = mysqli_query($GLOBALS['sqli_conn'], $sql);
    logToFile($sql, $result);
    echo "reset successful";
    return "reset successful";
}
if (strtolower($_GET['action']) == 'reset') {
    resetDemo();
}