public function getFeed() { $biz = 'gjelina-venice-2'; $url = 'http://api.yelp.com/v2/business/' . $biz; $this->token = env('YELP_ACCESS_TOKEN'); $this->secret = env('YELP_ACCESS_TOKEN_SECRET'); $this->consumer_key = env('YELP_CONSUMER_KEY'); $this->consumer_secret = env('YELP_CONSUMER_SECRET'); // Token object built using the OAuth library $token = new OAuthToken($this->token, $this->token_secret); // Consumer object built using the OAuth library $consumer = new OAuthConsumer($this->consumer_key, $this->consumer_secret); // Yelp uses HMAC SHA1 encoding $signature_method = new OAuthSignatureMethod_HMAC_SHA1(); // Build OAuth Request using the OAuth PHP library. Uses the consumer and token object created above. $oauthrequest = OAuthRequest::from_consumer_and_token($consumer, $token, 'GET', $url); // Sign the request $oauthrequest->sign_request($signature_method, $consumer, $token); // Get the signed URL $signed_url = $oauthrequest->to_url(); //$signed_url = str_replace("gjelina-venice-2?", "gjelina-venice-2&", $signed_url); echo $signed_url . "<br><br>"; $r = $this->callCurl($signed_url); $arr = json_decode($r); printR($arr); // foreach($arr->error as $k=>$v) { // echo rawurldecode($v)."<br><br>"; // } printR($r); exit; }
public function searchAction() { $bizArr = array(); $yelpBlvd = new YelpBlvd(); $arr = $yelpBlvd->search(); printR($arr); foreach ($arr as $key => $obj) { foreach ($obj->businesses as $index => $obj2) { $bizArr[$obj2->name] = $obj2->id; } } printR($bizArr); foreach ($bizArr as $name => $id) { $blvdEnt = $this->getBlvdMapper()->getBlvd(0, $name); if ($blvdEnt) { if ($blvdEnt->getYelp() != '') { continue; } $blvdEnt->setYelp($id); $this->getBlvdMapper()->saveBlvd($blvdEnt); } else { echo "<br>nothing found for: " . $name . "|" . $id . "<br>"; } } return false; }
public function getFeed() { if (($socialMediaArr = $this->instagramAdapter->getFeed()) !== false) { $this->socialMediaObj->addSocialMedia($socialMediaArr); } printR($socialMediaArr); exit('done'); }
public static function getCategory($slug) { // get category members $r = Member::getCategoryMembers($slug); printR($r); exit; // get member social media }
/** * Add a member (eg. twitter follower) to members table and try to categorize them * based on words in their description matching category words and/or scrape wikipedia page * */ public function addNewMembers(array $membersArr, $addToMembers = false, $matchToSimiliarSocialIds = false, $categorize = false) { // set member_social_id to lowercase and set member_social_id as key in members array $formattedMembersArr = []; foreach ($membersArr as $key => $arr) { $arr['member_social_id'] = strtolower($arr['member_social_id']); $formattedMembersArr[$arr['member_social_id']] = $arr; } $membersArr = $formattedMembersArr; /*// set to member_social_id to lowercase array_walk($membersArr, function(&$m) { $m['member_social_id'] = strtolower($m['member_social_id']); }); */ // only returns members with no matching member_social_id in member_social_id table // members in this membersArr will have no id from member table $newMembersArr = $this->getMemberSocialIdsNotInDB($membersArr); // get members not in newMembersArr (ie members already in db) $membersInDBArr = array_diff_key($membersArr, $newMembersArr); // update avatars of members not in newMembersArr (ie members already in db) printR($membersInDBArr); $this->updateAvatars($membersInDBArr); //update website of members not in newMembersArr $this->updateWebsiteUrl($membersInDBArr); $noMemberIdArr = array(); foreach ($newMembersArr as $key => $arr) { $memberEnt = new \App\MemberEntity(); $memberEnt = $memberEnt->init($arr); if ($matchToSimiliarSocialIds) { $memberEnt->setId($this->getMemberIdWithSocialId($memberEnt)); } DB::beginTransaction(); // Add to main member table if ($addToMembers && $memberEnt->getId() == 0) { // no member id for this member, insert them into the member table and assign an id $memberEnt->insertMember(); } // if member does not have a member id it is because a similar social id was not found // or $addToMembers was false, so build an array of not found so that member // may be added manually if ($memberEnt->getId() == 0) { $noMemberIdArr[] = $memberEnt; continue; } // reminder: getMemberSocialIdsNotInDB() allows only members without member_social_ids to be here $this->insertMemberSocialId($memberEnt); if ($categorize) { $this->categorizeMember($memberEnt); } DB::commit(); } $this->updatePrimaryAvatars(); return $noMemberIdArr; }
public function formatResponse($response) { if (!is_object($response) || !isset($response->data)) { return false; } $entArr = array(); foreach ($response->data as $obj) { printR($obj); $instagramEnt = new InstagramEntity(); $instagramEnt->setLink($obj->link)->setCaption($obj->caption->text)->setCreatedTime($obj->caption->created_time)->setId($obj->id)->setImage($obj->images->standard_resolution->url)->setWidth($obj->images->standard_resolution->width)->setHeight($obj->images->standard_resolution->height)->setUsername($obj->user->username); $entArr[] = $instagramEnt; } return $entArr; }
public function tumblrcronAction() { $tumblrBlvd = $this->getServiceLocator()->get('TumblrMy\\Model\\TumblrBlvd'); $client = $tumblrBlvd->getTumblrClient(); $r = $client->getBlogPosts($tumblrBlvd->blog_name, $options = null); if (!is_object($r)) { return false; } foreach ($r->posts as $key => $obj) { $entArr = $tumblrBlvd->formatTumblrForGallery($obj); foreach ($entArr as $ent) { printR($ent); $this->getGalleryMapper()->insertEnt($ent); } } return false; }
/** * Get the friends that $twitterScreenName is following * */ public function getFriends() { $cursor = -1; do { $cursor = $this->twitterAdapter->getFriends($cursor); } while ($cursor > 0); $friendsArr = $this->twitterAdapter->getFriendsArr(); if (count($friendsArr) > 0) { $addToMembersTable = true; $matchToSimiliarSocialIds = false; $categorize = true; $this->socialMediaObj->addNewMembers($friendsArr, $addToMembersTable, $matchToSimiliarSocialIds, $categorize); } else { echo "No new Twitter followers to add."; } printR($friendsArr); exit('asfd'); }
public function formatFavorites($response) { if (!is_object($response)) { return false; } $entArr = array(); $arr = $response->toValue(); foreach ($arr as $i => $row) { printR($row); if (!isset($row->entities->media[0]->media_url)) { continue; } $tweetEnt = new \Twitter\Model\TweetEntity(); $tweetEnt->setTweetId($row->id_str)->setScreenName($row->user->screen_name)->setCreatedAt(date("Y-m-d H:i:s"))->setMediaUrl($row->entities->media[0]->media_url)->setMediaWidth($row->entities->media[0]->sizes->medium->w)->setMediaHeight($row->entities->media[0]->sizes->medium->h)->setStatusUrl($row->entities->media[0]->expanded_url); $entArr[] = $tweetEnt; } printR($entArr); return $entArr; }
public function getFriends() { $cursor = -1; do { $cursor = $this->yelpAdapter->getFriends($cursor); } while ($cursor > 0); // operate on the formatted twitter feed $friendsArr = $this->yelpAdapter->getFriendsArr(); if (count($friendsArr) > 0) { $addToMembersTable = true; $matchToSimiliarSocialIds = false; // use twitter account as main source of ids $categorize = true; $this->socialMediaObj->addNewMembers($friendsArr, $addToMembersTable, $matchToSimiliarSocialIds, $categorize); } else { echo "No new Twitter followers to add."; } printR($friendsArr); exit('asfd'); }
public function instagramcronAction() { $disabledArr = $this->getBlvdMapper()->getInstagramDisabledArr(); $response = $this->getInstagramModel()->fetchFeed(); $entArr = $this->getInstagramModel()->formatResponse($response); foreach ($entArr as $ent) { if (in_array(strtolower($ent->getUsername()), $disabledArr)) { continue; } printR($ent); $blvdId = $this->getBlvdMapper()->getBlvdIdWithSocialUsername($ent->getUsername(), 'instagram'); if (!$blvdId) { echo $ent->getUsername() . " did not return a blvdId \n"; continue; } $ent->setBlvdId($blvdId); $ent = $this->getInstagramModel()->formatSocialMediaEnt($ent); $this->getSocialMediaMapper()->insertSocialMedia($ent); } return false; }
public function addlinksAction() { $form = new LinkAddForm(); $linkEnt = new LinkEntity(); $form->bind($linkEnt); $request = $this->getRequest(); if ($request->isPost()) { $form->setData($request->getPost()); if ($form->isValid()) { $this->getServiceLocator()->get('Links\\Model\\LinkMapper')->save($linkEnt); $msg = 'Added!'; } else { $msg = 'Errors!'; printR($form->getMessages()); exit; $msg .= implode("<br>", $form->getMessages()); } $this->flashMessenger()->addMessage($msg); } $this->redirect()->toRoute('links', array("action" => "index")); }
/** * Parse the feed * @param array $r feed result * @return array */ public function parseFeed(array $r) { printR($r); exit; $socialMediaArr = []; foreach ($r as $key => $obj) { $memberSocialId = strtolower($obj->user->screen_name); $socialId = $obj->id_str; $link = 'https://twitter.com/' . $memberSocialId . '/status/' . $socialId; $mediaUrl = ''; $mediaHeight = ''; $mediaWidth = ''; if (!empty($obj->entities->media)) { $media = $obj->entities->media; if (isset($media[0]->media_url)) { $mediaUrl = $media[0]->media_url; $mediaHeight = $media[0]->sizes->thumb->h; $mediaWidth = $media[0]->sizes->thumb->w; } } // replace shortened urls with full urls $text = $obj->text; if (!empty($obj->entities->urls)) { foreach ($obj->entities->urls as $key => $urlObj) { $text = str_replace($urlObj->url, $urlObj->expanded_url, $text); } } // for retweets, set full retweeted text to $text if (!empty($obj->retweeted_status)) { $retweetedText = $obj->retweeted_status->text; $text = preg_match("~RT @[^:]+: (.*?)~is", $text, $arr); $text = $arr[0] . $retweetedText; } $writtenAt = date("Y-m-d H:m:i", strtotime($obj->created_at)); $socialMediaArr[] = ['memberSocialId' => $memberSocialId, 'memberId' => 0, 'socialId' => $socialId, 'text' => $text, 'link' => $link, 'mediaUrl' => $mediaUrl, 'mediaHeight' => $mediaHeight, 'mediaWidth' => $mediaWidth, 'source' => 'twitter', 'written_at' => $writtenAt]; } return $socialMediaArr; }
public function saveFacebookPagePost(FacebookEntity $facebook) { $hydrator = new ClassMethods(); $data = $hydrator->extract($facebook); $select = $this->sql->select(); $whereArr = array('username' => $facebook->getUsername(), 'post_id' => $facebook->getPostId()); $select->where($whereArr); $statement = $this->sql->prepareStatementForSqlObject($select); //echo "<br><br>".$select->getSqlString($this->dbAdapter->getPlatform()); $results = $statement->execute(); printR($data); if ($results->count() == 0) { // insert action $action = $this->sql->insert(); $action->values($data); $statement = $this->sql->prepareStatementForSqlObject($action); $result = $statement->execute(); } $blvdId = $this->getServiceLocator()->get("Blvd\\Model\\BlvdMapper")->getBlvdIdWithSocialUsername($facebook->getUsername(), 'facebook'); if ($blvdId) { $this->getServiceLocator()->get("Blvd\\Model\\SocialMediaMapper")->saveFacebook($facebook, $blvdId); } }
//if (isset($_REQUEST['id'])) { // $found = $this->app->core->select('*', 'items', array('id' => $_REQUEST['id'], 'type' => IMDB_S)); // if ($found) { // $output = $this->app->get_imdb_episodes($this->app->core->single($found)); // } //} // //if (isset($_REQUEST['title'])) { // $type = isset($_REQUEST['type']) ? $_REQUEST['type'] : false; // $this->app->get_imdb($_REQUEST['title'], false, $type); //} ?> <!-- header --> <div class="container-fluid"> <div class="sidebar"> <div class="well"> <h4>Drives</h4> <?php $this->load_module('folders'); ?> </div> </div> <div class="content"> <div class="hero-unit"> <?php printR($output); ?> </div> </div> </div> <!-- footer -->
<?php require_once "lib/base.inc.php"; $s = new Session(false); $filName = basename(__FILE__, '.php'); /*SEO*/ $title = 'Login - Access to private area'; if (isset($_POST["user"]) == true) { $user = parseField("user"); $password = parseField("password"); if ($s->login($user, $password, true, true) > 0) { $s->goToDefaultUrl('/login.php'); } else { $notification = new Notification("Error", 'Usuario y contraseƱa dont match.'); } } include "parts/header.php"; include "pages/login.php"; $doDebug = parseGet("debug"); if ($doDebug > 0) { echo isset($debug) ? $debug : ''; printR($_POST); printR($s); } include "parts/footer.php";
public function setTopCardsValueArr($topCardsValueArr) { if (count($topCardsValueArr) > 5) { echo "More than five cards in topCardsValueArr:"; printR($topCardsValueArr); printR($this); } $this->topCardsValueArr = $topCardsValueArr; return $this; }
public function evalPlayers(array $playerArr) { $evalPokerHandModel = new EvalPokerHandModel(); $topHandEnt = ''; $topHandKey = false; //must be boolean false $tieArr = array(); $loserKeyArr = array(); $playerArr = $evalPokerHandModel->evalHands($playerArr); // first find the losers before looking for ties. Out of three players, two losers that tie isn't useful foreach ($playerArr as $key => $playerModel) { $handEnt = $playerModel->getHandEntity(); if ($key == 0) { $topHandEnt = $playerModel->getHandEntity(); $topHandKey = $key; continue; } // best is 1, royal straight flush down to high card, 10 // higher rank loses $currentHandRank = $handEnt->getPokerHandRank(); $topHandRank = $topHandEnt->getPokerHandRank(); if ($currentHandRank > $topHandRank) { $loserKeyArr[$key] = $key; $loserKeyArr = $tieArr + $loserKeyArr; } elseif ($currentHandRank < $topHandRank) { $loserKeyArr[$topHandKey] = $topHandKey; $loserKeyArr = $tieArr + $loserKeyArr; $tieArr = array(); // set current hand to tops $topHandEnt = $playerModel->getHandEntity(); $topHandKey = $key; } else { $tieArr[$key] = $handEnt; //$key; $tieArr[$topHandKey] = $topHandEnt; //$topHandKey; $tmpTieEnt = $handEnt; } } /* $numLosers = count($loserKeyArr); $numPlayers = count($playerArr); // if there are more than two players left after finding losers, there is a tie if ($numPlayers - $numLosers> 1) { foreach($playerArr as $key => $playerModel) { if (in_array($key, $loserKeyArr)) { continue; } $handEnt = $playerModel->getHandEntity(); if ($key == 0) { $topHandEnt = $playerModel->getHandEntity(); $topHandKey = $key; continue; } $handEnt = $playerModel->getHandEntity(); // best is 1, royal straight flush down to high card, 10 // higher rank loses // TODO: do i need this conditional? if ($handEnt->getPokerHandRank() < $topHandEnt->getPokerHandRank()) { $tieArr = array(); $topHandKey = $key; continue; } elseif ($handEnt->getPokerHandRank() == $topHandEnt->getPokerHandRank()) { $tieArr[$key] = $handEnt; $tieArr[$topHandKey] = $topHandEnt; $topHandKey = false; // make it easy to check simple attributes the ties share $tmpTieEnt = $handEnt; } } } elseif (false) { // no tie // set winning key (player position) foreach($playerArr as $key => $playerModel) { if (!in_array($key, $loserKeyArr)) { $topHandKey = $key; break; } } } */ // evaluate any ties if (count($tieArr) > 1) { // while there may be multiple hands with three of a kind or four of a kind, their can be no permanent ties amongst them // as there aren't enough cards. eg. two three of a kinds of Jacks requires six Jacks if ($tmpTieEnt->getPokerHandRank() == 3) { //if ($tmpTieEnt->getIsFourOfAKind()) { $count = 0; foreach ($tieArr as $key => $handEnt) { if ($count == 0) { $topValue = $handEnt->getFourOf(); $topHandKey = $key; $count++; continue; } if ($handEnt->getFourOf() > $topValue) { $topHandKey = $key; $topValue = $handEnt->getFourOf(); } } } elseif ($tmpTieEnt->getPokerHandRank() == 7) { //} elseif ($tmpTieEnt->getIsThreeOfAKind()) { $count = 0; foreach ($tieArr as $key => $handEnt) { if ($count == 0) { $topValue = $handEnt->getThreeOf(); $topHandKey = $key; $count++; continue; } if ($handEnt->getThreeOf() > $topValue) { $topHandKey = $key; $topValue = $handEnt->getThreeOf(); } } //} elseif ($tmpTieEnt->getIsTwoOfAKind() || $tmpTieEnt->getIsTwoPair()) { } elseif ($tmpTieEnt->getPokerHandRank() == 9 || $tmpTieEnt->getPokerHandRank() == 8) { $count = 0; $stillTied = false; foreach ($tieArr as $key => $handEnt) { if ($count == 0) { $topCardsValueArr[$key] = $handEnt->getTopCardsValueArr(); $topValue = $handEnt->getTwoOf(); $topHandKey = $key; $count++; continue; } if ($handEnt->getTwoOf() > $topValue) { $topHandKey = $key; $topValue = $handEnt->getTwoOf(); } elseif ($handEnt->getTwoOf() == $topValue) { $stillTied = true; $topCardsValueArr[$key] = $handEnt->getTopCardsValueArr(); } } // if two pair of same value, pair of 2's versus pair of 2's if ($stillTied) { $topHandKey = false; $playerPositionArr = array(); foreach ($topCardsValueArr as $playerPositionOne => $cardOneArr) { $playerPositionArr[] = $playerPositionOne; foreach ($topCardsValueArr as $playerPositionTwo => $cardTwoArr) { if ($playerPositionOne == $playerPositionTwo) { continue; } foreach ($cardOneArr as $indexOne => $cardOneValue) { foreach ($cardTwoArr as $indexTwo => $cardTwoValue) { if ($indexOne == $indexTwo) { if ($cardOneValue < $cardTwoValue) { $topHandKey = $playerPositionTwo; break 4; } else { if ($cardOneValue > $cardTwoValue) { $topHandKey = $playerPositionOne; break 4; } } } } } } } } // unbreakable tie if ($topHandKey === false) { $playerArr[$playerPositionArr[0]]->setTiedWith(array($playerPositionArr[1])); $playerArr[$playerPositionArr[1]]->setTiedWith(array($playerPositionArr[0])); } //} elseif ($tmpTieEnt->getIsHighCard() || $tmpTieEnt->getIsStraight() || $tmpTieEnt->getIsRoyalStraightFlush() || $tmpTieEnt->getIsFlush()) { } else { if ($tmpTieEnt->getPokerHandRank() == 10 || $tmpTieEnt->getPokerHandRank() == 6 || $tmpTieEnt->getPokerHandRank() == 1 || $tmpTieEnt->getPokerHandRank() == 5) { // when these hands tie, high card determines winner // Put the values into simple arrays, but keep the key structure $topHandsArr = array(); foreach ($tieArr as $key => $handEnt) { foreach ($handEnt->getTopCardsArr() as $cardArr) { $topHandsArr[$key][] = $cardArr[0]; $topHandsKeysArr[$key] = $key; } } $topCard = 0; $loserKeyArr = array(); foreach ($topHandsArr as $keyOne => $arrOne) { // loop over each hand and compare to the other foreach ($topHandsArr as $keyTwo => $arrTwo) { // don't compare a hand to itself if ($keyOne == $keyTwo) { continue; } // if already determined that a hand lost, skip it if (in_array($keyOne, $loserKeyArr) || in_array($keyTwo, $loserKeyArr)) { continue; } // compare each card in the same position as the card in the same position in the other hand foreach ($arrOne as $indexOne => $cardValueOne) { foreach ($arrTwo as $indexTwo => $cardValueTwo) { if ($indexOne == $indexTwo) { if ($cardValueOne == $cardValueTwo) { continue; } elseif (in_array($keyOne, $loserKeyArr) || in_array($keyTwo, $loserKeyArr)) { continue; } elseif ($cardValueOne > $cardValueTwo && !isset($loserKeyArr[$keyTwo])) { // we have a winner // once designated as a loser, don't get inside this conditional again. eg. flush vs. flush, once high card is found, it is finished $loserKeyArr[$keyTwo] = $keyTwo; } elseif ($cardValueOne < $cardValueTwo && !isset($loserKeyArr[$keyOne])) { $loserKeyArr[$keyOne] = $keyOne; } } } } } } //remove losers foreach ($loserKeyArr as $loserKey) { unset($topHandsKeysArr[$loserKey]); } if (count($topHandsKeysArr) > 1) { $topHandKey = false; foreach ($topHandsKeysArr as $key => $tieKey) { // set who player is tied with $tmp = $topHandsKeysArr; unset($tmp[$tieKey]); $playerArr[$tieKey]->setTiedWith($tmp); } } else { list($topHandKey, ) = each($topHandsKeysArr); } } } } if ($topHandKey !== false) { if (!isset($playerArr[$topHandKey])) { var_dump($topHandKey); printR($this); } $playerArr[$topHandKey]->getHandEntity()->setIsWinningHand(true); } return $playerArr; }
/** * Return data for each user_id * @param array $userIdArr * @return array */ public function getTwitterFriends(array $userIdArr) { $limit = 100; $options = array(); $userArr = array(); for ($i = 0; $i < 1000; $i += $limit) { $slicedArr = array_slice($userIdArr, $i, $limit); if (count($slicedArr) == 0) { break; } $optionsArr['user_ids'] = $slicedArr; $optionsArr['include_entities'] = 1; $optionsArr['include_rts'] = 0; $optionsArr['exclude_replies'] = 1; $optionsArr['result_type'] = 'recent'; $response = $this->friendshipsLookup($optionsArr); if (!$response->isSuccess()) { $arr = $response->getErrors(); echo $arr[0]->message . "<br>"; die('B.) Something is wrong with my credentials!'); } $userArr = array_merge($userArr, $response->toValue()); } printR($userArr); return $userArr; }
public function formatTweet($obj, $twitterUserObj) { // Get most recent non-retweet status $text = ''; $created_at = ''; $tweet_id = 0; // extract expanded urls and replace shortened urls with expanded urls $media_url = ''; $media_height = 0; $media_width = 0; $status_url = ''; if (isset($obj->status)) { $source = $obj->status->source; if ($twitterUserObj->getFoodtruck() != 1 && (stristr($source, 'facebook') || stristr($source, 'instagram'))) { return false; } $tweet_id = $obj->status->id_str; $text = $obj->status->text; // if retweets are disabled for twitter user, return false $disableRetweets = $twitterUserObj->getDisableRetweets(); $disableAtTweets = $twitterUserObj->getDisableAtTweets(); if (isset($obj->status->retweeted_status) && is_object($obj->status->retweeted_status) && ($disableRetweets || $disableAtTweets)) { return false; } // if it is a retweet, get original text of tweet being retweeted as it gets truncated when being retweeted if (substr($text, 0, 4) == 'RT @' && isset($obj->status->retweeted_status->text)) { $rt = preg_match("~RT @[^:]+:~is", $text, $arr); if (isset($arr[0])) { $text = $arr[0] . " " . $obj->status->retweeted_status->text; } } $created_at = $obj->status->created_at; if (isset($obj->status->entities)) { if (isset($obj->status->entities->urls)) { foreach ($obj->status->entities->urls as $urlObj) { // 'tweetdeck' source apparently posts to twitter and instagram at once if ($twitterUserObj->getFoodtruck() != 1 && stristr($urlObj->expanded_url, "instagram")) { return false; } $text = str_replace($urlObj->url, $urlObj->expanded_url, $text); } } if (isset($obj->status->entities->media)) { foreach ($obj->status->entities->media as $urlObj) { $text = str_replace($urlObj->url, $urlObj->expanded_url, $text); // if expanded url is a status link to twitter, save it if (stristr($urlObj->expanded_url, "/status/") && $status_url == '') { $status_url = $urlObj->expanded_url; } if ($urlObj->media_url != '' && $media_url == '') { $media_url = $urlObj->media_url . ":thumb"; // all twitter thumbs are 150 x 150 $media_height = 150; $media_width = 150; //$media_height = $urlObj->sizes->large->h; //$media_width = $urlObj->sizes->large->w; break; //just get the one pic } } } } // get the tweet that this tweet is in reply to $reply_id = 0; if (false && $obj->status->in_reply_to_status_id_str != '') { $reply_id = $obj->status->in_reply_to_status_id_str; $tmp = $this->serviceLocator->get('Twitter\\Model\\TwitterBlvd')->statuses->show($reply_id); $tmp = $tmp->toValue(); echo "<hr>asdf<br>"; printR($tmp); $arr = array(); $arr['created_at'] = date("Y-m-d H:i:00", strtotime($tmp->created_at)); $arr['tweet_id'] = $tmp->id_str; $arr['screen_name'] = $tmp->user->screen_name; $arr['tweet'] = $tmp->text; $arr['twitter_id'] = $tmp->id_str; $arr['status_url'] = ''; $arr['tweet_parsed'] = ''; $arr['media_url'] = ''; $arr['media_width'] = 0; $arr['media_height'] = 0; echo "hey"; printR($arr); $tweetEnt = $this->setTweetEntity($arr); $this->saveTweet($tweetEnt); } } // If missing tweet_id, skip if ($tweet_id == 0) { return false; } $twitter_id = preg_replace("~[^0-9]~", "", $obj->id_str); $date_ut = strtotime($created_at); $created_at = date("Y-m-d H:i:00", $date_ut); $tweet_parsed = $this->utilityObj->parseText($text); $arr = array(); $arr['created_at'] = $created_at; $arr['tweet_id'] = $tweet_id; $arr['screen_name'] = $obj->screen_name; $arr['tweet'] = $text; $arr['twitter_id'] = $twitter_id; $arr['status_url'] = $status_url; $arr['tweet_parsed'] = $tweet_parsed; $arr['media_url'] = $media_url; $arr['media_width'] = $media_width; $arr['media_height'] = $media_height; $tweetEnt = $this->setTweetEntity($arr); return $tweetEnt; }
public static function getRecentItems() { $userRecord = X2Model::model('User')->findByPk(Yii::app()->user->getId()); //get array of type-ID pairs $recentItemsTemp = empty($userRecord->recentItems) ? array() : explode(',', $userRecord->recentItems); $recentItems = array(); //get record for each ID/type pair foreach ($recentItemsTemp as $item) { $itemType = strtok($item, '-'); $itemId = strtok('-'); switch ($itemType) { case 'c': // contact $record = X2Model::model('Contacts')->findByPk($itemId); break; case 't': // action $record = X2Model::model('Actions')->findByPk($itemId); break; case 'a': // account $record = X2Model::model('Accounts')->findByPk($itemId); break; case 'p': // campaign $record = X2Model::model('Campaign')->findByPk($itemId); break; case 'o': // opportunity $record = X2Model::model('Opportunity')->findByPk($itemId); break; case 'w': // workflow $record = X2Model::model('Workflow')->findByPk($itemId); break; case 's': // service case $record = X2Model::model('Services')->findByPk($itemId); break; case 'd': // document $record = X2Model::model('Docs')->findByPk($itemId); break; case 'l': // x2leads object $record = X2Model::model('X2Leads')->findByPk($itemId); break; case 'm': // media object $record = X2Model::model('Media')->findByPk($itemId); break; case 'r': // product $record = X2Model::model('Product')->findByPk($itemId); break; case 'q': // product $record = X2Model::model('Quote')->findByPk($itemId); break; case 'g': // group $record = X2Model::model('Groups')->findByPk($itemId); break; case 'f': // x2flow $record = X2Flow::model()->findByPk($itemId); break; default: printR('Warning: getRecentItems: invalid item type' . $itemType); continue; } if (!is_null($record)) { //only include item if the record ID exists array_push($recentItems, array('type' => $itemType, 'model' => $record)); } } return $recentItems; }
/** * A function to print a list of actions which are present in controller files * but no corresponding permission exists in the database. * * This function should ideally be run before each release as a developer tool * to view what permissions are missing from the software. Any controller action * with no permission associated with it is assumed to be allowed so this is * a good way to look for potential security holes. Please note that all * relevant controllers must be specified by name in the array at the top * of the function. */ public function actionFindMissingPermissions() { /**/ printR(self::findMissingPermissions()); }
public function getThumbsAction() { $galleryModel = new GalleryModel(); // width of html doc $screen_width = (int) $this->params()->fromQuery('screen_width'); //width of browser viewport $width = (int) $this->params()->fromQuery('width'); $height = (int) $this->params()->fromQuery('height'); $direction = $this->params()->fromQuery('direction'); $limit = $galleryModel->getLimit($width, $height); $page = (int) $this->params('page'); $offset = 0; if ($page > 0) { $offset = $page * $limit; } $dateYMon = $this->params('date', false); if (!$dateYMon) { $dateYMon = date("Y-M"); } else { // validate date $partsArr = explode("-", $dateYMon); if (date("Y") < $partsArr[0] || $this->getGalleryModel()->validateThreeLetterMonth($partsArr[1]) == false) { $dateYMon = date("Y-M"); } } $cache = $this->getGalleryModel()->getThumbGalleryCache($dateYMon); $key = $offset . "_" . $limit; $jsonStr = $cache->getItem($key, $success); if ($this->disableCache || !$success) { // get previous and next month dates from monthly nav arr $navArr = $this->getMonthlyNav(); $arr = $this->getGalleryModel()->getPrevAndNextDate($navArr, $dateYMon); $nextDateYMon = $arr['nextDateYMon']; $prevDateYMon = $arr['prevDateYMon']; $prevTotal = $arr['prevTotal']; $thumbArr = $this->getGalleryMapper()->fetchThumbArr($dateYMon, $offset, $limit, $prevDateYMon, $nextDateYMon, $prevTotal); printR($thumbArr); if (!$thumbArr) { $offset = 0; $dateYMon = 0; if ($direction == 'next' && $nextDateYMon) { $dateYMon = $nextDateYMon; } elseif ($prevDateYMon) { $dateYMon = $prevDateYMon; } if ($dateYMon) { $arr = $this->getGalleryModel()->getPrevAndNextDate($navArr, $dateYMon); $nextDateYMon = $arr['nextDateYMon']; $prevDateYMon = $arr['prevDateYMon']; $prevTotal = $arr['prevTotal']; $thumbArr = $this->getGalleryMapper()->fetchThumbArr($dateYMon, $offset, $limit, $prevDateYMon, $nextDateYMon, $prevTotal); } } if ($thumbArr) { $cache->setItem($key, serialize($thumbArr)); } } else { $thumbArr = unserialize($jsonStr); } $jsonModel = new JsonModel(array("result" => $thumbArr)); $jsonModel->setTerminal(true); return $jsonModel; }