Example #1
0
function is_junkblog($url, $strict = false)
{
    $url = normalize_url($url);
    $query = XN_Query::create('Content')->filter('owner->relativeUrl', '=', 'someblogs')->filter('type', 'eic', 'Website')->filter('my.url', '=', $url);
    $items = $query->execute();
    if (count($items)) {
        if ($strict === true && !$items[0]->my->verify) {
            return false;
        }
        return $items[0];
    }
    //end if count items
    if ($strict) {
        return false;
    }
    $page = strip_tags(file_get_contents($url));
    $stoplist = array('drunk', 'free links', 'sex', 'c**k', 'pussy', 'p**n', 'pr0n', 'pron', 'I went', 'I slept', 'slept with', 'my boss', 'loser', 'my cat', 'I love you', 'this update is');
    foreach ($stoplist as $stop) {
        if (stristr($page, ' ' . $stop . ' ')) {
            $dummy = file_get_contents('http://someblogs.ning.com/add.php?xn_auth=no&url=' . urlencode($url));
            return $strict ? false : true;
        }
        //end if stop
    }
    //end foreach stoplist
    return false;
}
Example #2
0
 /**
  * build a reference to a version
  *
  * Depending on parameter '[code]with_friendly_urls[/code]' and on action,
  * following results can be observed:
  *
  * - view - versions/view.php?id=123 or versions/view.php/123 or version-123
  *
  * - other - versions/edit.php?id=123 or versions/edit.php/123 or version-edit/123
  *
  * @param int the id of the version to handle
  * @param string the expected action ('view', 'print', 'edit', 'delete', ...)
  * @return string a normalized reference
  *
  * @see control/configure.php
  */
 public static function get_url($id, $action = 'view')
 {
     global $context;
     // list versions -- the id has to be an anchor (e.g., 'article:15')
     if ($action == 'list') {
         if ($context['with_friendly_urls'] == 'Y') {
             return 'versions/list.php/' . str_replace(':', '/', $id);
         } else {
             return 'versions/list.php?id=' . urlencode($id);
         }
     }
     // check the target action
     if (!preg_match('/^(delete|restore|view)$/', $action)) {
         return 'versions/' . $action . '.php?id=' . urlencode($id);
     }
     // normalize the link
     return normalize_url(array('versions', 'version'), $action, $id);
 }
<?php

