/**
  * @covers ::__construct
  * @covers ::username
  * @covers ::password
  * @covers ::url
  * @covers ::useContext
  */
 public function testConstructorSetsAllTheFieldsAccessibleBySetters()
 {
     $instance = new Instance('http://confluence.com:8090', 'admin', 'admin', false);
     $this->assertSame('http://confluence.com:8090', $instance->url());
     $this->assertSame('admin', $instance->username());
     $this->assertSame('admin', $instance->password());
     $this->assertSame(false, $instance->useContext());
 }
 public function __construct($row = false)
 {
     parent::__construct($row);
     if ($row) {
         $this->id = $row['id'];
         $this->profile_updated = $row['profile_updated'];
     }
 }
 public function __construct($row = false)
 {
     parent::__construct($row);
     if ($row) {
         $this->id = $row['id'];
         $this->last_favorite_id = $row['last_favorite_id'];
         $this->last_reply_id = $row['last_reply_id'];
     }
 }
Exemple #4
0
 public static function instance($db = null)
 {
     $key = sha1('Cron' . date('dmY'));
     $has = Instance::has('Cron', $key);
     if (true === $has) {
         return Instance::get('Cron', $key);
     } else {
         return Instance::make('Cron', $key, with(new self($db)));
     }
 }
Exemple #5
0
 public static function instance($tpl)
 {
     $key = sha1($tpl);
     $has = Instance::has('libView', $key);
     if (true === $has) {
         return Instance::get('libView', $key);
     } else {
         return Instance::make('libView', $key, new self($tpl));
     }
 }
Exemple #6
0
 public static function instance($route)
 {
     $key = sha1($route->controller . $route->action);
     $has = Instance::has('libMVC', $key);
     if (true === $has) {
         return Instance::get('libMVC', $key);
     } else {
         return Instance::make('libMVC', $key, new self($route));
     }
 }
Exemple #7
0
 public static function instance(Eventable $container = null)
 {
     $key = sha1('Dispatcher');
     $has = Instance::has('Dispatcher', $key);
     if (true === $has) {
         return Instance::get('Dispatcher', $key);
     } else {
         return Instance::make('Dispatcher', $key, with(new self($container)));
     }
 }
Exemple #8
0
 public static function instance($model)
 {
     $key = sha1($model->collection);
     $has = Instance::has('BoxObserver', $key);
     if (true === $has) {
         return Instance::get('BoxObserver', $key);
     } else {
         return Instance::make('BoxObserver', $key, new self($model));
     }
 }
Exemple #9
0
 public static function instance($entity, $ns = 'core')
 {
     $key = sha1(serialize(func_get_args()));
     $has = Instance::has('Fastdata', $key);
     if (true === $has) {
         return Instance::get('Fastdata', $key);
     } else {
         return Instance::make('Fastdata', $key, with(new self($entity, $ns)));
     }
 }
Exemple #10
0
 public function motor()
 {
     $has = Instance::has('fastDbMotor', sha1($this->collection));
     if (true === $has) {
         return Instance::get('fastDbMotor', sha1($this->collection));
     } else {
         $instance = new Client(['host' => 'localhost', 'port' => 6379, 'database' => 2]);
         return Instance::make('fastDbMotor', sha1($this->collection), $instance);
     }
 }
 public function __construct($row = false)
 {
     parent::__construct($row);
     if ($row) {
         $this->id = $row['id'];
         $this->last_page_fetched_replies = $row['last_page_fetched_replies'];
         $this->last_page_fetched_tweets = $row['last_page_fetched_tweets'];
         $this->last_favorite_id = $row['last_favorite_id'];
     }
 }
Exemple #12
0
 public static function instance($resource)
 {
     $key = sha1(serialize(func_get_args()));
     $has = Instance::has('Api', $key);
     if (true === $has) {
         return Instance::get('Api', $key);
     } else {
         return Instance::make('Api', $key, with(new self($resource)));
     }
 }
Exemple #13
0
 public static function instance($locale = 'fr')
 {
     $key = sha1(serialize(func_get_args()));
     $has = Instance::has('Lang', $key);
     if (true === $has) {
         return Instance::get('Lang', $key);
     } else {
         return Instance::make('Lang', $key, with(new self($app)));
     }
 }
