PHP User::data Examples

PHP User::data - 30 examples found. These are the top rated real world PHP examples of User::data extracted from open source projects. You can rate examples to help us improve the quality of examples.
Example #1
0
 public function getNotification($id)
 {
     //serves up the notification if the cid has permission to view it
     $user = new User();
     $pre = $this->_db->query("SELECT notifications.id AS notification_id, notifications.type, notifications.from, notifications.to_type, notifications.to, notifications.submitted, notifications.status,\n\t\t\t\t\t\t\t\t\tnotification_types.id, notification_types.group, notification_types.name AS type_name, notification_types.sort,\n\t\t\t\t\t\t\t\t\tnotification_groups.id, notification_groups.name, notification_groups.permission_required, notification_groups.sort,\n\t\t\t\t\t\t\t\t\tcontrollers.id, controllers.first_name, controllers.last_name, controllers.email\n\t\t\tFROM notifications\n\t\t\tLEFT JOIN notification_types ON notifications.type = notification_types.id\n\t\t\tLEFT JOIN notification_groups ON notifications.to = notification_groups.id\n\t\t\tLEFT JOIN controllers ON controllers.id = notifications.from\n\t\t\tWHERE notifications.id = ? OR notifications.to = ?", [[$id, $id]]);
     if (!$pre->count()) {
         throw new Exception("No record found for that ID");
     } else {
         $this->_data = $pre->first();
         if ($user->data()->id == $this->_data->from || $user->data()->id == 0 && $user->data()->id == $this->_data->to || $user->hasPermission($this->_data->permission_required)) {
             return $this->_data;
         }
         throw new Exception("Invalid permissions to view that record");
     }
 }
Example #2
0
 public function get($uid)
 {
     $pos = $this->_db->get('posts', "uid = {$uid} ORDER BY timestamp DESC");
     if ($pos->count()) {
         $posts = $pos->results();
         foreach ($posts as $post) {
             $friend = new User($post->fid);
             $friendName = $friend->data()->firstName . ' ' . $friend->data()->middleName . ' ' . $friend->data()->lastName;
             $datetime = new DateTime($post->timestamp);
             $timestamp = $datetime->format('l, F j, Y \\a\\t g:ia');
             $this->add(array('username' => $friend->data()->username, 'name' => $friendName, 'profilePicture' => $friend->data()->profilePicture, 'comment' => $post->comment, 'timestamp' => $timestamp));
         }
         return true;
     }
     return false;
 }
Example #3
0
 public function index()
 {
     $flash_string = '';
     if (Session::exists('home')) {
         $flash_string = Session::flash('home');
     }
     if (Session::exists('success')) {
         $flash_string = Session::flash('success');
     }
     $user = new User();
     if ($user->isLoggedIn()) {
         $this->view('account/index', ['register' => true, 'loggedIn' => 1, 'flash' => $flash_string, 'name' => $user->data()->name, 'user_id' => $user->data()->id, 'page_name' => 'Home']);
     } else {
         $this->view('home/index', ['loggedIn' => 0, 'page_name' => 'Home', 'flash' => $flash_string]);
     }
 }
Example #4
0
 public function search($input = array())
 {
     $where = '';
     $x = 1;
     foreach ($input as $field => $value) {
         if (!empty($value)) {
             $fields[$field] = $value;
         }
     }
     foreach ($fields as $field => $value) {
         if (!empty($value)) {
             $where .= $field . ' = ' . '\'' . $value . '\'';
             if (count($fields) !== 1 && $x < count($fields)) {
                 $where .= ' AND ';
             }
         }
         $x++;
     }
     $search = $this->_db->get('users', $where);
     if ($search->count()) {
         $results = $search->results();
         foreach ($results as $result) {
             $friend = new User($result->id);
             $this->_results[] = $friend->data();
         }
         return true;
     }
     return false;
 }
