本文整理汇总了PHP中drop_item函数的典型用法代码示例。如果您正苦于以下问题:PHP drop_item函数的具体用法?PHP drop_item怎么用?PHP drop_item使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了drop_item函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: expire_run
function expire_run($argv, $argc)
{
cli_startup();
$r = q("select id from item where (item_restrict & %d) and not (item_restrict & %d) and changed < UTC_TIMESTAMP() - INTERVAL 10 DAY", intval(ITEM_DELETED), intval(ITEM_PENDING_REMOVE));
if ($r) {
foreach ($r as $rr) {
drop_item($rr['id'], false, DROPITEM_PHASE2);
}
}
// physically remove anything that has been deleted for more than two months
$r = q("delete from item where ( item_restrict & %d ) and changed < UTC_TIMESTAMP() - INTERVAL 36 DAY", intval(ITEM_PENDING_REMOVE));
// make this optional as it could have a performance impact on large sites
if (intval(get_config('system', 'optimize_items'))) {
q("optimize table item");
}
logger('expire: start', LOGGER_DEBUG);
$r = q("SELECT channel_id, channel_address, channel_expire_days from channel where channel_expire_days != 0");
if ($r && count($r)) {
foreach ($r as $rr) {
logger('Expire: ' . $rr['channel_address'] . ' interval: ' . $rr['channel_expire_days'], LOGGER_DEBUG);
item_expire($rr['channel_id'], $rr['channel_expire_days']);
}
}
$x = get_sys_channel();
if ($x) {
// this should probably just fetch the channel_expire_days from the sys channel,
// but there's no convenient way to set it.
$expire_days = get_config('externals', 'expire_days');
if ($expire_days === false) {
$expire_days = 30;
}
if ($expire_days) {
item_expire($x['channel_id'], $expire_days);
}
}
return;
}
示例2: drop_items
function drop_items($items)
{
$uid = 0;
if (!local_channel() && !remote_channel()) {
return;
}
if (count($items)) {
foreach ($items as $item) {
$owner = drop_item($item, false);
if ($owner && !$uid) {
$uid = $owner;
}
}
}
// multiple threads may have been deleted, send an expire notification
if ($uid) {
Zotlabs\Daemon\Master::Summon(array('Notifier', 'expire', $uid));
}
}
示例3: poller_run
function poller_run($argv, $argc)
{
cli_startup();
$a = get_app();
$maxsysload = intval(get_config('system', 'maxloadavg'));
if ($maxsysload < 1) {
$maxsysload = 50;
}
if (function_exists('sys_getloadavg')) {
$load = sys_getloadavg();
if (intval($load[0]) > $maxsysload) {
logger('system: load ' . $load . ' too high. Poller deferred to next scheduled run.');
return;
}
}
$interval = intval(get_config('system', 'poll_interval'));
if (!$interval) {
$interval = get_config('system', 'delivery_interval') === false ? 3 : intval(get_config('system', 'delivery_interval'));
}
logger('poller: start');
// run queue delivery process in the background
proc_run('php', "include/queue.php");
// expire any expired mail
q("delete from mail where expires != '%s' and expires < UTC_TIMESTAMP() ", dbesc(NULL_DATE));
// expire any expired items
$r = q("select id from item where expires != '%s' and expires < UTC_TIMESTAMP() \n\t\tand not ( item_restrict & %d ) ", dbesc(NULL_DATE), intval(ITEM_DELETED));
if ($r) {
require_once 'include/items.php';
foreach ($r as $rr) {
drop_item($rr['id'], false);
}
}
// Ensure that every channel pings a directory server once a month. This way we can discover
// channels and sites that quietly vanished and prevent the directory from accumulating stale
// or dead entries.
$r = q("select channel_id from channel where channel_dirdate < UTC_TIMESTAMP() - INTERVAL 30 DAY");
if ($r) {
foreach ($r as $rr) {
proc_run('php', 'include/directory.php', $rr['channel_id'], 'force');
if ($interval) {
@time_sleep_until(microtime(true) + (double) $interval);
}
}
}
// publish any applicable items that were set to be published in the future
// (time travel posts)
$r = q("select id from item where ( item_restrict & %d ) and created <= UTC_TIMESTAMP() ", intval(ITEM_DELAYED_PUBLISH));
if ($r) {
foreach ($r as $rr) {
$x = q("update item set item_restrict = ( item_restrict ^ %d ) where id = %d limit 1", intval(ITEM_DELAYED_PUBLISH), intval($rr['id']));
if ($x) {
proc_run('php', 'include/notifier.php', 'wall-new', $rr['id']);
}
}
}
$abandon_days = intval(get_config('system', 'account_abandon_days'));
if ($abandon_days < 1) {
$abandon_days = 0;
}
// once daily run birthday_updates and then expire in background
// FIXME: add birthday updates, both locally and for xprof for use
// by directory servers
$d1 = intval(get_config('system', 'last_expire_day'));
$d2 = intval(datetime_convert('UTC', 'UTC', 'now', 'd'));
// Allow somebody to staggger daily activities if they have more than one site on their server,
// or if it happens at an inconvenient (busy) hour.
$h1 = intval(get_config('system', 'cron_hour'));
$h2 = intval(datetime_convert('UTC', 'UTC', 'now', 'G'));
$dirmode = get_config('system', 'directory_mode');
/**
* Cron Daily
*
* Actions in the following block are executed once per day, not on every poller run
*
*/
if ($d2 != $d1 && $h1 == $h2) {
require_once 'include/dir_fns.php';
check_upstream_directory();
call_hooks('cron_daily', datetime_convert());
$d3 = intval(datetime_convert('UTC', 'UTC', 'now', 'N'));
if ($d3 == 7) {
/**
* Cron Weekly
*
* Actions in the following block are executed once per day only on Sunday (once per week).
*
*/
call_hooks('cron_weekly', datetime_convert());
require_once 'include/hubloc.php';
prune_hub_reinstalls();
require_once 'include/Contact.php';
mark_orphan_hubsxchans();
/**
* End Cron Weekly
*/
}
update_birthdays();
// expire any read notifications over a month old
q("delete from notify where seen = 1 and date < UTC_TIMESTAMP() - INTERVAL 30 DAY");
// expire any expired accounts
//.........这里部分代码省略.........
示例4: delete_imported_item
/**
* @brief Deletes an imported item.
*
* @param array $sender
* * \e string \b hash a xchan_hash
* @param array $item
* @param int $uid
* @param boolean $relay
* @return boolean|int post_id
*/
function delete_imported_item($sender, $item, $uid, $relay)
{
logger('delete_imported_item invoked', LOGGER_DEBUG);
$ownership_valid = false;
$item_found = false;
$post_id = 0;
$r = q("select id, author_xchan, owner_xchan, source_xchan, item_deleted from item where ( author_xchan = '%s' or owner_xchan = '%s' or source_xchan = '%s' )\n\t\tand mid = '%s' and uid = %d limit 1", dbesc($sender['hash']), dbesc($sender['hash']), dbesc($sender['hash']), dbesc($item['mid']), intval($uid));
if ($r) {
if ($r[0]['author_xchan'] === $sender['hash'] || $r[0]['owner_xchan'] === $sender['hash'] || $r[0]['source_xchan'] === $sender['hash']) {
$ownership_valid = true;
}
$post_id = $r[0]['id'];
$item_found = true;
} else {
// perhaps the item is still in transit and the delete notification got here before the actual item did. Store it with the deleted flag set.
// item_store() won't try to deliver any notifications or start delivery chains if this flag is set.
// This means we won't end up with potentially even more delivery threads trying to push this delete notification.
// But this will ensure that if the (undeleted) original post comes in at a later date, we'll reject it because it will have an older timestamp.
logger('delete received for non-existent item - storing item data.');
/** @BUG $arr is undefined here, so this is dead code */
if ($arr['author_xchan'] === $sender['hash'] || $arr['owner_xchan'] === $sender['hash'] || $arr['source_xchan'] === $sender['hash']) {
$ownership_valid = true;
$item_result = item_store($arr);
$post_id = $item_result['item_id'];
}
}
if ($ownership_valid === false) {
logger('delete_imported_item: failed: ownership issue');
return false;
}
require_once 'include/items.php';
if ($item_found) {
if (intval($r[0]['item_deleted'])) {
logger('delete_imported_item: item was already deleted');
if (!$relay) {
return false;
}
// This is a bit hackish, but may have to suffice until the notification/delivery loop is optimised
// a bit further. We're going to strip the ITEM_ORIGIN on this item if it's a comment, because
// it was already deleted, and we're already relaying, and this ensures that no other process or
// code path downstream can relay it again (causing a loop). Since it's already gone it's not coming
// back, and we aren't going to (or shouldn't at any rate) delete it again in the future - so losing
// this information from the metadata should have no other discernible impact.
if ($r[0]['id'] != $r[0]['parent'] && intval($r[0]['item_origin'])) {
q("update item set item_origin = 0 where id = %d and uid = %d", intval($r[0]['id']), intval($r[0]['uid']));
}
}
require_once 'include/items.php';
// Use phased deletion to set the deleted flag, call both tag_deliver and the notifier to notify downstream channels
// and then clean up after ourselves with a cron job after several days to do the delete_item_lowlevel() (DROPITEM_PHASE2).
drop_item($post_id, false, DROPITEM_PHASE1);
tag_deliver($uid, $post_id);
}
return $post_id;
}
示例5: api_statuses_destroy
/**
*
*/
function api_statuses_destroy(&$a, $type)
{
if (api_user() === false) {
return false;
}
$user_info = api_get_user($a);
// params
$id = intval($a->argv[3]);
if ($id == 0) {
$id = intval($_REQUEST["id"]);
}
// Hotot workaround
if ($id == 0) {
$id = intval($a->argv[4]);
}
logger('API: api_statuses_destroy: ' . $id);
$ret = api_statuses_show($a, $type);
drop_item($id, false);
return $ret;
}
示例6: item_content
function item_content(&$a)
{
if (!local_channel() && !remote_channel()) {
return;
}
require_once 'include/security.php';
if (argc() == 3 && argv(1) === 'drop' && intval(argv(2))) {
require_once 'include/items.php';
$i = q("select id, uid, author_xchan, owner_xchan, source_xchan, item_restrict from item where id = %d limit 1", intval(argv(2)));
if ($i) {
$can_delete = false;
$local_delete = false;
if (local_channel() && local_channel() == $i[0]['uid']) {
$local_delete = true;
}
$sys = get_sys_channel();
if (is_site_admin() && $sys['channel_id'] == $i[0]['uid']) {
$can_delete = true;
}
$ob_hash = get_observer_hash();
if ($ob_hash && ($ob_hash === $i[0]['author_xchan'] || $ob_hash === $i[0]['owner_xchan'] || $ob_hash === $i[0]['source_xchan'])) {
$can_delete = true;
}
if (!($can_delete || $local_delete)) {
notice(t('Permission denied.') . EOL);
return;
}
// if this is a different page type or it's just a local delete
// but not by the item author or owner, do a simple deletion
if ($i[0]['item_restrict'] || $local_delete && !$can_delete) {
drop_item($i[0]['id']);
} else {
// complex deletion that needs to propagate and be performed in phases
drop_item($i[0]['id'], true, DROPITEM_PHASE1);
tag_deliver($i[0]['uid'], $i[0]['id']);
}
}
}
}
示例7: attach_delete
/**
* @brief Delete a file/directory from a channel.
*
* If the provided resource hash is from a directory it will delete everything
* recursively under this directory.
*
* @param int $channel_id
* The id of the channel
* @param string $resource
* The hash to delete
* @return void
*/
function attach_delete($channel_id, $resource, $is_photo = 0)
{
$c = q("SELECT channel_address FROM channel WHERE channel_id = %d LIMIT 1", intval($channel_id));
$channel_address = $c ? $c[0]['channel_address'] : 'notfound';
$photo_sql = $is_photo ? " and is_photo = 1 " : '';
$r = q("SELECT hash, flags, is_dir, is_photo, folder FROM attach WHERE hash = '%s' AND uid = %d {$photo_sql} limit 1", dbesc($resource), intval($channel_id));
if (!$r) {
return;
}
$cloudpath = get_parent_cloudpath($channel_id, $channel_address, $resource);
$object = get_file_activity_object($channel_id, $resource, $cloudpath);
// If resource is a directory delete everything in the directory recursive
if (intval($r[0]['is_dir'])) {
$x = q("SELECT hash, os_storage, is_dir, flags FROM attach WHERE folder = '%s' AND uid = %d", dbesc($resource), intval($channel_id));
if ($x) {
foreach ($x as $xx) {
attach_delete($channel_id, $xx['hash']);
}
}
}
// delete a file from filesystem
if (intval($r[0]['os_storage'])) {
$y = q("SELECT data FROM attach WHERE hash = '%s' AND uid = %d LIMIT 1", dbesc($resource), intval($channel_id));
if ($y) {
$f = 'store/' . $channel_address . '/' . $y[0]['data'];
if (is_dir($y[0]['data'])) {
@rmdir($y[0]['data']);
} elseif (file_exists($f)) {
unlink($f);
}
}
}
// delete from database
$z = q("DELETE FROM attach WHERE hash = '%s' AND uid = %d", dbesc($resource), intval($channel_id));
if ($r[0]['is_photo']) {
$x = q("select id, item_hidden from item where resource_id = '%s' and resource_type = 'photo' and uid = %d", dbesc($resource), intval($channel_id));
if ($x) {
drop_item($x[0]['id'], false, $x[0]['item_hidden'] ? DROPITEM_NORMAL : DROPITEM_PHASE1, true);
q("DELETE FROM photo WHERE uid = %d AND resource_id = '%s'", intval($channel_id), dbesc($resource));
}
}
// update the parent folder's lastmodified timestamp
$e = q("UPDATE attach SET edited = '%s' WHERE hash = '%s' AND uid = %d", dbesc(datetime_convert()), dbesc($r[0]['folder']), intval($channel_id));
file_activity($channel_id, $object, $object['allow_cid'], $object['allow_gid'], $object['deny_cid'], $object['deny_gid'], 'update', $notify = 0);
}
示例8: like_content
//.........这里部分代码省略.........
notice(t('Invalid request.') . EOL);
return $o;
}
killme();
}
// The resultant activity is going to be a wall-to-wall post, so make sure this is allowed
$perms = get_all_perms($owner_uid, $observer['xchan_hash']);
if (!($perms['post_like'] && $perms['view_profile'])) {
if ($interactive) {
notice(t('Permission denied.') . EOL);
return $o;
}
killme();
}
$ch = q("select * from channel left join xchan on channel_hash = xchan_hash where channel_id = %d limit 1", intval($owner_uid));
if (!$ch) {
if ($interactive) {
notice(t('Channel unavailable.') . EOL);
return $o;
}
killme();
}
if (!$plink) {
$plink = '[zrl=' . z_root() . '/profile/' . $ch[0]['channel_address'] . ']' . $post_type . '[/zrl]';
}
$links = array();
$links[] = array('rel' => 'alternate', 'type' => 'text/html', 'href' => z_root() . '/profile/' . $ch[0]['channel_address']);
$links[] = array('rel' => 'photo', 'type' => $ch[0]['xchan_photo_mimetype'], 'href' => $ch[0]['xchan_photo_l']);
$object = json_encode(array('type' => ACTIVITY_OBJ_PROFILE, 'title' => $ch[0]['channel_name'], 'id' => $ch[0]['xchan_url'] . '/' . $ch[0]['xchan_hash'], 'link' => $links));
// second like of the same thing is "undo" for the first like
$z = q("select * from likes where channel_id = %d and liker = '%s' and verb = '%s' and target_type = '%s' and target_id = '%s' limit 1", intval($ch[0]['channel_id']), dbesc($observer['xchan_hash']), dbesc($activity), dbesc($tgttype ? $tgttype : $objtype), dbesc($obj_id));
if ($z) {
q("delete from likes where id = %d limit 1", intval($z[0]['id']));
drop_item($z[0]['iid'], false);
if ($interactive) {
notice(t('Previous action reversed.') . EOL);
return $o;
}
killme();
}
} else {
// this is used to like an item or comment
$item_id = argc() == 2 ? notags(trim(argv(1))) : 0;
logger('like: verb ' . $verb . ' item ' . $item_id, LOGGER_DEBUG);
// get the item. Allow linked photos (which are normally hidden) to be liked
$r = q("SELECT * FROM item WHERE id = %d and (item_restrict = 0 or item_restrict = %d) LIMIT 1", intval($item_id), intval(ITEM_HIDDEN));
if (!$item_id || !$r) {
logger('like: no item ' . $item_id);
killme();
}
$item = $r[0];
$owner_uid = $item['uid'];
$owner_aid = $item['aid'];
$sys = get_sys_channel();
// if this is a "discover" item, (item['uid'] is the sys channel),
// fallback to the item comment policy, which should've been
// respected when generating the conversation thread.
// Even if the activity is rejected by the item owner, it should still get attached
// to the local discover conversation on this site.
if ($owner_uid != $sys['channel_id'] && !perm_is_allowed($owner_uid, $observer['xchan_hash'], 'post_comments')) {
notice(t('Permission denied') . EOL);
killme();
}
$r = q("select * from xchan where xchan_hash = '%s' limit 1", dbesc($item['owner_xchan']));
if ($r) {
$thread_owner = $r[0];
示例9: run
public static function run($argc, $argv)
{
cli_startup();
// perform final cleanup on previously delete items
$r = q("select id from item where item_deleted = 1 and item_pending_remove = 0 and changed < %s - INTERVAL %s", db_utcnow(), db_quoteinterval('10 DAY'));
if ($r) {
foreach ($r as $rr) {
drop_item($rr['id'], false, DROPITEM_PHASE2);
}
}
// physically remove anything that has been deleted for more than two months
/** @FIXME - this is a wretchedly inefficient query */
$r = q("delete from item where item_pending_remove = 1 and changed < %s - INTERVAL %s", db_utcnow(), db_quoteinterval('36 DAY'));
/** @FIXME make this optional as it could have a performance impact on large sites */
if (intval(get_config('system', 'optimize_items'))) {
q("optimize table item");
}
logger('expire: start', LOGGER_DEBUG);
$site_expire = get_config('system', 'default_expire_days');
logger('site_expire: ' . $site_expire);
$r = q("SELECT channel_id, channel_system, channel_address, channel_expire_days from channel where true");
if ($r) {
foreach ($r as $rr) {
// expire the sys channel separately
if (intval($rr['channel_system'])) {
continue;
}
// service class default (if non-zero) over-rides the site default
$service_class_expire = service_class_fetch($rr['channel_id'], 'expire_days');
if (intval($service_class_expire)) {
$channel_expire = $service_class_expire;
} else {
$channel_expire = $site_expire;
}
if (intval($channel_expire) && intval($channel_expire) < intval($rr['channel_expire_days']) || intval($rr['channel_expire_days'] == 0)) {
$expire_days = $channel_expire;
} else {
$expire_days = $rr['channel_expire_days'];
}
// if the site or service class expiration is non-zero and less than person expiration, use that
logger('Expire: ' . $rr['channel_address'] . ' interval: ' . $expire_days, LOGGER_DEBUG);
item_expire($rr['channel_id'], $expire_days);
}
}
$x = get_sys_channel();
if ($x) {
// this should probably just fetch the channel_expire_days from the sys channel,
// but there's no convenient way to set it.
$expire_days = get_config('system', 'sys_expire_days');
if ($expire_days === false) {
$expire_days = 30;
}
if (intval($site_expire) && intval($site_expire) < intval($expire_days)) {
$expire_days = $site_expire;
}
logger('Expire: sys interval: ' . $expire_days, LOGGER_DEBUG);
if ($expire_days) {
item_expire($x['channel_id'], $expire_days);
}
logger('Expire: sys: done', LOGGER_DEBUG);
}
}
示例10: wiki_delete_wiki
function wiki_delete_wiki($resource_id)
{
$w = wiki_get_wiki($resource_id);
$item = $w['wiki'];
if (!$item || !$w['path']) {
return array('item' => null, 'success' => false);
} else {
$drop = drop_item($item['id'], false, DROPITEM_NORMAL, true);
$pathdel = rrmdir($w['path']);
if ($pathdel) {
info('Wiki files deleted successfully');
}
return array('item' => $item, 'success' => $drop === 1 && $pathdel ? true : false);
}
}
示例11: photos_post
function photos_post(&$a)
{
logger('mod-photos: photos_post: begin', LOGGER_DEBUG);
logger('mod_photos: REQUEST ' . print_r($_REQUEST, true), LOGGER_DATA);
logger('mod_photos: FILES ' . print_r($_FILES, true), LOGGER_DATA);
$ph = photo_factory('');
$phototypes = $ph->supportedTypes();
$can_post = false;
$page_owner_uid = $a->data['channel']['channel_id'];
if (perm_is_allowed($page_owner_uid, get_observer_hash(), 'post_photos')) {
$can_post = true;
}
if (!$can_post) {
notice(t('Permission denied.') . EOL);
if (is_ajax()) {
killme();
}
return;
}
$s = abook_self($page_owner_uid);
if (!$s) {
notice(t('Page owner information could not be retrieved.') . EOL);
logger('mod_photos: post: unable to locate contact record for page owner. uid=' . $page_owner_uid);
if (is_ajax()) {
killme();
}
return;
}
$owner_record = $s[0];
if (argc() > 3 && argv(2) === 'album') {
$album = hex2bin(argv(3));
if ($album === t('Profile Photos')) {
// not allowed
goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
}
if (!photos_album_exists($page_owner_uid, $album)) {
notice(t('Album not found.') . EOL);
goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
}
/*
* RENAME photo album
*/
$newalbum = notags(trim($_REQUEST['albumname']));
if ($newalbum != $album) {
$x = photos_album_rename($page_owner_uid, $album, $newalbum);
if ($x) {
$newurl = str_replace(bin2hex($album), bin2hex($newalbum), $_SESSION['photo_return']);
goaway($a->get_baseurl() . '/' . $newurl);
}
}
/*
* DELETE photo album and all its photos
*/
if ($_REQUEST['dropalbum'] == t('Delete Album')) {
$res = array();
// get the list of photos we are about to delete
if (remote_user() && !local_user()) {
$str = photos_album_get_db_idstr($page_owner_uid, $album, remote_user());
} elseif (local_user()) {
$str = photos_album_get_db_idstr(local_user(), $album);
} else {
$str = null;
}
if (!$str) {
goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
}
$r = q("select id, item_restrict from item where resource_id in ( {$str} ) and resource_type = 'photo' and uid = %d", intval($page_owner_uid));
if ($r) {
foreach ($r as $i) {
drop_item($i['id'], false);
if (!$item_restrict) {
proc_run('php', 'include/notifier.php', 'drop', $i['id']);
}
}
}
// remove the associated photos in case they weren't attached to an item
q("delete from photo where resource_id in ( {$str} ) and uid = %d", intval($page_owner_uid));
}
goaway($a->get_baseurl() . '/photos/' . $a->data['channel']['channel_address']);
}
if (argc() > 2 && x($_REQUEST, 'delete') && $_REQUEST['delete'] === t('Delete Photo')) {
// same as above but remove single photo
$ob_hash = get_observer_hash();
if (!$ob_hash) {
goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
}
$r = q("SELECT `id`, `resource_id` FROM `photo` WHERE ( xchan = '%s' or `uid` = %d ) AND `resource_id` = '%s' LIMIT 1", dbesc($ob_hash), intval(local_user()), dbesc($a->argv[2]));
if ($r) {
q("DELETE FROM `photo` WHERE `uid` = %d AND `resource_id` = '%s'", intval($page_owner_uid), dbesc($r[0]['resource_id']));
$i = q("SELECT * FROM `item` WHERE `resource_id` = '%s' AND resource_type = 'photo' and `uid` = %d LIMIT 1", dbesc($r[0]['resource_id']), intval($page_owner_uid));
if (count($i)) {
q("UPDATE `item` SET item_restrict = (item_restrict | %d), `edited` = '%s', `changed` = '%s' WHERE `parent_mid` = '%s' AND `uid` = %d", intval(ITEM_DELETED), dbesc(datetime_convert()), dbesc(datetime_convert()), dbesc($i[0]['mid']), intval($page_owner_uid));
$url = $a->get_baseurl();
$drop_id = intval($i[0]['id']);
if ($i[0]['visible']) {
proc_run('php', "include/notifier.php", "drop", "{$drop_id}");
}
}
}
goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
//.........这里部分代码省略.........
示例12: poller_run
function poller_run($argv, $argc)
{
cli_startup();
$a = get_app();
$maxsysload = intval(get_config('system', 'maxloadavg'));
if ($maxsysload < 1) {
$maxsysload = 50;
}
if (function_exists('sys_getloadavg')) {
$load = sys_getloadavg();
if (intval($load[0]) > $maxsysload) {
logger('system: load ' . $load . ' too high. Poller deferred to next scheduled run.');
return;
}
}
$interval = intval(get_config('system', 'poll_interval'));
if (!$interval) {
$interval = get_config('system', 'delivery_interval') === false ? 3 : intval(get_config('system', 'delivery_interval'));
}
// Check for a lockfile. If it exists, but is over an hour old, it's stale. Ignore it.
$lockfile = 'store/[data]/poller';
if (file_exists($lockfile) && filemtime($lockfile) > time() - 3600 && !get_config('system', 'override_poll_lockfile')) {
logger("poller: Already running");
return;
}
// Create a lockfile. Needs two vars, but $x doesn't need to contain anything.
file_put_contents($lockfile, $x);
logger('poller: start');
// run queue delivery process in the background
proc_run('php', "include/queue.php");
// maintenance for mod sharedwithme - check for updated items and remove them
require_once 'include/sharedwithme.php';
apply_updates();
// expire any expired mail
q("delete from mail where expires != '%s' and expires < %s ", dbesc(NULL_DATE), db_utcnow());
// expire any expired items
$r = q("select id from item where expires != '%s' and expires < %s \n\t\tand item_deleted = 0 ", dbesc(NULL_DATE), db_utcnow());
if ($r) {
require_once 'include/items.php';
foreach ($r as $rr) {
drop_item($rr['id'], false);
}
}
// Ensure that every channel pings a directory server once a month. This way we can discover
// channels and sites that quietly vanished and prevent the directory from accumulating stale
// or dead entries.
$r = q("select channel_id from channel where channel_dirdate < %s - INTERVAL %s", db_utcnow(), db_quoteinterval('30 DAY'));
if ($r) {
foreach ($r as $rr) {
proc_run('php', 'include/directory.php', $rr['channel_id'], 'force');
if ($interval) {
@time_sleep_until(microtime(true) + (double) $interval);
}
}
}
// publish any applicable items that were set to be published in the future
// (time travel posts). Restrict to items that have come of age in the last
// couple of days to limit the query to something reasonable.
$r = q("select id from item where item_delayed = 1 and created <= %s and created > '%s' ", db_utcnow(), dbesc(datetime_convert('UTC', 'UTC', 'now - 2 days')));
if ($r) {
foreach ($r as $rr) {
$x = q("update item set item_delayed = 0 where id = %d", intval($rr['id']));
if ($x) {
proc_run('php', 'include/notifier.php', 'wall-new', $rr['id']);
}
}
}
$abandon_days = intval(get_config('system', 'account_abandon_days'));
if ($abandon_days < 1) {
$abandon_days = 0;
}
// once daily run birthday_updates and then expire in background
// FIXME: add birthday updates, both locally and for xprof for use
// by directory servers
$d1 = intval(get_config('system', 'last_expire_day'));
$d2 = intval(datetime_convert('UTC', 'UTC', 'now', 'd'));
// Allow somebody to staggger daily activities if they have more than one site on their server,
// or if it happens at an inconvenient (busy) hour.
$h1 = intval(get_config('system', 'cron_hour'));
$h2 = intval(datetime_convert('UTC', 'UTC', 'now', 'G'));
$dirmode = get_config('system', 'directory_mode');
/**
* Cron Daily
*
* Actions in the following block are executed once per day, not on every poller run
*
*/
if ($d2 != $d1 && $h1 == $h2) {
require_once 'include/dir_fns.php';
check_upstream_directory();
call_hooks('cron_daily', datetime_convert());
$d3 = intval(datetime_convert('UTC', 'UTC', 'now', 'N'));
if ($d3 == 7) {
/**
* Cron Weekly
*
* Actions in the following block are executed once per day only on Sunday (once per week).
*
*/
call_hooks('cron_weekly', datetime_convert());
//.........这里部分代码省略.........
示例13: contact_remove
function contact_remove($channel_id, $abook_id)
{
if (!$channel_id || !$abook_id) {
return false;
}
$archive = get_pconfig($channel_id, 'system', 'archive_removed_contacts');
if ($archive) {
q("update abook set abook_flags = ( abook_flags | %d ) where abook_id = %d and abook_channel = %d limit 1", intval(ABOOK_FLAG_ARCHIVED), intval($abook_id), intval($channel_id));
return true;
}
$r = q("select * from abook where abook_id = %d and abook_channel = %d limit 1", intval($abook_id), intval($channel_id));
if (!$r) {
return false;
}
$abook = $r[0];
if ($abook['abook_flags'] & ABOOK_FLAG_SELF) {
return false;
}
$r = q("select * from item where author_xchan = '%s' and uid = %d", dbesc($abook['abook_xchan']), intval($channel_id));
if ($r) {
foreach ($r as $rr) {
drop_item($rr['id'], false);
}
}
q("delete from abook where abook_id = %d and abook_channel = %d limit 1", intval($abook['abook_id']), intval($channel_id));
$r = q("delete from event where event_xchan = '%s' and uid = %d", dbesc($abook['abook_xchan']), intval($channel_id));
$r = q("delete from group_member where xchan = '%s' and uid = %d", dbesc($abook['abook_xchan']), intval($channel_id));
$r = q("delete from mail where ( from_xchan = '%s' or to_xchan = '%s' ) and channel_id = %d ", dbesc($abook['abook_xchan']), dbesc($abook['abook_xchan']), intval($channel_id));
return true;
}
示例14: do_mysql
case 'a':
case 'x':
$_GET['type'] = 4;
break;
default:
$_GET['type'] = 5;
break;
}
$lim = '';
if (!isset($_GET['all'])) {
$lim = 'LIMIT 1';
}
$q = do_mysql("SELECT fullname FROM items WHERE belongs = '" . $LOGIN . "' AND is_in = 'inv' AND realname = '" . $rn . "' " . $lim . ";");
while ($i = mysql_fetch_assoc($q)) {
$item = $i['fullname'];
drop_item($item, $LOGIN);
// esli prodolzhaetsja znachit vzjali
// nado zanesti v spisok ozhidanija veshej na pojavlenie
$rfn = $rn;
if (array_key_exists($rfn, $items)) {
// $items podkljuchen v faile s_loadmaps.php
// znachit nado udalitq avto obnovu
$act = do_mysql("SELECT actions FROM maps WHERE map = '" . $pl_map . "';");
$act = mysql_result($act, 0);
//echo '$act = '.$act.'<br/>';
if (strpos($act, '~') === false && strpos($act, $rfn) > 0) {
$act = '';
} else {
$act = explode('~', $act);
$cou = count($act);
for ($i = 0; $i < $cou; $i++) {
示例15: photos_post
function photos_post(&$a)
{
logger('mod-photos: photos_post: begin', LOGGER_DEBUG);
logger('mod_photos: REQUEST ' . print_r($_REQUEST, true), LOGGER_DATA);
logger('mod_photos: FILES ' . print_r($_FILES, true), LOGGER_DATA);
$ph = photo_factory('');
$phototypes = $ph->supportedTypes();
$can_post = false;
$page_owner_uid = $a->data['channel']['channel_id'];
if (perm_is_allowed($page_owner_uid, get_observer_hash(), 'write_storage')) {
$can_post = true;
}
if (!$can_post) {
notice(t('Permission denied.') . EOL);
if (is_ajax()) {
killme();
}
return;
}
$s = abook_self($page_owner_uid);
if (!$s) {
notice(t('Page owner information could not be retrieved.') . EOL);
logger('mod_photos: post: unable to locate contact record for page owner. uid=' . $page_owner_uid);
if (is_ajax()) {
killme();
}
return;
}
$owner_record = $s[0];
$acl = new AccessList($a->data['channel']);
if (argc() > 3 && argv(2) === 'album') {
$album = hex2bin(argv(3));
if ($album === t('Profile Photos')) {
// not allowed
goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
}
if (!photos_album_exists($page_owner_uid, $album)) {
notice(t('Album not found.') . EOL);
goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
}
/*
* RENAME photo album
*/
$newalbum = notags(trim($_REQUEST['albumname']));
if ($newalbum != $album) {
// @fixme - syncronise with DAV or disallow completely
goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
// $x = photos_album_rename($page_owner_uid,$album,$newalbum);
// if($x) {
// $newurl = str_replace(bin2hex($album),bin2hex($newalbum),$_SESSION['photo_return']);
// goaway($a->get_baseurl() . '/' . $newurl);
// }
}
/*
* DELETE photo album and all its photos
*/
if ($_REQUEST['dropalbum'] == t('Delete Album')) {
$res = array();
// get the list of photos we are about to delete
if (remote_channel() && !local_channel()) {
$str = photos_album_get_db_idstr($page_owner_uid, $album, remote_channel());
} elseif (local_channel()) {
$str = photos_album_get_db_idstr(local_channel(), $album);
} else {
$str = null;
}
if (!$str) {
goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
}
$r = q("select id from item where resource_id in ( {$str} ) and resource_type = 'photo' and uid = %d " . item_normal(), intval($page_owner_uid));
if ($r) {
foreach ($r as $i) {
attach_delete($page_owner_uid, $i['resource_id'], 1);
drop_item($i['id'], false, DROPITEM_PHASE1, true);
proc_run('php', 'include/notifier.php', 'drop', $i['id']);
}
}
// remove the associated photos in case they weren't attached to an item
q("delete from photo where resource_id in ( {$str} ) and uid = %d", intval($page_owner_uid));
// @FIXME do the same for the linked attach
}
goaway($a->get_baseurl() . '/photos/' . $a->data['channel']['channel_address']);
}
if (argc() > 2 && x($_REQUEST, 'delete') && $_REQUEST['delete'] === t('Delete Photo')) {
// same as above but remove single photo
$ob_hash = get_observer_hash();
if (!$ob_hash) {
goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
}
$r = q("SELECT `id`, `resource_id` FROM `photo` WHERE ( xchan = '%s' or `uid` = %d ) AND `resource_id` = '%s' LIMIT 1", dbesc($ob_hash), intval(local_channel()), dbesc($a->argv[2]));
if ($r) {
q("DELETE FROM `photo` WHERE `uid` = %d AND `resource_id` = '%s'", intval($page_owner_uid), dbesc($r[0]['resource_id']));
attach_delete($page_owner_uid, $r[0]['resource_id'], 1);
$i = q("SELECT * FROM `item` WHERE `resource_id` = '%s' AND resource_type = 'photo' and `uid` = %d LIMIT 1", dbesc($r[0]['resource_id']), intval($page_owner_uid));
if (count($i)) {
drop_item($i[0]['id'], true, DROPITEM_PHASE1);
$url = $a->get_baseurl();
}
}
goaway($a->get_baseurl() . '/photos/' . $a->data['channel']['channel_address'] . '/album/' . $_SESSION['album_return']);
//.........这里部分代码省略.........