// Make sure user is logged in
require_login();
// Normalize the URL
$href = normalize_url(@$_POST['href']);
// Strip tags, normalize whitespace, shorten if necessary
$summary = summarize($_POST['summary']);
// Filter content to prevent against XSS attacks
$content = filter_content($_POST['content']);
// Escape content for the database to prevent SQL injection
$href = $db->escape($href);
$summary = $db->escape($summary);
$space = $db->escape($_POST['space']);
$content = $db->escape($content);
$version = $db->escape($_POST['version']);
if (isset($_POST['status']) && is_numeric($_POST['status'])) {
    $status = $db->escape($_POST['status']);
} else {
    $status = 1;
}
// Check to make sure we have everything
if (empty($href)) {
    respond(0, "Please specify an 'href' argument.");
} else {
    if (empty($space)) {
        respond(0, "Please specify a 'space' argument.");
    } else {
        if (empty($content)) {
            respond(0, "Please specify a 'content' argument.");
        } else {
Example #4
0
				padding-left: 0px;
			}
		</style>
	</head>


	<body>
	<?php 
require 'header.php';
ob_flush();
flush();
if ($_GET['id']) {
    $person_id = mysql_real_escape_string($_GET['id'], $db);
} else {
    require 'normalize_url.php';
    $url = mysql_real_escape_string(normalize_url($_GET['url']), $db);
    if (!isset($_GET['nofetch'])) {
        shell_exec("ruby fetch_profile.rb '{$url}' 2>&1");
    }
    $person_id = @mysql_fetch_assoc(mysql_query("SELECT person_id FROM urls WHERE url='{$url}'", $db));
    $person_id = $person_id['person_id'];
}
//end if id
if (!$person_id) {
    die('No profile found!');
}
if (!isset($_GET['contacts'])) {
    $person = mysql_fetch_assoc(mysql_query("SELECT * FROM people WHERE person_id={$person_id}", $db));
    echo "\t\t" . '<div id="profile" class="vcard">' . "\n";
    $photos = mysql_query("SELECT value FROM fields WHERE type='photo' AND person_id={$person_id}", $db);
    if (mysql_num_rows($photos)) {
Example #5
0
<?php

require_once 'xn-app://someblogs/normalize_url.php';
$_REQUEST['url'] = normalize_url($_REQUEST['url']);
require_once 'is_junkblog.php';
$item = is_junkblog($_REQUEST['url']);
if ($_REQUEST['format'] == 'xml') {
    header('Content-Type: application/xml;charset=utf-8');
    echo '<blog>' . "\n";
    echo '   <result>' . ($item && $item->my->verify ? '1' : '0') . '</result>' . "\n";
    echo '   <blog_url>' . htmlspecialchars($_REQUEST['url']) . '</blog_url>';
    echo '</blog>';
} else {
    if ($item) {
        echo '<h2>Blog Found!</h2><p>' . htmlspecialchars($_REQUEST['url']) . ($item->my->verify ? " is a 'junk' blog.  If you think this listing is in error, please contact us using the 'Report This App' feature from the 'Popular' tab of the Ningbar, above." : " has been suggested as a 'junk' blog.  If you think this listing is in error, please vote 'Not Junk' on <a href=\"/\">the main page</a>.") . '</p>';
    } else {
        echo '<h2>Blog Not Found!</h2><p>' . htmlspecialchars($_REQUEST['url']) . " is not a 'junk' blog.</p>";
    }
    echo '<br /><p><a href="?url=' . $_REQUEST['url'] . '&amp;format=xml">Get these results as XML</a></p>';
}
//end if-else format
        //end while person = fetch people
        echo "], ";
    }
    //end if-else num_rows people
    return $matches;
}
//end function print_results
$n = explode(' ', $_GET['q']);
$nickname = mysql_real_escape_string($_GET['q'], $db);
$given_name = mysql_real_escape_string(array_shift($n), $db);
$family_name = mysql_real_escape_string(array_pop($n), $db);
$additional_name = mysql_real_escape_string(implode(' ', $n), $db);
$results = 0;
if ($_GET['pov']) {
    require 'normalize_url.php';
    $pov = @mysql_fetch_assoc(mysql_query("SELECT person_id FROM urls WHERE url='" . mysql_real_escape_string(normalize_url($_GET['pov']), $db) . "'"));
    $pov = intval($pov['person_id']);
    $people = mysql_query("SELECT people.person_id,people.fn,urls.url FROM contacts,urls,people WHERE contacts.person_id={$pov} AND contacts.url=urls.url AND urls.person_id=people.person_id AND people.fn LIKE '%{$nickname}%'", $db) or die(mysql_error());
    $results += print_results($people, $db, 'Matches from Contacts');
}
//end if pov
$people = mysql_query("SELECT person_id,fn FROM people WHERE `given-name` LIKE '%{$given_name}%' AND `family-name` LIKE '%{$family_name}%' AND `additional-name` LIKE '%{$additional_name}%'" . ($_GET['count'] ? ' LIMIT ' . intval($_GET['count']) : ''), $db) or die(mysql_error());
$results += print_results($people, $db, 'Exact matches');
$people = mysql_query("SELECT person_id,value AS fn FROM fields WHERE value LIKE '%{$nickname}%' AND (type='nickname' OR type='email')" . ($_GET['count'] ? ' LIMIT ' . intval($_GET['count'] - $results) : ''), $db) or die(mysql_error());
$results += print_results($people, $db, 'Nickname matches');
$people = mysql_query("SELECT person_id,fn FROM people WHERE fn LIKE '%{$nickname}%'" . ($_GET['count'] ? ' LIMIT ' . intval($_GET['count'] - $results) : ''), $db) or die(mysql_error());
$results += print_results($people, $db, 'Fuzzy matches');
echo '}';
if ($_GET['callback']) {
    echo ')';
}
Example #7
0
 /**
  * build a reference to a server
  *
  * Depending on parameter '[code]with_friendly_urls[/code]' and on action,
  * following results can be observed:
  *
  * - view - servers/view.php?id=123 or servers/view.php/123 or server-123
  *
  * - other - servers/edit.php?id=123 or servers/edit.php/123 or server-edit/123
  *
  * @param int the id of the server to handle
  * @param string the expected action ('view', 'print', 'edit', 'delete', ...)
  * @return string a normalized reference
  *
  * @see control/configure.php
  */
 public static function get_url($id, $action = 'view')
 {
     global $context;
     // check the target action
     if (!preg_match('/^(delete|edit|test|view)$/', $action)) {
         return 'servers/' . $action . '.php?id=' . urlencode($id);
     }
     // normalize the link
     return normalize_url(array('servers', 'server'), $action, $id);
 }
Example #8
0
 /**
  * build a reference to a section
  *
  * Depending on parameter '[code]with_friendly_urls[/code]' and on action,
  * following results can be observed:
  *
  * - view - sections/view.php?id=123 or sections/view.php/123 or section-123
  *
  * - other - sections/edit.php?id=123 or sections/edit.php/123 or section-edit/123
  *
  * If a fourth parameter is provided, it will take over the third one. This
  * is used to leverage nick names in YACS, as per the following invocation:
  * [php]
  * Sections::get_url($item['id'], 'view', $item['title'], $item['nick_name']);
  * [/php]
  *
  * @param int the id of the section to handle
  * @param string the expected action ('view', 'print', 'edit', 'delete', ...)
  * @param string additional data, such as section nick name, if any
  * @param string alternate name, if any, to take over on previous parameter
  * @return string a normalized reference
  *
  * @see control/configure.php
  */
 public static function get_url($id, $action = 'view', $name = NULL, $alternate_name = NULL)
 {
     global $context;
     // use nick name instead of regular name, if one is provided
     if ($alternate_name && $context['with_alternate_urls'] == 'Y') {
         $name = str_replace('_', ' ', $alternate_name);
     }
     // the service to check for updates
     if ($action == 'check') {
         if ($context['with_friendly_urls'] == 'Y') {
             return 'services/check.php/section/' . rawurlencode($id);
         } elseif ($context['with_friendly_urls'] == 'R') {
             return 'services/check.php?id=' . urlencode('section:' . $id);
         } else {
             return 'services/check.php?id=' . urlencode('section:' . $id);
         }
     }
     // the RSD link
     if ($action == 'EditURI') {
         if ($context['with_friendly_urls'] == 'Y') {
             return 'services/describe.php/' . rawurlencode($id);
         } elseif ($context['with_friendly_urls'] == 'R') {
             return 'services/describe.php/' . rawurlencode($id);
         } else {
             return 'services/describe.php?anchor=' . urlencode($id);
         }
     }
     // the rss feed for files --deprecated to files::get_url()
     if ($action == 'files') {
         if ($context['with_friendly_urls'] == 'Y') {
             return 'files/feed.php/section/' . rawurlencode($id);
         } elseif ($context['with_friendly_urls'] == 'R') {
             return 'files/feed.php/section/' . rawurlencode($id);
         } else {
             return 'files/feed.php?anchor=' . urlencode('section:' . $id);
         }
     }
     // invite someone to participate
     if ($action == 'invite') {
         if ($name) {
             return 'sections/invite.php?id=' . urlencode($id) . '&amp;invited=' . urlencode($name);
         } else {
             return 'sections/invite.php?id=' . urlencode($id);
         }
     }
     // the prefix for managing content
     if ($action == 'manage') {
         if ($name) {
             return 'sections/manage.php?id=' . urlencode($id) . '&amp;' . urlencode($name) . '=';
         } else {
             return 'sections/manage.php?id=' . urlencode($id);
         }
     }
     // check the target action
     if (!preg_match('/^(delete|describe|duplicate|edit|export|feed|import|invite|lock|mail|navigate|own|print|view)$/', $action)) {
         return 'sections/' . $action . '.php?id=' . urlencode($id) . '&action=' . urlencode($name);
     }
     // normalize the link
     return normalize_url(array('sections', 'section'), $action, $id, $name);
 }
Example #9
0
File: images.php Project: rair/yacs
 /**
  * build a reference to a image
  *
  * Depending on parameter '[code]with_friendly_urls[/code]' and on action,
  * following results can be observed:
  *
  * - view - images/view.php?id=123 or images/view.php/123 or image-123
  *
  * - other - images/edit.php?id=123 or images/edit.php/123 or image-edit/123
  *
  * @param int the id of the image to handle
  * @param string the expected action ('view', 'print', 'edit', 'delete', ...)
  * @return string a normalized reference
  *
  * @see control/configure.php
  */
 public static function get_url($id, $action = 'view')
 {
     global $context;
     // check the target action
     if (!preg_match('/^(delete|edit|set_as_icon|set_as_thumbnail|view)$/', $action)) {
         return 'images/' . $action . '.php?id=' . urlencode($id);
     }
     // normalize the link
     return normalize_url(array('images', 'image'), $action, $id);
 }
Example #10
0
        $channel->type = 'feeds';
        $channel->save();
        json_response($app, ['result' => 'ok']);
    }
});
$app->post('/channels/discover', function ($format = 'json') use($app) {
    if ($user = require_login_json($app)) {
        $params = $app->request()->params();
        // $feeds = array(
        //   array('url' => 'http://pk.dev/', 'display_url' => friendly_url('http://pk.dev/'), 'type' => 'microformats2'),
        //   array('url' => 'http://pk.dev/articles.atom', 'display_url' => friendly_url('http://pk.dev/articles.atom'), 'type' => 'atom')
        // );
        $feeds = [];
        // Parse the URL and check for microformats h-entry posts, as well as linked rss or atom feeds
        $html = request\get_url($params['url']);
        $url = normalize_url($params['url']);
        if ($html) {
            $mf2 = feeds\parse_mf2($html, $params['url']);
            // check if there are any h-entry posts
            $feed = feeds\find_feed_info($mf2);
            if ($feed) {
                $feeds[] = ['url' => $url, 'display_url' => friendly_url($url), 'icon' => '<i class="icon-microformats"></i>', 'enabled' => true];
            }
            $alternates = feeds\get_alternates($mf2);
            foreach ($alternates as $alt) {
                $feeds[] = ['url' => $alt['url'], 'display_url' => friendly_url($alt['url']), 'icon' => '<i class="fa fa-rss"></i>', 'enabled' => false];
            }
        }
        json_response($app, ['feeds' => $feeds]);
    }
});
Example #11
0
<?php

