Example #1
0
 /**
  * Set profile in smarty var
  * 
  * @param Smarty $smarty
  */
 public static function setProfile(Smarty $smarty)
 {
     $profileRequest = new Request(array("username" => array_key_exists("username", $_REQUEST) ? $_REQUEST["username"] : null, "auth_token" => $smarty->getTemplateVars('CURRENT_USER_AUTH_TOKEN')));
     $profileRequest->method = "UserController::apiProfile";
     $response = ApiCaller::call($profileRequest);
     if ($response["status"] === "ok") {
         $response["userinfo"]["graduation_date"] = is_null($response["userinfo"]["graduation_date"]) ? null : gmdate('d/m/Y', $response["userinfo"]["graduation_date"]);
         $response["userinfo"]["birth_date"] = is_null($response["userinfo"]["birth_date"]) ? null : gmdate('d/m/Y', $response["userinfo"]["birth_date"]);
         $smarty->assign('profile', $response);
     } else {
         $smarty->assign('STATUS_ERROR', $response["error"]);
     }
 }
Example #2
0
 /**
  * Set profile in smarty var
  *
  * @param Smarty $smarty
  */
 public static function setProfile(Smarty $smarty)
 {
     $profileRequest = new Request(array('username' => array_key_exists('username', $_REQUEST) ? $_REQUEST['username'] : null, 'auth_token' => $smarty->getTemplateVars('CURRENT_USER_AUTH_TOKEN')));
     $profileRequest->method = 'UserController::apiProfile';
     $response = ApiCaller::call($profileRequest);
     if ($response['status'] === 'ok') {
         $response['userinfo']['graduation_date'] = is_null($response['userinfo']['graduation_date']) ? null : gmdate('d/m/Y', $response['userinfo']['graduation_date']);
         $response['userinfo']['birth_date'] = is_null($response['userinfo']['birth_date']) ? null : gmdate('d/m/Y', $response['userinfo']['birth_date']);
         $smarty->assign('profile', $response);
     } else {
         $smarty->assign('STATUS_ERROR', $response['error']);
     }
 }
<?php

require_once 'ApiCaller.php';
ApiCaller::httpEntryPoint();
Example #4
0
                                <span class="input-group-btn">
                                <button class="btn btn-default" type="button">
                                    <i class="fa fa-search"></i>
                                </button>
                            </span>
                            </div>
                            <!-- /input-group -->
                        </li>
                        <li>
                            <a href="index.html"><i class="fa fa-dashboard fa-fw"></i> Dashboard</a>
                        </li>
                        <li>
								<?php 
include_once 'apicaller.php';
// $apicaller = new ApiCaller('APP001', '28e336ac6c9423d946ba02d19c6a2632','http://localhost:8000/api');
$apicaller = new ApiCaller('APP001', '28e336ac6c9423d946ba02d19c6a2632', 'http://localhost/gnt-aops/public/api');
$data = $apicaller->sendRequest(array('action' => 'login', 'apiname' => 'aops', 'apipass' => 'password', 'member_id' => 2, 'username' => 'natalius', 'name' => 'Natalius Sen', 'tgllahir' => '09101987', 'tglaplikasi' => '09101987', 'sponsor_id' => 0, 'introducer_id' => 0));
echo '<a href="http://localhost/gnt-aops/public/loginapi/' . $data . '"><i class="fa fa-edit fa-fw"></i>Prospecting System</a>';
// echo '<a href="http://localhost:8000/loginapi/'.$data.'"><i class="fa fa-edit fa-fw"></i>Prospecting System</a>';
?>

                        </li>
                    </ul>
                </div>
                <!-- /.sidebar-collapse -->
            </div>
            <!-- /.navbar-static-side -->
        </nav>

        <div id="page-wrapper">
            <div class="row">
Example #5
0
<?php

require_once "../server/bootstrap.php";
require_once "api/ApiCaller.php";
$r = new Request(array("contest_alias" => $_REQUEST["contest_alias"], "auth_token" => $smarty->getTemplateVars('CURRENT_USER_AUTH_TOKEN')));
$r->method = "ContestController::apiReport";
$fullResponse = ApiCaller::call($r);
if ($fullResponse["status"] == "ok") {
    $response = $fullResponse["ranking"];
    for ($i = 0; $i < count($response); $i++) {
        if (!isset($response[$i]['problems'])) {
            continue;
        }
        foreach ($response[$i]['problems'] as &$problem) {
            if (!isset($problem['run_details']) || !isset($problem['run_details']['groups'])) {
                continue;
            }
            foreach ($problem['run_details']['groups'] as &$group) {
                foreach ($group['cases'] as &$case) {
                    $case['meta']['time'] = (double) $case['meta']['time'];
                    $case['meta']['time-wall'] = (double) $case['meta']['time-wall'];
                    $case['meta']['mem'] = (double) $case['meta']['mem'] / 1024.0 / 1024.0;
                }
            }
        }
    }
    $smarty->assign('contestReport', $response);
    $smarty->display('../templates/contest.report.tpl');
}
Example #6
0
<?php

session_start();
include_once 'apicaller.php';
$apicaller = new ApiCaller('APP001', '28e336ac6c9423d946ba02d19c6a2632', 'http://localhost/aops-server/');
$todo_items = $apicaller->sendRequest(array('controller' => 'member', 'action' => 'getmemberchilds', 'username' => 'aops', 'userpass' => 'password', 'member_id' => 4));
echo var_dump($todo_items);
Example #7
0
<?php

include_once 'bootstrap.php';
switch ($_POST['productType']) {
    case 'resource':
        $_POST['productType'] = 1;
        break;
    case 'product':
        $_POST['productType'] = 2;
        break;
    default:
        die('wtf?');
        break;
}
$data = array('name' => $_POST['name'], 'product' => (int) $_POST['resource'], 'productType' => (int) $_POST['productType']);
if (empty($data['name']) || empty($data['product']) || empty($data['productType'])) {
    header('Location: http://' . Config::get('domain'));
}
$response = ApiCaller::get('company/create', $data, true);
if ($response->status) {
    $_SESSION['user']->gold -= Company::CREATION_COST;
}
header('Location: http://' . Config::get('domain') . '/companies.htm');
<?php

session_start();
var_dump($_POST['markasdone_button']);
?>

<?php 
session_start();
include_once 'apicaller.php';
$apicaller = new ApiCaller('APP001', '28e336ac6c9423d946ba02d19c6a2632', 'http://localhost/simpletodo_api/');
$mark_as_done = isset($_POST['markasdone_button']) ? 'true' : $_POST['is_done'];
$new_item = $apicaller->sendRequest(array('controller' => 'todo', 'action' => 'update', 'todo_id' => $_POST['todo_id'], 'title' => $_POST['title'], 'due_date' => $_POST['due_date'], 'description' => $_POST['description'], 'is_done' => $mark_as_done, 'username' => $_SESSION['username'], 'userpass' => $_SESSION['userpass']));
header('Location: todo.php');
exit;
Example #9
0
<?php

header('Content-type: application/json');
// its json
include_once 'apicaller.php';
session_start();
$apicaller = new ApiCaller('APP001', '28e336ac6c9423d946ba02d19c6a2632', 'http://radmation.com/budget/');
$bill_items = $apicaller->sendRequest(array('controller' => 'bill', 'action' => 'read', 'username' => $_SESSION['username'], 'userpass' => $_SESSION['userpass']));
//echo '';
echo $bill_items;
Example #10
0
<?php 
include_once 'apicaller.php';
session_start();
$apicaller = new ApiCaller('APP001', '28e336ac6c9423d946ba02d19c6a2632', 'http://radmation.com/budget/');
//$bill->is_gain = $this->_params['is_gain']; // bill name/type todo add me
//$bill->bill_name = $this->_params['bill_name']; // bill name/type todo change me from bill type
//$bill->frequency = $this->_params['frequency']; // how often todo SINGLE WEEKLY BI-WEEKLY MONTHLY
//$bill->due_period = $this->_params['due_period']; // how often todo enum('eom','bom')
//$bill->every_x_days = $this->_params['every_x_days']; // how often todo int add me
//$bill->on_the_x = $this->_params['on_the_x']; // how often todo int add me
//$bill->amount = $this->_params['amount']; // dollar amount
$updated_bill = $apicaller->sendRequest(array('controller' => 'bill', 'action' => 'update', 'username' => $_SESSION['username'], 'userpass' => $_SESSION['userpass'], 'bill_id' => '112', 'is_gain' => '0', 'bill_name' => 'Radleys Bill', 'frequency' => 'weekly', 'every_x_days' => '15', 'amount' => '1000.50'));
//echo '';
echo $updated_bill;
Example #11
0
<?php

