set frequency of poll per contact, other misc fixes (photo now has contact-id)
This commit is contained in:
parent
a4a46d82df
commit
3fd4b4264e
|
@ -204,6 +204,7 @@ CREATE TABLE IF NOT EXISTS `mail` (
|
||||||
CREATE TABLE IF NOT EXISTS `photo` (
|
CREATE TABLE IF NOT EXISTS `photo` (
|
||||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
`uid` int(10) unsigned NOT NULL,
|
`uid` int(10) unsigned NOT NULL,
|
||||||
|
`contact-id` int(10) unsigned NOT NULL,
|
||||||
`resource-id` char(255) NOT NULL,
|
`resource-id` char(255) NOT NULL,
|
||||||
`created` datetime NOT NULL,
|
`created` datetime NOT NULL,
|
||||||
`edited` datetime NOT NULL,
|
`edited` datetime NOT NULL,
|
||||||
|
|
|
@ -17,7 +17,7 @@ require_once('include/items.php');
|
||||||
|
|
||||||
if($argc < 2)
|
if($argc < 2)
|
||||||
exit;
|
exit;
|
||||||
|
dbg(3);
|
||||||
$a->set_baseurl($argv[1]);
|
$a->set_baseurl($argv[1]);
|
||||||
|
|
||||||
$contacts = q("SELECT * FROM `contact` WHERE `dfrn-id` != '' AND `self` = 0 AND `blocked` = 0 AND `readonly` = 0 ORDER BY RAND()");
|
$contacts = q("SELECT * FROM `contact` WHERE `dfrn-id` != '' AND `self` = 0 AND `blocked` = 0 AND `readonly` = 0 ORDER BY RAND()");
|
||||||
|
@ -27,6 +27,39 @@ if($argc < 2)
|
||||||
|
|
||||||
foreach($contacts as $contact) {
|
foreach($contacts as $contact) {
|
||||||
|
|
||||||
|
if($contact['priority']) {
|
||||||
|
|
||||||
|
$update = false;
|
||||||
|
$t = $contact['last-update'];
|
||||||
|
|
||||||
|
switch ($contact['priority']) {
|
||||||
|
case 5:
|
||||||
|
if(datetime_convert('UTC','UTC', 'now') > datetime_convert('UTC','UTC', t . " + 1 month"))
|
||||||
|
$update = true;
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
if(datetime_convert('UTC','UTC', 'now') > datetime_convert('UTC','UTC', t . " + 1 week"))
|
||||||
|
$update = true;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
if(datetime_convert('UTC','UTC', 'now') > datetime_convert('UTC','UTC', t . " + 1 day"))
|
||||||
|
$update = true;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
if(datetime_convert('UTC','UTC', 'now') > datetime_convert('UTC','UTC', t . " + 12 hour"))
|
||||||
|
$update = true;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
default:
|
||||||
|
if(datetime_convert('UTC','UTC', 'now') > datetime_convert('UTC','UTC', t . " + 1 hour"))
|
||||||
|
$update = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if(! $update)
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$importer_uid = $contact['uid'];
|
$importer_uid = $contact['uid'];
|
||||||
|
|
||||||
$r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` = 1 LIMIT 1",
|
$r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` = 1 LIMIT 1",
|
||||||
|
@ -44,7 +77,8 @@ if($argc < 2)
|
||||||
$url = $contact['poll'] . '?dfrn_id=' . $contact['dfrn-id'] . '&type=data&last_update=' . $last_update ;
|
$url = $contact['poll'] . '?dfrn_id=' . $contact['dfrn-id'] . '&type=data&last_update=' . $last_update ;
|
||||||
|
|
||||||
$xml = fetch_url($url);
|
$xml = fetch_url($url);
|
||||||
|
echo "URL: " . $url;
|
||||||
|
echo "XML: " . $xml;
|
||||||
if(! $xml)
|
if(! $xml)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -61,12 +95,19 @@ if($argc < 2)
|
||||||
openssl_public_decrypt($challenge,$postvars['challenge'],$contact['pubkey']);
|
openssl_public_decrypt($challenge,$postvars['challenge'],$contact['pubkey']);
|
||||||
|
|
||||||
$xml = post_url($contact['poll'],$postvars);
|
$xml = post_url($contact['poll'],$postvars);
|
||||||
if(! strlen($xml))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
echo "XML response:" . $xml . "\r\n";
|
echo "XML response:" . $xml . "\r\n";
|
||||||
echo "Length:" . strlen($xml) . "\r\n";
|
echo "Length:" . strlen($xml) . "\r\n";
|
||||||
|
|
||||||
|
if(! strlen($xml)) {
|
||||||
|
// an empty response may mean there's nothing new - record the fact that we checked
|
||||||
|
$r = q("UPDATE `contact` SET `last-update` = '%s' WHERE `id` = %d LIMIT 1",
|
||||||
|
dbesc(datetime_convert()),
|
||||||
|
intval($contact['id'])
|
||||||
|
);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$feed = new SimplePie();
|
$feed = new SimplePie();
|
||||||
$feed->set_raw_data($xml);
|
$feed->set_raw_data($xml);
|
||||||
$feed->enable_order_by_date(false);
|
$feed->enable_order_by_date(false);
|
||||||
|
|
|
@ -40,15 +40,20 @@ function contacts_post(&$a) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$priority = intval($_POST['priority']);
|
||||||
|
if($priority > 5 || $priority < 0)
|
||||||
|
$priority = 0;
|
||||||
|
|
||||||
$rating = intval($_POST['reputation']);
|
$rating = intval($_POST['reputation']);
|
||||||
if($rating > 5 || $rating < 0)
|
if($rating > 5 || $rating < 0)
|
||||||
$rating = 0;
|
$rating = 0;
|
||||||
|
|
||||||
$reason = notags(trim($_POST['reason']));
|
$reason = notags(trim($_POST['reason']));
|
||||||
|
|
||||||
$r = q("UPDATE `contact` SET `profile-id` = %d, `rating` = %d, `reason` = '%s'
|
$r = q("UPDATE `contact` SET `profile-id` = %d, `priority` = %d , `rating` = %d, `reason` = '%s'
|
||||||
WHERE `id` = %d AND `uid` = %d LIMIT 1",
|
WHERE `id` = %d AND `uid` = %d LIMIT 1",
|
||||||
intval($profile_id),
|
intval($profile_id),
|
||||||
|
intval($priority),
|
||||||
intval($rating),
|
intval($rating),
|
||||||
dbesc($reason),
|
dbesc($reason),
|
||||||
intval($contact_id),
|
intval($contact_id),
|
||||||
|
@ -91,12 +96,6 @@ function contacts_content(&$a) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// $photo = str_replace('-4.jpg', '' , $r[0]['photo']);
|
|
||||||
// $photos = q("SELECT `id` FROM `photo` WHERE `resource-id` = '%s' AND `uid` = %d",
|
|
||||||
// dbesc($photo),
|
|
||||||
// intval($_SESSION['uid'])
|
|
||||||
// );
|
|
||||||
|
|
||||||
if($cmd == 'block') {
|
if($cmd == 'block') {
|
||||||
$blocked = (($orig_record[0]['blocked']) ? 0 : 1);
|
$blocked = (($orig_record[0]['blocked']) ? 0 : 1);
|
||||||
$r = q("UPDATE `contact` SET `blocked` = %d WHERE `id` = %d AND `uid` = %d LIMIT 1",
|
$r = q("UPDATE `contact` SET `blocked` = %d WHERE `id` = %d AND `uid` = %d LIMIT 1",
|
||||||
|
@ -130,18 +129,17 @@ function contacts_content(&$a) {
|
||||||
if($cmd == 'drop') {
|
if($cmd == 'drop') {
|
||||||
$r = q("DELETE FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
|
$r = q("DELETE FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
|
||||||
intval($contact_id),
|
intval($contact_id),
|
||||||
intval($_SESSION['uid']));
|
intval($_SESSION['uid'])
|
||||||
|
);
|
||||||
|
|
||||||
// if(count($photos)) {
|
q("DELETE FROM `item` WHERE `contact-id` = %d AND `uid` = %d ",
|
||||||
// foreach($photos as $p) {
|
intval($contact_id),
|
||||||
// q("DELETE FROM `photos` WHERE `id` = %d LIMIT 1",
|
intval($_SESSION['uid'])
|
||||||
// $p['id']);
|
);
|
||||||
// }
|
q("DELETE FROM `photo` WHERE `contact-id` = %d AND `uid` = %d ",
|
||||||
// }
|
|
||||||
|
|
||||||
if(intval($contact_id))
|
intval($contact_id),
|
||||||
q("DELETE FROM `item` WHERE `contact-id` = %d LIMIT 1",
|
intval($_SESSION['uid'])
|
||||||
intval($contact_id)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
notice("Contact has been removed." . EOL );
|
notice("Contact has been removed." . EOL );
|
||||||
|
@ -186,6 +184,10 @@ function contacts_content(&$a) {
|
||||||
}
|
}
|
||||||
|
|
||||||
$o .= replace_macros($tpl,array(
|
$o .= replace_macros($tpl,array(
|
||||||
|
'$poll_interval' => contact_poll_interval($r[0]['priority']),
|
||||||
|
'$last_update' => (($r[0]['last-update'] == '0000-00-00 00:00:00')
|
||||||
|
? t('Never')
|
||||||
|
: datetime_convert('UTC',date_default_timezone_get(),$r[0]['last-update'],'D, j M Y, G:i A')),
|
||||||
'$profile_select' => contact_profile_assign($r[0]['profile-id']),
|
'$profile_select' => contact_profile_assign($r[0]['profile-id']),
|
||||||
'$contact_id' => $r[0]['id'],
|
'$contact_id' => $r[0]['id'],
|
||||||
'$block_text' => (($r[0]['blocked']) ? t('Unblock this contact') : t('Block this contact') ),
|
'$block_text' => (($r[0]['blocked']) ? t('Unblock this contact') : t('Block this contact') ),
|
||||||
|
|
|
@ -91,10 +91,11 @@ function dfrn_confirm_post(&$a) {
|
||||||
|
|
||||||
$hash = hash('md5',uniqid(mt_rand(),true));
|
$hash = hash('md5',uniqid(mt_rand(),true));
|
||||||
|
|
||||||
$r = q("INSERT INTO `photo` ( `uid`, `resource-id`, `created`, `edited`, `filename`,
|
$r = q("INSERT INTO `photo` ( `uid`, `contact-id`, `resource-id`, `created`, `edited`, `filename`,
|
||||||
`height`, `width`, `data`, `scale` )
|
`height`, `width`, `data`, `scale` )
|
||||||
VALUES ( %d, '%s', '%s', '%s', '%s', %d, %d, '%s', 4 )",
|
VALUES ( %d, %d, '%s', '%s', '%s', '%s', %d, %d, '%s', 4 )",
|
||||||
intval($local_uid),
|
intval($local_uid),
|
||||||
|
intval($dfrn_record),
|
||||||
dbesc($hash),
|
dbesc($hash),
|
||||||
datetime_convert(),
|
datetime_convert(),
|
||||||
datetime_convert(),
|
datetime_convert(),
|
||||||
|
@ -107,10 +108,11 @@ function dfrn_confirm_post(&$a) {
|
||||||
$photo_failure = true;
|
$photo_failure = true;
|
||||||
|
|
||||||
$img->scaleImage(80);
|
$img->scaleImage(80);
|
||||||
$r = q("INSERT INTO `photo` ( `uid`, `resource-id`, `created`, `edited`, `filename`,
|
$r = q("INSERT INTO `photo` ( `uid`, `contact-id`, `resource-id`, `created`, `edited`, `filename`,
|
||||||
`height`, `width`, `data`, `scale` )
|
`height`, `width`, `data`, `scale` )
|
||||||
VALUES ( %d, '%s', '%s', '%s', '%s', %d, %d, '%s', 5 )",
|
VALUES ( %d, %d, '%s', '%s', '%s', '%s', %d, %d, '%s', 5 )",
|
||||||
intval($local_uid),
|
intval($local_uid),
|
||||||
|
intval($dfrn_record),
|
||||||
dbesc($hash),
|
dbesc($hash),
|
||||||
datetime_convert(),
|
datetime_convert(),
|
||||||
datetime_convert(),
|
datetime_convert(),
|
||||||
|
|
|
@ -23,6 +23,11 @@
|
||||||
<a href="contacts/$contact_id/drop" id="contact-edit-drop-link" onclick="return confirmDelete();" ><img src="images/b_drophide.gif" alt="Delete contact" title="Delete contact" onmouseover="imgbright(this);" onmouseout="imgdull(this);" /></a>
|
<a href="contacts/$contact_id/drop" id="contact-edit-drop-link" onclick="return confirmDelete();" ><img src="images/b_drophide.gif" alt="Delete contact" title="Delete contact" onmouseover="imgbright(this);" onmouseout="imgdull(this);" /></a>
|
||||||
</div>
|
</div>
|
||||||
<div id="contact-edit-nav-end"></div>
|
<div id="contact-edit-nav-end"></div>
|
||||||
|
<div id="contact-edit-poll-wrapper">
|
||||||
|
<div id="contact-edit-last-update-text">Last updated: <span id="contact-edit-last-updated">$last_update</span</div>
|
||||||
|
<div id="contact-edit-poll-text">Update public posts: </div>
|
||||||
|
$poll_interval
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="contact-edit-end" ></div>
|
<div id="contact-edit-end" ></div>
|
||||||
|
|
||||||
|
|
|
@ -26,12 +26,12 @@ function contact_reputation($current) {
|
||||||
$o .= "<select id=\"contact-reputation-selector\" name=\"reputation\" />\r\n";
|
$o .= "<select id=\"contact-reputation-selector\" name=\"reputation\" />\r\n";
|
||||||
|
|
||||||
$rep = array(
|
$rep = array(
|
||||||
0 => "Unknown | Not categorised",
|
0 => t('Unknown | Not categorised'),
|
||||||
1 => "Block immediately",
|
1 => t('Block immediately'),
|
||||||
2 => "Shady, spammer, self-marketer",
|
2 => t('Shady, spammer, self-marketer'),
|
||||||
3 => "Known to me, but no opinion",
|
3 => t('Known to me, but no opinion'),
|
||||||
4 => "OK, probably harmless",
|
4 => t('OK, probably harmless'),
|
||||||
5 => "Reputable, has my trust"
|
5 => t('Reputable, has my trust')
|
||||||
);
|
);
|
||||||
|
|
||||||
foreach($rep as $k => $v) {
|
foreach($rep as $k => $v) {
|
||||||
|
@ -43,4 +43,24 @@ function contact_reputation($current) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function contact_poll_interval($current) {
|
||||||
|
|
||||||
|
$o = '';
|
||||||
|
$o .= '<select id="contact-poll-interval" name="poll" />' . "\r\n";
|
||||||
|
|
||||||
|
$rep = array(
|
||||||
|
0 => t('Frequently'),
|
||||||
|
1 => t('Hourly'),
|
||||||
|
2 => t('Twice daily'),
|
||||||
|
3 => t('Daily'),
|
||||||
|
4 => t('Weekly'),
|
||||||
|
5 => t('Monthly')
|
||||||
|
);
|
||||||
|
|
||||||
|
foreach($rep as $k => $v) {
|
||||||
|
$selected = (($k == $current) ? " selected=\"selected\" " : "");
|
||||||
|
$o .= "<option value=\"$k\" $selected >$v</option>\r\n";
|
||||||
|
}
|
||||||
|
$o .= "</select>\r\n";
|
||||||
|
return $o;
|
||||||
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ body {
|
||||||
background: #FEFEFE;
|
background: #FEFEFE;
|
||||||
color: #444444;
|
color: #444444;
|
||||||
font-family: "Lucida Grande", Tahoma, sans-serif;
|
font-family: "Lucida Grande", Tahoma, sans-serif;
|
||||||
letter-spacing: 1px;
|
/* letter-spacing: 1px; */
|
||||||
/* font-family: verdana, sans-serif; */
|
/* font-family: verdana, sans-serif; */
|
||||||
font-size: 90%;
|
font-size: 90%;
|
||||||
margin-left: 10px;
|
margin-left: 10px;
|
||||||
|
@ -880,6 +880,14 @@ input#dfrn-url {
|
||||||
margin-left: 30px;
|
margin-left: 30px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#contact-edit-poll-wrapper {
|
||||||
|
margin-left: 50px;
|
||||||
|
margin-top: 30px;
|
||||||
|
}
|
||||||
|
#contact-edit-poll-text {
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
#contact-edit-photo-wrapper {
|
#contact-edit-photo-wrapper {
|
||||||
margin-bottom: 20px;
|
margin-bottom: 20px;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue