public function __construct(Setup $setup, Cookies $cookies, Locales $locales) { parent::__construct(); $this->setup = $setup; $this->cookies = $cookies; $this->locales = $locales; // Instantiate login method class $login_class = $this->setup->loginMethod; $this->loginMethod = new $login_class($setup, $cookies, $locales); // Error message to display to the user $this->fieldNeeded = $this->locales->locale('field-needed'); // Check if user is logged in $this->getLogin(); }
public static function recent_posts($val) { $ret = ""; $values = explode(",", $val); if (count($values) > 0) { $posts = PostData::getLast($values[0]); if (count($posts) > 0) { $ret = "<ul type='none'>"; foreach ($posts as $p) { $ret .= "<li><i class='fa fa-file-text-o'></i> <a href='./?view=post&id=" . $p->id . "'>" . $p->title . "</a></li>"; } $ret .= "</ul>"; } } return $ret; }
public function __construct(ReadComments $read_comments, Locales $locales, Cookies $cookies, Login $login, Misc $misc) { parent::__construct(); $this->readComments = $read_comments; $this->commentData = $read_comments->data; $this->setup = $read_comments->setup; $this->locales = $locales; $this->cookies = $cookies; $this->login = $login; $this->misc = $misc; $this->spamCheck = new SpamCheck($this->setup); $this->metalevels = array($this->setup->dir, $this->setup->rootDirectory . '/pages'); // Default email headers $this->setHeaders($this->setup->noreplyEmail); // URL back to comment $this->kickbackURL = $this->setup->filePath; // Add URL queries to kickback URL if (!empty($this->setup->URLQueries)) { $this->kickbackURL .= '?' . $this->setup->URLQueries; } }
public function collectInfo() { $cmd_count = 0; // $categories = array('1' => 'check-in', '2' => 'link', '3' => 'status','4'=>'photo', '5' => 'video', '6' => 'comment', '7' => 'others',); $categories = array('2' => 'link', '3' => 'status', '5' => 'video', '4' => 'photo'); $facebook = $_SESSION['facebook']; //***************Set Times*********** $all_friends = $facebook->api('/me/friends'); $days_threshold = 3; ini_set('max_execution_time', 60 * 60); $start_time = mktime(0, 0, 0, date("m"), date("d") - $days_threshold, date("Y")); $end_time = time(); $time_step = 4 * 60 * 60; //for when FB did not return the posts for a whole period of time and we had to make sub-queries //***************Set User Attributes & Save in DB**************** $user = $facebook->getUser(); if ($user) { $this->fbid = $user; $this->start_time = date("Y-m-d H:i:s", $start_time); $this->end_time = date("Y-m-d H:i:s", $end_time); $this->created_at = new CDbExpression('NOW()'); if ($this->save()) { // Yii::log('success'); // echo 'success'; } else { print_r($this->getErrors()); } } else { // echo 'cannot save user in DB!'; } $cmd_count++; $i = 0; //****************Save All Friends' Basic information in DB******************* for ($f = 0; $f < sizeof($all_friends['data']); $f++) { $fbid = $all_friends['data'][$f]['id']; $friend = new Friend(); $friend->fbid = $fbid; $friend->name = $all_friends['data'][$f]['name']; $friend->user = $this->id; if ($friend->save()) { //Yii::log('success'); // echo 'success'; } else { Yii::log($this->getErrors()); print_r($this->getErrors()); } } //*************************************Fetch News Feed (Shown Stories)********************************* //******Before, querying the whole time period did not retreive the NewsFeed Posts => // I made it to time-slots using $time_step variable => // but now, it does not work! and querying over the whole period works well! So, I came back to the first method!******** // for ($ctime = $start_time; $ctime < $end_time; $ctime += $time_step) { // $accesToken = Yii::app()->facebook->getAccessToken(); // $cmd = "me/home?fields=id,from,type,link,story,picture,source,name,description,message&limit=500&since=" . $ctime . "&until=" . ($ctime + $time_step); $cmd = "me/home?fields=id,from,type,link,story,picture,source,name,description,message,created_time&limit=500&since=" . $start_time . "&until=" . $end_time; // $cmd = "me/home?fields=id,from,type,link,story,picture,source,name,description,message&limit=500"; $me = $facebook->api($cmd); echo "cmd: " . $cmd . "<br>"; echo "size of data: " . sizeof($me['data']) . '<br>'; $cmd_count++; //************Save News Feed Stories at DB************ $saved_shown_posts_count = 0; for ($j = 0; $j < sizeof($me['data']); $j++) { $postdata = new PostData(); $postdata->user = $this->id; if (isset($me['data'][$j]['id'])) { $postdata->post_id = $me['data'][$j]['id']; // echo 'post_id(all): '. $postdata->post_id. '<br>'; } if (isset($me['data'][$i]['from'])) { //Save post's authors' attributes if (isset($me['data'][$i]['from']['id'])) { $postdata->from_id = $me['data'][$j]['from']['id']; // this is the author's Facebook ID. } if (isset($me['data'][$j]['from']['name'])) { $postdata->from_name = $me['data'][$j]['from']['name']; } if (isset($postdata->from_id)) { // $friend_id = Friend::model()->find('fbid=:fbid AND user=:user', array(':fbid' => $postdata->from_id, ':user' => $this->id)); $friend_obj = Friend::model()->find(array('select' => 'id', 'condition' => 'fbid=:fbid AND user=:user', 'params' => array(':fbid' => $postdata->from_id, ':user' => $this->id))); //echo $friend_id['id'] . '<br>'; if (isset($friend_obj['id'])) { $postdata->friend = $friend_obj['id']; //this is the autor's Database ID and it needs to be saved! } } } if (isset($me['data'][$j]['description'])) { $postdata->description = $me['data'][$j]['description']; } if (isset($me['data'][$j]['name'])) { $postdata->name = $me['data'][$j]['name']; } if (isset($me['data'][$j]['story'])) { $postdata->story = $me['data'][$j]['story']; } if (isset($me['data'][$j]['link'])) { $postdata->link = $me['data'][$j]['link']; } if (isset($me['data'][$j]['picture'])) { $postdata->picture = $me['data'][$j]['picture']; } if (isset($me['data'][$j]['message'])) { $postdata->message = $me['data'][$j]['message']; } if (isset($me['data'][$j]['source'])) { $postdata->source = $me['data'][$j]['source']; } if (isset($me['data'][$j]['created_time'])) { echo "time: " . $me['data'][$j]['created_time'] . '<br>'; $timestamp = strtotime($me['data'][$j]['created_time']); $postdata->created_time = date($timestamp); } if (isset($me['data'][$j]['type'])) { $postdata->type = $me['data'][$j]['type']; } //*****Save postdata***** if ($postdata->save()) { } else { //Yii::log($postdata->getErrors()); //echo 'cannot save this post since:<br>'; //print_r($postdata->getErrors()); return; } } }
<?php $image = PostData::getById($_POST['post_id']); $image->title = $_POST['title']; $image->user_id = Session::getUID(); $image->update(); print "<script>window.location='index.php?view=slider';</script>"; // }
<script type="text/javascript"> function loadcomments(t,r){ $.post("./?action=loadcomments","t="+t+"&r="+r, function(data){ $("#comments-"+t+"-"+r).html(data); }); } </script> <?php $team_id = $params["team_id"]; $user = $params["user"]; $posts = PostData::getAllByUserIdTeamId($user->id, $team_id); if (count($posts) > 0) { ?> <div id="statuses"> <table class="table table-bordered"> <?php /* Obtener las imagenes asociadas a un post/status */ foreach ($posts as $p) { //$pis = $p->getPIS(); ?> <tr> <td> <div class="caption" style="padding-bottom:0;"> <?php $authordata = $p->getAuthor(); $pf = ProfileData::getByUserId($authordata->id); if ($pf->image != "") { ?> <img src="<?php echo "storage/users/" . $authordata->id . "/profile/" . $pf->image; ?>
<?php if (Session::getUID() != "") { $handle = new Upload($_FILES['image']); $post = new PostData(); if ($handle->uploaded) { $url = "storage/images/"; $handle->Process($url); $post->image = $handle->file_dst_name; } $content = ""; $post->title = $_POST['title']; $post->content = ""; $post->user_id = Session::getUID(); $x = $post->add(); // setcookie("postadded",$x[1]); // print "<script>window.location='index.php?module=editpost&id=$x[1]';</script>"; print "<script>window.location='index.php?view=slider';</script>"; }
<?php $post = PostData::getById($_POST['post_id']); $post->is_slide = 1; $x = $post->update(); print "<script>window.location='index.php?view=slider';</script>";
<?php /** * BookMedik * @author evilnapsis * @url http://evilnapsis.com/about/ **/ if (isset($_POST)) { $p = PostData::getById($_POST['id']); $p->title = $_POST['title']; $p->content = $_POST['content']; $public = 0; if ($_POST['is_public']) { $public = 1; } $p->is_public = $public; // $p->user_id = 1; $p->update(); setcookie("added", $p->title); print "<script>window.location='index.php?view=editpost&id={$p->id}';</script>"; }
public function actionUpdatePosts($pid, $value) { $post_obj = PostData::model()->findByPK($pid); if (!isset($post_obj->changed)) { $post_obj->changed = $value; } else { if ($post_obj->changed == 0) { $post_obj->changed = 1; } else { $post_obj->changed = 0; } } $post_obj->save(); }
<p class='alert alert-info'><i class='icon-trash'></i> Se ha eliminado en el slider exitosamente la publicacion: <b><?php echo $post->title; ?> </b></p> <?php setcookie("slidedeleted", "", time() - 18600); unset($_COOKIE['slidedeleted']); } ?> <br> <?php // $posts = PostData::getAllByUser(Session::getUID()); $posts = PostData::getPosts(); $slides = 0; if (count($posts) > 0) { ?> <div class='posts' id='posts'> <table class="table table-bordered"> <?php foreach ($posts as $post) { ?> <tr> <td><div class='title'><a href='index.php?view=editpost&id=<?php echo $post->id; ?> '><?php echo $post->title; ?>
<?php /** * BookMedik * @author evilnapsis **/ if (isset($_POST)) { $p = new PostData(); $p->title = $_POST['title']; $p->content = $_POST['content']; $public = 0; if (isset($_POST['is_public'])) { $public = 1; } $p->is_public = $public; $p->user_id = 1; $p->add(); // setcookie("added",$p->title); print "<script>window.location='index.php?view=newpost';</script>"; }
public static function renderSlidles() { if (count(self::$posts) > 0) { $posts10 = PostData::get10ByUserId(self::$user->id); $last_id = null; // recorremos todos los posts foreach ($posts10 as $post) { $post_id = $post->id; $post_title = $post->title; $post_content = $post->content; $theme = ThemeData::getById($post->theme_id); $header_background_color = $theme->header_background_color; $header_text_color = $theme->header_text_color; $body_background_color = $theme->body_background_color; $body_text_color = $theme->body_text_color; $content = $post_content; $buttons = ""; $love_button = ""; $user_id = self::$user->id; $loved = LoveData::LoveId($post->id); if ($loved == true) { $love_button = '<button class="btn btn-danger"><i class="glyphicon glyphicon-heart"></i> Love It</button>'; } else { $love_button = <<<LLL <button id="loveit-{$post_id}" class="btn btn-default "><i class="glyphicon glyphicon-heart"></i> Love It</button> <script> \$("#loveit-"+"{$post_id}").click(function(){ \txhr = new XMLHttpRequest(); \txhr.open("POST","index.php?view=loveit"+"&postid={$post_id}",false); \txhr.send(); \tconsole.log(xhr.responseText); \t\$("#loveit-"+"{$post_id}").removeClass("btn-default"); \t\$("#loveit-"+"{$post_id}").addClass("btn-danger"); }); </script> LLL; } if ($post->image == null) { $content = $post_content; } $buttons .= '<button id="reslidle-$post_id" class="btn btn-default "><i class="glyphicon glyphicon-th-large"></i> Reslidle It</button> '; $buttons .= $love_button; print <<<XXX \t\t\t\t<div class="row"> \t\t\t\t\t<div class="col-md-12"> \t\t\t\t\t\t<div class="slide" style="box-shadow:-1px 1px 10px #999;"> \t\t\t\t\t\t\t<div class="header" style="background:{$header_background_color};color:{$header_text_color};padding:10px;"> \t\t\t\t\t\t\t\t<div class="btn-group pull-right"> \t\t\t\t\t\t\t\t <button type="button" class="btn btn-link dropdown-toggle" data-toggle="dropdown"> \t\t\t\t\t\t\t\t<i class="glyphicon glyphicon-chevron-down"></i> \t\t\t\t\t\t\t\t </button> \t\t\t\t\t\t\t\t <ul class="dropdown-menu" role="menu"> \t\t\t\t\t\t\t\t <li><a href="index.php?view=post&id={$post_id}" target="_blank"><i class="glyphicon glyphicon-eye-open"></i> Ver</a></li> \t\t\t\t\t\t\t\t <li><a href="index.php?view=editpost&id={$post_id}"><i class="glyphicon glyphicon-pencil"></i> Editar</a></li> \t\t\t\t\t\t\t\t <li class="divider"></li> \t\t\t\t\t\t\t\t <li><a href="#"><i class="glyphicon glyphicon-trash"></i> Eliminar</a></li> \t\t\t\t\t\t\t\t </ul> \t\t\t\t\t\t\t\t</div> \t\t\t \t\t\t\t\t\t\t<div style="font-size:26px;">{$post_title}</div> \t\t\t\t\t\t\t</div> \t\t\t\t\t\t\t<div class="body" style="background:{$body_background_color};color:{$theme->body_text_color};padding:10px;font-size:18px;font-wieght:none;"> \t\t\t\t\t\t\t<p>{$content}</p> \t\t\t\t\t\t\t<div class='pull-right'> \t\t\t\t\t\t\t{$buttons} \t\t\t\t\t\t\t</div> \t\t\t\t\t\t\t<div class='clearfix'></div> \t\t\t\t\t\t\t</div> \t\t\t\t\t\t</div>\t \t\t\t\t\t\t<br>\t\t\t\t \t\t\t\t\t</div> \t\t\t\t</div> XXX; $last_id = $post_id; } /// aqui termina el foreach if (count(self::$posts) > 10) { print "<div id='more-1'><button id='btn-more-1' class='btn btn-default btn-lg btn-block'><i class='glyphicon glyphicon-refresh'></i> Cargar mas ...</button></div>"; print <<<MMM \t\t\t<script> \t\t\t\t\$("#btn-more-1").click(function(){ \t\t\t\t\txhr = new XMLHttpRequest(); \t\t\t\t\txhr.open("GET","loadsldl.php?uid={$user_id}&from={$last_id}&ref=2",false); \t\t\t\t\txhr.send(); \t\t\t\t\t\$("#more-1").html(xhr.responseText); \t\t\t\t}); \t\t\t</script> MMM; } } }
<script type="text/javascript"> function loadcomments(t,r){ $.post("./?action=loadcomments","t="+t+"&r="+r, function(data){ $("#comments-"+t+"-"+r).html(data); }); } </script> <?php $from = $params["from"]; $user = $params["user"]; $posts = PostData::getAllByUserId($user->id); if (count($posts) > 0) { ?> <div id="statuses"> <table class="table table-bordered"> <?php /* Obtener las imagenes asociadas a un post/status */ foreach ($posts as $p) { //$pis = $p->getPIS(); ?> <tr> <td> <div class="caption" style="padding-bottom:0;"> <?php $authordata = $p->getAuthor(); $pf = ProfileData::getByUserId($authordata->id); if ($pf->image != "") { ?> <img src="<?php echo "storage/users/" . $authordata->id . "/profile/" . $pf->image; ?>
if (Session::exists("user_id") && !empty($_POST)) { $image = null; $image_id = 0; $handle = new Upload($_FILES['image']); if ($handle->uploaded) { $url = "storage/users/{$_SESSION['user_id']}/images/"; $handle->Process($url); // $handle->file_dst_name; $image = new ImageData(); $image->src = $handle->file_dst_name; $image->level_id = $_POST["level_id"]; $image->user_id = $_SESSION["user_id"]; $image_id = $image->add(); } $post_id = 0; if ($_POST["content"] != "") { $post = new PostData(); $post->content = $_POST["content"]; $post->level_id = $_POST["level_id"]; $post->author_ref_id = $_SESSION["user_id"]; $post->receptor_ref_id = $_SESSION["user_id"]; $post_id = $post->add(); if ($handle->uploaded) { $pi = new PostImageData(); $pi->post_id = $post_id[1]; $pi->image_id = $image_id[1]; $pi->add(); } } Core::redir("./?view=home"); }
private function parseUserInputs($form_id, &$post_id = null, $preview = false, $force_form_count = false, $specific_post_id = null) { global $post, $_post_to_create, $_current_post; // reference to the form submission method global ${'_' . StaticClass::METHOD}; $method =& ${'_' . StaticClass::METHOD}; // get post inputs if (isset($post_id) && !empty($post_id) && null !== $post_id && false !== $post_id && !$preview) { $post_id = intval($post_id); } elseif (isset($post->ID) && !$preview) { $post_id = $post->ID; } else { $post_id = false; } $formHelper = $this->_formHelper; // get recaptcha settings StaticClass::$_staticGlobal['RECAPTCHA'] = $formHelper->getRecaptchaSettings(StaticClass::$_staticGlobal['RECAPTCHA']); $form = $this->_formData; $this->_post_ID = $post_id; // load form data //$this->_formData=$formHelper->loadForm($form_id, $preview); if ($formHelper->isError($form)) { return $form; } $form_id = $form->getForm()->ID; $_fields = $form->getFields(); $form_type = $_fields['form_settings']->form['type']; $post_type = $_fields['form_settings']->post['post_type']; // if this is an edit form and no post id given if (('edit' == $form_type && false === $post_id && !$preview || isset($_GET['action']) && $_GET['action'] == 'edit_translation' && 'translation' == $form_type) && false === $post_id && !$preview) { return $formHelper->error(__('No post specified', 'wp-cred')); } // get existing post data if edit form and post given if (('edit' == $form_type && !$preview || isset($_GET['action']) && $_GET['action'] == 'edit_translation' && 'translation' == $form_type) && !$preview) { if ($_current_post == 0) { $_current_post = $post_id; } $is_current_edit = false; if (is_null($specific_post_id) && $_current_post > 0) { $is_current_edit = true; $post_id = $_current_post; } $this->_post_ID = $post_id; //$this->_postData=$formHelper->getPostData($post_id); require_once "PostData.php"; $postdata = new PostData(); $this->_postData = $postdata->getUserData($post_id); if ($formHelper->isError($this->_postData)) { return $this->_postData; } if ($is_current_edit) { $post_type = $this->_postData->post->post_type; } if (!$is_current_edit && $this->_postData->post->post_type != $post_type) { return $formHelper->error(__('User Form type and post type do not match', 'wp-cred')); } } else { //Fixed https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/186563662/comments //conditional not working after failed submition //$this->_post_ID=$post_id; //removed creates side effect to other stuff ! } // check if user has access to this form if (!$preview && !$formHelper->checkUserFormAccess($form_type, $form_id, $this->_postData)) { return $formHelper->error(); } // Deprecated // set allowed file types StaticClass::$_staticGlobal['MIMES'] = $formHelper->getAllowedMimeTypes(); // get custom post fields $fields_settings = $formHelper->getFieldSettings($post_type); // instantiate Zebra Form if (false !== $force_form_count) { $form_count = $force_form_count; } else { $form_count = StaticClass::$_globalStatic['COUNT']; } // strip any unneeded parsms from current uri $actionUri = $formHelper->currentURI(array('_tt' => time()), array('_success', '_success_message')); $prg_form_id = $formHelper->createPrgID($form_id, $form_count); $my_form_id = $formHelper->createFormID($form_id, $form_count); $this->_zebraForm = new CredForm($my_form_id, $form_type, $post_id, $actionUri, $preview); $this->_zebraForm->setLanguage(StaticClass::$_staticGlobal['LOCALES']); if ($formHelper->isError($this->_zebraForm)) { return $this->_zebraForm; } // all fine here $this->_postType = $post_type; $this->_content = $form->getForm()->post_content; $this->out_['fields'] = $fields_settings; $this->out_['count'] = $form_count; $this->out_['prg_id'] = $prg_form_id; return true; }
* @brief Agregar likes apartir del id y tipo de referencia con el usuario logeado. **/ if (Session::exists("user_id") && !empty($_POST)) { $h = HeartData::getByRUT($_POST["r"], $_SESSION["user_id"], $_POST["t"]); if ($h == null) { $h = new HeartData(); $h->ref_id = $_POST["r"]; $h->user_id = $_SESSION["user_id"]; $h->type_id = $_POST["t"]; $h->add(); echo HeartData::countByRT($_POST["r"], $_POST["t"])->c; /////////// send notifications $user_id = null; $author_id = null; if ($_POST["t"] == 1) { $post = PostData::getReceptorId($_POST["r"]); $user_id = $post->receptor_ref_id; $author_id = $post->author_ref_id; } else { if ($_POST["t"] == 2) { $post = ImageData::getUserId($_POST["r"]); $user_id = $post->user_id; $author_id = $post->user_id; } } if ($author_id != $_SESSION["user_id"] && $user_id != $_SESSION["user_id"]) { // si es el mismo autor del post, entonces no le notificamos $notification = new NotificationData(); $notification->not_type_id = 1; // like $notification->type_id = $_POST["t"];
<section class="content"> <?php if (Session::getUID() != "") { $post = PostData::getById($_GET['id']); if ($post != null) { ?> <div class='row'> <div class='col-md-10'> <a href='index.php?module=dashboard' class='btn pull-right'><i class='icon-tasks'></i></a> <h2 class='roboto'><?php echo $post->title; ?> <small>Editar</small></h2> <form enctype="multipart/form-data" method='post' action='index.php?view=updatepost' class='form-horizontal' id='form_upload'> <div class="control-group" id='title'> <label class="control-label" for="inputEmail">* TÃtulo</label> <div class="controls"> <input type="text" name='title' id="input_title" style='width:100%;' placeholder="Titulo de la publicacion" value='<?php echo $post->title; ?> '> <span class='help-inline' id='title_control'>* Debes escribir un titulo a la publicacion.</span> </div> </div> <?php if ($post->image == "") { ?> <div class="control-group">
<?php require_once 'post.php'; $data = $_REQUEST['data']; $arr_data = array('data' => $data); $url = 'http://localhost:8080/test_api'; $obj = new PostData(); $obj->setData($url, $arr_data); $res = $obj->setPost(); echo $res; /*$res = json_decode($res); $res = json_decode($res); echo nl2br("Name : ".$res->{'data'}[0]->{'name'}."\nAddress : ".$res->{'data'}[0]->{'address'}."\nCity : ".$res->{'data'}[0]->{'city'}."\nState : ".$res->{'data'}[0]->{'state'}); */
<?php if (Session::getUID() != "") { $post = PostData::getById($_GET["post_id"]); $post->del(); print "<script>window.location='index.php?view=slider';</script>"; }