include_once 'bootstrap.php';
$post = array('email' => $_POST['login'], 'password' => $_POST['password']);
if (empty($post['email']) || empty($post['password'])) {
    header('Location: http://' . Config::get('domain'));
}
$userToken = ApiCaller::get('usertoken/create', $post);
if ($userToken->status == 1) {
    $_SESSION['app']->userToken = $userToken->data;
    $userData = ApiCaller::get('user/get', array(), true);
    if ($userData->status == 1) {
        $_SESSION['user'] = $userData->data;
        setcookie('uid', $_SESSION['user']->id, time() + 60 * 60 * 24 * 7, '/');
        // 1 week
        setcookie('__utmf', md5($_SESSION['user']->id), time() + 60 * 60 * 24 * 7, '/');
        // 1 week
    }
}
header('Location: http://' . Config::get('domain'));
Example #12
0
<?php

/**
 * Created by PhpStorm.
 * User: Radley
 * Date: 12/13/2015
 * Time: 3:45 PM
 */
header('Content-type: application/json');
// its json
include_once 'apicaller.php';
session_start();
$apicaller = new ApiCaller('APP001', '28e336ac6c9423d946ba02d19c6a2632', 'http://radmation.com/budget/');
$bill_items = $apicaller->sendRequest(array('controller' => 'bill', 'action' => 'delete', 'username' => $_SESSION['username'], 'userpass' => $_SESSION['userpass'], 'bill_id' => '111'));
//echo '';
echo $bill_items;
Example #13
0
 public static function getmemberchilds($member_id)
 {
     try {
         $apicaller = new ApiCaller(MemberAPI::API_KEY, MemberAPI::API_SECRET, MemberAPI::API_TARGET);
         $todo_items = $apicaller->sendRequest(array('controller' => 'member', 'action' => 'getmemberchilds', 'username' => MemberAPI::API_USERNAME, 'userpass' => MemberAPI::API_PASSWORD, 'member_id' => $member_id));
         return $todo_items;
     } catch (Exception $e) {
         return 'Trouble Connection';
     }
 }
Example #14
0
<?php 
include_once 'apicaller.php';
session_start();
$apicaller = new ApiCaller('APP001', '28e336ac6c9423d946ba02d19c6a2632', 'http://radmation.com/budget/');
//$bill->is_gain = $this->_params['is_gain']; // bill name/type todo add me
//$bill->bill_name = $this->_params['bill_name']; // bill name/type todo change me from bill type
//$bill->frequency = $this->_params['frequency']; // how often todo SINGLE WEEKLY BI-WEEKLY MONTHLY
//$bill->due_period = $this->_params['due_period']; // how often todo enum('eom','bom')
//$bill->every_x_days = $this->_params['every_x_days']; // how often todo int add me
//$bill->on_the_x = $this->_params['on_the_x']; // how often todo int add me
//$bill->amount = $this->_params['amount']; // dollar amount
$added_bill = $apicaller->sendRequest(array('controller' => 'bill', 'action' => 'create', 'username' => $_SESSION['username'], 'userpass' => $_SESSION['userpass'], 'is_gain' => '1', 'bill_name' => 'Amandas Bill', 'frequency' => 'weekly', 'due_period' => '', 'every_x_days' => '10', 'amount' => '500.50'));
//echo '';
$added_bill;
//echo  $enc_request = base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, '28e336ac6c9423d946ba02d19c6a2632', json_encode($added_bill), MCRYPT_MODE_ECB));
Example #15
0
            $request["auth_token"] = $cs["auth_token"];
        }
        for ($i = 4; $i + 1 < sizeof($args); $i += 2) {
            $request[$args[$i]] = urldecode($args[$i + 1]);
        }
        $request->method = $controllerName . "::" . $methodName;
        return $request;
    }
    /**
     * Sets all required headers for the API called via HTTP
     * 
     * @param array $response
     */
    private static function setHttpHeaders(array $response)
    {
        // Scumbag IE y su cache agresivo.
        header("Expires: Tue, 03 Jul 2001 06:00:00 GMT");
        header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
        header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
        header("Cache-Control: post-check=0, pre-check=0", false);
        header("Pragma: no-cache");
        // Set header accordingly
        if (isset($response["header"])) {
            header($response["header"]);
        } else {
            header("Content-Type: application/json");
        }
    }
}
ApiCaller::$log = Logger::getLogger("ApiCaller");
Example #16
0
            $request[$args[$i]] = urldecode($args[$i + 1]);
        }
        $request->method = $controllerName . '::' . $methodName;
        return $request;
    }
    /**
     * Sets all required headers for the API called via HTTP
     *
     * @param array $response
     */
    private static function setHttpHeaders(array $response)
    {
        // Scumbag IE y su cache agresivo.
        header('Expires: Tue, 03 Jul 2001 06:00:00 GMT');
        header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
        header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0');
        header('Cache-Control: post-check=0, pre-check=0', false);
        header('Pragma: no-cache');
        // Set header accordingly
        if (isset($response['header'])) {
            header($response['header']);
            if ($response['header'] == 'HTTP/1.1 401 UNAUTHORIZED') {
                header('WWW-Authenticate: omegaUp location="/login"');
            }
        } else {
            header('Content-Type: application/json');
        }
    }
}
ApiCaller::$log = Logger::getLogger('ApiCaller');
<?php