// Check for content based on URL
$href = $db->escape(normalize_url(@$_POST['href']));
// Sanity check
if (empty($href)) {
    respond(0, "Please specify an 'href' argument.");
}
$response = array();
if (empty($user)) {
    // Only check for public content
    $response['count'] = $db->value("\n    SELECT COUNT(id)\n    FROM shift\n    WHERE status = 1\n    AND href = '{$href}'\n  ");
} else {
    // Check for both public and private content
    $response['count'] = $db->value("\n    SELECT COUNT(s.id)\n    FROM shift s,\n         user u\n    WHERE (\n      s.status = 1\n      OR (\n        s.status = 2\n        AND s.user_id = {$user->id}\n      )\n    )\n    AND s.user_id = u.id\n    AND s.href = '{$href}'\n  ");
    $response['username'] = $user->username;
    $response['email'] = $user->email;
}
// Done
respond(1, $response);
Example #12
0
 /**
  * build a reference to a category
  *
  * Depending on parameter '[code]with_friendly_urls[/code]' and on action,
  * following results can be observed:
  *
  * - view - categories/view.php?id=123 or categories/view.php/123 or categorie-123
  *
  * - other - categories/edit.php?id=123 or categories/edit.php/123 or category-edit/123
  *
  * @param int the id of the category to handle
  * @param string the expected action ('view', 'print', 'edit', 'delete', ...)
  * @param string additional data, such as category name, if any
  * @return string a normalized reference
  *
  * @see control/configure.php
  */
 public static function get_url($id, $action = 'view', $name = NULL)
 {
     global $context;
     // select a category for an anchor
     if ($action == 'select') {
         return 'categories/select.php?anchor=' . urlencode($id);
     }
     // check the target action
     if (!preg_match('/^(delete|describe|edit|feed|mail|navigate|print|view)$/', $action)) {
         return 'categories/' . $action . '.php?id=' . urlencode($id) . '&action=' . urlencode($name);
     }
     // normalize the link
     return normalize_url(array('categories', 'category'), $action, $id, $name);
 }
Example #13
0
File: users.php Project: rair/yacs
 /**
  * build a reference to a user
  *
  * Depending on parameter '[code]with_friendly_urls[/code]' and on action,
  * following results can be observed:
  *
  * - view - users/view.php?id=123 or users/view.php/123 or user-123
  *
  * - other - users/edit.php?id=123 or users/edit.php/123 or user-edit/123
  *
  * @param int the id of the user to handle
  * @param string the expected action ('view', 'print', 'edit', 'delete', ...)
  * @param string user name
  * @return string a normalized reference
  *
  * @see control/configure.php
  */
 public static function get_url($id, $action = 'view', $name = NULL)
 {
     global $context;
     // track something -- the id has to be an anchor (e.g., 'article:15')
     if ($action == 'track') {
         if ($context['with_friendly_urls'] == 'Y') {
             return 'users/track.php/' . str_replace(':', '/', $id);
         } elseif ($context['with_friendly_urls'] == 'R') {
             return 'users/track.php/' . str_replace(':', '/', $id);
         } else {
             return 'users/track.php?anchor=' . urlencode($id);
         }
     }
     // assign users to an anchor
     if ($action == 'select') {
         return 'users/select.php?member=' . urlencode($id);
     }
     // list watchers
     if ($action == 'watch') {
         return 'users/select.php?anchor=' . urlencode($id);
     }
     // check the target action
     if (!preg_match('/^(contact|delete|describe|edit|element|feed|fetch_vcard|leave|mail|navigate|password|print|select_avatar|share|transfer|validate|view|visit)$/', $action)) {
         return 'users/' . $action . '.php?id=' . urlencode($id) . '&action=' . urlencode($name);
     }
     // 		// view user profile --use only the nick name, since it is unique
     // 		if(($action == 'view') && $name) {
     // 			$id = $name;
     // 			$name = '';
     // 		}
     // normalize the link
     return normalize_url(array('users', 'user'), $action, $id, $name);
 }
function social_networking_get_normalized_urls($url, $level = 0)
{
    global $social_networking_normalized_urls;
    $openIDc = new WordpressOpenIDRegistration();
    $page = social_networking_getTidy($url);
    if (is_int($url[strlen($url) - 1])) {
        unset($url[strlen($url) - 1]);
    }
    $social_networking_normalized_urls[] = $openIDc->normalize_username(normalize_url($url));
    $theParser = xml_parser_create();
    xml_parse_into_struct($theParser, $page, $vals);
    xml_parser_free($theParser);
    foreach ($vals as $el) {
        if (!in_array('me', explode(' ', strtolower(trim($el['attributes']['REL']))))) {
            continue;
        }
        $el['attributes']['HREF'] = trim($el['attributes']['HREF']);
        if (!$level) {
            social_networking_get_normalized_urls($el['attributes']['HREF'], $level + 1);
        }
        if (is_int($el['attributes']['HREF'][strlen($el['attributes']['HREF']) - 1])) {
            unset($el['attributes']['HREF'][strlen($el['attributes']['HREF']) - 1]);
        }
        $tmp[] = $openIDc->normalize_username(normalize_url($el['attributes']['HREF']));
    }
    //end foreach vals as el
}
Example #15
0
function process_avatarurl($url)
{
    global $vbulletin;
    if ($url == '') {
        return;
    }
    if (stripos($url, 'http:') !== false) {
        return reverse_htmlentities(normalize_url($url));
    } else {
        if (is_vb()) {
            if (strpos($url, '/') === 0) {
                $host = parse_url($vbulletin->options['bburl']);
                return normalize_url($host['scheme'] . '://' . $host['host'] . reverse_htmlentities($url));
            } else {
                return normalize_url($vbulletin->options['bburl'] . '/' . reverse_htmlentities($url));
            }
        } else {
            if (is_phpbb()) {
                return normalize_url(fr_get_phpbb_bburl() . reverse_htmlentities($url));
            } else {
                if (is_xen()) {
                    return normalize_url(fr_get_xenforo_bburl() . '/' . reverse_htmlentities($url));
                }
            }
        }
    }
}
<?php

require_once 'xn-app://singpolymaplay/getTidy.php';
require_once 'xn-app://xoxotools/proxy/normalize_url.php';
require_once 'php2yubnubarray.php';
$doc = new DOMDocument();
$doc->preserveWhiteSpace = false;
if ($_REQUEST['url']) {
    $doc->loadHTML(getTidy(normalize_url($_REQUEST['url'])));
} else {
    $doc->loadHTML($_REQUEST['data']);
}
$xpath = new DOMXPath($doc);
$results = $xpath->query($_REQUEST['query']);
$final = array();
foreach ($results as $node) {
    $newDom = new DOMDocument();
    $newDom->appendChild($newDom->importNode($node, 1));
    $final[] = str_replace("<?xml version=\"1.0\"?>\n", '', $newDom->saveXML());
}
//end foreach results as node
$_REQUEST['as'] = $_REQUEST['as'] ? $_REQUEST['as'] : 'xml';
echo php2yubnubarray($final, $_REQUEST['as'], $_REQUEST['callback']);
Example #17
0
 /**
  * build a reference to a location
  *
  * Depending on parameter '[code]with_friendly_urls[/code]' and on action,
  * following results can be observed:
  *
  * - view - locations/view.php?id=123 or locations/view.php/123 or location-123
  *
  * - other - locations/edit.php?id=123 or locations/edit.php/123 or location-edit/123
  *
  * @param int the id of the location to handle
  * @param string the expected action ('view', 'print', 'edit', 'delete', ...)
  * @param string additional data, such as file name, if any
  * @return string a normalized reference
  *
  * @see control/configure.php
  */
 public static function get_url($id, $action = 'view', $name = NULL)
 {
     global $context;
     // check the target action
     if (!preg_match('/^(delete|edit|map_on_earth|map_on_google|view)$/', $action)) {
         return 'locations/' . $action . '.php?id=' . urlencode($id) . '&action=' . urlencode($name);
     }
     // normalize the link
     return normalize_url(array('locations', 'location'), $action, $id, $name);
 }
Example #18
0
<?php