Example #5
0
 public function addNewUser($username, $firstname, $lastname, $password)
 {
     if (!$this->userExists($username)) {
         $newUser = new User($username, $firstname, $lastname, $password);
         $this->usersData->addNew($newUser->data(), 'username');
         return true;
     } else {
         return false;
     }
 }
 function index()
 {
     $user = new User();
     if ($user->hasPermission('admin')) {
         echo "Welcome admin!";
     } else {
         echo "Welcome " . $user->data()->name . "!";
     }
     $this->htmlResponse("index.html", ['title' => 'JN', 'error' => Session::flash('error'), 'success' => Session::flash('success')]);
 }
Example #7
0
 public static function deleteById($productId)
 {
     $db = self::getInstance();
     $user = new User();
     $userId = $user->data()->id;
     $sql = "DELETE FROM `Products` WHERE `Products`.`user` = ? AND `Products`.`id` = ?;";
     if (!$db->query($sql, [$userId, $productId])) {
         return false;
     }
     return true;
 }
Example #8
0
 public static function login($userid = '', $password = '', $remember = false)
 {
     $user = new User($userid);
     if (!empty($userid) && !empty($password) && $user->exists()) {
         if (Hash::checkPassword($password, $user->data()->password)) {
             self::forceLogin($user, $remember);
             return true;
         }
     }
     return false;
 }
Example #9
0
 public static function deleteUnit($name)
 {
     $db = self::getInstance();
     $user = new User();
     $userId = $user->data()->id;
     $sql = "DELETE FROM `Unit` WHERE `Unit`.`Name` = ? AND `Unit`.`user` = ?;";
     if ($db->query($sql, [$name, $userId])) {
         return true;
     } else {
         return true;
     }
 }
Example #10
0
 /**
  * Set additional data for the user account. This is used for storing additional content
  * that isn't supported by the default user table.
  */
 public function setData($name, $value)
 {
     if (self::$_user['id'] == 0) {
         // Cant set data for anonymous user
         return false;
     }
     if (User::data()->where('user_id', '=', self::$_user['id'])->andWhere('name', '=', $name)->first()) {
         User::data()->where('user_id', '=', self::$_user['id'])->andWhere('name', '=', $name)->update(array('value' => $value));
     } else {
         User::data()->insert(array('user_id' => self::$_user['id'], 'name' => $name, 'value' => $value));
     }
 }
Example #11
0
 public static function getComponentsByDishId($dishId)
 {
     $db = self::getInstance();
     $user = new User();
     $userId = $user->data()->id;
     $sql = "SELECT `Dishes`.`id`, `Recipes`.`recipeName`, `Recipes`.`recipeCost`, `Recipes`.`yeild`, `Recipes`.`yeildUnit`, `DishRecipes`.`quantity`, `DishRecipes`.`unit`, `Unit`.`Ratio`\n\t\t\tFROM `Dishes`\n\t\t\tJOIN `DishRecipes`\n\t\t\tON `Dishes`.`id` = `DishRecipes`.`Dishes_id`\n\t\t\tAND `DishRecipes`.`Dishes_id` = ?\n\t\t\tAND `Dishes`.`user` = ?\n\t\t\tJOIN `Recipes`\n\t\t\tON `DishRecipes`.`Recipes_id` = `Recipes`.`id`\n\t\t\tJOIN `Unit`\n\t\t\tON `DishRecipes`.`unit` = `Unit`.`Name`;";
     if ($ingredient = $db->query($sql, [$dishId, $userId])->results()) {
         return $ingredient;
     } else {
         return false;
     }
 }
Example #12
0
 public static function getIngredientsByRecipeId($recipeId)
 {
     $db = self::getInstance();
     $user = new User();
     $userId = $user->data()->id;
     $sql = "SELECT `Products`.`productName`, `Products`.`id`, `Products`.`costPerKiloUnit`, `ProductRecipes`.`Recipes_id`, `ProductRecipes`.`quantity`, `ProductRecipes`.`unit`, `Unit`.`Ratio`, `Unit`.`UnitType`\n\t\t\tFROM `Products`\n\t\t\tJOIN `ProductRecipes`\n\t\t\tON `Products`.`id` = `ProductRecipes`.`Products_id`\n\t\t\tAND `ProductRecipes`.`Recipes_id` = ?\n\t\t\tAND `Products`.`user` = ?\n\t\t\tJOIN `Unit`\n\t\t\tON `ProductRecipes`.`unit` = `Unit`.`Name`\n\t\t\tORDER BY `ProductRecipes`.`id` ASC;";
     if ($ingredient = $db->query($sql, [$recipeId, $userId])->results()) {
         return $ingredient;
     } else {
         return false;
     }
 }
