function fill_user_photos() { $users = User::find_all(); foreach ($users as $user) { create_user_photos($user->id); } }
public function rules() { if (!$this->rules_cache || $reload) { $id = mysql_real_escape_string($this->id); $this->rules_cache = User::find_all("aclrules.acls_id = '{$id}'"); } return $this->rules_cache; }
public function testAssociationLoadsData() { $users = User::find_all(array('include' => 'photos')); foreach ($users as $user) { foreach ($user->photos as $photo) { $this->assertEquals($user->id, $photo->user_id); } } }
public function testFindAll() { $users = User::find_all(); $users = collect(function ($o) { return $o->name; }, $users); //we sort them to assure they are compaired in an order that will return true $this->assertEquals(asort($users), asort($this->users)); }
public function testFindAllConditionsOrderLimit() { $users = User::find_all(array('limit' => '0,5', 'order' => 'my_int DESC', 'conditions' => "name LIKE '%names%'")); $test_compair = range(10, 6); $test = array(); foreach ($users as $user) { $test[] = $user->my_int; } $this->assertEquals($test_compair, $test); }
public function up() { $table = $this->alter_table('users'); $table->timestamp('channel_updated'); $table->go(); foreach (User::find_all() as $user) { $user->channel_updated = DateHelper::to_string('db', time()); $user->save(); } }
static function is_logged_in() { if (!isset(Login::$logged_in)) { Login::$logged_in = FALSE; if (!empty($_COOKIE['username'])) { $conn = Db::get_connection(); $user_factory = new User(); $users = $user_factory->find_all(array('where_clause' => "`utente` = '{$conn->escape($_COOKIE['username'])}'", 'limit' => 1)); if (count($users) > 0) { $user = $users[0]; Login::$logged_in = md5($user->utente . self::magic_phrase) == @$_COOKIE['userID']; } Db::close_connection($conn); } } return Login::$logged_in; }
public function create($group_id = null) { $group = self::load_group($group_id); if ($this->post) { $added = false; foreach ($_POST['users'] as $id) { $user = User::find_by_id($id); if ($user) { $user_group = new UserGroup(); $user_group->user_id = $user->id; $user_group->group_id = $group->id; if ($user_group->save()) { $added = true; } } } if ($added) { Site::Flash("notice", "The users have been added to the group"); } Redirect("admin/groups/{$group->id}"); } $group_users = array(); foreach ($group->users() as $user) { $group_users[] = $user->id; } $users = array(); $all_users = User::find_all("", "nickname ASC"); foreach ($all_users as $user) { if (!in_array($user->id, $group_users)) { $users[] = $user; } } if (count($users) == 0) { Site::Flash("error", "There are no more users to add."); Redirect("admin/groups/{$group->id}"); } $this->assign("users", $users); $this->assign("group", $group); $this->title = "Add Users"; $this->render("user_group/create.tpl"); }
public function test_basic_find() { $count = User::count(); FuzzyTest::assert_equal($count, 3, "Should find three users here"); $matches = User::find_all(); FuzzyTest::assert_equal(count($matches), 3, "Should find three users here"); $count = User::count(array('email' => '*****@*****.**')); FuzzyTest::assert_equal($count, 1, "Should find one user here"); $matches = User::find(array('email' => '*****@*****.**')); FuzzyTest::assert_equal(count($matches), 1, "Should find one user here"); $u = $matches[0]; FuzzyTest::assert_equal($u->email, "*****@*****.**", "Found wrong user"); $count = User::count(array('first_name' => 'Ben')); FuzzyTest::assert_equal($count, 2, "Should find two users here"); $matches = User::find(array('first_name' => 'Ben')); FuzzyTest::assert_equal(count($matches), 2, "Should find two users here"); $matches = User::find_all_by_first_name('Ben'); FuzzyTest::assert_equal(count($matches), 2, "Should find two users here"); $count = User::count_by_first_name('Ben'); FuzzyTest::assert_equal($count, 2, "Should find two users here"); $matches = User::find_all_by_email('*****@*****.**'); FuzzyTest::assert_equal(count($matches), 1, "Should find one user here"); $count = User::count_by_email('*****@*****.**'); FuzzyTest::assert_equal($count, 1, "Should find one user here"); $u = $matches[0]; FuzzyTest::assert_equal($u->email, "*****@*****.**", "Found wrong user"); $u = User::find_by_email('*****@*****.**'); FuzzyTest::assert_equal($u->email, "*****@*****.**", "Found wrong user"); $matches = User::find_all_by_email_and_first_name('*****@*****.**', 'Ben'); FuzzyTest::assert_equal(count($matches), 1, "Should find one user here"); $count = User::count_by_email_and_first_name('*****@*****.**', 'Ben'); FuzzyTest::assert_equal($count, 1, "Should find one user here"); $u = $matches[0]; FuzzyTest::assert_equal($u->email, "*****@*****.**", "Found wrong user"); $matches = User::find(array('first_name' => 'Ben', 'limit' => 1)); FuzzyTest::assert_equal(count($matches), 1, "Should find one user here"); $matches = User::find(array('first_name' => 'Ben', 'order_by' => 'registration_date')); FuzzyTest::assert_equal(count($matches), 2, "Should find two users here"); $u = $matches[0]; FuzzyTest::assert_equal($u->email, "*****@*****.**", "Sorted results in the wrong order"); $matches = User::find(array('first_name' => 'Ben', 'order_by' => 'email', 'sort' => "descending")); FuzzyTest::assert_equal(count($matches), 2, "Should find two users here"); $u = $matches[0]; FuzzyTest::assert_equal($u->email, "*****@*****.**", "Sorted results in the wrong order"); $matches = User::find(array('first_name' => 'Ben', 'order_by' => 'email', 'sort' => "ascending")); FuzzyTest::assert_equal(count($matches), 2, "Should find two users here"); $u = $matches[1]; FuzzyTest::assert_equal($u->email, "*****@*****.**", "Found wrong user"); $matches = User::find(array('email_not' => '*****@*****.**')); FuzzyTest::assert_equal(count($matches), 2, "Should find two users here"); }
<?php require_once "../includes/initialize.php"; if (!$session->is_logged_in()) { redirect_to("login.php"); } ?> <?php include_layout_template('header.php'); $user = User::find_by_id(1, "users"); echo $user->fullname; echo "<hr />"; $users = User::find_all("users"); foreach ($users as $user) { echo "User: "******"<br />"; echo "Name: " . $user->fullname . "<br /><br />"; } ?> <ul> <li><a href="logfile.php">View Log file</a></li> <li><a href="logout.php">Logout</a></li> </ul> <?php include_layout_template('footer.php');
$user_name_input = Input::get('name'); $salt = Hash::salt(32); try { $user->create(['username' => Input::get('username'), 'password' => Hash::make(Input::get('password'), $salt), 'salt' => $salt, 'name' => Input::get('name'), 'joined' => date('Y-m-d H:i:s'), 'group' => Input::get('group')]); Session::flash('register', $user_name_input . ' has been registered and can now log in!'); } catch (Exception $e) { die($e->getMessage()); } } } } //The code below holds true //even if no submission is made //to register a new user $all_users_obj = new User(); $all_users_obj->find_all(); $all_users_data = $all_users_obj->data(); } } ?> <!--include reg_user_header.php--> <?php include '../includes/layout/reg_user_header.php'; ?> <section class="user_interface row"> <section class="user_interface_panel col-xs-12 col-sm-8"> <article> <p>
public function edit() { $signup = self::load_signup($id); if ($signup->event->enddate <= time()) { Site::Flash("error", "It is not possible to edit this booking"); Redirect("bookings/{$signup->id}"); } // Seating Manager $managers = array('' => 'None'); $clan = mysql_real_escape_string(Site::CurrentUser()->clan); if ($clan != '') { $id = mysql_real_escape_string(Site::CurrentUser()->id); $allManagers = User::find_all("users.clan = '{$clan}'", "users.nickname ASC"); foreach ($allManagers as $manager) { $permalink = $manager->permalink(); $managers[$permalink] = $manager->nickname; } } $currentManager = ''; if ($signup->manager_id) { $currentManager = $signup->manager->permalink(); } if ($this->post and !$this->csrf) { global $site; $site['flash']['error'] = "Invalid form submission"; } elseif ($this->post) { $signup->lift_required = $_POST['lift_required']; if (!$signup->paid and !$signup->event_ticket->hidden) { $ticket_id = mysql_real_escape_string($_POST['ticket']); if ($ticket_id != $signup->event_ticket_id) { $event_id = mysql_real_escape_string($signup->event_id); $ticket = EventTicket::find("event_tickets.id = '{$ticket_id}' AND event_tickets.event_id = '{$event_id}' AND event_tickets.hidden = false"); if ($ticket) { $signup->event_ticket_id = $ticket->id; $signup->event_ticket = $ticket; } } } $save = true; if ($this->PostData('manager_id')) { $manager = User::find_by_nickname($this->PostData('manager_id')); if ($manager && array_key_exists($manager->permalink(), $managers)) { $signup->manager_id = $manager->id; } else { global $site; $site['flash']['error'] = "Unable to find the seat manager you selected"; $save = false; } } else { $signup->manager_id = null; } if ($save && $signup->save()) { // Remove any services that don't fit this booking if (!$signup->event_ticket->participant) { $signup_id = mysql_real_escape_string($signup->id); $services = EventService::find_all("event_services.event_signup_id = '{$signup_id}' AND participant = true"); $paid = array(); foreach ($services as $service) { if ($service->paid) { // Service has been paid, don't remove it, email staff $paid[] = $service; } else { $service->destroy(); } } if (count($paid) > 0) { // One or more services were unsuitable but paid for (this should // really not happen! Let's email staff and they can handle it } } Site::Flash("notice", "Your event booking has been updated"); Redirect("bookings/{$signup->id}"); } } $this->assign("signup", $signup); $this->assign("tickets", $signup->event->public_tickets()); $this->assign("managers", $managers); $this->assign("currentManager", $currentManager); $this->title = "My Bookings :: " . $signup->event->name . " :: Edit"; $this->render("event_signup/edit.tpl"); }
*/ function echo_memory_usage() { $mem_usage = memory_get_usage(true); if ($mem_usage < 1024) { var_dump($mem_usage . " bytes"); } elseif ($mem_usage < 1048576) { var_dump(round($mem_usage / 1024, 2) . " kilobytes"); } else { var_dump(round($mem_usage / 1048576, 2) . " megabytes"); } } echo_memory_usage(); define('MYSQL_DATABASE', 'nimble_record_test'); require_once dirname(__FILE__) . '/../../../nimble_support/base.php'; require_once dirname(__FILE__) . '/../../../nimble_record/base.php'; require_once dirname(__FILE__) . '/../../../nimble_record/migrations/migration.php'; require_once dirname(__FILE__) . '/../../../nimble_record/migrations/lib/migration_runner.php'; require_once dirname(__FILE__) . '/../model/user.php'; require_once dirname(__FILE__) . '/../model/photo.php'; $settings = array('host' => 'localhost', 'database' => MYSQL_DATABASE, 'username' => 'root', 'password' => '', 'adapter' => 'mysql'); NimbleRecord::establish_connection($settings); echo_memory_usage(); $u = User::find_all(array('limit' => '0,500')); echo_memory_usage(); $u->clear(); echo_memory_usage(); $u2 = User::find_all(); echo_memory_usage(); $u2->clear(); echo_memory_usage();
public function users() { if (!$this->users_cache || $reload) { $id = mysql_real_escape_string($this->id); $this->users_cache = User::find_all("users.aclgroup_id = '{$id}'"); } return $this->users_cache; }
public function syncAgenti() { $imopediaSoap = new ImopediaSoap('http://syncapi.imopedia.ro/api2/sync.wsdl?' . time(), "ag1173api", "qrjefpkn8wa45ghsJw31l"); $imopediaSoap->connect(); $agenti = User::find_all(); foreach ($agenti as $agent) { $agarr['AGENTIA'] = 1173; $agarr['AGENT_ID'] = $agent->id; $agarr['CONTACT_PERS'] = $agent->full_name(); $agarr['CONTACT_TEL'] = $agent->Telefon; $agarr['CONTACT_EMAIL'] = $agent->Email; //$agarr['AGENT_IMAGE'] = base64_encode(file_get_contents("http://igor.lanconect.ro/Imob2009/".$agent->image_path())); $agarr['AGENT_IMAGE'] = str_replace(" ", "%20", "http://igor.lanconect.ro/Imob2009/" . $agent->image_path()); $agobj = $this->arrayToObject($agarr); //$soap_result = $imopediaSoap->execute('saveAgent', $options); $rrr = $imopediaSoap->execute('saveAgent', $agobj); } $imopediaSoap->disconnect(); return true; }
<?php require_once "init.php"; $script = Script::find_by_code('sync_stats_profiles'); $script->start(); ob_start(); $time = date("H:i:s"); echo "[{$time}] Updating user profile stats\r\n\r\n"; global $config; $user = array(); $stats_results = array(array()); // Get all users that require updating (that is, // don't have values for each game) $users = User::find_all("\n\t\tusers.steam_id IS NOT NULL\n\t\tAND users.steam_id != ''\n\t\tAND (user_profiles.hlstatsx_l4d_user IS NULL\n\t\tOR user_profiles.hlstatsx_l4d2_user IS NULL\n\t\tOR user_profiles.hlstatsx_tf2_user IS NULL)\n\t"); if (count($users) > 0) { // Grab all results from the stats db in 1 query to avoid hundreds of hits $stats_connection = mysql_connect($config['epicstats']['hostname'], $config['epicstats']['username'], $config['epicstats']['password']); if (!$stats_connection) { throw new Error500('Unable to connect to database'); } $result = mysql_select_db($config['epicstats']['database'], $stats_connection); if (!$result) { throw new Error500('Unable to select database'); } $results = mysql_query("\n\t\t\tSELECT `playerId`, `uniqueId`, `game`\n\t\t\tFROM `hlstats_playeruniqueids`\n\t\t", $stats_connection); // Represent the data while ($row = mysql_fetch_assoc($results)) { $stats_results["{$row['uniqueId']}"]["{$row['game']}"] = $row['playerId']; } mysql_close($stats_connection); // Re-establish database connection for epic
<?php require_once '../../includes/initialize.php'; ?> <?php // if(!$session->is_logged_in()){ // redirect_to('login.php'); // } ?> <?php $admins = User::find_all(); ?> <?php include_layout_template("admin_header"); ?> <nav> <br> <a href="index.php"> « Back</a> </nav> <div class="page"> <?php echo $message; ?> <table> <h2>Manage Admins</h2>
<?php require_once '../includes/database.php'; require_once '../includes/user.php'; $user = new User($db); $my_user = $user->find_by_id(1); echo $my_user->get_full_name(); echo "<hr />"; $users = $user->find_all(); foreach ($users as $user) { echo "User: "******"<br />"; echo "Name: " . $user->get_full_name() . "<br /><br />"; echo "<hr />"; }
public function users() { $this->users = User::find_all(); }
<?php require_once dirname(__FILE__) . "/../models/user.php"; if (Login::is_logged_in()) { $user_factory = new User(); $users = $user_factory->find_all(array('where_clause' => "`utente` = '{$_COOKIE['username']}' ")); $user = $users[0]; ?> <div id="login-greetings"> Benvenuto, <b><?php echo $user->nome; ?> </b> (<a href="/common/logout.php">Logout</a>) </div> <?php }
// $User = new User(); // $found_user = $User->find_by_id(8); $user = User::find_by_id(8); echo $user->username . "<br />"; echo $user->user_id . "<br />"; echo $user->password . "<br />"; echo "<hr />"; //--------------------------------------------------- echo "List of Users E-mails: <br />"; $users = User::find_all(); foreach ($users as $user) { echo $user->email . "; "; } echo "<hr />"; //--------------------------------------------------- $users = User::find_all(); foreach ($users as $user) { echo "User ID: " . $user->user_id . "<br />"; echo "User: "******"<br />"; echo "E-mail: " . $user->email . "<br />"; echo "Password: "******"<br /><br />"; // while ($user = $database->fetch_array($user_set)) { // echo "User: "******"<br /><br />"; // echo "Location: ". $user['location'] ."<br /><br />"; // echo "Name: ". $user['first_name'] ." " . $user['last_name'] ."<br /><br />"; //} } echo "<hr />"; echo __FILE__ . "<br />"; echo __LINE__ . "<br />"; echo dirname(__FILE__) . "<br />";
function posteazaAgent() { global $s; global $session_id; $agenti = User::find_all(); foreach ($agenti as $agent) { $agentxml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>"; $agentxml .= "<agent>\n\t\t<id>{$agent->id}</id>\n\t\t<email>{$agent->Email}</email>\n\t\t<mobil>{$agent->Telefon}</mobil>\n\t\t<nume>" . $agent->full_name() . "</nume>\n\t\t<username>{$agent->User}</username>\n\t\t<password>{$agent->Parola}</password>\n\t\t<functie>Broker imobiliar</functie>\n\t\t"; if ($agent->Poza != "") { $agentxml .= "<poza>" . base64_encode(file_get_contents(".." . DS . $agent->image_path())) . "</poza>"; } // <telefon>0314398268</telefon> $agentxml .= "</agent>"; //echo $agentxml.""; // publica AGENT $operatie = "MOD"; try { $result = $s->__soapCall('publica_agent', array('publica_agent' => array('id' => $agent->id, 'sid' => $session_id, 'operatie' => $operatie, 'agentxml' => $agentxml))); } catch (Exception $e) { die('Eroare Publicare agent: ' . $e->getMessage()); } echo '<pre>PUBLICARE Agent id ' . $agent->id . ': ' . print_r($result, true) . '</pre>'; } }
<?php require_once "../includes/database.php"; require_once "../includes/user.php"; if (isset($database)) { echo "true"; } else { echo "false"; } echo "<br>"; echo $database->escape_value("It's working"); echo "<br>"; $sql = "INSERT INTO users (id, username, password, first_name, last_name) "; $sql .= "VALUES (1, 'towermedia', 'Global003!', 'Ryan', 'Hightower')"; //$result = $database->query($sql); $sql = "SELECT * FROM users WHERE id=1"; $result_set = $database->query($sql); $found_user = $database->fetch_array($result_set); echo $found_user["username"]; echo "<hr>"; $found_user = User::find_by_id(1); echo $found_user['username']; echo "<hr>"; $user_set = User::find_all(); while ($user = $database->fetch_array($user_set)) { echo "Username: "******"<br />"; echo "Name: " . $user['first_name'] . " " . $user['last_name'] . "<br />"; }
public function testCollectionWithCallStaticXML() { $users = User::find_all(); $this->assertEquals('<?xml version="1.0" encoding="UTF-8"?> <users><user><address></address><id>1</id><last_name></last_name><my_int>1</my_int><name>names1</name></user><user><address></address><id>2</id><last_name></last_name><my_int>2</my_int><name>names2</name></user><user><address></address><id>3</id><last_name></last_name><my_int>3</my_int><name>names3</name></user><user><address></address><id>4</id><last_name></last_name><my_int>4</my_int><name>names4</name></user><user><address></address><id>5</id><last_name></last_name><my_int>5</my_int><name>names5</name></user><user><address></address><id>6</id><last_name></last_name><my_int>6</my_int><name>names6</name></user><user><address></address><id>7</id><last_name></last_name><my_int>7</my_int><name>names7</name></user><user><address></address><id>8</id><last_name></last_name><my_int>8</my_int><name>names8</name></user><user><address></address><id>9</id><last_name></last_name><my_int>9</my_int><name>names9</name></user><user><address></address><id>10</id><last_name></last_name><my_int>10</my_int><name>names10</name></user></users>', NimbleSerializer::XML($users, array('except' => array('updated_at', 'created_at')))); }
echo $locatieIcons . $proprietateIcon[2]; ?> ' height='25'></img></td> <td class="column ui-widget-header ui-corner-all" style=" text-align:center;"><img src='<?php echo $locatieIcons . $proprietateIcon[3]; ?> ' height='25'></img></td> <td class="column ui-widget-header ui-corner-all" style=" text-align:center;"><img src='<?php echo $locatieIcons . $proprietateIcon[4]; ?> ' height='25'></img></td> <td class="column ui-widget-header ui-corner-all" style=" text-align:center;">total</td> </tr> <?php $agenti = User::find_all(); $total = array(); $oferte_active = array(); for ($i = 0; $i <= 24; $i++) { $total[$i] = 0; } $i = 0; foreach ($agenti as $agent) { if ($agent->id == 1) { continue; } $i++; $class = $i % 2 ? "row odd" : "row even"; echo "<tr class='{$class}'>"; echo "<td style='font-weight: bold;'>{$agent->full_name()}</td>"; // oferte active
/** * @fn request_password * @short Action method to send a new password to a registered user. */ function request_password() { if (!Antispam::check_math()) { $this->flash(Antispam::random_comment(), 'error'); $this->redirect_to(array('action' => 'lost_password')); } $user_factory = new User(); $users = $user_factory->find_all(array('where_clause' => "`email` = '{$_POST['email']}'", 'limit' => 1)); if (count($users) > 0) { $user = $users[0]; $request = new PasswordRequest(); $request->user_id = $user->id; $request->created_at = date("Y-m-d H:i:s"); $request->hash = md5($request->created_at . $request->user_id . 'Questa non la sai'); $request->save(); $this->redirect_to(array('action' => 'request_sent')); } $this->flash(l('No such user'), 'error'); $this->redirect_to(array('action' => 'lost_password')); }
public static function chat_users_wrappers() { $output = ""; $output .= "<div class='col-md-3'>"; $output .= "<div class='chat-users'>"; $output .= "<div class='users-list'>"; $users = User::find_all(); foreach ($users as $user) { if ($user->username == 'Captainbraliaji' || $user->username == 'kamy' || $user->username == 'admin') { $output .= static::chat_users($user); } } $output .= "</div>"; $output .= "</div>"; $output .= "</div>"; return $output; }
<?php require_once 'init.php'; ini_set('display_errors', 1); $users = User::find_all("users.password NOT LIKE '\$2y%'", 'users.id ASC', 1000, 0); foreach ($users as $user) { echo "[{$user}] {$user->nickname}\r\n"; $hash = password_hash($user->password, PASSWORD_BCRYPT); $user->password = $hash; $user->password_confirmation = $hash; $user->save(); }
?> </textarea></dt> <dt><label class="label">data actualizare</label><input type="text" name="ClDataActualizare" id="dataactualizare" value="<?php echo convert_date($client->DataActualizare); ?> "></input> <input type="button" id="calendar-trigger" value='...'/><br/> <script> var cal1=Calendar.setup({onSelect:function(){cal1.hide();}}); cal1.manageFields("calendar-trigger", "dataactualizare", "%d/%m/%Y"); </script> </dt> <dt> <label class="label">agent</label><select name='ClidUtilizator' class="standard"> <?php $userlist = User::find_all(); foreach ($userlist as $agent) { echo "<option "; if ($agent->id == $client->idUtilizator) { echo "selected='selected'"; } echo "value='" . $agent->id . "'>{$agent->full_name()}"; echo "</option>"; } ?> </select> </dt> </dl> </fieldset>
<a href="add_user.php" class="btn btn-primary">Add user</a> <div class="col-xs-12"> <table class="table table-striped table-hover"> <thead> <tr> <th>Id</th> <th>Photo</th> <th>Username</th> <th>Firstname</th> <th>Lastname</th> </tr> </thead> <tbody> <?php $user_found = User::find_all(); ?> <?php foreach ($user_found as $user) { ?> <tr> <td><?php echo $user->id; ?> </td> <td> <img class="img-thumbnail img-responsive thumb-user" src ="<?php echo $user->image_path_and_placeholder(); ?> "/> </td>