aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Zotlabs/Daemon/Ratenotif.php126
-rw-r--r--Zotlabs/Module/Connedit.php3
-rw-r--r--Zotlabs/Module/Prate.php107
-rw-r--r--Zotlabs/Module/Rate.php174
-rw-r--r--Zotlabs/Module/Ratings.php109
-rw-r--r--Zotlabs/Module/Ratingsearch.php78
6 files changed, 0 insertions, 597 deletions
diff --git a/Zotlabs/Daemon/Ratenotif.php b/Zotlabs/Daemon/Ratenotif.php
deleted file mode 100644
index 8afde2c4c..000000000
--- a/Zotlabs/Daemon/Ratenotif.php
+++ /dev/null
@@ -1,126 +0,0 @@
-<?php
-
-namespace Zotlabs\Daemon;
-
-require_once('include/zot.php');
-require_once('include/queue_fn.php');
-
-
-class Ratenotif {
-
- static public function run($argc,$argv) {
-
-
- // Deprecated
- return;
-
-
- require_once("datetime.php");
- require_once('include/items.php');
-
- if($argc < 3)
- return;
-
-
- logger('ratenotif: invoked: ' . print_r($argv,true), LOGGER_DEBUG);
-
- $cmd = $argv[1];
-
- $item_id = $argv[2];
-
-
- if($cmd === 'rating') {
- $r = q("select * from xlink where xlink_id = %d and xlink_static = 1 limit 1",
- intval($item_id)
- );
- if(! $r) {
- logger('rating not found');
- return;
- }
-
- $encoded_item = array(
- 'type' => 'rating',
- 'encoding' => 'zot',
- 'target' => $r[0]['xlink_link'],
- 'rating' => intval($r[0]['xlink_rating']),
- 'rating_text' => $r[0]['xlink_rating_text'],
- 'signature' => $r[0]['xlink_sig'],
- 'edited' => $r[0]['xlink_updated']
- );
- }
-
- $channel = channelx_by_hash($r[0]['xlink_xchan']);
- if(! $channel) {
- logger('no channel');
- return;
- }
-
-
- $primary = get_directory_primary();
-
- if(! $primary)
- return;
-
-
- $interval = ((get_config('system','delivery_interval') !== false)
- ? intval(get_config('system','delivery_interval')) : 2 );
-
- $deliveries_per_process = intval(get_config('system','delivery_batch_count'));
-
- if($deliveries_per_process <= 0)
- $deliveries_per_process = 1;
-
- $deliver = array();
-
- $x = z_fetch_url($primary . '/regdir');
- if($x['success']) {
- $j = json_decode($x['body'],true);
- if($j && $j['success'] && is_array($j['directories'])) {
-
- foreach($j['directories'] as $h) {
- if($h == z_root())
- continue;
-
- $hash = random_string();
- $n = zot_build_packet($channel,'notify',null,null,'',$hash);
-
- queue_insert(array(
- 'hash' => $hash,
- 'account_id' => $channel['channel_account_id'],
- 'channel_id' => $channel['channel_id'],
- 'posturl' => $h . '/post',
- 'notify' => $n,
- 'msg' => json_encode($encoded_item)
- ));
-
-
- $x = q("select count(outq_hash) as total from outq where outq_delivered = 0");
- if(intval($x[0]['total']) > intval(get_config('system','force_queue_threshold',300))) {
- logger('immediate delivery deferred.', LOGGER_DEBUG, LOG_INFO);
- update_queue_item($hash);
- continue;
- }
-
- $deliver[] = $hash;
-
- if(count($deliver) >= $deliveries_per_process) {
- Master::Summon(array('Deliver',$deliver));
- $deliver = array();
- if($interval)
- @time_sleep_until(microtime(true) + (float) $interval);
- }
- }
-
- // catch any stragglers
-
- if(count($deliver)) {
- Master::Summon(array('Deliver',$deliver));
- }
- }
- }
-
- logger('ratenotif: complete.');
- return;
-
- }
-}
diff --git a/Zotlabs/Module/Connedit.php b/Zotlabs/Module/Connedit.php
index 61fe4a889..82cecd3e1 100644
--- a/Zotlabs/Module/Connedit.php
+++ b/Zotlabs/Module/Connedit.php
@@ -220,9 +220,6 @@ class Connedit extends Controller {
if($z)
$record = $z[0]['xlink_id'];
}
- if($record) {
- Master::Summon(array('Ratenotif','rating',$record));
- }
}
if(($_REQUEST['pending']) && intval($orig_record[0]['abook_pending'])) {
diff --git a/Zotlabs/Module/Prate.php b/Zotlabs/Module/Prate.php
deleted file mode 100644
index 8b71657b8..000000000
--- a/Zotlabs/Module/Prate.php
+++ /dev/null
@@ -1,107 +0,0 @@
-<?php
-namespace Zotlabs\Module;
-
-
-use Zotlabs\Lib\Crypto;
-
-class Prate extends \Zotlabs\Web\Controller {
-
- function init() {
- if($_SERVER['REQUEST_METHOD'] === 'post')
- return;
-
- if(! local_channel())
- return;
-
- $channel = \App::get_channel();
-
- $target = argv(1);
- if(! $target)
- return;
-
- $r = q("select * from xlink where xlink_xchan = '%s' and xlink_link = '%s' and xlink_static = 1",
- dbesc($channel['channel_hash']),
- dbesc($target)
- );
- if($r)
- json_return_and_die(array('rating' => $r[0]['xlink_rating'],'rating_text' => $r[0]['xlink_rating_text']));
- killme();
- }
-
- function post() {
-
- if(! local_channel())
- return;
-
- $channel = \App::get_channel();
-
- $target = trim($_REQUEST['target']);
- if(! $target)
- return;
-
- if($target === $channel['channel_hash'])
- return;
-
- $rating = intval($_POST['rating']);
- if($rating < (-10))
- $rating = (-10);
- if($rating > 10)
- $rating = 10;
-
- $rating_text = trim(escape_tags($_REQUEST['rating_text']));
-
- $signed = $target . '.' . $rating . '.' . $rating_text;
-
- $sig = base64url_encode(Crypto::sign($signed,$channel['channel_prvkey']));
-
-
- $z = q("select * from xlink where xlink_xchan = '%s' and xlink_link = '%s' and xlink_static = 1 limit 1",
- dbesc($channel['channel_hash']),
- dbesc($target)
- );
- if($z) {
- $record = $z[0]['xlink_id'];
- $w = q("update xlink set xlink_rating = '%d', xlink_rating_text = '%s', xlink_sig = '%s', xlink_updated = '%s'
- where xlink_id = %d",
- intval($rating),
- dbesc($rating_text),
- dbesc($sig),
- dbesc(datetime_convert()),
- intval($record)
- );
- }
- else {
- $w = q("insert into xlink ( xlink_xchan, xlink_link, xlink_rating, xlink_rating_text, xlink_sig, xlink_updated, xlink_static ) values ( '%s', '%s', %d, '%s', '%s', '%s', 1 ) ",
- dbesc($channel['channel_hash']),
- dbesc($target),
- intval($rating),
- dbesc($rating_text),
- dbesc($sig),
- dbesc(datetime_convert())
- );
- $z = q("select * from xlink where xlink_xchan = '%s' and xlink_link = '%s' and xlink_static = 1 limit 1",
- dbesc($channel['channel_hash']),
- dbesc($orig_record[0]['abook_xchan'])
- );
- if($z)
- $record = $z[0]['xlink_id'];
- }
- if($record) {
- \Zotlabs\Daemon\Master::Summon(array('Ratenotif','rating',$record));
- }
-
- json_return_and_die(array('result' => true));;
- }
-
-
-
-
-
-
-
-
-
-
-
-
-}
diff --git a/Zotlabs/Module/Rate.php b/Zotlabs/Module/Rate.php
deleted file mode 100644
index d29c370fc..000000000
--- a/Zotlabs/Module/Rate.php
+++ /dev/null
@@ -1,174 +0,0 @@
-<?php
-namespace Zotlabs\Module;
-
-
-
-use Zotlabs\Lib\Crypto;
-
-class Rate extends \Zotlabs\Web\Controller {
-
- function init() {
-
- if(! local_channel())
- return;
-
- $channel = \App::get_channel();
-
- $target = $_REQUEST['target'];
- if(! $target)
- return;
-
- \App::$data['target'] = $target;
-
- if($target) {
- $r = q("SELECT * FROM xchan where xchan_hash like '%s' LIMIT 1",
- dbesc($target)
- );
- if($r) {
- \App::$poi = $r[0];
- }
- else {
- $r = q("select * from site where site_url like '%s' and site_type = %d",
- dbesc('%' . $target),
- intval(SITE_TYPE_ZOT)
- );
- if($r) {
- \App::$data['site'] = $r[0];
- \App::$data['site']['site_url'] = strtolower($r[0]['site_url']);
- }
- }
- }
-
-
- return;
-
- }
-
-
- function post() {
-
- if(! local_channel())
- return;
-
- if(! \App::$data['target'])
- return;
-
- if(! $_REQUEST['execute'])
- return;
-
- $channel = \App::get_channel();
-
- $rating = intval($_POST['rating']);
- if($rating < (-10))
- $rating = (-10);
- if($rating > 10)
- $rating = 10;
-
- $rating_text = trim(escape_tags($_REQUEST['rating_text']));
-
- $signed = \App::$data['target'] . '.' . $rating . '.' . $rating_text;
-
- $sig = base64url_encode(Crypto::sign($signed,$channel['channel_prvkey']));
-
- $z = q("select * from xlink where xlink_xchan = '%s' and xlink_link = '%s' and xlink_static = 1 limit 1",
- dbesc($channel['channel_hash']),
- dbesc(\App::$data['target'])
- );
-
- if($z) {
- $record = $z[0]['xlink_id'];
- $w = q("update xlink set xlink_rating = '%d', xlink_rating_text = '%s', xlink_sig = '%s', xlink_updated = '%s'
- where xlink_id = %d",
- intval($rating),
- dbesc($rating_text),
- dbesc($sig),
- dbesc(datetime_convert()),
- intval($record)
- );
- }
- else {
- $w = q("insert into xlink ( xlink_xchan, xlink_link, xlink_rating, xlink_rating_text, xlink_sig, xlink_updated, xlink_static ) values ( '%s', '%s', %d, '%s', '%s', '%s', 1 ) ",
- dbesc($channel['channel_hash']),
- dbesc(\App::$data['target']),
- intval($rating),
- dbesc($rating_text),
- dbesc($sig),
- dbesc(datetime_convert())
- );
- $z = q("select * from xlink where xlink_xchan = '%s' and xlink_link = '%s' and xlink_static = 1 limit 1",
- dbesc($channel['channel_hash']),
- dbesc(\App::$data['target'])
- );
- if($z)
- $record = $z[0]['xlink_id'];
- }
-
- if($record) {
- \Zotlabs\Daemon\Master::Summon(array('Ratenotif','rating',$record));
- }
-
- }
-
- function get() {
-
- if(! local_channel()) {
- notice( t('Permission denied.') . EOL);
- return;
- }
-
- // if(! \App::$data['target']) {
- // notice( t('No recipients.') . EOL);
- // return;
- // }
-
- $rating_enabled = get_config('system','rating_enabled');
- if(! $rating_enabled) {
- notice('Ratings are disabled on this site.');
- return;
- }
-
- $channel = \App::get_channel();
-
- $r = q("select * from xlink where xlink_xchan = '%s' and xlink_link = '%s' and xlink_static = 1",
- dbesc($channel['channel_hash']),
- dbesc(\App::$data['target'])
- );
- if($r) {
- \App::$data['xlink'] = $r[0];
- $rating_val = $r[0]['xlink_rating'];
- $rating_text = $r[0]['xlink_rating_text'];
- }
- else {
- $rating_val = 0;
- $rating_text = '';
- }
-
- if($rating_enabled) {
- $rating = replace_macros(get_markup_template('rating_slider.tpl'),array(
- '$min' => -10,
- '$val' => $rating_val
- ));
- }
- else {
- $rating = false;
- }
-
- $o = replace_macros(get_markup_template('rating_form.tpl'),array(
- '$header' => t('Rating'),
- '$website' => t('Website:'),
- '$site' => ((\App::$data['site']) ? '<a href="' . \App::$data['site']['site_url'] . '" >' . \App::$data['site']['site_url'] . '</a>' : ''),
- 'target' => \App::$data['target'],
- '$tgt_name' => ((\App::$poi && \App::$poi['xchan_name']) ? \App::$poi['xchan_name'] : sprintf( t('Remote Channel [%s] (not yet known on this site)'), substr(\App::$data['target'],0,16))),
- '$lbl_rating' => t('Rating (this information is public)'),
- '$lbl_rating_txt' => t('Optionally explain your rating (this information is public)'),
- '$rating_txt' => $rating_text,
- '$rating' => $rating,
- '$rating_val' => $rating_val,
- '$slide' => $slide,
- '$submit' => t('Submit')
- ));
-
- return $o;
-
- }
-}
diff --git a/Zotlabs/Module/Ratings.php b/Zotlabs/Module/Ratings.php
deleted file mode 100644
index 055b16ca3..000000000
--- a/Zotlabs/Module/Ratings.php
+++ /dev/null
@@ -1,109 +0,0 @@
-<?php
-namespace Zotlabs\Module;
-
-require_once('include/dir_fns.php');
-
-
-class Ratings extends \Zotlabs\Web\Controller {
-
- function init() {
-
- if(observer_prohibited()) {
- return;
- }
-
- if(local_channel())
- load_contact_links(local_channel());
-
- $dirmode = intval(get_config('system','directory_mode'));
-
- $x = find_upstream_directory($dirmode);
- if($x)
- $url = $x['url'];
-
- $rating_enabled = get_config('system','rating_enabled');
-
- if(! $rating_enabled)
- return;
-
- if(argc() > 1)
- $hash = argv(1);
-
- if(! $hash) {
- notice('Must supply a channel identififier.');
- return;
- }
-
- $results = false;
-
- $x = z_fetch_url($url . '/ratingsearch/' . urlencode($hash));
-
-
- if($x['success'])
- $results = json_decode($x['body'],true);
-
-
- if((! $results) || (! $results['success'])) {
-
- notice('No results.');
- return;
- }
-
- if(array_key_exists('xchan_hash',$results['target']))
- \App::$poi = $results['target'];
-
- $friends = array();
- $others = array();
-
- if($results['ratings']) {
- foreach($results['ratings'] as $n) {
- if(is_array(\App::$contacts) && array_key_exists($n['xchan_hash'],\App::$contacts))
- $friends[] = $n;
- else
- $others[] = $n;
- }
- }
-
- \App::$data = array('target' => $results['target'], 'results' => array_merge($friends,$others));
-
- if(! \App::$data['results']) {
- notice( t('No ratings') . EOL);
- }
-
- return;
- }
-
-
-
-
-
- function get() {
-
- if(observer_prohibited()) {
- notice( t('Public access denied.') . EOL);
- return;
- }
-
- $rating_enabled = get_config('system','rating_enabled');
-
- if(! $rating_enabled)
- return;
-
- $site_target = ((array_key_exists('target',\App::$data) && array_key_exists('site_url',\App::$data['target'])) ?
- '<a href="' . \App::$data['target']['site_url'] . '" >' . \App::$data['target']['site_url'] . '</a>' : '');
-
-
- $o = replace_macros(get_markup_template('prep.tpl'),array(
- '$header' => t('Ratings'),
- '$rating_lbl' => t('Rating: ' ),
- '$website' => t('Website: '),
- '$site' => $site_target,
- '$rating_text_lbl' => t('Description: '),
- '$raters' => \App::$data['results']
- ));
-
- return $o;
- }
-
-
-}
diff --git a/Zotlabs/Module/Ratingsearch.php b/Zotlabs/Module/Ratingsearch.php
deleted file mode 100644
index dcbfd6a9b..000000000
--- a/Zotlabs/Module/Ratingsearch.php
+++ /dev/null
@@ -1,78 +0,0 @@
-<?php
-namespace Zotlabs\Module;
-
-
-
-class Ratingsearch extends \Zotlabs\Web\Controller {
-
- function init() {
-
- $ret = array('success' => false);
-
- $dirmode = intval(get_config('system','directory_mode'));
-
- if($dirmode == DIRECTORY_MODE_NORMAL) {
- $ret['message'] = 'This site is not a directory server.';
- json_return_and_die($ret);
- }
-
- if(argc() > 1)
- $hash = argv(1);
-
- if(! $hash) {
- $ret['message'] = 'No channel identifier';
- json_return_and_die($ret);
- }
-
- if(strpos($hash,'@')) {
- $r = q("select * from hubloc where hubloc_addr = '%s' limit 1",
- dbesc($hash)
- );
- if($r)
- $hash = $r[0]['hubloc_hash'];
- }
-
- $p = q("select * from xchan where xchan_hash like '%s'",
- dbesc($hash . '%')
- );
-
- if($p)
- $target = $p[0]['xchan_hash'];
- else {
- $p = q("select * from site where site_url like '%s' and site_type = %d ",
- dbesc('%' . $hash),
- intval(SITE_TYPE_ZOT)
- );
- if($p) {
- $target = strtolower($hash);
- }
- else {
- $ret['message'] = 'Rating target not found';
- json_return_and_die($ret);
- }
- }
-
- if($p)
- $ret['target'] = $p[0];
-
- $ret['success'] = true;
-
- $r = q("select * from xlink left join xchan on xlink_xchan = xchan_hash
- where xlink_link = '%s' and xlink_rating != 0 and xlink_static = 1
- and xchan_hidden = 0 and xchan_orphan = 0 and xchan_deleted = 0
- order by xchan_name asc",
- dbesc($target)
- );
-
- if($r) {
- $ret['ratings'] = $r;
- }
- else
- $ret['ratings'] = array();
-
- json_return_and_die($ret);
-
- }
-
-
-}