Example #13
0
 function onAuthCheckLoggedIn(Am_Event_AuthCheckLoggedIn $event)
 {
     $status = $this->getStatus();
     if ($status == self::LOGGED_AND_LINKED) {
         $event->setSuccessAndStop($this->linkedUser);
     } elseif ($status == self::LOGGED_OUT && !empty($_GET['fb_login'])) {
         $this->linkedUser->data()->set(self::FACEBOOK_LOGOUT, null)->update();
         $event->setSuccessAndStop($this->linkedUser);
     } elseif ($status == self::LOGGED_IN && $this->getDi()->request->get('fb_login')) {
         $this->linkedUser = $this->createAccount();
         $event->setSuccessAndStop($this->linkedUser);
     }
 }
Example #14
0
 public function form($id = "")
 {
     if (empty($id)) {
         $head['title'] = 'Yönetici Ekle';
         $head['meta']['author'] = 'Bursa yazılım';
         $headData["kullaniciAdi"] = User::data()->username;
         $bodyVeri["data"] = ['action' => siteUrl('yonetim/ekle')];
         $bodyVeri["data"] = ['action' => siteUrl('yonetim/ekle'), 'yoneticiDetay' => ["username" => "", "pass" => "", "email" => "", "isim" => "", "soyisim" => "", "durum" => "", "ban_durum" => ""]];
     } else {
         $head['title'] = 'Yönetici Düzenle';
         $head['meta']['author'] = 'Bursa yazılım';
         $headData["kullaniciAdi"] = User::data()->username;
         $yoneticiDetay = $this->yonetici->detay($id);
         $bodyVeri["data"] = ['action' => siteUrl('yonetim/duzenle/' . $id), 'yoneticiDetay' => $yoneticiDetay];
     }
     $data['head'] = Import::view('head', $headData, true);
     $data['footer'] = Import::view('footer', '', true);
     $data['body'] = Import::view('yonetimForm', $bodyVeri, true);
     Import::masterPage($data, $head);
 }
 function changePassword()
 {
     $input = Input::parse();
     if (Token::check($input['token'])) {
         $validate = new Validate();
         $validate->check($input, array('password_current' => ['required' => true, 'min' => 6], 'password' => ['required' => true, 'min' => 6], 'password_repeat' => ['required' => true, 'min' => 6, 'matches' => 'password']));
         if ($validate->passed()) {
             $user = new User();
             if (Hash::make($input['password_current'], config::get('encryption/salt')) !== $user->data()->password) {
                 echo "incorrent password";
             } else {
                 $user->update(array('password' => Hash::make($input['password'], config::get('ecryption/salt'))));
                 Session::flash('success', 'Successfully changed password');
                 Redirect::to('changepassword');
             }
         } else {
             Session::flash('error', $validate->errors());
             Redirect::to('changepassword');
         }
     }
 }
Example #16
0
 public function changeSubscription(User $user, array $addLists, array $deleteLists)
 {
     foreach ($addLists as $listId) {
         $list = $this->getAccount()->lists->getById($listId);
         try {
             $custom_fields = array();
             foreach ($this->getConfig('fields', array()) as $f) {
                 $custom_fields[$f] = (string) $user->get($f);
                 if (!strlen($custom_fields[$f])) {
                     $custom_fields[$f] = (string) $user->data()->get($f);
                 }
             }
             $info = array('email' => $user->email, 'name' => $user->getName(), 'ip_address' => $user->remote_addr);
             if ($custom_fields) {
                 $info['custom_fields'] = $custom_fields;
             }
             $subs = $list->subscribers->create($info);
         } catch (AWeberAPIException $e) {
             if ($e->getMessage() == 'email: Subscriber already subscribed.') {
                 return true;
             }
             $this->getDi()->errorLogTable->log($e);
             return false;
         }
         $attr = $subs->attrs();
         $id = $attr['id'];
         $user->data()->set('aweber.' . $listId, $id)->update();
     }
     foreach ($deleteLists as $listId) {
         $uid = $user->data()->get('aweber.' . $listId);
         if (!$uid) {
             return true;
         }
         $list = $this->getAccount()->lists->getById($listId);
         $sub = $list->subscribers->getById($uid);
         $res = $sub->delete();
         $user->set('aweber.' . $listId, null)->update();
     }
     return true;
 }