session_start();
include_once 'apicaller.php';
$apicaller = new ApiCaller('APP001', '28e336ac6c9423d946ba02d19c6a2632', 'http://localhost/simpletodo_api/');
$new_item = $apicaller->sendRequest(array('controller' => 'todo', 'action' => 'delete', 'todo_id' => $_GET['todo_id'], 'username' => $_SESSION['username'], 'userpass' => $_SESSION['userpass']));
header('Location: todo.php');
exit;
Example #18
0
<?php

require_once "../server/bootstrap.php";
require_once "api/ApiCaller.php";
$triedToLogin = false;
$emailVerified = true;
$c_Session = new SessionController();
if (isset($_POST["request"]) && $_POST["request"] == "login") {
    // user wants to login natively
    $r = new Request();
    $r["usernameOrEmail"] = $_POST["user"];
    $r["password"] = $_POST["pass"];
    $r->method = "UserController::apiLogin";
    $response = ApiCaller::call($r);
    if ($response["status"] === "error") {
        if ($response["errorcode"] === 600 || $response["errorcode"] === 601) {
            $emailVerified = false;
        }
    }
    $triedToLogin = true;
}
if (isset($_GET["state"])) {
    $c_Session->LoginViaFacebook();
    $triedToLogin = true;
}
if (isset($_GET["shva"])) {
    $triedToLogin = true;
}
if ($c_Session->CurrentSessionAvailable()) {
    if (isset($_GET['redirect'])) {
        die(header('Location: ' . $_GET['redirect']));
Example #19
0
<?php

session_start();
include_once 'apicaller.php';
/*ApiCaller(<API NAME>,<API KEY>,<URL SERVER>)*/
$apicaller = new ApiCaller('APP001', '28e336ac6c9423d946ba02d19c6a2632', 'http://localhost/gnt-aops/public/api');
$data = $apicaller->sendRequest(array('action' => 'logout', 'apiname' => 'aops', 'apipass' => 'password', 'member_id' => 3));
Example #20
0
<?php

/**
 * Sample API php client application
 *
 * In this example we will fetch ip by its id
 *
 *	http://phpipam/api/client/getSubnetById.php?id=3
 */
# config
include_once '../apiConfig.php';
# API caller class
include_once '../apiClient.php';
# commands
$req['controller'] = "addresses";
$req['action'] = "read";
$req['format'] = "decimal";
$req['id'] = 1;
# wrap in try to catch exceptions
try {
    # initialize API caller
    $apicaller = new ApiCaller($app['id'], $app['enc'], $url, $format);
    # send request
    $response = $apicaller->sendRequest($req);
    print "<pre>";
    print_r($response);
} catch (Exception $e) {
    //catch any exceptions and report the problem
    print "Error: " . $e->getMessage();
}
Example #21
0
<?php

$products = ApiCaller::get('product/list');
$products = $products->data;
$resources = ApiCaller::get('resource/list');
$resources = $resources->data;
?>

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
  xmlns:og="http://ogp.me/ns#"
  xmlns:fb="http://www.facebook.com/2008/fbml">
<head>

    <meta property="fb:admins" content="100001950649351" />
    <meta property="fb:app_id" content="202930519772507" />     
    <META http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <meta name="keywords" content="e-sim, mmog, browser game, free game, multiplayer game, social game"/>
    <meta name="description" content="Free strategic browser game. Fight, earn money, manage businesses"/>
    <meta property="og:site_name" content="e-Sim"/>
    <base href="http://<?php 
echo Config::get('domain');
?>
/">
    
    
    <meta http-equiv="Last-Modified" content="2013-12-08 12:58:57" />
    <meta property="og:image" content="images/PrimeraLogo.png"/>
    <meta property="og:description" content="Free strategic browser game. Fight, earn money, manage businesses. Join us, let's have some fun together, help your ecountry to grow."/>