Exemple #14
0
 public static function instance($tolerance = 0.2, $sort = true)
 {
     $key = sha1(serialize(func_get_args()));
     $has = Instance::has('Phonetic', $key);
     if (true === $has) {
         return Instance::get('Phonetic', $key);
     } else {
         return Instance::make('Phonetic', $key, new self($tolerance, $sort));
     }
 }
 public function __construct($row = false)
 {
     parent::__construct($row);
     if ($row) {
         $this->id = $row['id'];
         $this->followed_by_next_cursor = $row['followed_by_next_cursor'];
         $this->follows_next_cursor = $row['follows_next_cursor'];
         $this->next_max_like_id = $row['next_max_like_id'];
     }
 }
Exemple #16
0
 public static function instance($name, $duration = 3600)
 {
     $args = func_get_args();
     $key = sha1(serialize($args));
     $has = Instance::has('Session', $key);
     if (true === $has) {
         return Instance::get('Session', $key);
     } else {
         return Instance::make('Session', $key, new self($name, $duration));
     }
 }
Exemple #17
0
 public static function instance($db, $table)
 {
     $args = func_get_args();
     $key = sha1(serialize($args));
     $has = Instance::has('ArDb', $key);
     if (true === $has) {
         return Instance::get('ArDb', $key);
     } else {
         return Instance::make('ArDb', $key, new self($db, $table));
     }
 }
Exemple #18
0
 public static function instance($context = null)
 {
     $context = is_null($context) ? 'core' : $context;
     $has = Instance::has('ioc', $context);
     if (true === $has) {
         return Instance::get('ioc', $context);
     } else {
         $instance = lib('container');
         return Instance::make('ioc', $context, $instance);
     }
 }
Exemple #19
0
 public function init()
 {
     parent::init();
     $host = '127.0.0.1';
     $dbname = 'tmc_test';
     $connection = new Connection(['dsn' => 'mysql:host=' . $host . ';dbname=' . $dbname, 'username' => 'root', 'password' => '', 'charset' => 'utf8', 'tablePrefix' => 't_']);
     $connection->open();
     $this->db = $connection;
     if ($this->cache !== null) {
         $this->cache = Instance::ensure($this->cache, Cache::className());
     }
 }
Exemple #20
0
 public static function instance($db, $table)
 {
     $db = is_null($db) ? 'global' : $db;
     $table = is_null($table) ? 'store' : $table;
     $key = sha1($db . $table);
     $has = Instance::has('GlobalStore', $key);
     if (true === $has) {
         return Instance::get('GlobalStore', $key);
     } else {
         return Instance::make('GlobalStore', $key, new self($db, $table));
     }
 }
/**
 * Lookup list of instances associated with this user
 * @param username value of username in moodle, currently this is ccid
 *
 * @return array list of instance records associated with user. array( stdClass, ...) stdClass->id, stdClass->url, stdClass->token, stdClass->sourceid
 */
function eclass_getUserInstances($username)
{
    global $DB, $CFG;
    //using default cache name
    $eCache = new EclassCache();
    $data = $eCache->getData(INSTANCES_DATAKEY);
    if ($data != ECLASS_CACHE_EXPIRED) {
        return $data;
    }
    //otherwise do a query
    $dbman = $DB->get_manager();
    //check if our tables exist
    if (!$dbman->table_exists("eclass_instances") || !$dbman->table_exists("eclass_user_instances")) {
        return array();
    }
    $records = $DB->get_records_sql("select i.* from {eclass_instances} AS i JOIN {eclass_user_instances} AS ui ON (i.id = ui.instance_id) where ui.userid = :userid", array('userid' => $username));
    $eCache->setData(INSTANCES_DATAKEY, 5, $records);
    $instances = Instance::wrapRecords($records);
    debugging("User Instances Found: " . print_r($records, true), DEBUG_DEVELOPER);
    return $instances;
}
Exemple #22
0
 function gui_send_instance($user, $activityId, $instanceId)
 {
     if (!$this->getOne("select count(*)\n                      from " . GALAXIA_TABLE_PREFIX . "instance_activities\n                      where activityId=? and instanceId=? and user=?", array($activityId, $instanceId, $user)) || $this->getOne("select count(*) \n                      from " . GALAXIA_TABLE_PREFIX . "instance_activities gia\n                      INNER JOIN " . GALAXIA_TABLE_PREFIX . "activity_roles gar ON gar.activityId=gia.activityId\n                      INNER JOIN " . GALAXIA_TABLE_PREFIX . "user_roles gur ON gar.roleId=gur.roleId\n                      where gia.instanceId=? and gia.activityId=? and gia.user=? and gur.user=?", array($instanceId, $activityId, '*', $user))) {
         return false;
     }
     include_once GALAXIA_LIBRARY . '/src/API/Instance.php';
     $instance = new Instance($this->db);
     $instance->getInstance($instanceId);
     $instance->complete($activityId, true, false);
     unset($instance);
 }
 public function deletesrv()
 {
     if (!Auth::check()) {
         return View::make('login');
     }
     $input = Input::all();
     $validator = Validator::make($input, array('gid' => "integer | required"), array('gid.required' => 'Security Error. IP Logged.', 'gid.integer' => 'Security Error. IP Logged.'));
     if ($validator->fails()) {
         $messages = $validator->messages();
         $errors = array();
         foreach ($messages->all() as $message) {
             array_push($errors, $message);
         }
         return $errors;
     } else {
         $instance = Instance::where('uid', Auth::user()->id)->where('id', Input::get('gid'))->first();
         $instance->delete();
         return "success";
     }
 }