Example #17
0
 public function payoutInfoAction()
 {
     $form = new Am_Form();
     $form->setAction($this->getUrl());
     $this->getModule()->addPayoutInputs($form);
     $form->addSubmit('_save', array('value' => ___('Save')));
     $form->addDataSource(new Am_Request($d = $this->user->toArray()));
     if ($form->isSubmitted() && $form->validate()) {
         foreach ($form->getValue() as $k => $v) {
             if ($k[0] == '_') {
                 continue;
             }
             if ($k == 'aff_payout_type') {
                 $this->user->set($k, $v);
             } else {
                 $this->user->data()->set($k, $v);
             }
         }
         $this->user->update();
     }
     $this->view->form = $form;
     $this->view->display('aff/payout-info.phtml');
 }
Example #18
0
 public function get($type, $uid)
 {
     switch ($type) {
         case 'friend':
             $table = 'friends_request';
             break;
     }
     $req = $this->_db->get($table, "uid = '{$uid}' ORDER BY timestamp DESC");
     if ($req->count()) {
         $requests = $req->results();
         foreach ($requests as $request) {
             $friend = new User($request->fid);
             $friendName = $friend->data()->firstName . ' ' . $friend->data()->middleName . ' ' . $friend->data()->lastName;
             switch ($table) {
                 case 'friends_request':
                     $this->add(array('fid' => $friend->data()->id, 'username' => $friend->data()->username, 'name' => $friendName, 'profilePicture' => $friend->data()->profilePicture));
                     break;
             }
         }
         return true;
     }
     return false;
 }
$user = new User();
if (Input::exists('post') && $user->isLoggedIn()) {
    $data = Input::get('data');
    $validate = new Validate();
    $validation = $validate->check($data, array('receiver' => array('name' => 'receiver', 'required' => true), 'context' => array('name' => 'context', 'required' => true)));
    if ($validation->passed()) {
        $postId = $data['postId'];
        $reply = new DBReply();
        $receiver = $data['receiver'];
        $context = $data['context'];
        if (array_key_exists("imgs", $data)) {
            $imgs = implode("|", $data['imgs']);
        } else {
            $imgs = '';
        }
        try {
            $reply->create(array('post_id' => $postId, 'context' => $context, 'imgs' => $imgs, 'reply_time' => date('Y-m-d H:i:s'), 'sender' => $user->data()->id, 'receiver' => $receiver));
            Session::delete('post');
            //Session::flash('forum','create post successfully');
            Session::flash('post', "回帖成功");
            echo 'success';
            //Redirect::to('index.php');
        } catch (Exception $e) {
            die($e->getMessage());
        }
    } else {
        echo 'empty';
    }
} else {
    echo 'noLogin';
}
<?php

/**
 * Created by Chris on 9/29/2014 3:53 PM.
 */
