function verify($name, $password, $remember) { $t = new twitter($name, $password, user_type()); $user = $t->veverify(); if (!isset($user->error) && isset($user->name)) { $time = $remember ? time() + 3600 * 24 * 365 : 0; setEncryptCookie('twitterID', $name, $time, '/'); setEncryptCookie('twitterPW', $password, $time, '/'); setcookie('friends_count', $user->friends_count, $time, '/'); setcookie('statuses_count', $user->statuses_count, $time, '/'); setcookie('followers_count', $user->followers_count, $time, '/'); setcookie('imgurl', $user->profile_image_url, $time, '/'); setcookie('name', $user->name, $time, '/'); $twDM = $t->directMessages(false, false, 1); if ($twDM === false) { } else { if (count($twDM) == 0) { } else { setCookie("meSinceId", $twDM[0]->id); } } return true; } else { return false; } }
/** * take the recorded twitter screen name and parse it through the template * @param string $screenName * @return string|unknown */ protected function format($screenName) { if (trim($screenName) == '') { return ''; } require_once COM_FABRIK_FRONTEND . DS . 'libs' . DS . 'twitter' . DS . 'class.twitter.php'; $twitter = new twitter(); $params =& $this->getParams(); static $error; $tmpl = $params->get('twitter_profile_template'); $tmpl = str_replace('{screen_name}', $screenName, $tmpl); if (!$twitter->twitterAvailable()) { if (!isset($error)) { $error = true; JError::raiseNotice(500, 'Looks like twitters down'); } $tmpl = preg_replace("/{[^}\\s]+}/i", '', $tmpl); return $tmpl; } $user = $twitter->showUser($screenName); foreach ($user as $k => $v) { if (is_object($v)) { foreach ($v as $k2 => $v2) { $tmpl = str_replace('{' . $k . '.' . $k2 . '}', $v2, $tmpl); } } else { $tmpl = str_replace('{' . $k . '}', $v, $tmpl); } } $tmpl = preg_replace("/{[^}\\s]+}/i", '', $tmpl); return $tmpl; }
/** * */ function validate_request() { global $_REQUEST; $errors = array(); $link = @mysql_connect($_REQUEST['dbhost'], $_REQUEST['dbuser'], $_REQUEST['dbpass']); if (!$link) { $errors['db'][] = "Unable to connect to the database. Please check your credentials and try again."; } if (!mysql_select_db($_REQUEST['dbname'])) { $errors['db'][] = "The database name you specified does not exist."; } require_once "include/class.twitter.php"; $twitter = new twitter(); $twitter->username = $_REQUEST['twuser']; $twitter->password = $_REQUEST['twpass']; if (!$twitter->verifyCredentials()) { $errors['twitter'][] = 'The Twitter username and password you entered is incorrect. Do you need <a href="http://twitter.com/account/resend_password">a reminder of your password</a>?'; } // make sure tag has a value // make sure title and subtitle exists // make sure cache is writable if (count($errors) == 0) { return NULL; } return $errors; }
static function install() { Database::instance()->query("CREATE TABLE {twitter_tweets} (\n `id` int(9) NOT NULL AUTO_INCREMENT,\n `item_id` int(9) NOT NULL,\n `sent` int(9) NULL,\n `twitter_id` decimal(20,0) NULL,\n `tweet` varchar(255) NOT NULL,\n `user_id` int(9) NOT NULL,\n PRIMARY KEY (`id`))\n DEFAULT CHARSET=utf8;"); Database::instance()->query("CREATE TABLE {twitter_users} (\n `id` int(9) NOT NULL AUTO_INCREMENT,\n `oauth_token` varchar(64) NOT NULL,\n `oauth_token_secret` varchar(64) NOT NULL,\n `screen_name` varchar(16) NOT NULL,\n `twitter_user_id` int(9) NOT NULL,\n `user_id` int(9) NOT NULL,\n PRIMARY KEY (`id`))\n DEFAULT CHARSET=utf8;"); module::set_version("twitter", 1); twitter::reset_default_tweet(); }
/** * bit.ly module's settings * @todo Show default tweet value after resetting it! */ public function index() { $form = twitter::get_configure_form(); if (request::method() == "post") { access::verify_csrf(); if ($form->validate()) { $consumer_key = $form->twitter_oauth->consumer_key->value; $consumer_secret = $form->twitter_oauth->consumer_secret->value; $reset_tweet = $form->twitter_message->reset_tweet->value; if ($reset_tweet) { $default_tweet = twitter::reset_default_tweet(); } else { $default_tweet = $form->twitter_message->default_tweet->value; } $shorten_urls = $form->urls->shorten_urls->value; module::set_var("twitter", "consumer_key", $consumer_key); module::set_var("twitter", "consumer_secret", $consumer_secret); module::set_var("twitter", "default_tweet", $default_tweet); module::set_var("twitter", "shorten_urls", $shorten_urls); message::success("Twitter settings saved"); url::redirect("admin/twitter"); } } $is_registered = twitter::is_registered(); $v = new Admin_View("admin.html"); $v->page_title = t("Twitter"); $v->content = new View("admin_twitter.html"); $v->content->form = $form; $v->content->is_registered = $is_registered; print $v; }
function verify($name, $password, $remember) { $t = new twitter($name, $password); $user = $t->verify(); print_r($user); if (!isset($user->error) && isset($user->name)) { $time = $remember ? time() + 3600 * 24 * 365 : 0; setEncryptCookie('twitese_name', $user->screen_name, $time, '/'); setEncryptCookie('twitese_pw', $password, $time, '/'); setcookie('friends_count', $user->friends_count, $time, '/'); setcookie('statuses_count', $user->statuses_count, $time, '/'); setcookie('followers_count', $user->followers_count, $time, '/'); setcookie('imgurl', $user->profile_image_url, $time, '/'); setcookie('name', $user->name, $time, '/'); return true; } else { return $user; } }
public static function handler($data = null) { Session::init(); $key = Cache::PREFIX . 'sessionReq_' . Session::getId(); if (apc_exists($key)) { Session::setBatchVars(apc_fetch($key)); apc_delete($key); } $ip = Session::getVar('ip'); if (Session::isLoggedIn() && Session::getVar('lockToIP') && $ip != null && $ip != $_SERVER['REMOTE_ADDR']) { Session::destroy(); header('Location: ' . Url::format('/')); die; } Session::setVar('ip', $_SERVER['REMOTE_ADDR']); $twitter = new twitter(ConnectionFactory::get('redis')); Layout::set('tweets', $twitter->getOfficialTweets()); self::slowBan(); self::errorBan(); }
function tt() { echo $this->htmlheader(); $username = p("u"); $password = p("pa"); $post = p("p"); $reid = p("re"); $other = p("o"); $usertimeline = p("ut"); $count = p("count"); if (!$count) { $count = 20; } $twitter = new twitter($username, $password); if ($this->is_post() && $post) { //$username = "******"; // Twitter のアカウント //$password = "******"; // パスワード //$post = "ほげほげ"; // 投稿する内容 $twitter->update($post); } echo "<form method=POST>\r\n\t\t<br><textarea name=p id=p rows=3 cols=40></textarea><br><input type=text name=re id=re><br><input type=submit><hr>UT<input type=checkbox name=ut checked=true><input type=text name=u value='{$username}'><input type=password name=pa value='{$password}'><br><input type=text name=o value='{$other}'><input type=text name=count value={$count}></form><br>"; if ($usertimeline && $username && $password) { $result = $twitter->userTimeline; //$result=preg_replace('/\n|\r/',"",$result); var_dump($result); /*preg_match_all("/<id>([^<]+)<\/id> *<text>([^<]+)<\/text>/", $result, $matches); foreach ($matches[0] as $val) { //echo "matched: " . $val[0] . "\n"; echo "" . $val . "<br>"; }*/ echo "<hr>"; } exit; //$api_url = "http://tinyurl.com/api-create.php?url="; //$url = "http://example.com/"; //$result = @file_get_contents( $api_url.$url ); }
/** * @Route("/thankyou") * @Route("/thankyou/") */ public function thankyouAction($getTitle, $getPostContent) { $twitter = new twitter(); $twitter->setPostContent($getPostContent); $twitter->setTitle($getTitle); $twitter->setCreated(time()); $twitter->setLastEdit($getTitle); $em = $this->getDoctrine()->getManager(); $em->persist($twitter); $em->flush(); return $this->render('twitter/success.html.twig', array('getTitle' => $getTitle, 'getPostContent' => $getPostContent, 'current_year' => date("Y"))); }
$i = 0; foreach ($PRELOAD as $key) { echo "\t\tpic{$i}= new Image(" . $key['w'] . ", " . $key['h'] . ");\n"; echo "\t\tpic{$i}.src=\"" . $SITE_PREFIX . "imgs/" . $key['src'] . "\";\n"; $i++; } echo "</script>\n"; } ?> </head> <body> <?php if (isset($TWEETER) && $TWEETER) { $view_root = dirname(__FILE__) . "/"; include $view_root . "../model/twitter.php"; $twit = new twitter(); $notices = $twit->showUpdates(); $owner = explode(":", $notices); // Messy but goody $owner = $owner[0] . ':'; ?> <div class = "tweet-tweet" ><!-- I do love my tweeter --> <div class = "tweet-text" > <div class = "shim" > <?php //echo ltrim( $notices[0]['descr'], $notices[0]['owner'] . ":" ); // hackasauris rex echo ltrim($notices, $owner); ?> </div> </div> </div>
function __construct2($userscreen_name, $userpassword) { $t = new twitter(); $t->username = '******'; $t->password = '******'; //$t->verifyCredentials(); //print_r($t->responseInfo); $res = $t->showUser($userscreen_name); if ($res === false) { echo "ERROR logging in<hr/>"; echo "<pre>"; print_r($t->responseInfo); echo "</pre>"; } else { $this->userid = $res->id; $this->username = $res->name; $this->userscreen_name = $userscreen_name; $this->userpassword = $userpassword; $this->userdefaultzoom = 2; $this->userlastlogon = date(DATE_RFC822); $this->userlocation = $res->location; $this->userdescription = $res->description; $this->userprofile_image_url = $res->profile_image_url; $this->userurl = $res->url; $this->userprotected = $res->user_protected; } }
} else { $_msg .= " (scheduled)"; } $objNZBLog->writeLine($_msg); if ($run_mode) { $run_mode_result = $_msg . "<br />"; } # Twitter settings $twitter_enabled = false; # Check cURL support $curl_enabled = function_exists('curl_init') ? true : false; # The Twitter class needs the cURL library if ($appConfig->twitterenabled == "yes") { if ($curl_enabled) { # Instantiate a Twitter object $objTwitter = new twitter($appConfig->twitteruser, substr(base64_decode($appConfig->twitterpass), 13)); $strTweet = $appConfig->twittermessage; if (strpos($strTweet, '%nzbgetter') !== false) { $objSettings = new nzbg_conf("general"); $strTweet = str_replace('%nzbgetter', $objSettings->title . ' ' . $objSettings->version, $strTweet); } $twitter_enabled = true; } else { $_msg = "PHP cURL is not enabled, so no tweets are send!"; $objNZBLog->writeLine($_msg); if ($run_mode) { $run_mode_result = $_msg . "<br />"; } } } # Instantiate download list object and retreive download list as an array
} else { // not a header, but message if (preg_match("/http:\\/\\/www.vtc.com\\/products\\/[\\w\\s\\-\\!]+\\.(htm)/", $lines[$i], $matches)) { $link = $matches[0]; } $message .= $lines[$i] . "\n"; } if (trim($lines[$i]) == "") { // empty line, header section has ended $splittingheaders = false; } } $post = $subject . "\n" . $link; // shorten the url and twitter $link = urlencode($link); $productUrl = "http://api.bit.ly/v3/shorten?login="******"&apiKey=" . $apikey . "&longUrl=" . $link . "&format=json"; $short = file_get_contents($productUrl); $s = json_decode($short); // Send to twitter include_once 'twitter/twitter.php'; $curTwitter = new twitter("vtc", $vtcpass); if ($s->status_txt == 'OK') { $shorturl = $s->data->url; $twitter_status = $subject . " - " . $shorturl . " #tutorials #vtc"; $curTwitter->setStatus($twitter_status); mail($to, $subject, $shorturl, 'From:release@example.com'); } else { $er = $s->status_txt; $x = $er . " : " . $link; mail($to, $subject, $x, 'From:release@example.com'); }
# Fetch all items to array $arrQueueList = $objQueue->get_xml_as_array(); # Instantiate the Log object $objNZBLog = new nzbg_log($appConfig); # Extra check if the item to process is correct if ($_GET['t'] == $arrQueueList[$intEntryID]['matchtitle']) { # Move file to another directory using http://php.net/rename if (@rename(dirname(__FILE__) . '/__exec__/queue/' . $arrQueueList[$intEntryID]['nzb'], $appConfig->nzbfolder . $arrQueueList[$intEntryID]['nzb'])) { $objQueue->delete_download($intEntryID); $arrPlaceholders = array('ITEM' => $arrQueueList[$intEntryID]['nzb'], 'FONT_COLOR' => 'black', 'COLOR' => 'green'); $objNZBLog->writeLine("Processed \"" . $arrQueueList[$intEntryID]['nzb'] . "\" to incoming NZB directory."); # Tweet ? if ($appConfig->twitterenabled == "yes") { if (function_exists('curl_init')) { # Instantiate a Twitter object $objTwitter = new twitter($appConfig->twitteruser, substr(base64_decode($appConfig->twitterpass), 13)); $strTweet = $appConfig->twittermessage; if (strpos($strTweet, '%nzbgetter') !== false) { $objSettings = new nzbg_conf("general"); $strTweet = str_replace('%nzbgetter', $objSettings->title . ' ' . $objSettings->version, $strTweet); } $strTweet = str_replace('%download', $arrQueueList[$intEntryID]['matchtitle'], $strTweet); $objTwitter->updateStatus($strTweet); $objNZBLog->writeLine("Tweeting download " . $arrQueueList[$intEntryID]['matchtitle']); } } } else { $arrPlaceholders = array('ITEM' => 'An error occured! Please try again.', 'FONT_COLOR' => 'red', 'COLOR' => 'red'); $objNZBLog->writeLine("Failed processing \"" . $arrQueueList[$intEntryID]['nzb'] . "\" to incoming NZB directory."); } } else {
<html> <head> <title>BRN/MCHL</title> <link href="css/main.css" rel="stylesheet" type="text/css" media="screen" /> <script src="http://code.jquery.com/jquery-latest.js"></script> </head> <body> <h1>TSKTSKTSKTSKTSK</h1> <div id="c" align="center" > <div id="x" align="center" > <h2>Twitter</h2> <?php require 'class.twitter.php'; $t = new twitter(); $t->user_agent = 'mchl.me'; $t->type = 'xml'; $results = $t->userTimeline($id = '7821812'); foreach ($results as $tweets) { foreach ($tweets as $var => $val) { if ($var == 'text') { print "<tweet>{$val}<br><br></tweet>"; } //end if } //end foreach } //end foreach ?> </div>
function post_insert() { $permalink = $_POST['permalink']; if (!$permalink) { $this->view->error = 'it\'s empty'; $this->view->render('tweet/insert'); die; } if (!preg_match('/^(http(?:s)?:\\/\\/)?((www\\.twitter\\.com)|(twitter\\.com))\\/([a-zA-Z0-9_]+)\\/status\\/([0-9]+)$/', $permalink)) { $this->view->error = 'this\'s not a twitter link'; $this->view->permalink = $permalink; $this->view->render('tweet/insert'); die; } // // if ($this->model->get_tweet()) { // // } $twitter = twitter::gettwitter(); $result = $twitter->get('statuses/oembed', array('url' => $permalink, 'align' => 'center')); if ($result->errors) { $this->view->error = 'twit bulunamadı'; $this->view->permalink = $permalink; $this->view->render('tweet/insert'); die; } $response = $this->model->insert($result); header('location: /' . $response); // $this->view->data=$result; // $this->view->render('tweet/insert'); // $ch = curl_init(); // $timeout = 5; // // curl_setopt($ch, CURLOPT_URL, $permalink); // curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // curl_setopt($ch, CURLOPT_HEADER, false); // curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); // // $data = curl_exec($ch); // // curl_close($ch); // // $dom=new DOMDocument; // $dom->validateOnParse=false; // $dom->standalone=true; // $dom->preserveWhiteSpace=true; // $dom->strictErrorChecking=false; // $dom->substituteEntities=false; // $dom->recover=true; // $dom->formatOutput=false; // /* Load the XML data */ // libxml_use_internal_errors(true); // $dom->loadXML($data); // libxml_clear_errors(); // // $this->view->data=$dom->getElementsByTagName('head')->getElementsByTagName("meta"); // $this->view->render('tweet/insert'); // die; // // $this->model->insert(); // $url = explode('/', ltrim(parse_url($_POST['permalink'], PHP_URL_PATH),'/')); // $tweet_author = $url[0]; // $tweet_id =$url[2]; }
<?php require_once dirname(__FILE__) . "/config.php"; require_once dirname(__FILE__) . "/includes/class.twitter.php"; $object = new twitter($nusername); $tweets = $object->fetch_tweets($tweets_number); $followers = $object->fetch_followers($followers_number); // Gets the folder path without filename function GetFileDir($php_self) { $filename2 = ""; $filename = explode("/", $php_self); for ($i = 0; $i < count($filename) - 1; ++$i) { $filename2 .= $filename[$i] . '/'; } return $filename2; } $base_url = GetFileDir($_SERVER['PHP_SELF']); echo <<<EOD <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> \t<meta http-equiv="cache-control" content="no-cache"> \t<meta http-equiv="pragma" content="no-cache"> \t<meta http-equiv="expires" content="-1"> \t<meta http-equiv="content-type" content="text/html; charset=UTF-8"/> \t \t<link type="text/css" rel="stylesheet" media="all" href="{$base_url}/includes/css/twitter.css?v=1.0.3" /> \t </head>
static function context_menu($menu, $theme, $item) { if (identity::active_user()->id > 1 && twitter::is_registered()) { $menu->get("options_menu")->append(Menu::factory("dialog")->id("twitter")->label(t("Share on Twitter"))->css_class("ui-icon-link g-twitter-share")->url(url::site("twitter/dialog/{$item->id}"))); } }
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(); } }
<?php include_once 'twitter.php'; $curTwitter = new twitter("Stockchase", "7467632acton"); if (isset($_POST['submit'])) { $twitter_status = $_POST['twitter_stat']; if (strlen($twitter_status) > 0) { if ($curTwitter->setStatus($twitter_status) == true) { echo "<p>Updated Succesfully</p>"; } else { echo "<p>Twitter is unavailable at this time</p>"; } } else { echo "<p>Error: I won't send blank messages!</p>"; } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Set your status on Twitter</title> </head> <body> <h2>Set your status on Twitter</h2> <p><strong>What are you doing?</strong></p> <form action="<?php echo $_SERVER['PHP_SELF']; ?>
$tr = trim($tag); DB::execute('insert into blog_tag (id) values (?)', $tr); DB::execute('insert into blog_post_tag (tag_id, post_id) values (?, ?)', $tr, $p->id); } } require_once 'apps/blog/lib/Filters.php'; // autopost if ($autopost) { if ($autopost_pom) { $pom = new Pingomatic(); $pom->post($appconf['Blog']['title'], 'http://' . $_SERVER['HTTP_HOST'] . '/blog'); } if ($autopost_tw && !empty($appconf['Twitter']['username']) && !empty($appconf['Twitter']['password'])) { $b = new Bitly(); $short = $b->shorten('http://' . $_SERVER['HTTP_HOST'] . '/blog/post/' . $p->id . '/' . URLify::filter($p->title)); $t = new twitter(); $t->username = $appconf['Twitter']['username']; $t->password = $appconf['Twitter']['password']; $t->update($p->title . ' ' . $short); } } // reset blog rss cache $memcache->delete('blog_rss'); $_POST['page'] = 'blog/post/' . $p->id . '/' . URLify::filter($p->title); $lock->remove(); $this->hook('blog/edit', $_POST); $this->redirect('/blog/admin'); } $page->title = 'An Error Occurred'; echo 'Error Message: ' . $p->error; } else {
/** * Post a status update to Twitter * @param int $item_id */ public function tweet($item_id) { access::verify_csrf(); $item = ORM::factory("item", $item_id); $form = twitter::get_tweet_form($item); if ($form->validate()) { $item_url = url::abs_site($item->relative_url_cache); $user = $this->_get_twitter_user(identity::active_user()->id); $consumer_key = module::get_var("twitter", "consumer_key"); $consumer_secret = module::get_var("twitter", "consumer_secret"); require_once MODPATH . "twitter/vendor/twitteroauth/twitteroauth.php"; $connection = new TwitterOAuth($consumer_key, $consumer_secret, $user->oauth_token, $user->oauth_token_secret); $message = $form->twitter_message->tweet->value; $attach_image = $form->twitter_message->attach_image->value; if ($attach_image == 1) { $filename = APPPATH . "../var/resizes/" . $item->relative_path_cache; $handle = fopen($filename, "rb"); $image = fread($handle, filesize($filename)); fclose($handle); $response = $connection->upload('statuses/update_with_media', array('media[]' => "{$image};type=image/jpeg;filename={$filename}", 'status' => $message)); } else { $response = $connection->post('statuses/update', array('status' => $message)); } if (200 == $connection->http_code) { message::success(t("Tweet sent!")); json::reply(array("result" => "success", "location" => $item->url())); } else { message::error(t("Unable to send, your Tweet has been saved. Please try again later: %http_code, %response_error", array("http_code" => $connection->http_code, "response_error" => $response->error))); log::error("content", "Twitter", t("Unable to send tweet: %http_code", array("http_code" => $connection->http_code))); json::reply(array("result" => "success", "location" => $item->url())); } $tweet->item_id = $item_id; !empty($response->id) ? $tweet->twitter_id = $response->id : ($tweet->twitter_id = NULL); $tweet->tweet = $message; $tweet->id = $form->twitter_message->tweet_id->value; $this->_save_tweet($tweet); } else { json::reply(array("result" => "error", "html" => (string) $form)); } }
<?php foreach ($_REQUEST as $k => $v) { error_log($k . ' => ' . $v); } function connect($host, $user, $pass) { return @mysql_connect($host, $user, $pass); } if ($_REQUEST['method'] == "twitter") { require "class.twitter.php"; $twitter = new twitter(); $twitter->username = $_REQUEST['username']; $twitter->password = $_REQUEST['password']; error_log("verifying twitter username and password"); $result = $twitter->verifyCredentials(); if ($result->{'error'}) { echo "false"; } else { echo "true"; } } else { if ($_REQUEST['method'] == "dbauth") { $link = connect($_REQUEST['dbhost'], $_REQUEST['dbuser'], $_REQUEST['dbpass']); if (!$link) { error_log('fail auth!!'); echo "false"; } echo "true"; } else { if ($_REQUEST['method'] == "dbname") {
/** * Post a status update to Twitter * @param int $item_id */ public function tweet($item_id) { access::verify_csrf(); $item = ORM::factory("item", $item_id); $form = twitter::get_tweet_form($item); if ($form->validate()) { $item_url = url::abs_site($item->relative_url_cache); $user = $this->_get_twitter_user(identity::active_user()->id); $consumer_key = module::get_var("twitter", "consumer_key"); $consumer_secret = module::get_var("twitter", "consumer_secret"); require_once MODPATH . "twitter/vendor/twitteroauth/twitteroauth.php"; $connection = new TwitterOAuth($consumer_key, $consumer_secret, $user->oauth_token, $user->oauth_token_secret); $message = $form->twitter_message->tweet->value; $response = $connection->post('statuses/update', array('status' => $message)); if (200 == $connection->http_code) { message::success(t("Tweet sent!")); json::reply(array("result" => "success", "location" => $item->url())); } else { message::error(t("Unable to send, your Tweet has been saved. Please try again later.")); log::error("content", "Twitter", t("Unable to send tweet: %http_code", array("http_code" => $connection->http_code))); json::reply(array("result" => "success", "location" => $item->url())); } $tweet->item_id = $item_id; !empty($response->id) ? $tweet->twitter_id = $response->id : ($tweet->twitter_id = NULL); $tweet->tweet = $message; $tweet->id = $form->twitter_message->tweet_id->value; $this->_save_tweet($tweet); } else { json::reply(array("result" => "error", "html" => (string) $form)); } }
<div class="inner-slider"> <? if ($twitterAvailable) :?> <? if ($userTimeline) :?> <? foreach ($userTimeline as $tweet) : ?> <div class="twitter__slide"> <a href="http://twitter.com/<?php echo \Arr::get($config, 'user', 'propellercomms'); ?> " class="twitter__slide__link" target="_blank"></a> <p><?php echo twitter::convertLinks($tweet->text); ?> </p> </div> <? endforeach; ?> <? else : ?> <p>Twitter is down. Try again later.</p> <? endif;?> <? else :?>