//TODO check that email is valid $newUser = $_POST; //add file info for user profile picture $newUser['userimage'] = $_FILES['userimage']['name']; createUser($newUser, $_FILES['userimage'], $db); } elseif ($_GET['action'] == 'edit') { $user = new User($_SESSION['userData']); $viewedUser = new User(loadUser($db, $_GET['id'])); echo $user->isAdmin(); echo $user->getID(); if ($_GET['id'] == $user->getID()) { echo 'can edit this entry'; $userHtml = $viewedUser->displayEditable(); } else { echo 'cannot edit this entry'; $userHtml = $viewedUser->display(); } } elseif ($_GET['action'] == 'update') { } function createUser($user, $userImage, $db) { $query = 'INSERT INTO users VALUES (null, :email , :password , :fName, :lName, :imageName, :admin) '; try { $results = $db->prepare($query); $results->execute(array(':email' => $user['email'], ':password' => password_hash($user['password'], PASSWORD_DEFAULT), ':fName' => $user['fname'], ':lName' => $user['lname'], ':imageName' => $user['userimage'], ':admin' => 0)); } catch (Exception $e) { echo $e->getMessage(); exit; } $filename = "./img/" . $userImage['name']; move_uploaded_file($userImage['tmp_name'], $filename);
AuthLdap::importUserFromServers(array('name' => $_POST['login'])); } Html::back(); } else { if (isset($_POST['add_ext_auth_simple'])) { if (isset($_POST['login']) && !empty($_POST['login'])) { Session::checkRight("user", User::IMPORTEXTAUTHUSERS); $input = array('name' => $_POST['login'], '_extauth' => 1, 'add' => 1); $user->check(-1, CREATE, $input); $newID = $user->add($input); Event::log($newID, "users", 4, "setup", sprintf(__('%1$s adds the item %2$s'), $_SESSION["glpiname"], $_POST["login"])); } Html::back(); } else { Session::checkRight("user", READ); Html::header(User::getTypeName(Session::getPluralNumber()), '', "admin", "user"); $user->display(array('id' => $_GET["id"])); Html::footer(); } } } } } } } } } } } } }
public function profile() { $profile = User::display(); require_once 'views/user/profile.php'; }
item.find('div.progress').css('width', '100%'); item.find('span.progressvalue').text('100%'); var pathtofile='<a href="uploads/'+file.name+'" target="_blank" >view »</a>'; item.addClass('success').find('p.status').html('Done!!! | '+pathtofile); } }) .bind('uploadComplete', function(event, file){ $("#loading_frame").fadeIn(500); load_page("usercp.php?<?php echo isset($_REQUEST["inactive_user"]) ? "inactive_user={$_REQUEST["inactive_user"]}" : ""; ?> &selectedTab=" + $("#tabs").tabs("option", "selected")); }) }); </script> <div id="avatar_upload_control"> <div style="text-align: center;"> <span class="button" id="avatarUploadButton"></span> <div id="queuestatus"></div> <ol id="log"></ol> </div> <div style="text-align: center;"><?php echo $user->display(); ?> </div> </div> </div> </div> <?php require_once "{$_SESSION["root_path"]}/page_bottom.php";
<meta name="author" content="Thomas Machin"> <link rel="stylesheet" href="style.css"> <!--[if lt IE 9]> <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> </head> <body> <?php //if user is logged in, load their userdata if (isset($_SESSION['loggedIn'])) { echo 'logged in <br>'; $loggedIn = true; $user = new User($_SESSION['userData']); $user->display(); } else { //if not logged in, show create new user form echo 'not logged in <br>'; $loggedIn = false; ?> <div class="createuser"> <form enctype="multipart/form-data" action="users.php?action=create" method="POST"> <fieldset> <label>Email address: <input type="text" name="email" placeholder="*****@*****.**"></input></label> <br/> <label>Password: <input type="password" name="password" placeholder="password"></input></label> <br/> <label>Profile picture: <input type="file" name="userimage"></input></label> <br/> <label>First name: <input type="text" name="fname" placeholder="First name"></input></label>
function displayItem($action = '') { //print 'ACTION: '.$action.'<br>'; switch ($action) { case "intro": showIntro(); break; case "clearsession": session_destroy(); break; case "logout": session_destroy(); break; case "authenticates": if (0) { /* If oauth_token is missing get it */ if ($_REQUEST['oauth_token'] != NULL && $_SESSION['oauth_state'] === 'start') { $_SESSION['oauth_state'] = $state = 'returned'; } print "State: " . $state . "<br>"; switch ($state) { default: /* Create TwitterOAuth object with app key/secret */ $to = new TwitterOAuth($consumer_key, $consumer_secret); /* Request tokens from twitter */ $tok = $to->getRequestToken(); /* Save tokens for later */ $_SESSION['oauth_request_token'] = $token = $tok['oauth_token']; $_SESSION['oauth_request_token_secret'] = $tok['oauth_token_secret']; $_SESSION['oauth_state'] = "start"; /* Build the authorization URL */ $request_link = $to->getAuthorizeURL($token); /* Build link that gets user to twitter to authorize the app */ $content = 'Click on the link to go to twitter to authorize your account.'; $content .= '<a href="' . $request_link . '">' . $request_link . '</a>'; break; case 'returned': /* If the access tokens are already set skip to the API call */ if ($_SESSION['oauth_access_token'] === NULL && $_SESSION['oauth_access_token_secret'] === NULL) { /* Create TwitterOAuth object with app key/secret and token key/secret from default phase */ $to = new TwitterOAuth($consumer_key, $consumer_secret, $_SESSION['oauth_request_token'], $_SESSION['oauth_request_token_secret']); /* Request access tokens from twitter */ $tok = $to->getAccessToken(); /* Save the access tokens. Normally these would be saved in a database for future use. */ $_SESSION['oauth_access_token'] = $tok['oauth_token']; $_SESSION['oauth_access_token_secret'] = $tok['oauth_token_secret']; } /* Random copy */ $content = 'your account should now be registered with twitter. Check here:<br />'; $content .= '<a href="https://twitter.com/account/connections">https://twitter.com/account/connections</a>'; /* Create TwitterOAuth with app key/secret and user access key/secret */ $to = new TwitterOAuth($consumer_key, $consumer_secret, $_SESSION['oauth_access_token'], $_SESSION['oauth_access_token_secret']); /* Run request on twitter API as user. */ //Nathaniel's Additions $to = new TwitterOAuth($consumer_key, $consumer_secret, $_SESSION['oauth_access_token'], $_SESSION['oauth_access_token_secret']); $xml = new SimpleXMLElement($to->OAuthRequest('https://twitter.com/account/verify_credentials.xml', array(), 'GET')); print_r($to->OAuthRequest('https://twitter.com/account/verify_credentials.xml', array(), 'GET')); //print "|" . $_SESSION['oauth_access_token'] . " -- " . $_SESSION['oauth_access_token_secret'] . "|<br>"; $userobj = new User($xml, $_SESSION['oauth_access_token'], $_SESSION['oauth_access_token_secret']); //print "|" . $_SESSION['oauth_access_token'] . " -- " . $_SESSION['oauth_access_token_secret'] . "|<br>"; //session_start(); $_SESSION['userLoggedInID'] = (string) $userobj->userid; $userobj->display(); $db = new DB(); $db->open(); $db->insertUser($userobj); $db->close(); break; } print 'User ID: ' . $_SESSION['userLoggedInID'] . '<br>'; print_r($content); } break; case "loginas": if (!$_GET["id"]) { print 'Missing login id'; } $db = new DB(); $db->open(); $thisuser = $db->getUserByID($_GET["id"]); $db->close(); logInUser($thisuser); $thisuser->display(); print 'Welcome ' . $_SESSION['userLoggedInName'] . ' <a href="./index.php?act=logout">Log Out</a><br>'; break; case "login": print ' <form name="login" action="index.php" method="get"> Username: <input type="text" name="user" /><br> Password: <input type="password" name="pass"/><br> <input type="hidden" name="act" value="handlelogin"/> <input type="submit" value="Submit" /> </form> '; $text = $_GET["text"]; break; case "handlelogin": if (!$_GET["user"] || !$_GET["pass"]) { print '<b> Log in to TweetSampler: </b><br>'; print ' <form name="login" action="index.php" method="get"> Username: <input type="text" name="user" /><br> Password: <input type="password" name="pass"/><br> <input type="hidden" name="act" value="handlelogin"/> <input type="submit" value="Submit" /> </form> '; } else { $db = new DB(); $db->open(); if ($db->getUserLoggedIn($_GET["user"], $_GET["pass"])) { print 'Success'; } else { print 'Failure'; } $db->close(); } break; case "updatestatus": print '<form name="input" action="" method="post"> Tweet Content:<br> <textarea onkeyup="lengthchange(this);" id="tweettext" cols="50" rows="3"></textarea><br> Remaining: <span id="remaining">140</span> characters <input type="button" value="Post" onClick="javascript:submitPost(\'' . $_SESSION["userLoggedInScreenName"] . '\');"/> </form> <span id="aftersubmit"></span>'; break; case "oldupdatestatus": $t = new twitter(); $text = $_GET["text"]; echo "<b>Update Status: <b><br>"; echo $text; $tweet = $t->update($text); if ($tweet != NULL) { $tweet->display(); } else { print 'Error - Status update not posted.'; } break; case "ajaxupdatestatus": $t = new twitter(); $text = $_GET["text"]; echo "<b>Update Status: <b><br>"; echo $text; $t->update($text); break; case "updatetweets": $t = new twitter(); echo "<b>Update Tweets: <b><br>"; $t->showZoomedTweets(0, 300); break; case "deletetweets": $db = new DB(); $db->open(); echo "<b>Delete Tweets: <b><br>"; $db->deleteAllTweets(); $db->close(); break; case "deleteusertweets": $db = new DB(); $db->open(); echo "<b>Delete User Tweets: <b><br>"; $db->deleteUserTweets(); $db->close(); break; case "readtweet": $db = new DB(); $db->open(); $id = $_GET["id"]; $db->readTweetByID($id); $db->close(); break; case "showallusers": $db = new DB(); $db->open(); echo "<b>Show All Users: <b><br>"; $db->getAllUsers(); $db->close(); break; case "showzoomedtweets": print '<div class="slider" id="slider01"> <div class="left"></div> <div class="right"></div> <img src="img/knob.png" width="31" height="15" /> </div> <div id="results">Results</div>'; //Show zoomedTweets //for($i=1;$i<=20;$i++){ // print "<a href='./index.php?act=showzoomedtweets&zoom=". $i ."'> ". $i ." </a>"; // if($i != 20){ // print "|"; // } else { // print "<br>"; // } //} //$db = new DB(); //$db->open(); //echo "<b>Show Zoomed Tweets: <b><br>"; //$zoom = $_GET["zoom"]; //$db->getZoomedTweets($zoom); //$db->close(); break; case "showalltweets": $db = new DB(); $db->open(); echo "<b>Show All Tweets: </b><br>"; $db->getAllTweetsUserBlind(); $db->close(); break; case "showallmytweets": $db = new DB(); $db->open(); echo "<b>Show All Tweets: </b><br>"; $db->getAllTweets(); $db->close(); break; case "showunreadtweets": $db = new DB(); $db->open(); echo "<b>Show Unread Tweets: </b><br>"; $db->getAllUnreadTweets(); //$db->getXUnreadTweets(); $db->close(); break; case "showreadtweets": $db = new DB(); $db->open(); echo "<b>Show read Tweets: </b><br>"; $db->getAllReadTweets(); $db->close(); break; case "showlocaltweet": $db = new DB(); $db->open(); echo "<b>Show Tweet by ID: </b><br>"; $tweetid = $_GET["id"]; if ($tweetid == NULL) { print "No tweetid entered. Please try again"; break; } $tweet = $db->getTweetByID($tweetid, $_SESSION['userLoggedInID']); if ($tweet == -1) { print 'Ooops - Tweet not found locally<br>'; } else { $tweet->display(); } $db->close(); break; case "showlocaluser": print ' showlocaluser'; $db = new DB(); $db->open(); echo "<b>Show User by ID: </b><br>"; $userid = $_GET["id"]; $user = $db->getUserByID($userid); $user->display(); $db->close(); break; default: showIntro(); } }
?> "; }); </script> <div class="wrap" style="margin: 5px 0;"> <fieldset> <legend style="font-size: 1.1em;"><img src="files/site_images/layout/user-32.png" style="vertical-align: middle;"/><span style="vertical-align: middle;"> <?php echo $a->get_full_name(); ?> (<?php echo $a->display_name; ?> )</span></legend> <div style="margin: 5px;"><?php echo $a->display(); ?> </div> <div style="margin: 5px; text-align: left;"> <div><img src="files/site_images/layout/email-16.png" style="vertical-align: middle; margin: 0 5px;"/><span style="vertical-align: middle;"><?php if (empty($a->email)) { echo translate("Unknown", "Không biết"); } else { echo "<a href='mailto:{$a->email}'>{$a->email}</a>"; } ?> </span></div> <div><img src="files/site_images/layout/key-16.png" style="vertical-align: middle; margin: 0 5px;"/><span style="vertical-align: middle;"><?php switch ($a->role) { default: echo translate("Member", "Thành viên");