define('ROOT_DIR', dirname(__FILE__));
set_include_path(get_include_path() . PATH_SEPARATOR . ROOT_DIR . DIRECTORY_SEPARATOR . 'library');
set_include_path(get_include_path() . PATH_SEPARATOR . ROOT_DIR . DIRECTORY_SEPARATOR . 'includes');
require_once 'dump.php';
require_once 'validateurl.php';
$testcases = array(array('HTTP://www.Example.com/', 'http://www.example.com/'), array('http://www.example.com/a%c2%b1b', 'http://www.example.com/a%C2%B1b'), array('http://www.example.com/%7Eusername/', 'http://www.example.com/~username/'), array('http://www.example.com', 'http://www.example.com/'), array('http://www.example.com:80/bar.html', 'http://www.example.com/bar.html'), array('http://www.example.com/../a/b/../c/./d.html', 'http://www.example.com/a/c/d.html'), array('eXAMPLE://a/./b/../b/%63/%7bfoo%7d', 'example://a/b/c/%7Bfoo%7D'), array('http://www.yahoo.com/%a1', 'http://www.yahoo.com/%A1'), array('http://fancysite.nl/links/doit.pl?id=2029', 'http://fancysite.nl/links/doit.pl?id=2029'), array('http://example.com?arg1=1', 'http://example.com/?arg1=1'), array('http://example.com/index.php?arg2=2&arg1=1', 'http://example.com/index.php?arg1=1&arg2=2'), array('http://example.com/?&arg1=1&&arg2', 'http://example.com/?arg1=1'), array('http://example.com/?arg1=', 'http://example.com/'), array('http://example.com/index.html#fragment', 'http://example.com/index.html#fragment'), array('HtTp://*****:*****@www.ExAmPle.com:80/Blah', 'http://*****:*****@www.example.com/Blah'), array('http://example.com:81/index.html', 'http://example.com:81/index.html'), array('https://example.com:443', 'https://example.com/'));
foreach ($testcases as $tc) {
    list($url, $normurl) = $tc;
    $newurl = normalize_url($url);
    echo $url, ' => ', $newurl;
    if ($newurl != $normurl) {
        echo ' != ', $normurl;
    }
    echo PHP_EOL;
}
Example #19
0
	</head>

	<body>
		<h1>Twitter to OpenMicroBlogging Bridge</h1>
		<p>Due to <a href="http://laconi.ca/trac/ticket/55">licensing issues</a>, tweeple must have licensed under CC-BY using <a href="http://tweetcc.com">tweetcc</a> for this to work.</p>
