public function indexAction() { // Get, check and setup the parameters if (!($widget_id = $this->getRequest()->getParam("id"))) { throw new Stuffpress_Exception("No widget id provided to the widget controller"); } // Verify if the requested widget exist and get its data $widgets = new Widgets(); if (!($widget = $widgets->getWidget($widget_id))) { throw new Stuffpress_Exception("Invalid widget id"); } // Get the user $users = new Users(); $user = $users->getUser($widget['user_id']); // Get all sources configured for that user $properties = new Properties(array(Properties::KEY => $user->id)); // Get the bio data // User profile $this->view->username = $user->username; $this->view->first_name = $properties->getProperty('first_name'); $this->view->last_name = $properties->getProperty('last_name'); $this->view->bio = $properties->getProperty('bio'); $this->view->location = $properties->getProperty('location'); $this->view->avatar = $properties->getProperty('avatar_image'); // Get the widget properties $properties = new WidgetsProperties(array(Properties::KEY => $widget_id)); $title = $properties->getProperty('title'); $this->view->title = $title ? $title : "About {$user->username}"; }
public static function registerFakeUser($post) { $userName = $post['username']; $email = $post['email']; $fakeUser = Users::getUser($userName, $email); setcookie('eggmatters_com', md5($email), 0); return $fakeUser[0]; }
function getUser() { $db = getDB(); $app = Slim::getInstance(); // used for degugging if desired. $startTime = time(); $results = Users::getUser($db); if (!$results) { return; } // User ID is private so don't send it back to the client unset($results->user_id); sendResponse($results, $startTime); }
static function getUsers() { $sql = 'SELECT use_login FROM user;'; $sth = dbConnection()->prepare($sql); $sth->execute(); $fetch = $sth->fetchAll(); $i = 0; $users = array(); foreach ($fetch as $row) { $users[$i] = Users::getUser($row['use_login']); $i++; } return $users; }
public function expand($token) { if (!($url = $this->getUrl($token))) { return false; } if ($url['internal']) { $users = new Users(); if (!($user = $users->getUser($url['user_id']))) { return false; } $domain = Stuffpress_Application::getDomain($user); return "http://" . $domain . "/entry/" . $url['url']; } else { return $url['url']; } }
public function indexAction() { // Get, check and setup the parameters if (!($widget_id = $this->getRequest()->getParam("id"))) { throw new Stuffpress_Exception("No widget id provided to the widget controller"); } // Verify if the requested widget exist and get its data $widgets = new Widgets(); if (!($widget = $widgets->getWidget($widget_id))) { throw new Stuffpress_Exception("Invalid widget id"); } // Get the user $users = new Users(); $user = $users->getUser($widget['user_id']); // Get the widget properties $properties = new WidgetsProperties(array(Properties::KEY => $widget_id)); $title = $properties->getProperty('title'); $this->view->title = $title ? $title : "My playlist"; }
public function indexAction() { // Get, check and setup the parameters if (!($widget_id = $this->getRequest()->getParam("id"))) { throw new Stuffpress_Exception("No widget id provided to the widget controller"); } // Verify if the requested widget exist and get its data $widgets = new Widgets(); if (!($widget = $widgets->getWidget($widget_id))) { throw new Stuffpress_Exception("Invalid widget id"); } // Get the user $users = new Users(); $user = $users->getUser($widget['user_id']); // Get all sources configured for that user $properties = new Properties(array(Properties::KEY => $user->id)); // Get the friendconnect data $this->view->googlefc = $properties->getProperty('googlefc'); // Get the widget properties $properties = new WidgetsProperties(array(Properties::KEY => $widget_id)); $title = $properties->getProperty('title'); $this->view->title = $title; }
/** * Edit a users */ public function editAction() { $usersModel = new Users(); $form = $this->_getForm(false); $user = $usersModel->getUser($this->_getParam('userId')); $form->setDefaults($user); if ($this->getRequest()->isPost() && $form->isValid($_POST)) { $data = $form->getValues(); if ($usersModel->isUserNameInUse($data['user_name'], $user['user_id'])) { $form->getElement('user_name')->addValidator('customMessages', false, array('Username is already in use')); } if ($usersModel->isEmailInUse($data['user_email'], $user['user_id'])) { $form->getElement('user_email')->addValidator('customMessages', false, array('E-Mail is already in use')); } if ($form->isValid($_POST)) { $password = !empty($data['user_password']) ? $data['user_password'] : null; $usersModel->updateUser($user['user_id'], $data['user_name'], $data['user_email'], $data['user_role'], $password); $this->_helper->getHelper('Redirector')->gotoRouteAndExit(array(), 'users-index'); } } $this->view->form = $form; $this->view->users = $usersModel->getUsers(); }
private function genericVMcreateAndUserUpdate($username, $type) { $users = new Users(); $user = $users->getUser($username); if ($user != null && $user->user->vm_ip == "") { $bufferVM = null; while ($bufferVM == null) { $bufferVM = Cache::read('bufferVM'); } Cache::write('bufferVM', null); // pr($bufferVM); $users->{$type}($username, $bufferVM); $this->output['success'] = true; $this->output['new'] = true; $this->output['message'] = 'VM created with IP ' . $bufferVM['ip']; exec(Configure::read('Command.path')); } else { $this->output['success'] = true; $this->output['new'] = false; $this->output['message'] = 'VM already created with IP ' . $user->user->vm_ip; } echo json_encode($this->output); }
public function indexAction() { // Get, check and setup the parameters if (!($widget_id = $this->getRequest()->getParam("id"))) { throw new Stuffpress_Exception("No widget id provided to the widget controller"); } // Verify if the requested widget exist and get its data $widgets = new Widgets(); if (!($widget = $widgets->getWidget($widget_id))) { throw new Stuffpress_Exception("Invalid widget id"); } // Get the basename $host = trim(Zend_Registry::get("host"), '/'); // Get the user $users = new Users(); $user = $users->getUser($widget['user_id']); $username = $user->username; // Get the widget properties $properties = new WidgetsProperties(array(Properties::KEY => $widget_id)); $title = $properties->getProperty('title'); $this->view->title = $title ? $title : "Subscribe to my lifestream"; // RSS Link $this->view->feed = "http://{$host}/rss/feed.xml"; }
public function viewAction() { // Get another layout $this->_helper->layout->setlayout('story'); // Get, check and setup the parameters $story_id = $this->getRequest()->getParam("id"); $page = $this->getRequest()->getParam("page"); $page = $page == '' ? 'cover' : $page; $mode = $this->getRequest()->getParam("mode"); $embed = $this->getRequest()->getParam("embed"); $length = 8; //Verify if the requested user exist $stories = new Stories(); $story = $stories->getStory($story_id); // If not, then return to the home page with an error if (!$story) { throw new Stuffpress_NotFoundException("Story {$story_id} does not exist"); } //Get the story owner data for user properties $users = new Users(); $user = $users->getUser($story->user_id); // Load the user properties $properties = new Properties(array(Stuffpress_Db_Properties::KEY => $user->id)); // Are we the owner ? if (!$embed && $this->_application->user && $this->_application->user->id == $story->user_id) { $owner = true; } else { $owner = false; } // If the page is private, go back with an error if (!$owner && $properties->getProperty('is_private')) { throw new Stuffpress_AccessDeniedException("This page has been set as private."); } // If the story is draft, go back with an error if (!$owner && $story->is_hidden) { throw new Stuffpress_AccessDeniedException("This story has not been published yet."); } // Are we in edit mode ? if ($owner && $mode == 'edit') { $edit = true; } else { $edit = false; } $data = new StoryItems(); $count = $data->getItemsCount($story_id, $edit); $pages = ceil($count / $length); // Now we can check if the page number is valid if ($page != 'cover') { if ($page < 0) { $page = 0; } else { if ($page >= $pages) { $page = $pages - 1; } } } // If page is not a cover, get the items if ($page != 'cover') { $this->view->items = $data->getItems($story_id, $length, $page * $length, $edit); } // Add the data required by the view $this->view->embed = $embed; $this->view->username = $user->username; $this->view->edit = $edit; $this->view->owner = $owner; $this->view->image = $story->thumbnail; $this->view->user_id = $user->id; $this->view->story_id = $story->id; $this->view->story_title = $story->title; $this->view->story_subtitle = $story->subtitle; $this->view->is_private = $story->is_hidden; $this->view->is_geo = $stories->isGeo($story_id); // Navigation options $this->view->page = $page; $this->view->pages = $pages; // Add a previous button $e = $embed ? "embed/{$embed}/" : ""; if ($page == 'cover') { unset($this->view->previous); } else { if ($page == 0) { $action = $edit ? "edit" : "view"; $this->view->previous = "story/{$action}/id/{$story_id}/page/cover/{$e}"; } else { if ($page != 'cover' && $page > 0) { $action = $edit ? "edit" : "view"; $this->view->previous = "story/{$action}/id/{$story_id}/page/" . ($page - 1) . "/{$e}"; } } } // Add a next button if ($page == 'cover') { $action = $edit ? "edit" : "view"; $this->view->next = "story/{$action}/id/{$story_id}/page/0/{$e}"; } else { if ($page + 1 < $pages) { $action = $edit ? "edit" : "view"; $this->view->next = "story/{$action}/id/{$story_id}/page/" . ($page + 1) . "/{$e}"; } } // Prepare the generic view // Set the timezone to the user timezone $timezone = $story->timezone ? $story->timezone : $properties->getProperty('timezone'); date_default_timezone_set($timezone); // User provided footer (e.g. tracker) $user_footer = $properties->getProperty('footer'); $this->view->user_footer = $user_footer; // Javascript $this->view->headScript()->appendFile('js/prototype/prototype.js'); $this->view->headScript()->appendFile('js/scriptaculous/scriptaculous.js'); $this->view->headScript()->appendFile('js/storytlr/validateForm.js'); $this->view->headScript()->appendFile('js/controllers/story.js'); // Page title $this->view->headTitle($story->title . " | " . $story->subtitle); // Change layout if embedding if ($embed) { $this->_helper->layout->setlayout('embed_story'); } // Page layout $this->view->title = $properties->getProperty('title'); $this->view->subtitle = $properties->getProperty('subtitle'); $this->view->footer = $properties->getProperty('footer'); $this->view->section = "story"; }
public static function setupApplication() { // Set the default values $application = Stuffpress_Application::getInstance(); $application->user = null; $application->role = 'guest'; // Try to authenticate based on cookies try { $cookie = new Stuffpress_Cookie(); $user_id = $cookie->validate(); } catch (Exception $e) { $user_id = 0; } if ($user_id) { $users = new Users(); $user = $users->getUser($user_id); if ($user) { $application->user = $user; $application->role = 'member'; } } }
<?php require '../loader.php'; /** * get thread messages */ $thread_id = input_get('thread_id'); if ($thread_id) { $users = new Users(); $threads = new Threads(); $messages = new Messages(); $thread_messages_ids = $threads->getThreadMessages($thread_id); $thread_users_ids = $threads->getThreadUsers($thread_id); $thread_users = array(); for ($i = 0, $count = count($thread_users_ids); $i < $count; $i++) { $thread_users[] = $users->getUser($thread_users_ids[$i]); } $thread_messages = array(); for ($i = 0, $count = count($thread_messages_ids); $i < $count; $i++) { $message = $messages->getMessage($thread_messages_ids[$i]); $message['user'] = $users->getUser($message['sender_id']); unset($message['sender_id']); $thread_messages[] = $message; } echo output_json(TRUE, ERR_EMPTY, array('users' => $thread_users, 'messages' => $thread_messages)); } else { echo output_json(FALSE, ERR_MISSING_DATA); } /* End of file get_thread_messages.php */ /* Location ./scripts/get_thread_messages.php */
public function settimestampAction() { // Get, check and setup the parameters $source_id = $this->getRequest()->getParam("source"); $item_id = $this->getRequest()->getParam("item"); $timestamp = $this->getRequest()->getParam("timestamp"); //Verify if the requested source exist $sources = new Sources(); if (!($source = $sources->getSource($source_id))) { throw new Stuffpress_Exception("Error updating timestamp for source {$source} - Invalid source"); } // Get the user $users = new Users(); $user = $users->getUser($source['user_id']); // Check if we are the owner if ($this->_application->user->id != $user->id) { throw new Stuffpress_Exception("Error updating timestamp for source {$source} - Not the owner"); } // Get the user properties $properties = new Properties($user->id); // Check if the date is valid if (!($date = Stuffpress_Date::strToTimezone($timestamp, $properties->getProperty('timezone')))) { $this->addErrorMessage("Could not understand the provided date/time"); return $this->_forward('index'); } // Ok, we can change the title of the item $model = SourceModel::newInstance($source['service'], $source); $model->setTimestamp($item_id, $date); $this->addStatusMessage("Life is cool"); // We redirect to the stream $this->_forward('index'); }
$edit_name = $_POST['edit_name']; $edit_address = $_POST['edit_address']; if ($edit->updateUser($_GET['id'], $edit_name, $edit_address)) { header("Location: manage_veiw.php"); } else { echo 'Error'; } } ?> <html> <head> <meta charset="utf-8"> </head> <body> <form method="post" action="edit_user.php?<?php echo $_SERVER['QUERY_STRING']; ?> "> <h2>Edit user</h2> <?php foreach ($edit->getUser($_GET['id']) as $value) { echo "<input type=\"text\" name=\"edit_name\" value='{$value['1']}'><br >"; echo "<input type=\"text\" name=\"edit_address\" value='{$value['2']}'><br >"; } ?> <input type="submit" value="Submit" name="button"></br> </form> </body> </html>
function restore_pwd() { $answer = array(); //ответ //считываем данные $login = null; if (isset($_POST["login"])) { $login = $_POST["login"]; $user = Users::getUser(array("login" => $login)); if (empty($user)) { //если пользователь не найден //возвращаем текст ошибки $answer["error"] = array("msg" => "Пользователь не найден", "field" => "login"); return json_encode($answer); } $pwd = Crypt::password_generate(6); $error = Users::setUserPassword(array("login" => $login, "pwd1" => $pwd, "pwd2" => $pwd)); if ($error !== Users::ERROR_NOT) { //в случае ошибки возвращаем текст ошибки $answer["error"]["field"] = "submit"; $answer["error"]["msg"] = Users::errorMsg($error); return $answer; } if (!mail($login, "Пароль на MIR-NDV", "Ваш новый пароль: " . $pwd)) { $answer["error"] = array("msg" => "Извините, но не удалось отправить письмо на Ваш почтовый ящик " . $login); return json_encode($answer); } $answer["success"] = array("msg" => "На Ваш почтовый ящик " . $login . " отправлено письмо с новым паролем "); return json_encode($answer); } else { //если uid не задан //возвращаем текст ошибки $answer["error"] = array("msg" => "Пользователь не указан", "field" => "login"); return json_encode($answer); } $answer["error"] = array("msg" => "Извините, но не удалось восстановить пароль. Попробуйте повторить еще раз."); return json_encode($answer); }
<?php include_once "../core/model.php"; include_once "../models/users.php"; include_once "../views/functions.php"; $id_user = getIdFromUrl(); $user = new Users(); $user->getUser($id_user); include_once "admin-header.php"; echo "<a href='" . PATHSITE . "/admin-users'>Вернуться</a>"; // or href="javascript:history.go(-1)" ?> <h2>Настройки пользователя</h2> <form name="admin-user" action="http://localhost/iba/user/update" method="post" onsubmit="alert('Данные успешно сохранены!');"> <input type="hidden" id="id_user" name="id_user" value="<?php echo $user->id; ?> "> <label>Ваше имя:</label> <input type="text" id="name" name="name" maxlength="25" value="<?php echo $user->name; ?> " required> <label>Фамилия:</label> <input type="text" id="surname" name="surname" maxlength="25" value="<?php echo $user->surname; ?> " required>
protected function updateTwitter($items) { // Get the user $users = new Users(); $user = $users->getUser($this->getUserID()); // Get twitter credentials $properties = new Properties(array(Properties::KEY => $user->id)); $auth = $properties->getProperty('twitter_auth'); $services = $properties->getProperty('twitter_services'); $username = $properties->getProperty('twitter_username'); $password = $properties->getProperty('twitter_password'); $has_preamble = $properties->getProperty('preamble', true); // Return if not all conditions are met if (!$auth || !in_array($this->getID(), unserialize($services))) { return; } // Get an item $count = count($items); $data = new Data(); $source_id = $this->_source['id']; if ($count <= 3) { foreach ($items as $id) { $item = $data->getItem($source_id, $id); $title = strip_tags($item->getTitle()); $service = $this->getServiceName(); if ($item->getType() == SourceItem::STATUS_TYPE && strlen($title) < 140) { $tweet = $title; } else { $preamble = $has_preamble ? $item->getPreamble() : ""; $tweet = $preamble . $title; $url = $users->getUrl($user->id, "/entry/" . $item->getSlug()); if (strlen($tweet) + strlen($url) > 140) { $tweet = substr($tweet, 0, 140 - strlen($url) - 5) . "... {$url}"; } else { $tweet = "{$tweet} {$url}"; } } try { $twitter = new Stuffpress_Services_Twitter($username, $password); $twitter->sendTweet($tweet); } catch (Exception $e) { } } } else { $url = $users->getUrl($user->id); $tweet = sprintf($this->_update_tweet, $count, $url); try { $twitter = new Stuffpress_Services_Twitter($username, $password); $twitter->sendTweet($tweet); } catch (Exception $e) { } } }
$wTel = inputValue("wtel"); $smarty->assign("wtel", $wTel); $cTel = inputValue("ctel"); $smarty->assign("ctel", $cTel); $ct = inputValue("ct"); $smarty->assign("ct", $ct); $ctTel = inputValue("ctt"); $smarty->assign("ctt", $ctTel); $email = inputValue("email"); $smarty->assign("email", $email); /*if no error occured insert to db and verify that insert was successful*/ if (!strcmp($error, "")) { $user = new Users(); $uid = $_GET['uid']; $update = $user->updateUsers($title, $firstName, $mname, $lastName, $address, $city, $state, $zip, $hTel, $wTel, $cTel, $ct, $ctTel, $passWord, $email, $uid); $updated = $user->getUser($uid); if (!isset($update)) { $error = "*Please choose a unique email/userId <br>"; } else { if (!isset($update)) { $error = "*An Error is occured while inserting to the Database <br>\n Please consult your Systems Administrator"; } else { $smarty->assign("userPass", $passWord); $smarty->assign("updated", $updated); $success = "*Successfully updated Customer's information"; } } } } /*else db=false*/ }
<?php require_once 'connection.php'; require_once 'Users.php'; $dbUsers = new Users($conn); // Annað dæmi um notkun: // Sækjum user (skilar fylki) $user = $dbUsers->getUser(1); // kíkjum í user array print_r($user); echo "<br>"; // birtum bara nafnið Konráð (sæti nr. 2 í array) echo "{$user['1']}";
public function disable($user_id) { $results = Users::getUser($user_id); $name = $results['Name']; $query = $this->db->query("UPDATE users SET Active='0'WHERE id='{$user_id}'"); //$this -> session -> set_userdata('message_counter', '2'); $this->session->set_userdata('msg_error', $name . ' was disabled!'); $this->session->set_flashdata('filter_datatable', $name); //Filter datatable redirect('settings_management'); }
<?php require '../loader.php'; /** * send message */ $thread_id = input_post('thread_id'); $message_body = input_post('message'); $sender_id = input_post('sender_id'); if ($thread_id && $message_body && $sender_id) { $users = new Users(); $threads = new Threads(); $messages = new Messages(); $push = new PushService(); $message_id = $messages->createMessage($thread_id, $sender_id, $message_body); $threads->addMessageToThread($thread_id, $message_id); $message = $messages->getMessage($message_id); $message['user'] = $users->getUser($message['sender_id']); unset($message['sender_id']); $push->pushMessage($message_id); echo output_json(TRUE, ERR_EMPTY, $message); } else { echo output_json(FALSE, ERR_MISSING_DATA); } /* End of file send_message.php */ /* Location ./scripts/send_message.php */
if (!isset($_POST['password']) || empty(trim($_POST['password']))) { $errors[] = "Please, Enter a valid password"; } else { $user = new Users(); $is_exist = $user->checkBeforeLogin($_POST['email'], $_POST['password']); if (!$is_exist) { $errors[] = "email or password is invalid"; } else { } } if (!empty($errors)) { $_SESSION['errors'] = $errors; echo "<meta http-equiv='Refresh' content='0;url=login.php' />"; } else { $user = new Users(); $user->getUser($_POST['email'], $_POST['password']); $_SESSION['user_id'] = $user->id; /*********** check admin my work ************/ $admin = $user->check_admin($_POST['email'], $_POST['password']); $result = $user->get_id($_POST['email'], $_POST['password']); if ($admin) { echo "<meta http-equiv='Refresh' content='1;url=admin/index.php' />"; } else { // $result=$user->lock_search($result); // foreach ($result as $key => $value) // { // if ($value) // { // $errors[]="sorry ^_^ Username and password is Lock "; // } // else
function displayDeleteUser($login) { $u = Users::getUser($login); ?> <div class="container"> <div class="well well-lg text-center"> <h2>Supression d'un utilisateur</h2> <p> Vous êtes sur le point de supprimer l'utilisateur : " <?php echo $u->firstname . ' ' . $u->lastname; ?> " </p> <p> Confirmer cette opération ? </p> <form class="form-inline" id='deleteuserform' action='.' method='post'> <input type="hidden" name="login" value="<?php echo escape($u->login); ?> " /> <div class="form-group"> <a type="submit" class="btn btn-danger" href=".">Annuler</a> <button class="btn btn-primary" type="submit" name="send"> <span class="glyphicon glyphicon-save"></span> Confirmer </button> </div> <input type="hidden" name="action" value="sendDeleteForm" /> </form> </div> </div> <?php }
private function editItem($source_id, $item_id, $values) { //Verify if the requested item exist $data = new Data(); if (!($item = $data->getItem($source_id, $item_id))) { throw new Stuffpress_NotFoundException("This item does not exist."); } // Get the user $users = new Users(); $attributes = $item->getAttributes(); $user = $users->getUser($attributes['user_id']); // Check if we are the owner if ($this->_application->user->id != $user->id) { throw new Stuffpress_NotFoundException("Not the owner"); } // Process the date if available if (@$values['date_type'] == 'other') { $timestamp = Stuffpress_Date::strToTimezone($values['date'], $this->_properties->getProperty('timezone')); } else { $timestamp = time(); } // Process the tags if available $tag_input = @$values['tags']; $tags = explode(',',$tag_input); $data->setTags($source_id, $item_id, $tags); // Process the location if available $latitude = @$values['latitude']; $longitude = @$values['longitude']; if ($latitude && $longitude) { $data->setLocation($source_id, $item_id, $latitude, $longitude, 0); } // Update the item data $data->setTimestamp($source_id, $item_id, $timestamp); switch ($item->getType()) { case SourceItem::STATUS_TYPE: $status = html_entity_decode(@$values['title']); $item->setStatus($status); break; case SourceItem::BLOG_TYPE: $title = @$values['title']; $text = @$values['text']; $item->setTitle($title); $item->setContent($text); break; case SourceItem::LINK_TYPE: $title = @$values['title']; $link = @$values['link']; $desc = @$values['text']; $item->setTitle($title); $item->setLink($link); $item->setDescription($desc); break; case SourceItem::IMAGE_TYPE: $title = @$values['title']; $desc = @$values['text']; $item->setTitle($title); $item->setDescription($desc); break; case SourceItem::AUDIO_TYPE: $title = @$values['title']; $desc = @$values['text']; $item->setTitle($title); $item->setDescription($desc); break; case SourceItem::VIDEO_TYPE: $title = @$values['title']; $desc = @$values['text']; $item->setTitle($title); $item->setDescription($desc); break; } // Send notification if twitter post is enabled if ($this->_properties->getProperty('twitter_auth') && $values['twitter_notify']) { $this->notifyTwitter($item); } // Redirect to the timeline $host = $this->getHostname(); $username = $this->_application->user->username; $url = $this->getUrl($username, "/entry/" . $item->getSlug()); return $this->_redirect($url); }
$user_id = $argv[1]; } else { die("Usage: delete.php user_id\r\n"); } } // Update after deployment for location of non-public files $root = dirname(dirname(__FILE__)); // We're assuming the Zend Framework is already on the include_path // TODO this should be moved to the boostrap file set_include_path($root . '/application' . PATH_SEPARATOR . $root . '/application/admin/models' . PATH_SEPARATOR . $root . '/application/public/models' . PATH_SEPARATOR . $root . '/application/pages/models' . PATH_SEPARATOR . $root . '/application/widgets/models' . PATH_SEPARATOR . $root . '/library' . PATH_SEPARATOR . $root . '/library/Feedcreator' . PATH_SEPARATOR . get_include_path()); require_once 'Bootstrap.php'; Bootstrap::prepare(); /* ----- Code to be executed ----- */ // Fetch the user $udb = new Users(); if (!($user = $udb->getUser($user_id))) { die("No such user with id {$user_id}"); } // Ask for confirmation fwrite(STDOUT, "Are you sure to delete user {$user->username} ({$user->email}) ? Type 'yes': "); $answer = trim(fgets(STDIN)); if ($answer != 'yes') { die("Operation aborted, nothing was deleted.\r\n"); } // Assign the shard for the database Zend_Registry::set("shard", $user->id); // Fetch all sources and delete them $sdb = new Sources(); $sources = $sdb->getSources(); // Delete all sources and associated items if ($sources && count($sources) > 0) {
protected function updateTwitter($items) { // Get the user $users = new Users(); $shortUrl = new ShortUrl(); $user = $users->getUser($this->getUserID()); // Get twitter consumer tokens and user secrets $config = Zend_Registry::get("configuration"); $consumer_key = $config->twitter->consumer_key; $consumer_secret = $config->twitter->consumer_secret; // Get twitter credentials $properties = new Properties(array(Properties::KEY => $user->id)); $auth = $properties->getProperty('twitter_auth'); $services = $properties->getProperty('twitter_services'); $oauth_token = $properties->getProperty('twitter_oauth_token'); $oauth_token_secret = $properties->getProperty('twitter_oauth_token_secret'); if (!$consumer_key || !$consumer_secret || !$oauth_token || !$oauth_token_secret) { return; } $has_preamble = $properties->getProperty('preamble', true); // Return if not all conditions are met if (!$auth || !in_array($this->getID(), unserialize($services))) { return; } // Get an item $count = count($items); $data = new Data(); $source_id = $this->_source['id']; if ($count <= 3) { foreach($items as $id) { $item = $data->getItem($source_id, $id); $title = strip_tags($item->getTitle()); $service = $this->getServiceName(); if (($item->getType() == SourceItem::STATUS_TYPE ) && strlen($title) < 140) { $tweet = $title; } else { $preamble = $has_preamble ? $item->getPreamble() : ""; $tweet = $preamble . $title; $url = $users->getUrl($user->id, "s/" . $shortUrl->shorten($item->getSlug())); if (strlen($tweet) + strlen($url) > 140) { $tweet = substr($tweet, 0, 140 - strlen($url) - 5) . "... $url"; } else { $tweet = "$tweet $url"; } } try { $connection = new TwitterOAuth_Client($consumer_key, $consumer_secret, $oauth_token, $oauth_token_secret); $response = $connection->post('statuses/update', array('status' => $tweet)); } catch (Exception $e) {} } } else { $url = $users->getUrl($user->id); $tweet = sprintf($this->_update_tweet, $count, $url); try { $twitter = new Stuffpress_Services_Twitter($username, $password); $twitter->sendTweet($tweet); } catch (Exception $e) {} } }
require '../loader.php'; /** * get user threads */ $userId = input_get('user_id'); if ($userId) { $users = new Users(); $threads = new Threads(); $messages = new Messages(); $user_threads = array(); $user_threads_ids = $users->getUserThreads($userId); if ($user_threads_ids) { for ($i = 0, $count = count($user_threads_ids); $i < $count; $i++) { $user_threads[] = array('id' => $user_threads_ids[$i]); $thread_users = $threads->getThreadUsers($user_threads_ids[$i]); $user_threads[$i]['users'] = array(); for ($j = 0, $jCount = count($thread_users); $j < $jCount; $j++) { $user_threads[$i]['users'][] = $users->getUser($thread_users[$j]); } $last_message = $messages->getMessage($threads->getLastMessageOfThread($user_threads_ids[$i])); $last_message['user'] = $users->getUser($last_message['sender_id']); unset($last_message['sender_id']); $user_threads[$i]['last_message'] = $last_message; } } echo output_json(TRUE, ERR_EMPTY, $user_threads); } else { echo output_json(FALSE, ERR_MISSING_DATA); } /* End of file get_user_threads.php */ /* Location ./scripts/get_user_threads.php */
$hTel = inputValue("htel"); $smarty->assign("htel", $hTel); $wTel = inputValue("wtel"); $smarty->assign("wtel", $wTel); $cTel = inputValue("ctel"); $smarty->assign("ctel", $cTel); $ct = inputValue("ct"); $smarty->assign("ct", $ct); $ctTel = inputValue("ctt"); $smarty->assign("ctt", $ctTel); /*if no error occured insert to db and verify that insert was successful*/ if (!strcmp($error, "")) { $user = new Users($email); $insert = $user->insertToUsers($title, $firstName, $mname, $lastName, $address, $city, $state, $zip, $hTel, $wTel, $cTel, $ct, $ctTel, $passWord); if ($insert > 0) { $inserted = $user->getUser($insert); if (isset($inserted)) { $smarty->assign("userPass", $passWord); $smarty->assign("inserted", $inserted); $smarty->assign("success", "*Successfully inserted the new Customer's information"); $smarty->assign("inFlag", "true"); } else { $error = "*email/userId MUST be unique, Please choose another email/userId"; } } else { $error = "*An Error is occured while inserting to the Database <br>\n\t\t\t\t\t\tPlease consult your Systems Administrator"; } } } /*else $_POST variable is not null*/ $smarty->assign("error", $error);
public function addAction() { if (!$this->getRequest()->isPost()) { return $this->_helper->json->sendJson(true); } $form = $this->getForm(); if (!$form->isValid($_POST)) { return $this->_helper->json->sendJson($form->getErrorArray()); } // Get the values and proceed $values = $form->getValues(); $source_id = $values['source']; $item_id = $values['item']; $name = $values['name']; $email = $values['email']; $website = $values['website']; $comment = $values['comment']; $options = $values['options']; $timestamp = time(); $notify = @in_array('notify', $options) ? 1 : 0; // Get the source and the user owning it $data = new Data(); $sources = new Sources(); $users = new Users(); // Does the source exist ? if (!($source = $sources->getSource($source_id))) { return $this->_helper->json->sendJson(true); } // Does the item exists? if (!($item = $data->getItem($source_id, $item_id))) { return $this->_helper->json->sendJson(true); } // Does the user exist ? if (!($user = $users->getUser($source['user_id']))) { return $this->_helper->json->sendJson(true); } // Validate the website URL $matches = array(); if (!preg_match_all("/^http/", $website, $matches)) { $website = "http://{$website}"; } // Add the comment to the database $comments = new Comments(); $comments->addComment($source_id, $item_id, $comment, $name, $email, $website, $timestamp, $notify); // Send an email alert to owner $on_comment = $this->_properties->getProperty('on_comment'); $owner = $this->_application->user && $this->_application->user->email == $email ? true : false; if ($on_comment && !$owner) { $slug = $item->getSlug(); Stuffpress_Emails::sendCommentEmail($user->email, $user->username, $name, $email, $comment, $slug); } // Send email alerts to everyone else (skip owner and current submiter) $subscribers = $comments->getSubscriptions($source_id, $item_id); foreach ($subscribers as $subscriber) { if ($subscriber['email'] == $user->email || $subscriber['email'] == $email) { continue; } Stuffpress_Emails::sendCommentNotifyEmail($subscriber['email'], $subscriber['name'], $name, $comment, $source_id, $item_id); } // Ok send the result return $this->_helper->json->sendJson(false); }