require_once 'core/init.php';
$user = new User();
if (!$user->isLoggedIn()) {
    Redirect::to('index.php');
}
if (Input::exists()) {
    if (Token::check(Input::get('token'))) {
        $validate = new Validate();
        $validation = $validate->check($_POST, array('current_password' => array('required' => true, 'min' => 6), 'new_password' => array('required' => true, 'min' => 6), 'new_password_again' => array('required' => true, 'min' => 6, 'matches' => 'new_password')));
        if ($validate->passed()) {
            if (Hash::make(Input::get('current_password'), $user->data()->salt) !== $user->data()->password) {
                Session::flash('error', 'Your current password is incorrect.');
                Redirect::to('changepassword.php');
            } else {
                $salt = Hash::salt(32);
                $user->update(array('password' => Hash::make(Input::get('new_password'), $salt), 'salt' => $salt));
                Session::flash('success', 'Your password has been changed!');
                Redirect::to('index.php');
            }
        } else {
            foreach ($validate->errors() as $error) {
                echo $error, '<br>';
            }
        }
    }
}
Example #21
0
$user = new User();
if ($user->isLoggedIn()) {
    ?>
<html>
<head>
<meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <!-- Bootstrap -->
    <link href="css_login/bootstrap.min.css" rel="stylesheet">
    <link href="css_login/styles.css" rel="stylesheet">
</head>
<div class="profile">
<center><span class="txt_darkgrey">
     <p>Hello <a class="grey" href="profile.php?user=<?php 
    echo escape($user->data()->username);
    ?>
"><?php 
    echo escape($user->data()->username);
    ?>
</a>!</p>
     </span></center>
      
<div class="csi-service">
            <div class="container">
                <div class="row">
                    <div class="col-md-4">
                        <div class="csi-service-item">
                            <div>
                                <img src="css_login/images/images.jpg" class="roundrect" alt="icon" />
                                <span class="csi-service-item-header">PHEONIX EVENTS</span>
                            </div>
                            <p>CSI-DTU is known for organizing large number of exciting events both tech and non-tech.There is a lot in the bag for everyone, be it a computer geek, a gming lover, a debaterand so on.Check out all the events of PHEONIX-2015 by clicking on the button below. </p>
Example #22
0
/**
 * ***** eigentlich völlig überflüssig*******
 *
 * auf dieser seit kann der user die informationen zu seinem profil betrachten
 * momentan ist es leider nocht möglich informationen von anderen users zu betrachten,
 * da der username wia get übermittelt wird
 * vlt mit _data-> lookup in datenbank
 */
include 'includes/overall/header.php';
if ($username = Input::get('user')) {
    //user wird anhand des usernames in der datenbank gesucht
    $user = new User($username);
    if (!$user->exists()) {
        Redirect::to(404);
    } else {
        $data = $user->data();
    }
} else {
    Redirect::to('index.php');
}
?>

<h3><?php 
echo escape($data->username);
?>
</h3>

<p>Username: <?php 
echo escape($data->username);
?>
 </p>
 */
$user = new User();
//wenn der user nicht eingeloggt ist, hat er hier nicht verloren, daher weiterleiten auf index
if (!$user->isLoggedIn()) {
    Redirect::to('index.php');
}
if (Input::exists()) {
    //token beim user muss mit token auf sever übereinstimmen
    if (Token::check(Input::get('token'))) {
        $validate = new Validate();
        //die neuen passwörter werden validiert
        $validation = $validate->check($_POST, array('password_current' => array('required' => true), 'password_new' => array('required' => true, 'min' => 6), 'password_new_again' => array('required' => true, 'min' => 6, 'matches' => 'password_new')));
        //validierung war erfolgreich
        if ($validation->passed()) {
            //altes password mit dem password in der datenbank verglichen
            if (password_verify(Input::get('password_current'), $user->data()->password)) {
                //wenn auch das stimmt, kann das neue passwort in die datenbank gespeichert werden
                $user->update(array('password' => Hash::make(Input::get('password_new'))));
                //der user wird auf index weitergeleitet, dort wird die message angezeigt, dass sein pw aktualisiert wurde
                Session::flash('home', 'Your password has been changed');
                Redirect::to('index.php');
            } else {
                //falls es zu einem problem beim aktualisieren der db kommt, wird eine meldung ausgegeben
                echo 'Your current password is wrong';
            }
        } else {
            //falls die validierung nicht erfolgreich war, werden die errors ausgegeben
            foreach ($validation->errors() as $error) {
                echo $error, '<br>';
            }
        }
<?php 
if (Input::exists()) {
    if (Token::check(Input::get('token'))) {
        $validate = new Validate();
        $validation = $validate->check($_POST, array('name' => array('required' => true)));
        $uname = Input::get('name');
        if ($validation->passed()) {
            $user1 = new User();
            if ($user1->find($uname)) {
                //            echo "User exist";
                echo "<div class='text text-info'><strong>User Found. Click on your username to continue.</strong></div>";
                ?>
            <p> <a href="forgetpassCheckPoint.php" onclick="return confirm('Are you sure?')"> <?php 
                echo escape($user1->data()->username);
                ?>
 </a> </p>
        <?php 
                $_SESSION['phone'] = $user1->data()->phone;
                $_SESSION['id'] = $user1->data()->id;
                $_SESSION['flag'] = 1;
            } else {
                echo "<script>alert('User Not Found');</script>";
                //            echo "User Not Found";
            }
        } else {
            $str = "";
            foreach ($validation->errors() as $error) {
                $str .= $error;
                $str .= '\\n';
            }
            echo '<script type="text/javascript">alert("' . $str . '")</script>';
        }
Example #25
0
    //TODO: MAKE 404
}
if (!$user->isLoggedIn()) {
    Session::flash('error', 'It seems you are not logged in!');
    Redirect::to('/');
}
$db = DB::getInstance();
$q = $db->get('post', array('id', '=', escape($post_id)))->first();
if (Input::exists()) {
    if (Input::get('Submit')) {
        if (Token::check(Input::get('token'))) {
            $val = new Validation();
            $validate = $val->check($_POST, array('title' => array('required' => true), 'content' => array('required' => true)));
            if ($validate->passed()) {
                try {
                    $forums->createReply(array('title' => escape(Input::get('title')), 'post_id' => escape($post_id), 'content' => Input::get('content'), 'date' => date('Y-m-d- H:i:s'), 'user_id' => $user->data()->id));
                    Notifaction::createMessage($user->data()->username . ' posted a reply on your page', $forums->getPost2($post_id)->post_user);
                    session::flash('complete', 'You posted your reply!');
                    Redirect::to('/forums/view/' . $cat . '/' . $post_id);
                } catch (Exception $e) {
                    die($e->getMessage());
                }
            } else {
                echo 'val not passed';
            }
        } else {
            die('token failed');
        }
    } else {
        die('submit');
    }
}
Example #26
0
        if ($validation->passed()) {
            try {
                $user->update(array('name' => Input::get('name')));
                Session::flash('home', 'Your details have been updated');
                Redirect::to('index.php');
            } catch (Exception $e) {
                die($e->getMessage());
            }
        } else {
            foreach ($validation->errors() as $error) {
                echo $error, '<br>';
            }
        }
    }
}
?>

<form action="" method="post">
	<div class="field">
		<label for="name">Name</label>
		<input type="text" name="name" value="<?php 
echo escape($user->data()->name);
?>
">
		<input type="submit" value="Update">
		<input type="hidden" name="token" value="<?php 
echo Token::generate();
?>
">
	</div>
</form>

include_once '../core/init.php';
$user = DB::getInstance()->query("SELECT * FROM users");
// if (Session::exists('success')) {
//     echo "<p>";
//     echo Session::flash('success');
//     echo "</p>";
// }
$user = new User();
?>
  
                <div class="row">
                    <div class="col-md-12">
                     <h2>Image Contiributors</h2>   
                        <h5>Welcome <?php 
echo $user->data()->name;
?>
 , Love to see you back. </h5>
                    </div>
                </div>
                 <!-- /. ROW  -->
                 <hr />
               
            <div class="row">
                <div class="col-md-12">
                    <!-- Advanced Tables -->
                    <div class="panel panel-default">
                        <div class="panel-heading">
                             Available image Contributor(s) : <?php 
echo DB::getInstance()->query("SELECT * FROM users WHERE stock='stock'")->count();
?>
        $fid = $friend->data()->id;
        $friendName = $friend->data()->firstName . ' ' . $friend->data()->middleName . ' ' . $friend->data()->lastName;
        if (!$user->isFriend($fid) && $user->getFriendRequests($fid)) {
            try {
                $user->addFriend($fid);
                Session::flash('alerts', array('info' => array('type' => 'success', 'title' => 'Request Accepted'), 'alerts' => array("You are now friends with {$friendName}.")));
            } catch (Exception $e) {
                die($e->getMessage());
            }
        }
        //}
    } else {
        if (isset($_POST['delete_friend_request'])) {
            //if(Token::check(Input::get('token'))) {
            $friend = new User($_POST['friend']);
            $fid = $friend->data()->id;
            $friendName = $friend->data()->firstName . ' ' . $friend->data()->middleName . ' ' . $friend->data()->lastName;
            if (!$user->isFriend($fid) && $user->getFriendRequests($fid)) {
                try {
                    $request = new Request();
                    $request->delete('friend', array('uid' => $user->data()->id, 'fid' => $fid));
                    Session::flash('alerts', array('info' => array('type' => 'success', 'title' => 'Request Deleted'), 'alerts' => array("You deleted {$friendName}'s friend request.")));
                } catch (Exception $e) {
                    die($e->getMessage());
                }
            }
            //}
        }
    }
}
?>
Example #29
0
//     echo Session::flash('success');
//     echo "</p>";
// }
if (Session::exists('home')) {
    echo "<p>";
    echo Session::flash('home');
    echo "</p>";
}
$user = new User();
if ($user->isLoggedIn()) {
    //echo "Logged In";
    ?>
    <p>Hello
        <a href="display.php?user=<?php 
    echo $user->data()->username;
    ?>
"><?php 
    echo $user->data()->username;
    ?>
</a>
    </p>
    <ul>
        <li><a href="logout.php">Logout</a></li>
        <li><a href="update.php">Update Info</a></li>
         <li><a href="changepassword.php">Change Password</a></li>
    </ul>
<?php 
    if ($user->hasPermission('admin')) {
        echo "<p> You are an admin</p>";
    }
} else {
    echo "<p> You need to <a href='ingia.php'>log in</a> or <a href='register.php'>Register</p>";
Example #30
0
 public function form($id = "")
 {
     /*
      * Haber Form hem ekleme hemde güncellemede kullanılması için $id parametresi koyulmuştur.
      * Her yapılacak ekleme ve düzenleme işlemi için ayrı ayrı View dosyası oluşturup
      * dosya kalabalığı oluşturmak yerine bu şekilde kullanmayı tercih ediyorum
      * Eğer id boş ise haber ekleme yapar $id değeri dolu ise düzenleme yapmak için
      * $id değerine sahip ilgili haberin verisini çeker.
      * */
     if (empty($id)) {
         $head['title'] = 'Haber Ekle';
         $head['meta']['author'] = 'Bursa yazılım';
         $headData["kullaniciAdi"] = User::data()->username;
         /*
          * haberForm view sayfası hem ekleme hem düzenlemede kullanıldığı için
          * View'da ki formun action adresini de değişkenle gönderiyoruz.
          * Bu if koşulu içinde $id boş olduğu için formumuz haber ekleme formu olarak çalışacak
          * else koşulu içinde ise düzenleme yapılacağından action verileri haber/duzenle 'ye gönderecek
          * */
         $bodyVeri["data"] = ['action' => siteUrl('haber/ekle')];
         /*
          * 'haberDetay'=>["baslik"=>"","detay"=>"","etiketler"=>"","durum"=>""
          * dizilimi, haber ekleme formunda hata vermemesi için değişkenlere boş veri gönderir.
          *
          * */
         $bodyVeri["data"] = ['action' => siteUrl('haber/ekle'), 'haberDetay' => ["baslik" => "", "detay" => "", "etiketler" => "", "durum" => ""]];
     } else {
         $head['title'] = 'Haber Ekle';
         $head['meta']['author'] = 'Bursa yazılım';
         $headData["kullaniciAdi"] = User::data()->username;
         $haberDetay = $this->haberler->detay($id);
         $bodyVeri["data"] = ['action' => siteUrl('haber/duzenle/' . $id), 'haberDetay' => $haberDetay];
     }
     $data['head'] = Import::view('head', $headData, true);
     $data['footer'] = Import::view('footer', '', true);
     $data['body'] = Import::view('haberForm', $bodyVeri, true);
     Import::masterPage($data, $head);
 }