function broadcast_notifixious_notice(&$model, &$rec) { $notifixkey = ''; $login = '******'; $pass = ''; $notifixurl = 'notifixio.us'; if (!isset($rec->title)) { return; } if (!get_profile_id()) { return; } $installed = environment('installed'); if (!in_array('notifixious', $installed)) { return; } if (!class_exists('Services_JSON')) { lib_include('json'); } $url = "http://" . $notifixurl . "/sources/find.json"; $params = "url=" . urlencode(get_bloginfo('rss2_url')); $results = notifixious_http_request($url . "?" . $params, "GET"); $jsonobj = json_decode($results[1]); $source_id = $jsonobj->sources->source->permalink; if ($source_id != "") { update_option('notifixiousSourceId', '' . $source_id . '', '', 'no'); update_option('notifixiousRegistered', '1', '', 'no'); update_option('notifixiousClaimed', '0', '', 'yes'); } else { update_option('notifixiousSourceId', '0', '', 'no'); update_option('notifixiousRegistered', '0', '', 'no'); } $post = get_post($rec); $title = urlencode($post->post_title); $text = urlencode($post->post_content); $link = urlencode($post->guid); $url = "http://" . urlencode($login) . ":" . urlencode($pass) . "@" . $notifixurl . "/sources/" . $source_id . "/events.json?" . "event[title]=" . $title . "&event[text]=" . $text . "&event[link]=" . $link; echo $url; exit; //http://:@?event[title]=&event[text]=&event[link]= $arr = notifixious_http_request($url, "POST"); print_r($arr); exit; }
function send_to_twitter(&$model, &$rec) { if (!get_profile_id()) { return; } // if the Record does not have a title or uri, bail out if (!isset($rec->title) || !isset($rec->uri)) { return; } if (get_option('twitter_status') != 'enabled') { return; } global $db, $prefix; $sql = "SELECT oauth_key,oauth_secret FROM " . $prefix . "twitter_users WHERE profile_id = " . get_profile_id(); $result = $db->get_result($sql); if ($db->num_rows($result) == 1) { // http://abrah.am lib_include('twitteroauth'); $key = $db->result_value($result, 0, 'oauth_key'); $secret = $db->result_value($result, 0, 'oauth_secret'); $consumer_key = environment('twitterKey'); $consumer_secret = environment('twitterSecret'); $to = new TwitterOAuth($consumer_key, $consumer_secret, $key, $secret); $notice_content = substr($rec->title, 0, 140); $content = $to->OAuthRequest('https://twitter.com/statuses/update.xml', array('status' => $notice_content), 'POST'); } else { wp_plugin_include('twitter-tools'); // set a flag on aktt global $aktt; $aktt->tweet_from_sidebar = false; // truncate the tweet at 140 chars $notice_content = substr($rec->title, 0, 140); // activate Twitter Tools $_GET['activate'] = true; // trip the init() function aktt_init(); // make a new tweet object $tweet = new aktt_tweet(); // set the tweetbody $tweet->tw_text = stripslashes($notice_content); // send the tweet to Twitter $aktt->do_tweet($tweet); } }
function send_ping(&$model, &$rec) { if (!PING) { return; } global $db; global $request; $req =& $request; $Entry =& $db->get_table('entries'); $notify_table = $model->table; $recid = $rec->id; if (!empty($db->prefix)) { $chan = $db->prefix; } else { $chan = "chan"; } if (REALTIME_HOST) { $o = owner_of($rec); $payload = array(); if (environment('threaded') && isset($rec->parent_id) && $rec->parent_id > 0) { // push a P2 comment $par = $db->get_record('posts', $rec->parent_id); $tweet = render_comment($rec, $o, $par); $payload['html'] = $tweet; if ($rec->parent_id > 0) { $payload['in_reply_to'] = "#commentcontent-" . $rec->parent_id; } else { $payload['in_reply_to'] = "#content-" . $rec->parent_id; } } else { // push a P2 tweet $o = owner_of($rec); $tweet = '<hr />' . "\n"; $tweet .= '<h4>' . "\n"; $tweet .= '<span class="meta"> <span class="actions"> <a href="' . $request->url_for(array('resource' => $notify_table, 'id' => $recid)) . '" class="thepermalink">Permalink</a> | <a href="' . $request->url_for(array('resource' => $notify_table, 'id' => $recid)) . '" class="post-reply-link" rel="' . $recid . '">Reply</a> <br />' . "\n"; $tweet .= '</span> <br />' . "\n"; $tweet .= '<img alt="" src="' . $o->avatar . '" class="avatar avatar-48" height="48" width="48" /> <a class="nick" href="' . $o->profile . '" title="Posts by ' . $o->nickname . '">' . $o->nickname . '</a> ' . laconica_time($rec->created) . ' | <a href="">0</a> </span>' . "\n"; $tweet .= '</h4>' . "\n"; $tweet .= '<div class="postcontent" id="content-<?php echo $recid; ">' . "\n"; $tweet .= '<p>' . "\n"; $tweet .= render_notice($rec->title, $rec, $o); $tweet .= '</p>' . "\n"; $tweet .= '</div>' . "\n"; $tweet .= '<!-- // postcontent -->' . "\n"; $tweet .= '<div class="bottom_of_entry">' . "\n"; $tweet .= ' ' . "\n"; $tweet .= '</div>' . "\n"; $tweet .= '<div class="commentlist">' . "\n"; $tweet .= '</div>' . "\n"; $oldstyle = false; if ($oldstyle) { $tweet = ''; $tweet .= '<li id="prologue-' . $rec->id . '" class="user_id_' . $o->id . '">'; $tweet .= '<img alt=\'\' src=\'' . $o->avatar . '\' class=\'avatar avatar-48\' height=\'48\' width=\'48\' />'; $tweet .= '<h4>'; $tweet .= '<a href="' . $o->profile . '" title="Posts by ' . $o->nickname . '">' . $o->nickname . '</a> <span class="meta">' . date("g:i A", strtotime($rec->created)) . '<em>on</em> ' . date(get_settings('date_format'), strtotime($rec->created)) . ' |'; $tweet .= ' <span class="actions">'; $tweet .= ' <a href="' . $request->url_for(array('resource' => $notify_table, 'action' => 'entry.html', 'id' => $recid)) . '" class="thepermalink">Permalink</a>'; $tweet .= ' </span>'; $tweet .= ' <br />'; $tweet .= ' </span>'; $tweet .= ' </h4>'; $tweet .= ' <div class="postcontent" id="content-' . $rec->id . '"><p>' . render_notice($rec->title, $rec, $o) . '</p></div>'; $tweet .= ' <div class="bottom_of_entry"> </div>'; $tweet .= ' <ul class="commentlist">'; // $tweet .= ' <ul id="comments" class="commentlist">'; $tweet .= ' </ul>'; $tweet .= '</li>'; } $payload['html'] = $tweet; $payload['in_reply_to'] = 0; } if (!class_exists('Services_JSON')) { lib_include('json'); } $json = new Services_JSON(); $load = $json->encode($payload); $curl = curl_init("http://" . REALTIME_HOST . ":" . REALTIME_PORT); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_TIMEOUT, 1); curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'ADDMESSAGE ' . $chan . ' ' . addslashes($load)); $output = curl_exec($curl); } if (!get_profile_id()) { return; } if (array_key_exists('target_id', $model->field_array)) { $e = $Entry->find($rec->attributes['target_id']); if ($e) { $notify_table = $e->resource; $recid = $e->record_id; } } $url = environment('ping_server'); if (empty($url)) { return; } $url .= "=" . $request->url_for(array('resource' => $notify_table, 'action' => 'entry.html', 'id' => $recid)); $curl = curl_init($url); $method = "GET"; curl_setopt($curl, CURLOPT_HEADER, false); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl, CURLOPT_HTTPGET, $method == "GET"); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($curl); }
* EVERY PHP REQUEST GOES THROUGH THIS FILE (see .htaccess in webroot) * PLEASE BE VERY CAREFUL WHEN MAKING CHANGES */ // Set the webroot if (isset($_SERVER['CONTEXT_DOCUMENT_ROOT']) && $_SERVER['CONTEXT_DOCUMENT_ROOT']) { $GLOBALS['webroot'] = $_SERVER['CONTEXT_DOCUMENT_ROOT']; } else { if (preg_match('/(\\/var\\/www\\/dev.underthecouch.org\\/[^\\/]+)\\//', __FILE__, $matches) == 1) { $GLOBALS['webroot'] = $matches[1]; } } // Require the necessary includes require_once 'common/php/constants.php'; require_once 'common/php/include.php'; lib_include('db_lib'); lib_include('session_lib'); db_include('get_webpage_access_allowed'); // Initialize the database connection get_or_connect_to_db(); // Start a session set_session_save_handler(); SessionLib::startSession(); SessionLib::registerSession(); // Make sure we can access the page we want $requested_page = $_REQUEST['file']; if (!get_webpage_access_allowed($requested_page)) { require_once '404.php'; } else { // Finally load the requested page if (isset($requested_page) && file_exists($requested_page)) { require_once $requested_page;
$GLOBALS['PATH']['app'] = $app; $GLOBALS['PATH']['library'] = $app . 'library' . DIRECTORY_SEPARATOR; $GLOBALS['PATH']['controllers'] = $app . 'controllers' . DIRECTORY_SEPARATOR; $GLOBALS['PATH']['models'] = $app . 'models' . DIRECTORY_SEPARATOR; $GLOBALS['PATH']['plugins'] = $app . 'plugins' . DIRECTORY_SEPARATOR; $GLOBALS['PATH']['dbscript'] = $GLOBALS['PATH']['library'] . 'dbscript' . DIRECTORY_SEPARATOR; /** * load dbscript minimal functions & classes */ foreach (array('_functions', 'bootloader', 'mapper', 'route', 'genericiterator', 'collection', 'view', 'cookie') as $module) { include $GLOBALS['PATH']['dbscript'] . $module . '.php'; } // load HTTP_Negotiate by Gary Court lib_include('http_negotiate'); // load Cake's inflector lib_include('inflector'); error_reporting(E_ALL & ~E_NOTICE & ~E_WARNING); $dbscript_error_handler = set_error_handler('dbscript_error'); /** * cross-platform magic-quotes init */ // turn off magic quotes @set_magic_quotes_runtime(0); // if get_magic_quotes_gpc, strip quotes or slashes if (get_magic_quotes_gpc()) { if (@ini_get('magic_quotes_sybase') == '1') { $_GET = magic_quotes_stripquotes($_GET); $_POST = magic_quotes_stripquotes($_POST); $_COOKIE = magic_quotes_stripquotes($_COOKIE); $_REQUEST = magic_quotes_stripquotes($_REQUEST); } else {
function _oauth(&$vars) { // top stream, re-connect to subtwitter-db extract($vars); global $prefix; $Blog =& $db->model('Blog'); if (empty($db->prefix)) { if (isset($_REQUEST['oauth_token'])) { $tabresult = $db->get_result("SHOW tables"); $tables = array(); $tablist = array(); for ($i = 0; $tables[$i] = mysql_fetch_assoc($tabresult); $i++) { foreach ($tables[$i] as $k => $v) { $tablist[] = $v; } } while ($b = $Blog->MoveNext()) { if (!empty($b->prefix) && in_array($b->prefix . "_db_sessions", $tablist)) { $sql = "SELECT data FROM " . $b->prefix . "_db_sessions WHERE data LIKE '%" . $db->escape_string($_REQUEST['oauth_token']) . "%'"; $result = $db->get_result($sql); if ($db->num_rows($result) == 1) { // XXX subdomain upgrade $redir = blog_url($b->nickname, true); $redir .= 'oauth_login'; $redir .= "&oauth_token=" . $_REQUEST['oauth_token']; $content = '<script type="text/javascript">' . "\n"; $content .= ' // <![CDATA[' . "\n"; $content .= " location.replace('" . $redir . "');" . "\n"; $content .= ' // ]]>' . "\n"; $content .= '</script>' . "\n"; return vars(array(&$content), get_defined_vars()); } } } } } // http://abrah.am lib_include('twitteroauth'); /* Sessions are used to keep track of tokens while user authenticates with twitter */ /* Consumer key from twitter */ $consumer_key = environment('twitterKey'); /* Consumer Secret from twitter */ $consumer_secret = environment('twitterSecret'); /* Set up placeholder */ $content = NULL; /* Set state if previous session */ $state = $_SESSION['oauth_state']; /* Checks if oauth_token is set from returning from twitter */ $session_token = $_SESSION['oauth_request_token']; /* Checks if oauth_token is set from returning from twitter */ $oauth_token = $_REQUEST['oauth_token']; /* Set section var */ $section = $_REQUEST['section']; /* If oauth_token is missing get it */ if ($_REQUEST['oauth_token'] != NULL && $_SESSION['oauth_state'] === 'start') { /*{{{*/ $_SESSION['oauth_state'] = $state = 'returned'; } /*}}}*/ /* * 'default': Get a request token from twitter for new user * 'returned': The user has authorize the app on twitter */ 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 */ $Blog =& $db->model('Blog'); if (!empty($db->prefix) && isset($_REQUEST['oauth_token'])) { $tabresult = $db->get_result("SHOW tables"); $tables = array(); $tablist = array(); for ($i = 0; $tables[$i] = mysql_fetch_assoc($tabresult); $i++) { foreach ($tables[$i] as $k => $v) { $tablist[] = $v; } } while ($b = $Blog->MoveNext()) { if (!empty($b->prefix) && in_array($b->prefix . "_db_sessions", $tablist)) { $sql = "SELECT id FROM " . $b->prefix . "_db_sessions WHERE data LIKE '%" . $db->escape_string($_REQUEST['oauth_token']) . "%'"; $result = $db->get_result($sql); if ($db->num_rows($result) == 1) { $sess = $db->result_value($result, 0, "id"); $del = $db->get_result("DELETE FROM " . $b->prefix . "_db_sessions WHERE id = '{$sess}'"); } } } } $_SESSION['oauth_request_token'] = $token = $tok['oauth_token']; $_SESSION['oauth_request_token_secret'] = $tok['oauth_token_secret']; $_SESSION['oauth_state'] = "start"; if (isset($_GET['forward']) && !empty($_SERVER['HTTP_REFERER'])) { $_SESSION['oauth_twitter'] = $_SERVER['HTTP_REFERER']; } else { $_SESSION['oauth_twitter'] = $request->base; } /* Build the authorization URL */ $auth_url = $to->getAuthorizeURL($token); if (empty($auth_url)) { $content = 'Request token not found, <a href="' . $request->url_for('oauth_login') . '">click here to try again...</a>'; } else { $content = '<script type="text/javascript">' . "\n"; $content .= ' // <![CDATA[' . "\n"; $content .= " location.replace('" . $auth_url . "');" . "\n"; $content .= ' // ]]>' . "\n"; $content .= '</script>' . "\n"; } break; case 'returned': if (isset($_SESSION['oauth_twitter'])) { $redirect_to = $_SESSION['oauth_twitter']; } else { $redirect_to = $request->base; } /* 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']; if (!($_SESSION['oauth_access_token'] === NULL && $_SESSION['oauth_access_token_secret'] === NULL)) { unset($_SESSION['oauth_request_token']); unset($_SESSION['oauth_request_token_secret']); } } $to = new TwitterOAuth($consumer_key, $consumer_secret, $_SESSION['oauth_access_token'], $_SESSION['oauth_access_token_secret']); $session_oauth_token = $_SESSION['oauth_access_token']; $session_oauth_secret = $_SESSION['oauth_access_token_secret']; $content = $to->OAuthRequest('https://twitter.com/account/verify_credentials.json', array(), 'GET'); if (!class_exists('Services_JSON')) { lib_include('json'); } $json = new Services_JSON(); $user = $json->decode($content); if (empty($user)) { trigger_error('The server said: ' . $content, E_USER_ERROR); } if (empty($prefix) && in_array('invites', $db->tables)) { $Invite =& $db->model('Invite'); $result = $Invite->find_by('nickname', $user->screen_name); if (!$result) { trigger_error('Sorry, you have not been invited yet ' . environment('email_from'), E_USER_ERROR); } } $Identity =& $db->model('Identity'); $Person =& $db->model('Person'); $TwitterUser =& $db->model('TwitterUser'); $twuser = $TwitterUser->find_by('twitter_id', $user->id); // a) twitter user exists, does not have a profile_id // b) twitter user exists, HAS a profile_id // c) twitter user does not exist if ($twuser) { if (!$twuser->profile_id) { // a $i = make_identity(array($user->screen_name, $user->profile_image_url, $user->name, $user->description, $user->url, $user->location)); if (!$i) { trigger_error('sorry I was unable to create an identity', E_USER_ERROR); } $twuser->set_value('profile_id', $i->id); $twuser->set_value('oauth_key', $session_oauth_token); $twuser->set_value('oauth_secret', $session_oauth_secret); $twuser->save_changes(); if (!$twuser) { trigger_error('sorry I was unable to create a twitter user', E_USER_ERROR); } } else { // b $i = $Identity->find($twuser->profile_id); if (!$i) { trigger_error('sorry I was unable to find the identity', E_USER_ERROR); } if ($session_oauth_token != $twuser->oauth_key) { $twuser->set_value('oauth_key', $session_oauth_token); $twuser->set_value('oauth_secret', $session_oauth_secret); $twuser->save_changes(); } } } else { // c $i = make_identity(array($user->screen_name, $user->profile_image_url, $user->name, $user->description, $user->url, $user->location)); if (!$i) { trigger_error('sorry I was unable to create an identity', E_USER_ERROR); } $twuser = make_twuser($user, $i->id, $session_oauth_token, $session_oauth_secret); if (!$twuser) { trigger_error('sorry I was unable to create a twitter user', E_USER_ERROR); } } $_SESSION['oauth_person_id'] = $i->person_id; if (empty($redirect_to)) { $content = "<p>there was an error in the oauth routine, sorry</p>"; } else { $content = '<script type="text/javascript">' . "\n"; $content .= ' // <![CDATA[' . "\n"; $content .= " location.replace('" . $redirect_to . "');" . "\n"; $content .= ' // ]]>' . "\n"; $content .= '</script>' . "\n"; } break; } /*}}}*/ return vars(array(&$content), get_defined_vars()); }
function installed_apps_json(&$vars) { extract($vars); if (!class_exists('Services_JSON')) { lib_include('json'); } $json = new Services_JSON(); $apps_list = array(); $i = $Identity->find(get_profile_id()); while ($s = $i->NextChild('settings')) { if ($s->name == 'app') { $s = $Setting->find($s->id); $e = $s->FirstChild('entries'); $apps_list[$e->etag] = $s->value; } } header("Content-Type: application/javascript"); print $json->encode($apps_list); exit; }
function delete_from_post(&$req) { trigger_before('delete_from_post', $this, $req); global $db; if ($this->has_metadata && !isset($req->params['entry']['etag'])) { trigger_error("Sorry, the etag was not submitted with the database entry", E_USER_ERROR); } $fields = $this->fields_from_request($req); if ($this->has_metadata) { $atomentry = $db->models['entries']->find_by('etag', $req->params['entry']['etag']); $recid = $atomentry->attributes['record_id']; } else { $recid = $req->id; } $rec = $this->find($recid); if ($this->has_metadata) { $Person =& $db->model('Person'); $Group =& $db->model('Group'); $p = $Person->find(get_person_id()); if (!($p->id == $atomentry->attributes['person_id']) && !$this->can_superuser($req->resource)) { trigger_error("Sorry, your id does not match the owner of the database entry", E_USER_ERROR); } } $coll = environment('collection_cache'); if ($this->has_metadata && isset($coll[$req->resource]) && $coll[$req->resource]['location'] == 'aws') { $ext = extension_for($atomentry->content_type); $pkname = $rec->primary_key; global $prefix; $aws_file = $prefix . $rec->table . $rec->{$pkname} . "." . $ext; lib_include('S3'); $s3 = new S3(environment('awsAccessKey'), environment('awsSecretKey')); if (!$s3) { trigger_error('Sorry, there was a problem connecting to Amazon Web Services', E_USER_ERROR); } if ($s3->getBucket(environment('awsBucket')) && $s3->getObject(environment('awsBucket'), urlencode($aws_file))) { $result = $s3->deleteObject(environment('awsBucket'), urlencode($aws_file)); if (!$result) { trigger_error('Sorry, there was a problem deleting the file from Amazon Web Services', E_USER_ERROR); } } } $result = $db->delete_record($rec); trigger_after('delete_from_post', $this, $req); }
function realtime($callback, $payload, $prefix = false) { if (defined('PING') && !PING) { return; } if (defined('REALTIME_HOST') && !REALTIME_HOST) { return; } global $db; if ($prefix) { $chan = $prefix; } elseif (!empty($db->prefix)) { $chan = $db->prefix; } else { $chan = "chan"; } if (!class_exists('Services_JSON')) { lib_include('json'); } $json = new Services_JSON(); $payload['callback'] = $callback; $load = $json->encode($payload); $curl = curl_init("http://" . REALTIME_HOST . ":" . REALTIME_PORT); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_TIMEOUT, 1); curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'ADDMESSAGE ' . $chan . ' ' . addslashes($load)); curl_exec($curl); }
$options['busy'] = 0; $options['last_id'] = 0; $options['latest_id'] = 0; add_option($optname, $options); } if (!$options['busy']) { $options['busy'] = 1; //update_option($optname,$options); $tu = split("_", $key); $follow[$tu[1]] = array($optname, $options); } } } foreach ($follow as $tuid => $options) { // http://abrah.am lib_include('twitteroauth'); global $db; $TwitterUser =& $db->model('TwitterUser'); $tu = $TwitterUser->find($tuid); if ($tu) { $latest = false; $key = $tu->oauth_key; $secret = $tu->oauth_secret; $consumer_key = environment('twitterKey'); $consumer_secret = environment('twitterSecret'); $to = new TwitterOAuth($consumer_key, $consumer_secret, $tu->oauth_key, $tu->oauth_secret); $timelineurl = 'https://twitter.com/statuses/friends_timeline.atom'; if ($options[1]['last_id']) { $timelineurl .= '?since_id=' . $options[1]['last_id'] . '&count=200'; admin_alert('starting from ' . $options[1]['last_id'] . ' for ' . $tu->screen_name); }
$s->save_changes(); $s->set_etag(); } else { $sett->set_value('value', $setting_value); $sett->save_changes(); } $profile = get_profile(); redirect_to($request->url_for(array("resource" => $profile->nickname)) . "/settings"); } if (isset($_POST['ajax_shorten'])) { if (!signed_in()) { return; } $url = $_POST['ajax_shorten']; shortener_init(); lib_include('json'); global $wp_ozh_yourls; if (!$wp_ozh_yourls) { wp_ozh_yourls_admin_init(); } $service = wp_ozh_yourls_service(); if (empty($service)) { add_option('ozh_yourls', array('service' => 'other', 'location' => '', 'yourls_path' => '', 'yourls_url' => '', 'yourls_login' => '', 'yourls_password' => '', 'rply_login' => '', 'rply_password' => '', 'other' => 'rply')); global $wp_ozh_yourls; if (!$wp_ozh_yourls) { wp_ozh_yourls_admin_init(); } $service = wp_ozh_yourls_service(); } $shorturl = wp_ozh_yourls_api_call(wp_ozh_yourls_service(), $_POST['ajax_shorten']); if ($shorturl) {
function setting_widget_helper($nam, $nammode, $namurl, $namentry, $listdata) { if (!class_exists("Services_JSON")) { lib_include("json"); } $json = new Services_JSON(); global $request; echo ' var submit_to' . $nam . ' = "' . $namurl . '"; $(".jeditable_' . $nam . '").mouseover(function() { $(this).highlightFade({end:\'#def\'}); }); $(".jeditable_' . $nam . '").mouseout(function() { $(this).highlightFade({end:\'#fff\', speed:200}); }); $(".jeditable_' . $nam . '").editable(submit_to' . $nam . ', { indicator : "<img src=\'' . base_path(true) . 'resource/jeditable/indicator.gif\'>", data : \'' . $json->encode($listdata) . '\', submitdata : function() { return {"entry[etag]" : "' . $namentry->etag . '"}; }, name : "setting[value]", type : "select", placeholder : "' . placeholder_value($nammode, $listdata) . '", noappend : "true", submit : "OK", tooltip : "Click to edit...", cancel : "Cancel", callback : function(value, settings) { $(this).html(settings[\'jsonarr\'][value-0]); return(value); } }); '; }
function do_shorten() { add_include_path(library_path() . 'urlshort/upload'); require_once 'includes/config.php'; // settings require_once 'includes/gen.php'; // url generation and location $perma = parse_url($_SERVER['REQUEST_URI']); $_PERMA = explode("/", $perma['path']); @array_shift($_PERMA); $shorturl = new shorturl(); $msg = ''; $strurl = ''; global $db, $request; $Url =& $db->model('Url'); global $pretty_url_base; $urlbase = $pretty_url_base; global $prefix; if (!empty($prefix)) { $sql = "SELECT urlbase FROM shorteners WHERE nickname LIKE '" . $db->escape_string($request->username) . "'"; $sql .= " AND password LIKE '" . $db->escape_string($request->password) . "'"; $result = $db->get_result($sql); $url_base = $db->result_value($result, 0, "urlbase"); if ($db->num_rows($result) == 1) { $urlbase = 'http://' . $url_base; } else { trigger_error('sorry the username and password were incorrect', E_USER_ERROR); } } else { $parts = split('\\.', $urlbase); if (count($parts) > 2) { $urlbase = 'http://' . $parts[1] . '.' . $parts[2]; } } if (REWRITE) { $urlbase = $urlbase . dirname($_SERVER['PHP_SELF']); } else { $urlbase = 'http://' . $request->domain . $_SERVER['PHP_SELF']; } if (isset($request->url)) { $longurl = trim(mysql_escape_string($request->url)); $plain = trim(mysql_escape_string($request->plain)); $protocol_ok = false; if (count($allowed_protocols)) { foreach ($allowed_protocols as $ap) { if (strtolower(substr($longurl, 0, strlen($ap))) == strtolower($ap)) { $protocol_ok = true; break; } } } else { $protocol_ok = true; } $protocol_ok = true; $plaincheck = check_plain($plain); // url Required The destination URL to be shortened. // custom Optional A custom URL that is preferred to an auto-generated URL. // searchtags Optional A search string value to attach to a tr.im URL. // privacycode Optional A string value that must be appended after the URL. // newtrim Optional If present with any value, it will force the creation of a new tr.im URL. // sandbox Optional If present with any value a test data set will be returned, and no URL created. This is intended for testing so that you do not consume API calls or insert pointless data while in development. // api_key Optional An application API key assigned to your application. // username Optional A tr.im username that you would like to attach the URL to. // password Optional The password for the tr.im username referenced above. // if the id has been sent to this script if (isset($request->custom) && strlen(trim($request->custom))) { $shorten = trim(mysql_escape_string($request->custom)); $string = "{$shorten}"; list($string1, $string2) = explode("{$install_path}", $string); $shortid = $string1 . $string2; $q2 = 'SELECT url FROM `urls` WHERE `id` LIKE CONVERT(_utf8 \'' . $shortid . '\' USING latin1)'; $result2 = mysql_query($q2); while ($row = mysql_fetch_array($result2, MYSQL_ASSOC)) { printf($row["url"]); exit; } if (mysql_num_rows($result2) == $result2) { $longurl = mysql_result($result2, 1); } else { header('HTTP/1.1 500 Internal Server Error'); exit; } } $make_new_url = true; $q2 = 'SELECT id FROM ' . URL_TABLE . ' WHERE (url="' . $longurl . '")'; $result2 = mysql_query($q2); if (mysql_num_rows($result2)) { $make_new_url = false; } if (isset($request->searchtags)) { $longurl .= $request->searchtags; } if (isset($request->privacycode)) { $longurl .= $request->privacycode; } if (isset($request->newtrim)) { $make_new_url = true; } if ($protocol_ok && $plaincheck) { if (isset($request->sandbox)) { $trimresponse = array('trimpath' => 'w92s', 'reference' => 'lsTZf8vHaslrrmskREhbRArpHh125c', 'trimmed' => '10/08/2009', 'destination' => "http://www.google.com/", 'trim_path' => 'w92S', 'domain' => 'google.com', 'url' => 'http://tr.im/w92S', 'visits' => 0, 'status' => array('result' => 'OK', 'code' => '200', 'message' => 'tr.im URL Added.'), 'date_time' => '2009/08/10 05:46:13 -0400'); $time_of = time(); $responsetype = $request->client_wants; $trimpath = $trimresponse['trimpath']; $reference = $trimresponse['reference']; $trimmed = $trimresponse['trimmed']; $destination = $trimresponse['destination']; $trim_path = $trimresponse['trim_path']; $domain = $trimresponse['domain']; $strurl = $trimresponse['url']; $visits = 0; $status_result = 'OK'; $status_code = '200'; $date_time = $trimresponse['date_time']; } else { $shorturl->add_url($longurl, $plain); if (REWRITE) { $strurl = $urlbase . '' . $shorturl->get_id($longurl); } else { $strurl = $urlbase . '?id=' . $shorturl->get_id($longurl); } $time_of = time() - 3 * 60 * 60; $responsetype = $request->client_wants; $id = $shorturl->get_id($longurl); $trimpath = $id; $reference = get_code(); $trimmed = date("d/m/Y", $time_of); $destination = $longurl; $trim_path = $id; $url_parts = @parse_url($longurl); $domain = $url_parts["host"]; $visits = 0; $status_result = 'OK'; $status_code = '200'; $date_time = date("Y/m/d H:i:s O", $time_of); $l = $Url->find_by(array('id' => $id)); if ($make_new_url) { $l->set_value('text', $plain); $l->set_value('title', $plain); $l->set_value('trimurl', $strurl); $l->set_value('created', date("Y-m-d H:i:s", $time_of)); $l->set_value('date', date("Y-m-d H:i:s", $time_of)); $l->set_value('trimpath', $trimpath); $l->set_value('trimref', $reference); $l->set_value('trimmed', $trimmed); $l->set_value('trimvisits', $visits); $l->set_value('trimtime', $date_time); $l->save_changes(); } else { $reference = $l->reference; $trimpath = $l->trimpath; $reference = $l->trimref; $trimmed = $l->trimmed; $trimpath = $l->trimpath; $trim_path = $l->trimpath; $visits = $l->trimvisits; $date_time = $l->trimtime; $l->set_value('trimvisits', $l->trimvisits + 1); $l->save_changes(); } } $arr = array('destination', 'url', 'trimmed'); if ($responsetype == 'json') { foreach ($arr as $var) { ${$var} = str_replace('/', '\\/', ${$var}); } } if (substr($longurl, -strlen($domain)) == $domain) { $destination .= '\\/'; } $callback1 = ''; $callback2 = ''; if (isset($request->callback)) { $callback1 = $request->callback . '('; $callback2 = ')'; } if ($responsetype == 'json') { header('Content-Type: application/json'); header("Content-Disposition: inline"); } if ($responsetype == 'xml') { echo '<?xml version="1.0" encoding="UTF-8"?> <trim> <status result="OK" code="200" message="tr.im URL Added."/> <url>' . $strurl . '</url> <reference>' . $reference . '</reference> <trimpath>' . $trimpath . '</trimpath> </trim>'; } if ($responsetype == 'json') { echo $callback1 . '{"trimpath": "' . $trimpath . '", "reference": "' . $reference . '", "trimmed": "' . $trimmed . '", "destination": "' . $destination . '", "trim_path": "' . $trim_path . '", "domain": "' . $domain . '", "url": "' . $strurl . '", "visits": ' . $visits . ', "status": {"result": "' . $status_result . '", "code": "' . $status_code . '", "message": "tr.im URL Added."}, "date_time": "' . $date_time . '"}' . $callback2; } } $redircode = '<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title></title> <META HTTP-EQUIV="Refresh" CONTENT="0;URL=' . stripslashes($destination) . '"> <meta name="robots" content="noindex"/> <link rel="canonical" href="' . stripslashes($destination) . '"/> </head> <body> </body> </html>'; $make_s3 = false; if ($url_base && $make_s3) { $redirfile = tempnam("/tmp", $url_base . '/' . $trimpath); $handle = fopen($redirfile, "w"); fwrite($handle, $redircode); fclose($handle); lib_include('S3'); $s3 = new S3(environment('awsAccessKey'), environment('awsSecretKey')); if ($s3) { $s3->getBucket($url_base); $s3->putObjectFile($redirfile, $url_base, $trimpath, 'public-read'); } } } exit; }
function _edit(&$vars) { extract($vars); if (!class_exists('Services_JSON')) { lib_include('json'); } $TwitterUser =& $db->model('TwitterUser'); $tu = $TwitterUser->find_by(array('profile_id' => get_profile_id()), 1); if ($tu) { $method = 'oauth'; } else { $method = 'password'; $password = $Setting->find_by(array('name' => 'aktt_twitter_password', 'profile_id' => get_profile_id())); if (!$password) { $password = $Setting->base(); $password->set_value('profile_id', get_profile_id()); $password->set_value('person_id', get_person_id()); $password->set_value('name', 'aktt_twitter_password'); $password->save_changes(); $password->set_etag(); $password = $Setting->find($password->id); $pword = ""; } if (!empty($password->value)) { $pword = "******"; } // get the one-to-one-related child-record from "entries" $pEntry =& $password->FirstChild('entries'); $passurl = $request->url_for(array('resource' => 'settings', 'id' => $password->id, 'action' => 'put')); $username = $Setting->find_by(array('name' => 'aktt_twitter_username', 'profile_id' => get_profile_id())); if (!$username) { $username = $Setting->base(); $username->set_value('profile_id', get_profile_id()); $username->set_value('person_id', get_person_id()); $username->set_value('name', 'aktt_twitter_username'); $username->save_changes(); $username->set_etag(); $username = $Setting->find($username->id); } // get the one-to-one-related child-record from "entries" $uEntry =& $username->FirstChild('entries'); $userurl = $request->url_for(array('resource' => 'settings', 'id' => $username->id, 'action' => 'put')); } $stat = $Setting->find_by(array('name' => 'twitter_status', 'profile_id' => get_profile_id())); if (!$stat) { $stat = $Setting->base(); $stat->set_value('profile_id', get_profile_id()); $stat->set_value('person_id', get_person_id()); $stat->set_value('name', 'twitter_status'); $stat->set_value('value', 'enabled'); $stat->save_changes(); $stat->set_etag(); $stat = $Setting->find($stat->id); } // get the one-to-one-related child-record from "entries" $sEntry =& $stat->FirstChild('entries'); $staturl = $request->url_for(array('resource' => 'settings', 'id' => $stat->id, 'action' => 'put')); $status = $stat->value; $aktwitter_tw_text_options = array('disabled' => 'disabled', 'enabled' => 'enabled'); if ($method == 'password') { return vars(array(&$aktwitter_tw_text_options, &$status, &$staturl, &$pword, &$userurl, &$passurl, &$password, &$sEntry, &$username, &$uEntry, &$pEntry, &$profile, &$method), get_defined_vars()); } if ($method == 'oauth') { return vars(array(&$aktwitter_tw_text_options, &$status, &$staturl, &$sEntry, &$profile, &$method), get_defined_vars()); } }
<?php db_include('create_or_update_blog_post'); lib_include('email_lib'); if (!is_admin()) { header('HTTP/1.0 403 Forbidden'); $display_message = 'Access forbidden!'; $redirect = '/index.php'; } else { $params = ['title' => $_POST['title'], 'body' => $_POST['body'], 'author' => SessionLib::get('user_member.member')]; $posted = create_or_update_blog_post($params); if ($posted) { $display_message = 'Wrote post! <br />'; $redirect = "/blog/blog.php?id={$posted}"; if (isset($_POST['sendemail']) && $_POST['sendemail']) { $sent_mail = send_html_email('*****@*****.**', $_POST['title'], $_POST['body']); $display_message .= $sent_email ? 'Sent email!' : 'Failed to send email!'; } } else { $display_message = 'Failed to write post!'; $redirect = '/blog/writeblog.php'; $_POST['blog_fail_return'] = true; } } ?> <!doctype html> <html> <head> <meta charset="utf-8"> <title>Under the Couch - Posting Blog Post...</title>
function like($id) { $tk = new BuzzToken(); $apiroot = $tk->api_root; $url = $apiroot . '/@me/@liked/' . $id; $params = array('oauth_consumer_key' => $this->consumer->key, 'oauth_timestamp' => time(), 'oauth_version' => OAuthRequest::$version, 'oauth_nonce' => md5(microtime() . mt_rand()), 'oauth_token' => $this->token->key); $params['alt'] = 'json'; $oauthRequest = OAuthRequest::from_request('PUT', $url, $params); $oauthRequest->sign_request($this->method, $this->consumer, $this->token); $url = $oauthRequest->to_url(); $data = new bz_data(); $data->noop = 'noop'; $data2 = new bz_data(); $data2->data = $data; if (!function_exists('json_encode')) { lib_include('json'); } $buzzjson = json_encode($data2); $headers = array(); $headers[] = 'Content-Type: application/json'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POSTFIELDS, $buzzjson); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0); curl_setopt($ch, CURLOPT_FAILONERROR, false); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); return @curl_exec($ch); }
<?php db_include('get_webpage_access_allowed'); lib_include('ical_lib'); $now = new DateTime(); $end = new DateTime(); $now = $now->sub(new DateInterval('P1D')); $end = $end->add(new DateInterval('P3W')); $icsDates = ics_to_array(URL_ICAL_BOOKING); $events = get_ics_events($icsDates, $now, $end); usort($events, 'compare_ics_events'); ?> <aside> <?php if (get_webpage_access_allowed('ui/sidebar_admin.php')) { include 'sidebar_admin.php'; } ?> <center><b>Upcoming Events</b></center> <?php foreach ($events as $key => $value) { ?> <br /> <?php echo "{$value['Date']} {$value['Time']}"; ?> <br /> <?php
function aws_putfile(&$rec, $pkvalue) { global $request, $prefix; $file = $prefix . $rec->table . $pkvalue . "." . extension_for(type_of($_FILES[strtolower(classify($rec->table))]['name'][$this->file_upload[0]])); lib_include('S3'); $s3 = new S3(environment('awsAccessKey'), environment('awsSecretKey')); if (!$s3) { trigger_error('Sorry, there was a problem connecting to Amazon Web Services', E_USER_ERROR); } if (!$s3->getBucket(environment('awsBucket'))) { $result = $s3->putBucket(environment('awsBucket'), 'public-read'); if (!$result) { trigger_error('Sorry, there was a problem creating the bucket ' . environment('awsBucket') . ' at Amazon Web Services', E_USER_ERROR); } } if (file_exists($this->file_upload[1])) { if (!$s3->putObjectFile($this->file_upload[1], environment('awsBucket'), $file, 'public-read')) { trigger_error('Sorry, there was a problem uploading the file to Amazon Web Services', E_USER_ERROR); } unlink($this->file_upload[1]); } $this->file_upload = false; }