/** * @param array $contents * * @return \Kisma\Core\SeedBag */ public function __construct($contents = array()) { parent::__construct($contents); // Anything left, goes in the bag if (!empty($contents) && (is_array($contents) || $contents instanceof \Traversable)) { foreach ($contents as $_key => $_value) { $this->set($_key, $_value); unset($contents[$_key]); } } }
$_SESSION['yel']['member']['hash'] = ""; $response['errors'] = array('error' => 'bad_login'); echo $xml_dom->get_xml_from_array($response); exit; } $response['login'] = array('status' => 'ok'); echo $xml_dom->get_xml_from_array($response); exit; } if ($_POST['action'] == 'linkedin_login') { $id = $_POST['id']; $hash = $_POST['hash']; $sid = $_POST['sid']; $linkedin_id = $_POST['linkedin_id']; if (empty($sid)) { $seed = Seed::generateSeed(); $hash = sha1($id . md5($linkedin_id) . $seed['login']['seed']); $sid = $seed['login']['id']; } $_SESSION['yel']['member']['id'] = $id; $_SESSION['yel']['member']['hash'] = $hash; $_SESSION['yel']['member']['sid'] = $sid; $_SESSION['yel']['member']['linkedin_id'] = $linkedin_id; header('Content-type: text/xml'); $member = new Member($id, $sid); // 1. find whether this member exists, from the ID $criteria = array('columns' => "COUNT(*) AS is_exists", 'match' => "email_addr = '" . $id . "'"); $result = $member->find($criteria); if ($result[0]['is_exists'] != '1') { // sign the member up $joined_on = today();
<?php require_once "../private/lib/utilities.php"; $data = Seed::generateSeed(); $sid = $data['login']['id']; $seed = $data['login']['seed']; $uid = 'acme123'; $password = '******'; $hash = sha1($uid . md5($password) . $seed); echo $sid . ": " . $seed . "<br>"; echo $hash . "<br>"; $employer = new Employer($uid, $sid); ?> <p style="font-weight: bold;">Logging in... </p><p><?php if ($employer->isRegistered($hash)) { if ($employer->setSessionWith($hash)) { echo "Success"; } } if (!$employer->isLoggedIn($hash)) { echo "failed"; exit; } ?> </p><p style="font-weight: bold;">Update my details... </p><p><?php $old_data = $employer->get(); echo "Before...<br><br>"; echo "<pre>"; print_r($old_data); echo "</pre><br><br>"; $data = array();
function load_file($filepath) { $rootPath = getcwd() . "/.."; if (file_exists($rootPath . $filepath)) { require_once $rootPath . $filepath; return 1; } else { return 0; } } //Migrate load_file('/config/config_local.php'); load_file('/library/debug.php'); load_file('/library/naming_convention.php'); load_file('/app/exception/database_exception.php'); load_file('/library/db/db.php'); load_file('/library/active_record.php'); load_file('/library/migration.php'); $migration = new Migration(); $migration->up(); //Seeds load_file('/library/object.php'); load_file('/library/db/db_obj.php'); load_file('/library/db/db_model.php'); load_file('/library/db/repository.php'); load_file('/db/seed.php'); echo '== creating seed' . "\n"; $seed = new Seed(); $seed->create(); echo '== setup done' . "\n";
<?php require_once dirname(__FILE__) . "/../private/lib/utilities.php"; header('Content-type: text/xml'); $xml_dom = new XMLDOM(); if ($GLOBALS['protocol'] == 'https') { if (empty($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == 'off') { $response['errors'] = array('error' => 'insecure'); echo $xml_dom->get_xml_from_array($response); exit; } } /* Generate the seed and return the ID and SEED in XML format. A seed and a seed id are required for web-based authentication. The SHA1 hash is generated by concatenating id, md5(password) and seed. */ $response = Seed::generateSeed(); if ($response === false) { // Return an error XML if there is a problem. $response['errors'] = array('error' => 'An error occured while generating seed.'); } echo $xml_dom->get_xml_from_array($response);
/** * @param array $settings */ public function __construct($settings = array()) { // Wire up a destructor to call when I die register_shutdown_function(function () { $this->__destruct(); static::_destruct(); }); // Phone home. Calls __wakeup() from base parent::__construct($settings); // Call static constructor and save our instance off static::_construct($this); static::$_instance = $this; }