Merge pull request #214 from annando/master
API, Locking, some changes to "vier"
This commit is contained in:
commit
c3867f4ce4
12 changed files with 272 additions and 22 deletions
|
@ -83,5 +83,8 @@ $a->config['system']['no_regfullname'] = true;
|
|||
// If set to true the priority settings of ostatus contacts are used
|
||||
$a->config['system']['ostatus_use_priority'] = false;
|
||||
|
||||
// If enabled all items are cached in the given directory
|
||||
// If enabled, all items are cached in the given directory
|
||||
$a->config['system']['itemcache'] = "";
|
||||
|
||||
// If enabled, the lockpath is used for a lockfile to check if the poller is running
|
||||
$a->config['system']['lockpath'] = "";
|
||||
|
|
151
include/api.php
151
include/api.php
|
@ -784,8 +784,145 @@
|
|||
}
|
||||
api_register_func('api/statuses/show','api_statuses_show', true);
|
||||
|
||||
//api_register_func('api/statuses/mentions','api_statuses_mentions', true);
|
||||
//api_register_func('api/statuses/replies','api_statuses_mentions', true);
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function api_statuses_repeat(&$a, $type){
|
||||
if (local_user()===false) return false;
|
||||
|
||||
$user_info = api_get_user($a);
|
||||
|
||||
// params
|
||||
$id = intval($a->argv[3]);
|
||||
|
||||
logger('API: api_statuses_repeat: '.$id);
|
||||
|
||||
//$include_entities = (x($_REQUEST,'include_entities')?$_REQUEST['include_entities']:false);
|
||||
|
||||
$r = q("SELECT `item`.*, `item`.`id` AS `item_id`, `contact`.`nick` as `reply_author`,
|
||||
`contact`.`name`, `contact`.`photo`, `contact`.`url` as `reply_url`, `contact`.`rel`,
|
||||
`contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`,
|
||||
`contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
|
||||
FROM `item`, `contact`
|
||||
WHERE `item`.`visible` = 1 and `item`.`moderated` = 0 AND `item`.`deleted` = 0
|
||||
AND `contact`.`id` = `item`.`contact-id`
|
||||
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
|
||||
$sql_extra
|
||||
AND `item`.`id`=%d",
|
||||
intval($id)
|
||||
);
|
||||
|
||||
$_REQUEST['body'] = html_entity_decode("♲ ", ENT_QUOTES, 'UTF-8')."[url=".$r[0]['reply_url']."]".$r[0]['reply_author']."[/url] \n".$r[0]['body'];
|
||||
$_REQUEST['profile_uid'] = local_user();
|
||||
$_REQUEST['type'] = 'wall';
|
||||
$_REQUEST['api_source'] = true;
|
||||
|
||||
require_once('mod/item.php');
|
||||
item_post($a);
|
||||
|
||||
if ($type == 'xml')
|
||||
$ok = "true";
|
||||
else
|
||||
$ok = "ok";
|
||||
|
||||
return api_apply_template('test', $type, array('$ok' => $ok));
|
||||
}
|
||||
api_register_func('api/statuses/retweet','api_statuses_repeat', true);
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function api_statuses_destroy(&$a, $type){
|
||||
if (local_user()===false) return false;
|
||||
|
||||
$user_info = api_get_user($a);
|
||||
|
||||
// params
|
||||
$id = intval($a->argv[3]);
|
||||
|
||||
logger('API: api_statuses_destroy: '.$id);
|
||||
|
||||
require_once('include/items.php');
|
||||
drop_item($id, false);
|
||||
|
||||
if ($type == 'xml')
|
||||
$ok = "true";
|
||||
else
|
||||
$ok = "ok";
|
||||
|
||||
return api_apply_template('test', $type, array('$ok' => $ok));
|
||||
}
|
||||
api_register_func('api/statuses/destroy','api_statuses_destroy', true);
|
||||
|
||||
/**
|
||||
*
|
||||
* http://developer.twitter.com/doc/get/statuses/mentions
|
||||
*
|
||||
*/
|
||||
function api_statuses_mentions(&$a, $type){
|
||||
if (local_user()===false) return false;
|
||||
|
||||
$user_info = api_get_user($a);
|
||||
// get last newtork messages
|
||||
|
||||
|
||||
// params
|
||||
$count = (x($_REQUEST,'count')?$_REQUEST['count']:20);
|
||||
$page = (x($_REQUEST,'page')?$_REQUEST['page']-1:0);
|
||||
if ($page<0) $page=0;
|
||||
$since_id = (x($_REQUEST,'since_id')?$_REQUEST['since_id']:0);
|
||||
$max_id = (x($_REQUEST,'max_id')?$_REQUEST['max_id']:0);
|
||||
//$since_id = 0;//$since_id = (x($_REQUEST,'since_id')?$_REQUEST['since_id']:0);
|
||||
|
||||
$start = $page*$count;
|
||||
|
||||
//$include_entities = (x($_REQUEST,'include_entities')?$_REQUEST['include_entities']:false);
|
||||
|
||||
$myurl = $a->get_baseurl() . '/profile/'. $a->user['nickname'];
|
||||
$myurl = substr($myurl,strpos($myurl,'://')+3);
|
||||
$myurl = str_replace(array('www.','.'),array('','\\.'),$myurl);
|
||||
$diasp_url = str_replace('/profile/','/u/',$myurl);
|
||||
$sql_extra .= sprintf(" AND `item`.`parent` IN (SELECT distinct(`parent`) from item where ( `author-link` regexp '%s' or `tag` regexp '%s' or tag regexp '%s' )) ",
|
||||
dbesc($myurl . '$'),
|
||||
dbesc($myurl . '\\]'),
|
||||
dbesc($diasp_url . '\\]')
|
||||
);
|
||||
|
||||
if ($max_id > 0)
|
||||
$sql_extra .= ' AND `item`.`id` <= '.intval($max_id);
|
||||
|
||||
$r = q("SELECT `item`.*, `item`.`id` AS `item_id`,
|
||||
`contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`,
|
||||
`contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`,
|
||||
`contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
|
||||
FROM `item`, `contact`
|
||||
WHERE `item`.`uid` = %d
|
||||
AND `item`.`visible` = 1 and `item`.`moderated` = 0 AND `item`.`deleted` = 0
|
||||
AND `contact`.`id` = `item`.`contact-id`
|
||||
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
|
||||
$sql_extra
|
||||
AND `item`.`id`>%d
|
||||
ORDER BY `item`.`received` DESC LIMIT %d ,%d ",
|
||||
intval($user_info['uid']),
|
||||
intval($since_id),
|
||||
intval($start), intval($count)
|
||||
);
|
||||
|
||||
$ret = api_format_items($r,$user_info);
|
||||
|
||||
|
||||
$data = array('$statuses' => $ret);
|
||||
switch($type){
|
||||
case "atom":
|
||||
case "rss":
|
||||
$data = api_rss_extra($a, $data, $user_info);
|
||||
}
|
||||
|
||||
return api_apply_template("timeline", $type, $data);
|
||||
}
|
||||
api_register_func('api/statuses/mentions','api_statuses_mentions', true);
|
||||
api_register_func('api/statuses/replies','api_statuses_mentions', true);
|
||||
|
||||
|
||||
function api_statuses_user_timeline(&$a, $type){
|
||||
|
@ -1309,12 +1446,11 @@
|
|||
|
||||
/*
|
||||
Not implemented by now:
|
||||
favorites
|
||||
favorites/create
|
||||
favorites/destroy
|
||||
statuses/public_timeline
|
||||
statuses/mentions
|
||||
statuses/replies
|
||||
statuses/retweets_of_me
|
||||
statuses/destroy
|
||||
statuses/retweet
|
||||
friendships/create
|
||||
friendships/destroy
|
||||
friendships/exists
|
||||
|
@ -1322,9 +1458,6 @@ friendships/show
|
|||
account/update_location
|
||||
account/update_profile_background_image
|
||||
account/update_profile_image
|
||||
favorites
|
||||
favorites/create
|
||||
favorites/destroy
|
||||
blocks/create
|
||||
blocks/destroy
|
||||
oauth/authorize
|
||||
|
|
|
@ -230,7 +230,8 @@ function bbcode($Text,$preserve_nl = false) {
|
|||
$Text);
|
||||
|
||||
// [img=widthxheight]image source[/img]
|
||||
$Text = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism", '<img src="$3" style="height: $2px; width: $1px;" >', $Text);
|
||||
//$Text = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism", '<img src="$3" style="height: $2px; width: $1px;" >', $Text);
|
||||
$Text = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism", '<img src="$3" style="width: $1px;" >', $Text);
|
||||
|
||||
// Images
|
||||
// [img]pathtoimage[/img]
|
||||
|
|
|
@ -83,12 +83,15 @@ function collecturls($message) {
|
|||
$urls = array();
|
||||
foreach ($result as $treffer) {
|
||||
// A list of some links that should be ignored
|
||||
$list = array("/user/", "/tag/", "/profile/", "/search?search=", "mailto:", "/u/", "/node/",
|
||||
$list = array("/user/", "/tag/", "/group/", "/profile/", "/search?search=", "mailto:", "/u/", "/node/",
|
||||
"//facebook.com/profile.php?id=", "//plus.google.com/");
|
||||
foreach ($list as $listitem)
|
||||
if (strpos($treffer[1], $listitem) !== false)
|
||||
$ignore = true;
|
||||
|
||||
if ((strpos($treffer[1], "//plus.google.com/") !== false) and (strpos($treffer[1], "/posts") !== false))
|
||||
$ignore = false;
|
||||
|
||||
if (!$ignore)
|
||||
$urls[$treffer[1]] = $treffer[1];
|
||||
}
|
||||
|
|
32
include/pidfile.php
Normal file
32
include/pidfile.php
Normal file
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
class pidfile {
|
||||
private $_file;
|
||||
private $_running;
|
||||
|
||||
public function __construct($dir, $name) {
|
||||
$this->_file = "$dir/$name.pid";
|
||||
|
||||
if (file_exists($this->_file)) {
|
||||
$pid = trim(file_get_contents($this->_file));
|
||||
if (posix_kill($pid, 0)) {
|
||||
$this->_running = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (! $this->_running) {
|
||||
$pid = getmypid();
|
||||
file_put_contents($this->_file, $pid);
|
||||
}
|
||||
}
|
||||
|
||||
public function __destruct() {
|
||||
if ((! $this->_running) && file_exists($this->_file)) {
|
||||
unlink($this->_file);
|
||||
}
|
||||
}
|
||||
|
||||
public function is_already_running() {
|
||||
return $this->_running;
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -25,10 +25,20 @@ function poller_run($argv, $argc){
|
|||
require_once('include/Contact.php');
|
||||
require_once('include/email.php');
|
||||
require_once('include/socgraph.php');
|
||||
require_once('include/pidfile.php');
|
||||
|
||||
load_config('config');
|
||||
load_config('system');
|
||||
|
||||
$lockpath = get_config('system','lockpath');
|
||||
if ($lockpath != '') {
|
||||
$pidfile = new pidfile($lockpath, 'poller.lck');
|
||||
if($pidfile->is_already_running()) {
|
||||
logger("poller: Already running");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
$a->set_baseurl(get_config('system','url'));
|
||||
|
||||
load_hooks();
|
||||
|
|
1
view/api_test_xml.tpl
Normal file
1
view/api_test_xml.tpl
Normal file
|
@ -0,0 +1 @@
|
|||
<ok>$ok</ok>
|
|
@ -2549,4 +2549,4 @@ list-style-type: disc;
|
|||
#photos-upload-newalbum-div {
|
||||
float: left;
|
||||
width: 175px;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2546,4 +2546,4 @@ list-style-type: disc;
|
|||
#photos-upload-newalbum-div {
|
||||
float: left;
|
||||
width: 175px;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2526,4 +2526,4 @@ list-style-type: disc;
|
|||
#photos-upload-newalbum-div {
|
||||
float: left;
|
||||
width: 175px;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2687,4 +2687,4 @@ list-style-type: disc;
|
|||
#photos-upload-newalbum-div {
|
||||
float: left;
|
||||
width: 175px;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -108,6 +108,7 @@
|
|||
|
||||
.tools { background-position: -50px -40px;}
|
||||
.lock { background-position: -70px -40px;}
|
||||
.unlock { background-position: -90px -40px;}
|
||||
|
||||
.video { background-position: -110px -40px;}
|
||||
.youtube { background-position: -130px -40px;}
|
||||
|
@ -139,8 +140,8 @@
|
|||
|
||||
.icon {
|
||||
display: block;
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
background-image: url('icons.png');
|
||||
}
|
||||
|
||||
|
@ -415,17 +416,21 @@ code {
|
|||
background: #EEE;
|
||||
}
|
||||
.tool .label {
|
||||
float: left;
|
||||
/* float: left; */
|
||||
}
|
||||
.tool .action {
|
||||
float: right;
|
||||
}
|
||||
.tool a {
|
||||
color: #000;
|
||||
/* color: #000; */
|
||||
}
|
||||
.tool a:hover {
|
||||
text-decoration: none;
|
||||
text-decoration: underline;
|
||||
}
|
||||
.sidebar-group-element {
|
||||
/* color: #000; */
|
||||
}
|
||||
|
||||
/* popup notifications */
|
||||
div.jGrowl div.notice {
|
||||
background: #511919 url("../../../images/icons/48/notice.png") no-repeat 5px center;
|
||||
|
@ -604,6 +609,10 @@ nav #nav-apps-link.selected {
|
|||
padding: 5px 10px; */
|
||||
}
|
||||
|
||||
.notify-seen {
|
||||
background: none repeat scroll 0 0 #DDDDDD;
|
||||
}
|
||||
|
||||
ul.menu-popup {
|
||||
position: absolute;
|
||||
display: none;
|
||||
|
@ -970,6 +979,7 @@ section {
|
|||
margin-bottom: 1px;
|
||||
}
|
||||
.wall-item-container .wall-item-actions-social a {
|
||||
float: left;
|
||||
margin-right: 1em;
|
||||
}
|
||||
.wall-item-container .wall-item-actions-tools {
|
||||
|
@ -1244,7 +1254,8 @@ section {
|
|||
#jot #jot-tools li.loading img {
|
||||
margin-top: 10px;
|
||||
}
|
||||
#jot #jot-title {
|
||||
/* #jot */
|
||||
#jot-title {
|
||||
border: 0px;
|
||||
margin: 0px;
|
||||
height: 20px;
|
||||
|
@ -1272,6 +1283,56 @@ section {
|
|||
line-height: 20px;
|
||||
padding-right: 20px;
|
||||
}
|
||||
|
||||
#profile-jot-submit {
|
||||
float: right;
|
||||
margin-left: 15px;
|
||||
}
|
||||
#profile-upload-wrapper {
|
||||
float: left;
|
||||
margin-left: 15px;
|
||||
}
|
||||
#profile-attach-wrapper {
|
||||
float: left;
|
||||
margin-left: 15px;
|
||||
}
|
||||
#profile-link-wrapper {
|
||||
float: left;
|
||||
margin-left: 15px;
|
||||
}
|
||||
#profile-video-wrapper {
|
||||
float: left;
|
||||
margin-left: 15px;
|
||||
}
|
||||
#profile-audio-wrapper {
|
||||
float: left;
|
||||
margin-left: 15px;
|
||||
}
|
||||
#profile-location-wrapper {
|
||||
float: left;
|
||||
margin-left: 15px;
|
||||
}
|
||||
#profile-nolocation-wrapper {
|
||||
float: left;
|
||||
margin-left: 15px;
|
||||
}
|
||||
#jot-perms-icon {
|
||||
float: right;
|
||||
margin-left: 15px;
|
||||
}
|
||||
#jot-preview-link {
|
||||
float: right;
|
||||
}
|
||||
#profile-jot-end {
|
||||
clear: both;
|
||||
}
|
||||
#profile-jot-text_tbl {
|
||||
width: 800px;
|
||||
}
|
||||
#profile-jot-wrapper {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
/** buttons **/
|
||||
/*input[type="submit"] {
|
||||
border: 0px;
|
||||
|
@ -1585,6 +1646,12 @@ blockquote {
|
|||
border-left: 1px solid #D2D2D2;
|
||||
padding-left: 9px;
|
||||
margin: 0 0 0 .8ex;
|
||||
color: #777;
|
||||
}
|
||||
|
||||
.oembed {
|
||||
font-size: large;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
/* ================== */
|
||||
|
|
Loading…
Reference in a new issue