<?php 
require 'normalize_url.php';
session_start();
if (isset($_REQUEST['forget'])) {
    unset($_SESSION['profile_url']);
}
if ($_REQUEST['profile_url'] && !strstr($_REQUEST['profile_url'], '.')) {
    $_REQUEST['profile_url'] = 'http://identi.ca/' . $_REQUEST['profile_url'];
}
if ($_REQUEST['profile_url']) {
    $_SESSION['profile_url'] = normalize_url(str_replace("'", '', $_REQUEST['profile_url']));
}
if (!$_SESSION['profile_url']) {
    ?>

<form method="get" action="/"><div>
	<label for="profile_url">Enter your identi.ca <strong>username</strong>
			<br />
		or laconica <strong>profile link</strong>:</label>
	<input type="text" id="profile_url" name="profile_url" />
	<input type="submit" value="Go" />
</div></form>

<?php 
} else {
    if (isset($_REQUEST['done'])) {
Example #20
0
File: dates.php Project: rair/yacs
 /**
  * build a reference to a date
  *
  * Depending on parameter '[code]with_friendly_urls[/code]' and on action,
  * following results can be observed:
  *
  * - view - dates/view.php?id=123 or dates/view.php/123 or date-123
  *
  * - other - dates/edit.php?id=123 or dates/edit.php/123 or date-edit/123
  *
  * @param int the id of the date to handle
  * @param string the expected action ('view', 'print', 'edit', 'delete', ...)
  * @return string a normalized reference
  *
  * @see control/configure.php
  */
 public static function get_url($id, $action = 'view')
 {
     global $context;
     // get a one-year calendar -- id is the target year (e.g., '1999')
     if ($action == 'year') {
         if ($context['with_friendly_urls'] == 'Y') {
             return 'dates/year.php/' . rawurlencode($id);
         } elseif ($context['with_friendly_urls'] == 'R') {
             return 'dates/year.php/' . rawurlencode($id);
         } else {
             return 'dates/year.php?year=' . urlencode($id);
         }
     }
     // get a one-month calendar -- id is the target month (e.g., '199903', '1999-03' or '1999/03')
     if ($action == 'month') {
         // do not accept more than 7 chars
         if (strlen($id) > 7) {
             $id = substr($id, 0, 7);
         }
         // expand the compact form (e.g., '199903' -> '1999/03')
         if (strlen($id) == 6) {
             $id = substr($id, 0, 4) . '/' . substr($id, 5, 2);
         }
         // normalize separator
         $id = str_replace('-', '/', $id);
         if ($context['with_friendly_urls'] == 'Y') {
             return 'dates/month.php/' . $id;
         } elseif ($context['with_friendly_urls'] == 'R') {
             return 'dates/month.php/' . $id;
         } else {
             return 'dates/month.php?month=' . urlencode($id);
         }
     }
     // get a one-day calendar -- id is the target day (e.g., '19990325', '1999-03-25' or '1999/03/25')
     if ($action == 'day') {
         // do not accept more than 10 chars
         if (strlen($id) > 10) {
             $id = substr($id, 0, 10);
         }
         // expand the compact form (e.g., '19990325' -> '1999/03/25')
         if (strpos($id, '/') === FALSE) {
             $id = substr($id, 0, 4) . '/' . substr($id, 4, 2) . '/' . substr($id, 6, 2);
         }
         // normalize separator
         $id = str_replace('-', '/', $id);
         if ($context['with_friendly_urls'] == 'Y') {
             return 'dates/day.php/' . $id;
         } elseif ($context['with_friendly_urls'] == 'R') {
             return 'dates/day.php/' . $id;
         } else {
             return 'dates/day.php?day=' . urlencode($id);
         }
     }
     // check the target action
     if (!preg_match('/^(delete|edit|view)$/', $action)) {
         return 'dates/' . $action . '.php?id=' . urlencode($id);
     }
     // normalize the link
     return normalize_url(array('dates', 'date'), $action, $id);
 }
Example #21
0
<?php

if (!empty($_REQUEST['href'])) {
    // Load shifts by URL
    $href = normalize_url($_REQUEST['href']);
    $href = $db->escape($href);
    $shift_clause = "AND s.href = '{$href}'";
} else {
    if (!empty($_REQUEST['id'])) {
        // Load shifts by ID
        $id = $db->escape($_REQUEST['id']);
        if (strpos($id, ',') === false) {
            // Only want one shift
            $shift_clause = "AND s.url_slug = '{$id}'";
        } else {
            // Want multiple shifts
            $id = explode(',', $id);
            $id = "'" . implode("','", $id) . "'";
            $shift_clause = "AND s.url_slug IN ({$id})";
        }
    } else {
        $shift_clause = "";
    }
}
// For table view sorting
if (!empty($_REQUEST['sortByColumn'])) {
    $sortByColumn = $db->escape($_REQUEST['sortByColumn']);
} else {
    $sortByColumn = 'created';
}
// For table view sorting
Example #22
0
 /**
  * build a reference to an article
  *
  * Depending on parameter '[code]with_friendly_urls[/code]' and on action,
  * following results can be observed:
  *
  * - view - articles/view.php?id=123 or articles/view.php/123 or article-123
  *
  * - other - articles/edit.php?id=123 or articles/edit.php/123 or article-edit/123
  *
  * If a third parameter is provided, it may be used to achieve a nice link,
  * such as the following:
  * [php]
  * Articles::get_url(123, 'view', 'A very nice page');
  * [/php]
  * will result to
  * [snippet]
  * http://server/article-123-a-very-nice-page
  * [/snippet]
  *
  * If a fourth parameter is provided, it will take over the third one. This
  * is used to leverage nick names in YACS, as per the following invocation:
  * [php]
  * Articles::get_url($item['id'], 'view', $item['title'], $item['nick_name']);
  * [/php]
  *
  * @param int the id of the article to handle
  * @param string the expected action ('view', 'print', 'edit', 'delete', ...)
  * @param string additional data, such as page name, if any
  * @param string alternate name, if any, to take over on previous parameter
  * @return string a normalized reference
  *
  * @see control/configure.php
  */
 public static function get_url($id, $action = 'view', $name = NULL, $alternate_name = NULL)
 {
     global $context;
     // use alternate name instead of regular name, if one is provided
     if ($alternate_name && $context['with_alternate_urls'] == 'Y') {
         $name = str_replace('_', ' ', $alternate_name);
     }
     // the service to check for updates
     if ($action == 'check') {
         if ($context['with_friendly_urls'] == 'Y') {
             return 'services/check.php/article/' . rawurlencode($id);
         } elseif ($context['with_friendly_urls'] == 'R') {
             return 'services/check.php?id=' . urlencode('article:' . $id);
         } else {
             return 'services/check.php?id=' . urlencode('article:' . $id);
         }
     }
     // invite someone to participate
     if ($action == 'invite') {
         if ($name) {
             return 'articles/invite.php?id=' . urlencode($id) . '&amp;invited=' . urlencode($name);
         } else {
             return 'articles/invite.php?id=' . urlencode($id);
         }
     }
     // i like this page
     if ($action == 'like') {
         if ($context['with_friendly_urls'] == 'Y') {
             return 'articles/rate.php/' . rawurlencode($id) . '?rating=5&amp;referer=' . urlencode($context['self_url']);
         } elseif ($context['with_friendly_urls'] == 'R') {
             return 'article-rate/' . rawurlencode($id) . '?rating=5&amp;referer=' . urlencode($context['self_url']);
         } else {
             return 'articles/rate.php?id=' . urlencode($id) . '&amp;rating=5&amp;referer=' . urlencode($context['self_url']);
         }
     }
     // i dislike this page
     if ($action == 'dislike') {
         if ($context['with_friendly_urls'] == 'Y') {
             return 'articles/rate.php/' . rawurlencode($id) . '?rating=1&amp;referer=' . urlencode($context['self_url']);
         } elseif ($context['with_friendly_urls'] == 'R') {
             return 'article-rate/' . rawurlencode($id) . '?rating=1&amp;referer=' . urlencode($context['self_url']);
         } else {
             return 'articles/rate.php?id=' . urlencode($id) . '&amp;rating=1&amp;referer=' . urlencode($context['self_url']);
         }
     }
     // check the target action
     if (!preg_match('/^(delete|describe|duplicate|edit|export|fetch_as_msword|fetch_as_pdf|invite|lock|mail|move|navigate|own|print|publish|rate|stamp|unpublish|view)$/', $action)) {
         return 'articles/' . $action . '.php?id=' . urlencode($id) . '&action=' . urlencode($name);
     }
     // normalize the link
     return normalize_url(array('articles', 'article'), $action, $id, $name);
 }
<?php

require_once 'getTidy.php';
require_once 'xn-app://xoxotools/proxy/normalize_url.php';
$_REQUEST['url'] = normalize_url(trim($_REQUEST['url']));
$domain = explode('/', $_REQUEST['url']);
array_pop($domain);
$dir = implode('/', $domain) . '/';
$domain = 'http://' . strtolower($domain[2]);
$doc = new DOMDocument();
$doc->preserveWhiteSpace = false;
@$doc->loadHTML(getTidy($_REQUEST['url']));
function doresolve(&$results, $attribute, $domain, $dir)
{
    foreach ($results as $node) {
        $href = $node->getAttribute($attribute);
        if (preg_match('/^[^:]*:.*$/', $href)) {
            continue;
        }
        if (!$href) {
            $node->setAttribute($attribute, $_REQUEST['url']);
            continue;
        }
        if ($href[0] == '/') {
            $node->setAttribute($attribute, $domain . $href);
        } else {
            $node->setAttribute($attribute, $dir . $href);
        }
    }
    //end foreach results
}
Example #24
0
File: files.php Project: rair/yacs
 /**
  * build a reference to a file
  *
  * Depending on parameter '[code]with_friendly_urls[/code]' and on action,
  * following results can be observed:
  *
  * - view - files/view.php?id=123 or files/view.php/123 or file-123
  *
  * - other - files/edit.php?id=123 or files/edit.php/123 or file-edit/123
  *
  * @param int the id of the file to handle
  * @param string the expected action ('view', 'print', 'edit', 'delete', ...)
  * @param string additional data, such as file name, if any
  * @return string a normalized reference
  *
  * @see control/configure.php
  */
 public static function get_url($id, $action = 'view', $name = NULL)
 {
     global $context;
     // get files in rss -- the id has to be an anchor (e.g., 'article:15')
     if ($action == 'feed') {
         if ($context['with_friendly_urls'] == 'Y') {
             return 'files/feed.php/' . str_replace(':', '/', $id);
         } elseif ($context['with_friendly_urls'] == 'R') {
             return 'files/feed.php/' . str_replace(':', '/', $id);
         } else {
             return 'files/feed.php?anchor=' . urlencode($id);
         }
     }
     // add a file -- the id has to be an anchor (e.g., 'article:15')
     if ($action == 'file') {
         if ($context['with_friendly_urls'] == 'Y') {
             return 'files/edit.php/' . str_replace(':', '/', $id);
         } elseif ($context['with_friendly_urls'] == 'R') {
             return 'files/edit.php/' . str_replace(':', '/', $id);
         } else {
             return 'files/edit.php?anchor=' . urlencode($id);
         }
     }
     // confirm the download
     if ($action == 'confirm') {
         $action = 'fetch';
         $name = 'confirm';
     }
     // clear assignment
     if ($action == 'release') {
         $action = 'fetch';
         $name = 'release';
     }
     // reserve the file
     if ($action == 'reserve') {
         $action = 'fetch';
         $name = 'reserve';
     }
     // direct access to the file
     if ($action == 'direct') {
         // get file data
         $file = Files::get($id);
         // get path to the file
         $url = Files::get_path($file['anchor']) . '/' . rawurlencode($file['file_name']);
         return $url;
     }
     // check the target action
     if (!preg_match('/^(author|delete|edit|fetch|list|stream|thread|view)$/', $action)) {
         return 'files/' . $action . '.php?id=' . urlencode($id) . '&action=' . urlencode($name);
     }
     // normalize the link
     return normalize_url(array('files', 'file'), $action, $id, $name);
 }
Example #25
0
File: tables.php Project: rair/yacs
 /**
  * build a reference to a table
  *
  * Depending on parameter '[code]with_friendly_urls[/code]' and on action,
  * following results can be observed:
  *
  * - view - tables/view.php?id=123 or tables/view.php/123 or table-123
  *
  * - other - tables/edit.php?id=123 or tables/edit.php/123 or table-edit/123
  *
  * @param int the id of the table to handle
  * @param string the expected action ('view', 'print', 'edit', 'delete', ...)
  * @return string a normalized reference
  *
  * @see control/configure.php
  */
 public static function get_url($id, $action = 'view')
 {
     global $context;
     // check the target action
     if (!preg_match('/^(delete|edit|fetch_as_csv|fetch_as_json|fetch_as_raw|fetch_as_xml|view)$/', $action)) {
         return 'tables/' . $action . '.php?id=' . urlencode($id);
     }
     // normalize the link
     return normalize_url(array('tables', 'table'), $action, $id);
 }
Example #26
0
 /**
  * build a reference to a comment
  *
  * The action parameter defines the kind of link you want:
  * - 'comment' - a form to add a new comment to something - id has to reference an anchor (e.g., 'article:123')
  * - 'delete' - a form to delete a comment
  * - 'edit' - a form to edit a comment
  * - 'feed' - get comments as a feed - id has to reference an anchor (e.g., 'article:123')
  * - 'list' - list comments attached to something - id has to reference an anchor (e.g., 'article:123')
  * - 'navigate' - used to build a paging menu for comments - id has to reference an anchor (e.g., 'article:123')
  * - 'promote' - a form to turn a comment to an article
  * - 'quote' - use an existing comment in yours
  * - 'reply' - chain a comment to an existing one
  * - 'service.comment' - a service to add a new comment to something - id has to reference an anchor (e.g., 'article:123')
  * - 'thread' - a service to manage threads - id has to reference an anchor (e.g., 'article:123')
  * - 'view' - a page to zoom on one comment
  *
  * Depending on parameter '[code]with_friendly_urls[/code]' and on action,
  * following results can be observed:
  *
  * - view - comments/view.php?id=123 or comments/view.php/123 or comment-123
  *
  * - other - comments/edit.php?id=123 or comments/edit.php/123 or comment-edit/123
  *
  * @param mixed the id of the comment to handle, or some anchor reference, e.g., 'section:123'
  * @param string the expected action ('view', 'print', 'edit', 'delete', ...)
  * @return string a normalized reference
  *
  * @see control/configure.php
  */
 public static function get_url($id, $action = 'view')
 {
     global $context;
     // add an approval comment -- the id has to be an anchor (e.g., 'article:15')
     if ($action == 'approve') {
         if ($context['with_friendly_urls'] == 'Y') {
             return 'comments/approve.php/' . str_replace(':', '/', $id);
         } elseif ($context['with_friendly_urls'] == 'R') {
             return 'comments/approve.php/' . str_replace(':', '/', $id);
         } else {
             return 'comments/approve.php?anchor=' . urlencode($id);
         }
     }
     // add a comment -- the id has to be an anchor (e.g., 'article:15')
     if ($action == 'comment') {
         if ($context['with_friendly_urls'] == 'Y') {
             return 'comments/edit.php/' . str_replace(':', '/', $id);
         } elseif ($context['with_friendly_urls'] == 'R') {
             return 'comments/edit.php/' . str_replace(':', '/', $id);
         } else {
             return 'comments/edit.php?anchor=' . urlencode($id);
         }
     }
     // get comments in rss -- the id has to be an anchor (e.g., 'article:15')
     if ($action == 'feed') {
         if ($context['with_friendly_urls'] == 'Y') {
             return 'comments/feed.php/' . str_replace(':', '/', $id);
         } elseif ($context['with_friendly_urls'] == 'R') {
             return 'comments/feed.php/' . str_replace(':', '/', $id);
         } else {
             return 'comments/feed.php?anchor=' . urlencode($id);
         }
     }
     // list comments -- the id has to be an anchor (e.g., 'article:15')
     if ($action == 'list') {
         if ($context['with_friendly_urls'] == 'Y') {
             return 'comments/list.php/' . str_replace(':', '/', $id);
         } elseif ($context['with_friendly_urls'] == 'R') {
             return 'comment-list/' . $id;
         } else {
             return 'comments/list.php?id=' . urlencode($id);
         }
     }
     // navigate comments -- the id has to be an anchor (e.g., 'article:15')
     if ($action == 'navigate') {
         if ($context['with_friendly_urls'] == 'Y') {
             return 'comments/list.php/' . str_replace(':', '/', $id) . '/';
         } elseif ($context['with_friendly_urls'] == 'R') {
             return 'comments/list.php/' . str_replace(':', '/', $id) . '/';
         } else {
             return 'comments/list.php?id=' . urlencode($id) . '&amp;page=';
         }
     }
     // quote an existing comment
     if ($action == 'quote') {
         if ($context['with_friendly_urls'] == 'Y') {
             return 'comments/edit.php/quote/' . rawurlencode($id);
         } elseif ($context['with_friendly_urls'] == 'R') {
             return 'comments/edit.php/quote/' . rawurlencode($id);
         } else {
             return 'comments/edit.php?quote=' . urlencode($id);
         }
     }
     // reply to an existing comment
     if ($action == 'reply') {
         if ($context['with_friendly_urls'] == 'Y') {
             return 'comments/edit.php/reply/' . rawurlencode($id);
         } elseif ($context['with_friendly_urls'] == 'R') {
             return 'comments/edit.php/reply/' . rawurlencode($id);
         } else {
             return 'comments/edit.php?reply=' . urlencode($id);
         }
     }
     // add a comment, the service -- the id has to be an anchor (e.g., 'article:15')
     if ($action == 'service.comment') {
         if ($context['with_friendly_urls'] == 'Y') {
             return 'comments/post.php/' . str_replace(':', '/', $id);
         } elseif ($context['with_friendly_urls'] == 'R') {
             return 'comments/post.php/' . str_replace(':', '/', $id);
         } else {
             return 'comments/post.php?anchor=' . urlencode($id);
         }
     }
     // check the target action
     if (!preg_match('/^(delete|edit|promote|thread|view)$/', $action)) {
         return 'comments/' . $action . '.php?id=' . urlencode($id);
     }
     // normalize the link
     return normalize_url(array('comments', 'comment'), $action, $id);
 }
Example #27
0
/**
* Returns the normalized signature base string of this request
* @param string $http_method
* @param string $url
* @param array $params
* The base string is defined as the method, the url and the
* parameters (normalized), each urlencoded and the concated with &.
* @see http://oauth.net/core/1.0/#rfc.section.A.5.1
*/
function signature_base_string($http_method, $url, $params)
{
    // Decompose and pull query params out of the url
    $query_str = parse_url($url, PHP_URL_QUERY);
    if ($query_str) {
        $parsed_query = oauth_parse_str($query_str);
        // merge params from the url with params array from caller
        $params = array_merge($params, $parsed_query);
    }
    // Remove oauth_signature from params array if present
    if (isset($params['oauth_signature'])) {
        unset($params['oauth_signature']);
    }
    // Create the signature base string. Yes, the $params are double encoded.
    $base_string = rfc3986_encode(strtoupper($http_method)) . '&' . rfc3986_encode(normalize_url($url)) . '&' . rfc3986_encode(oauth_http_build_query($params));
    logit("signature_base_string:INFO:normalized_base_string:{$base_string}");
    return $base_string;
}
Example #28
0
<?php

if (!$_REQUEST['url']) {
    die('<h2>No URL Specified!</h2>');
}
if (!$_REQUEST['name']) {
    die('<h2>No Name Specified!</h2>');
}
require_once 'xn-app://someblogs/normalize_url.php';
$page = file_get_contents($_REQUEST['url']);
header('Content-type: text/javascript;charset=utf8');
preg_match_all('/<a[^<>]*?href=' . "['\"]" . '([^<>]*?)' . "['\"]" . '[^<>]*?>\\s*?' . $_REQUEST['name'] . '\\s*?<\\/a>/i', $page, $result);
if ($_REQUEST['callback']) {
    echo $_REQUEST['callback'] . '(';
}
if ($_REQUEST['parameter']) {
    echo $_REQUEST['parameter'] . ', ';
}
if ($result[1][1]) {
    echo '{"url":"' . normalize_url($result[1][1]) . '"}';
} else {
    if ($result[1][0]) {
        echo '{"url":"' . normalize_url($result[1][0]) . '"}';
    } else {
        echo '{"url":""}';
    }
}
if ($_REQUEST['callback']) {
    echo ')';
}