Exemple #24
0
 public function exists($val, $func)
 {
     return Instance::call($func, $val);
 }
Exemple #25
0
 /**
  * @covers Respect\Rest\Routes\Instance::getReflection
  */
 function test_getReflection_should_return_instance_of_current_routed_class()
 {
     $route = new Instance('any', '/', new \DateTime());
     $refl = $route->getReflection('format');
     $this->assertInstanceOf('ReflectionMethod', $refl);
 }
Exemple #26
0
 public static function instance($ns, $entity)
 {
     $key = sha1(serialize(func_get_args()));
     $has = Instance::has('Fastdb', $key);
     if (true === $has) {
         return Instance::get('Fastdb', $key);
     } else {
         return Instance::make('Fastdb', $key, new self($ns, $entity));
     }
 }
Exemple #27
0
 public static function verify()
 {
     require_once 'password.php';
     $args = func_get_args();
     if (isset($args[0])) {
         $username = strtolower($args[0]);
     } elseif (isset($_COOKIE["username"])) {
         $username = $_COOKIE["username"];
     }
     $DBI = Instance::get('DBI');
     $result["success"] = 0;
     if (isset($username) && !empty($username)) {
         $DBI->execute('SELECT * FROM user WHERE lower(username) = "' . strtolower($username) . '";', MYSQL_ASSOC);
         if ($data = Log::$statusLast["data"]["result"][0]) {
             if (isset($args[1])) {
                 $verify = password_verify($args[1], $data["password"]);
             } elseif (isset($_COOKIE["password"])) {
                 $verify = $data["password"] == $_COOKIE["password"];
             }
             if (isset($verify) && $verify) {
                 $result["data"] = $data;
                 $DBI->execute('(SELECT DISTINCT permissions.* FROM permissions JOIN user_permissions ON permissions.id = user_permissions.permissions_id WHERE user_id = "' . $user['id'] . '") UNION (SELECT DISTINCT permissions.* FROM permissions JOIN user_group_permissions ON permissions.id = user_group_permissions.permissions_id JOIN user_group ON user_group_permissions.user_group_id = user_group.id JOIN user_group_member ON user_group.id = user_group_member.user_group_id WHERE user_id = "' . $user['id'] . '");', MYSQL_ASSOC);
                 $result["permissions"] = Log::$statusLast["data"]["result"];
                 $result["message"] = "Account verified";
                 $result["success"] = 1;
             } else {
                 $result["message"] = "Bad Credentials";
             }
         } else {
             $result["message"] = "User Not Found";
         }
     } else {
         $result["message"] = "Insufficient Data";
     }
     return $result;
 }
Exemple #28
0
 /**
  *	Return list of countries indexed by ISO 3166-1 country code
  *	@return array
  **/
 function countries()
 {
     return Instance::constants($this, 'CC_');
 }
 protected static function _php($errType, $errMsg)
 {
     $instance = new Instance();
     return $instance->msg($errType, $errMsg);
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     session_start();
     if (!isset($_SESSION['AUTH']) || $_SESSION['AUTH'] == false) {
         \App::abort(500, 'User not authenticated');
     }
     $put = file_get_contents('php://input');
     $data = json_decode($put, true);
     if ($data['password'] != null) {
         $i = instanceUser::find($id);
         $inst = Instance::find($i->instanceId);
         $redis = \Redis::connection();
         // Using the Redis extension provided client
         $redis->publish('demeter', json_encode(array('command' => 'resetPassword', 'vm' => $inst->vmId, 'instanceId' => $inst->id, 'instanceName' => $inst->name, 'username' => $i->name, 'password' => $data['password'], 'netId' => $_SESSION['AUTH_USER'])));
         echo "success";
     }
 }