use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Database\DBStructure;
+use Friendica\Module\Login;
require_once 'include/network.php';
require_once 'include/plugin.php';
}
}
+ /**
+ * Return the provided variable value if it exists and is truthy or the provided
+ * default value instead.
+ *
+ * Works with initialized variables and potentially uninitialized array keys
+ *
+ * Usages:
+ * - defaults($var, $default)
+ * - defaults($array, 'key', $default)
+ *
+ * @brief Returns a defaut value if the provided variable or array key is falsy
+ * @see x()
+ * @return mixed
+ */
+ function defaults() {
+ $args = func_get_args();
+
+ if (count($args) < 2) {
+ throw new BadFunctionCallException('defaults() requires at least 2 parameters');
+ }
+ if (count($args) > 3) {
+ throw new BadFunctionCallException('defaults() cannot use more than 3 parameters');
+ }
+ if (count($args) === 3 && !is_array($args[0])) {
+ throw new BadFunctionCallException('defaults($arr, $key, $def) requires an array as first parameter');
+ }
+ if (count($args) === 3 && is_null($args[1])) {
+ throw new BadFunctionCallException('defaults($arr, $key, $def) $key is null');
+ }
+
+ $default = array_pop($args);
+
+ if (call_user_func_array('x', $args)) {
+ if (count($args) === 1) {
+ $return = $args[0];
+ } else {
+ $return = $args[0][$args[1]];
+ }
+ } else {
+ $return = $default;
+ }
+
+ return $return;
+ }
+
/**
* @brief Returns the baseurl.
*
}
}
-/**
- * @brief Wrapper for adding a login box.
- *
- * @param bool $register If $register == true provide a registration link.
- * This will most always depend on the value of $a->config['register_policy'].
- * @param bool $hiddens optional
- *
- * @return string Returns the complete html for inserting into the page
- *
- * @hooks 'login_hook'
- * string $o
- */
-function login($register = false, $hiddens = false)
-{
- $a = get_app();
- $o = "";
- $reg = false;
- if ($register) {
- $reg = array(
- 'title' => t('Create a New Account'),
- 'desc' => t('Register')
- );
- }
-
- $noid = Config::get('system', 'no_openid');
-
- $dest_url = $a->query_string;
-
- if (local_user()) {
- $tpl = get_markup_template("logout.tpl");
- } else {
- $a->page['htmlhead'] .= replace_macros(
- get_markup_template("login_head.tpl"),
- array(
- '$baseurl' => $a->get_baseurl(true)
- )
- );
-
- $tpl = get_markup_template("login.tpl");
- $_SESSION['return_url'] = $a->query_string;
- $a->module = 'login';
- }
-
- $o .= replace_macros(
- $tpl,
- array(
- '$dest_url' => $dest_url,
- '$logout' => t('Logout'),
- '$login' => t('Login'),
-
- '$lname' => array('username', t('Nickname or Email: ') , '', ''),
- '$lpassword' => array('password', t('Password: '), '', ''),
- '$lremember' => array('remember', t('Remember me'), 0, ''),
-
- '$openid' => !$noid,
- '$lopenid' => array('openid_url', t('Or login using OpenID: '),'',''),
-
- '$hiddens' => $hiddens,
-
- '$register' => $reg,
-
- '$lostpass' => t('Forgot your password?'),
- '$lostlink' => t('Password Reset'),
-
- '$tostitle' => t('Website Terms of Service'),
- '$toslink' => t('terms of service'),
-
- '$privacytitle' => t('Website Privacy Policy'),
- '$privacylink' => t('privacy policy'),
- )
- );
-
- call_hooks('login_hook', $o);
-
- return $o;
-}
-
/**
* @brief Used to end the current process, after saving session state.
*/
/**
* @brief Redirect to another URL and terminate this process.
*/
-function goaway($s)
+function goaway($path)
{
- if (!strstr(normalise_link($s), "http://")) {
- $s = System::baseUrl() . "/" . $s;
+ if (strstr(normalise_link($path), 'http://')) {
+ $url = $path;
+ } else {
+ $url = System::baseUrl() . '/' . ltrim($path, '/');
}
- header("Location: $s");
+ header("Location: $url");
killme();
}
function infinite_scroll_data($module)
{
if (PConfig::get(local_user(), 'system', 'infinite_scroll')
- && ($module == "network") && ($_GET["mode"] != "minimal")
+ && $module == 'network'
+ && defaults($_GET, 'mode', '') != 'minimal'
) {
// get the page number
- if (is_string($_GET["page"])) {
- $pageno = $_GET["page"];
- } else {
- $pageno = 1;
- }
+ $pageno = defaults($_GET, 'page', 1);
$reload_uri = "";
}
}
- if (($a->page_offset != "") && ! strstr($reload_uri, "&offset=")) {
+ $a = get_app();
+ if ($a->page_offset != "" && !strstr($reload_uri, "&offset=")) {
$reload_uri .= "&offset=" . urlencode($a->page_offset);
}
<?php
+
/**
* @file include/identity.php
*/
-
use Friendica\App;
use Friendica\Content\Feature;
use Friendica\Content\ForumManager;
dbesc($nickname)
);
- if (!$user && count($user) && !count($profiledata)) {
+ if (!$user && !count($user) && !count($profiledata)) {
logger('profile error: ' . $a->query_string, LOGGER_DEBUG);
notice(t('Requested account is not available.') . EOL);
$a->error = 404;
return;
}
+ if (!x($a->page, 'aside')) {
+ $a->page['aside'] = '';
+ }
+
+ if ($profiledata) {
+ $a->page['aside'] .= profile_sidebar($profiledata, true, $show_connect);
+
+ if (!DBM::is_result($user)) {
+ return;
+ }
+ }
+
$pdata = get_profiledata_by_nick($nickname, $user[0]['uid'], $profile);
if (empty($pdata) && empty($profiledata)) {
"SELECT `pub_keywords` FROM `profile` WHERE `uid` = %d AND `is-default` = 1 LIMIT 1",
intval($pdata['profile_uid'])
);
- if ($x && count($x))
+ if ($x && count($x)) {
$pdata['pub_keywords'] = $x[0]['pub_keywords'];
+ }
}
$a->profile = $pdata;
$a->profile['mobile-theme'] = PConfig::get($a->profile['profile_uid'], 'system', 'mobile_theme');
$a->profile['network'] = NETWORK_DFRN;
- $a->page['title'] = $a->profile['name'] . " @ " . $a->config['sitename'];
+ $a->page['title'] = $a->profile['name'] . ' @ ' . $a->config['sitename'];
- if (!$profiledata && !PConfig::get(local_user(), 'system', 'always_my_theme')) {
+ if (!$profiledata && !PConfig::get(local_user(), 'system', 'always_my_theme')) {
$_SESSION['theme'] = $a->profile['theme'];
}
$a->set_template_engine(); // reset the template engine to the default in case the user's theme doesn't specify one
- $theme_info_file = "view/theme/" . current_theme() . "/theme.php";
+ $theme_info_file = 'view/theme/' . current_theme() . '/theme.php';
if (file_exists($theme_info_file)) {
require_once $theme_info_file;
}
- if (! (x($a->page, 'aside'))) {
+ if (!x($a->page, 'aside')) {
$a->page['aside'] = '';
}
if (local_user() && local_user() == $a->profile['uid'] && $profiledata) {
$a->page['aside'] .= replace_macros(
- get_markup_template('profile_edlink.tpl'),
- array(
+ get_markup_template('profile_edlink.tpl'), array(
'$editprofile' => t('Edit profile'),
'$profid' => $a->profile['id']
)
* By now, the contact block isn't shown, when a different profile is given
* But: When this profile was on the same server, then we could display the contacts
*/
- if ($profiledata) {
- $a->page['aside'] .= profile_sidebar($profiledata, true, $show_connect);
- } else {
+ if (!$profiledata) {
$a->page['aside'] .= profile_sidebar($a->profile, $block, $show_connect);
}
- /*if (! $block)
- $a->page['aside'] .= contact_block();*/
-
return;
}
-
/**
* @brief Get all profil data of a local user
*
* Passing a non-zero profile ID can also allow a preview of a selected profile
* by the owner
*
+ * Includes all available profile data
+ *
* @param string $nickname nick
* @param int $uid uid
* @param int $profile ID of the profile
* @returns array
- * Includes all available profile data
*/
function get_profiledata_by_nick($nickname, $uid = 0, $profile = 0)
{
return $r;
}
-
/**
* @brief Formats a profile for display in the sidebar.
*
$o = '';
$location = false;
$address = false;
- // $pdesc = true;
// This function can also use contact information in $profile
$is_contact = x($profile, 'cid');
- if ((! is_array($profile)) && (! count($profile))) {
+ if (!is_array($profile) && !count($profile)) {
return $o;
}
- $profile['picdate'] = urlencode($profile['picdate']);
+ $profile['picdate'] = urlencode(defaults($profile, 'picdate', ''));
- if (($profile['network'] != "") && ($profile['network'] != NETWORK_DFRN)) {
+ if (($profile['network'] != '') && ($profile['network'] != NETWORK_DFRN)) {
$profile['network_name'] = format_network_name($profile['network'], $profile['url']);
} else {
- $profile['network_name'] = "";
+ $profile['network_name'] = '';
}
call_hooks('profile_sidebar_enter', $profile);
// don't show connect link to yourself
- $connect = (($profile['uid'] != local_user()) ? t('Connect') : false);
+ $connect = $profile['uid'] != local_user() ? t('Connect') : false;
// don't show connect link to authenticated visitors either
if (remote_user() && count($_SESSION['remote'])) {
// Is the local user already connected to that user?
if ($connect && local_user()) {
- if (isset($profile["url"])) {
- $profile_url = normalise_link($profile["url"]);
+ if (isset($profile['url'])) {
+ $profile_url = normalise_link($profile['url']);
} else {
- $profile_url = normalise_link(System::baseUrl()."/profile/".$profile["nickname"]);
+ $profile_url = normalise_link(System::baseUrl() . '/profile/' . $profile['nickname']);
}
if (dba::exists('contact', array('pending' => false, 'uid' => local_user(), 'nurl' => $profile_url))) {
}
}
- if ($connect && ($profile['network'] != NETWORK_DFRN) && !isset($profile['remoteconnect']))
+ if ($connect && ($profile['network'] != NETWORK_DFRN) && !isset($profile['remoteconnect'])) {
$connect = false;
+ }
$remoteconnect = null;
- if (isset($profile['remoteconnect']))
+ if (isset($profile['remoteconnect'])) {
$remoteconnect = $profile['remoteconnect'];
+ }
- if ($connect && ($profile['network'] == NETWORK_DFRN) && !isset($remoteconnect))
- $subscribe_feed = t("Atom feed");
- else
+ if ($connect && ($profile['network'] == NETWORK_DFRN) && !isset($remoteconnect)) {
+ $subscribe_feed = t('Atom feed');
+ } else {
$subscribe_feed = false;
+ }
- if (remote_user() || (get_my_url() && $profile['unkmail'] && ($profile['uid'] != local_user()))) {
+ if (remote_user() || (get_my_url() && x($profile, 'unkmail') && ($profile['uid'] != local_user()))) {
$wallmessage = t('Message');
- $wallmessage_link = "wallmessage/".$profile["nickname"];
+ $wallmessage_link = 'wallmessage/' . $profile['nickname'];
if (remote_user()) {
$r = q(
);
}
if ($r) {
- $remote_url = $r[0]["url"];
- $message_path = preg_replace("=(.*)/profile/(.*)=ism", "$1/message/new/", $remote_url);
- $wallmessage_link = $message_path.base64_encode($profile["addr"]);
+ $remote_url = $r[0]['url'];
+ $message_path = preg_replace('=(.*)/profile/(.*)=ism', '$1/message/new/', $remote_url);
+ $wallmessage_link = $message_path . base64_encode($profile['addr']);
}
} else {
$wallmessage = false;
// show edit profile to yourself
if (!$is_contact && $profile['uid'] == local_user() && Feature::isEnabled(local_user(), 'multi_profiles')) {
- $profile['edit'] = array(System::baseUrl(). '/profiles', t('Profiles'),"", t('Manage/edit profiles'));
+ $profile['edit'] = array(System::baseUrl() . '/profiles', t('Profiles'), '', t('Manage/edit profiles'));
$r = q(
"SELECT * FROM `profile` WHERE `uid` = %d",
local_user()
'alt' => t('Profile Image'),
'profile_name' => $rr['profile-name'],
'isdefault' => $rr['is-default'],
- 'visibile_to_everybody' => t('visible to everybody'),
+ 'visibile_to_everybody' => t('visible to everybody'),
'edit_visibility' => t('Edit visibility'),
);
}
}
}
if (!$is_contact && $profile['uid'] == local_user() && !Feature::isEnabled(local_user(), 'multi_profiles')) {
- $profile['edit'] = array(System::baseUrl(). '/profiles/'.$profile['id'], t('Edit profile'),"", t('Edit profile'));
+ $profile['edit'] = array(System::baseUrl() . '/profiles/' . $profile['id'], t('Edit profile'), '', t('Edit profile'));
$profile['menu'] = array(
'chg_photo' => t('Change profile photo'),
'cr_new' => null,
// Fetch the account type
$account_type = Contact::getAccountType($profile);
- if ((x($profile, 'address') == 1)
- || (x($profile, 'location') == 1)
- || (x($profile, 'locality') == 1)
- || (x($profile, 'region') == 1)
- || (x($profile, 'postal-code') == 1)
- || (x($profile, 'country-name') == 1)
+ if (x($profile, 'address')
+ || x($profile, 'location')
+ || x($profile, 'locality')
+ || x($profile, 'region')
+ || x($profile, 'postal-code')
+ || x($profile, 'country-name')
) {
$location = t('Location:');
}
- $gender = ((x($profile, 'gender') == 1) ? t('Gender:') : false);
-
-
- $marital = ((x($profile, 'marital') == 1) ? t('Status:') : false);
-
- $homepage = ((x($profile, 'homepage') == 1) ? t('Homepage:') : false);
+ $gender = x($profile, 'gender') ? t('Gender:') : false;
+ $marital = x($profile, 'marital') ? t('Status:') : false;
+ $homepage = x($profile, 'homepage') ? t('Homepage:') : false;
+ $about = x($profile, 'about') ? t('About:') : false;
+ $xmpp = x($profile, 'xmpp') ? t('XMPP:') : false;
- $about = ((x($profile, 'about') == 1) ? t('About:') : false);
-
- $xmpp = ((x($profile, 'xmpp') == 1) ? t('XMPP:') : false);
-
- if (($profile['hidewall'] || $block) && (! local_user()) && (! remote_user())) {
+ if ((x($profile, 'hidewall') || $block) && !local_user() && !remote_user()) {
$location = $pdesc = $gender = $marital = $homepage = $about = false;
}
$firstname = $split_name['first'];
$lastname = $split_name['last'];
- if ($profile['guid'] != "") {
+ if (x($profile, 'guid')) {
$diaspora = array(
'guid' => $profile['guid'],
'podloc' => System::baseUrl(),
$diaspora = false;
}
+ $contact_block = '';
+ $updated = '';
+ $contacts = 0;
if (!$block) {
$contact_block = contact_block();
intval($a->profile['uid'])
);
if (DBM::is_result($r)) {
- $updated = date("c", strtotime($r[0]['updated']));
+ $updated = date('c', strtotime($r[0]['updated']));
}
$r = q(
$p[$k] = $v;
}
- if (isset($p["about"])) {
- $p["about"] = bbcode($p["about"]);
+ if (isset($p['about'])) {
+ $p['about'] = bbcode($p['about']);
}
- if (isset($p["address"])) {
- $p["address"] = bbcode($p["address"]);
+ if (isset($p['address'])) {
+ $p['address'] = bbcode($p['address']);
} else {
- $p["address"] = bbcode($p["location"]);
+ $p['address'] = bbcode($p['location']);
}
- if (isset($p["photo"])) {
- $p["photo"] = proxy_url($p["photo"], false, PROXY_SIZE_SMALL);
+ if (isset($p['photo'])) {
+ $p['photo'] = proxy_url($p['photo'], false, PROXY_SIZE_SMALL);
}
$tpl = get_markup_template('profile_vcard.tpl');
- $o .= replace_macros(
- $tpl,
- array(
+ $o .= replace_macros($tpl, array(
'$profile' => $p,
'$xmpp' => $xmpp,
- '$connect' => $connect,
- '$remoteconnect' => $remoteconnect,
+ '$connect' => $connect,
+ '$remoteconnect' => $remoteconnect,
'$subscribe_feed' => $subscribe_feed,
'$wallmessage' => $wallmessage,
'$wallmessage_link' => $wallmessage_link,
'$account_type' => $account_type,
'$location' => $location,
- '$gender' => $gender,
- // '$pdesc' => $pdesc,
- '$marital' => $marital,
+ '$gender' => $gender,
+ '$marital' => $marital,
'$homepage' => $homepage,
'$about' => $about,
- '$network' => t('Network:'),
+ '$network' => t('Network:'),
'$contacts' => $contacts,
'$updated' => $updated,
'$diaspora' => $diaspora,
'$contact_block' => $contact_block,
- )
- );
+ ));
$arr = array('profile' => &$profile, 'entry' => &$o);
return $o;
}
-
function get_birthdays()
{
$a = get_app();
$o = '';
- if (! local_user() || $a->is_mobile || $a->is_tablet) {
+ if (!local_user() || $a->is_mobile || $a->is_tablet) {
return $o;
}
/*
* $mobile_detect = new Mobile_Detect();
* $is_mobile = $mobile_detect->isMobile() || $mobile_detect->isTablet();
- * if ($is_mobile)
- * return $o;
+ * if ($is_mobile)
+ * return $o;
*/
$bd_format = t('g A l F d'); // 8 AM Friday January 18
$bd_short = t('F d');
- $cachekey = "get_birthdays:".local_user();
+ $cachekey = 'get_birthdays:' . local_user();
$r = Cache::get($cachekey);
if (is_null($r)) {
$s = dba::p(
$classtoday = $istoday ? ' birthday-today ' : '';
if ($total) {
foreach ($r as &$rr) {
- if (! strlen($rr['name'])) {
+ if (!strlen($rr['name'])) {
continue;
}
$sparkle = '';
$url = $rr['url'];
if ($rr['network'] === NETWORK_DFRN) {
- $sparkle = " sparkle";
- $url = System::baseUrl() . '/redir/' . $rr['cid'];
+ $sparkle = ' sparkle';
+ $url = System::baseUrl() . '/redir/' . $rr['cid'];
}
$rr['link'] = $url;
$rr['title'] = $rr['name'];
- $rr['date'] = day_translate(datetime_convert('UTC', $a->timezone, $rr['start'], $rr['adjust'] ? $bd_format : $bd_short)) . (($today) ? ' ' . t('[today]') : '');
+ $rr['date'] = day_translate(datetime_convert('UTC', $a->timezone, $rr['start'], $rr['adjust'] ? $bd_format : $bd_short)) . (($today) ? ' ' . t('[today]') : '');
$rr['startime'] = null;
$rr['today'] = $today;
}
}
}
- $tpl = get_markup_template("birthdays_reminder.tpl");
- return replace_macros(
- $tpl,
- array(
+ $tpl = get_markup_template('birthdays_reminder.tpl');
+ return replace_macros($tpl, array(
'$baseurl' => System::baseUrl(),
'$classtoday' => $classtoday,
'$count' => $total,
'$event_reminders' => t('Birthday Reminders'),
'$event_title' => t('Birthdays this week:'),
'$events' => $r,
- '$lbr' => '{', // raw brackets mess up if/endif macro processing
+ '$lbr' => '{', // raw brackets mess up if/endif macro processing
'$rbr' => '}'
- )
- );
+ ));
}
-
function get_events()
{
require_once 'include/bbcode.php';
$a = get_app();
- if (! local_user() || $a->is_mobile || $a->is_tablet) {
+ if (!local_user() || $a->is_mobile || $a->is_tablet) {
return $o;
}
/*
- * $mobile_detect = new Mobile_Detect();
- * $is_mobile = $mobile_detect->isMobile() || $mobile_detect->isTablet();
- * if ($is_mobile)
- * return $o;
+ * $mobile_detect = new Mobile_Detect();
+ * $is_mobile = $mobile_detect->isMobile() || $mobile_detect->isTablet();
+ * if ($is_mobile)
+ * return $o;
*/
$bd_format = t('g A l F d'); // 8 AM Friday January 18
- $bd_short = t('F d');
+ $classtoday = '';
$s = dba::p(
"SELECT `event`.* FROM `event`
$r = array();
if (DBM::is_result($s)) {
- $now = strtotime('now');
$istoday = false;
while ($rr = dba::fetch($s)) {
}
$description = substr(strip_tags(bbcode($rr['desc'])), 0, 32) . '... ';
- if (! $description) {
+ if (!$description) {
$description = t('[No description]');
}
$today = ((substr($strt, 0, 10) === datetime_convert('UTC', $a->timezone, 'now', 'Y-m-d')) ? true : false);
$rr['title'] = $title;
- $rr['description'] = $desciption;
- $rr['date'] = day_translate(datetime_convert('UTC', $rr['adjust'] ? $a->timezone : 'UTC', $rr['start'], $bd_format)) . (($today) ? ' ' . t('[today]') : '');
+ $rr['description'] = $description;
+ $rr['date'] = day_translate(datetime_convert('UTC', $rr['adjust'] ? $a->timezone : 'UTC', $rr['start'], $bd_format)) . (($today) ? ' ' . t('[today]') : '');
$rr['startime'] = $strt;
$rr['today'] = $today;
dba::close($s);
$classtoday = (($istoday) ? 'event-today' : '');
}
- $tpl = get_markup_template("events_reminder.tpl");
- return replace_macros(
- $tpl,
- array(
+ $tpl = get_markup_template('events_reminder.tpl');
+ return replace_macros($tpl, array(
'$baseurl' => System::baseUrl(),
'$classtoday' => $classtoday,
'$count' => count($r),
'$event_reminders' => t('Event Reminders'),
'$event_title' => t('Events this week:'),
'$events' => $r,
- )
- );
+ ));
}
function advanced_profile(App $a)
$uid = $a->profile['uid'];
$o .= replace_macros(
- get_markup_template('section_title.tpl'),
- array(
- '$title' => t('Profile')
+ get_markup_template('section_title.tpl'), array(
+ '$title' => t('Profile')
)
);
$profile = array();
- $profile['fullname'] = array( t('Full Name:'), $a->profile['name'] ) ;
+ $profile['fullname'] = array(t('Full Name:'), $a->profile['name']);
if ($a->profile['gender']) {
- $profile['gender'] = array( t('Gender:'), $a->profile['gender'] );
+ $profile['gender'] = array(t('Gender:'), $a->profile['gender']);
}
if (($a->profile['dob']) && ($a->profile['dob'] > '0001-01-01')) {
$year_bd_format = t('j F, Y');
$short_bd_format = t('j F');
+ $val = intval($a->profile['dob']) ?
+ day_translate(datetime_convert('UTC', 'UTC', $a->profile['dob'] . ' 00:00 +00:00', $year_bd_format))
+ : day_translate(datetime_convert('UTC', 'UTC', '2001-' . substr($a->profile['dob'], 5) . ' 00:00 +00:00', $short_bd_format));
- $val = ((intval($a->profile['dob']))
- ? day_translate(datetime_convert('UTC', 'UTC', $a->profile['dob'] . ' 00:00 +00:00', $year_bd_format))
- : day_translate(datetime_convert('UTC', 'UTC', '2001-' . substr($a->profile['dob'], 5) . ' 00:00 +00:00', $short_bd_format)));
-
- $profile['birthday'] = array( t('Birthday:'), $val);
+ $profile['birthday'] = array(t('Birthday:'), $val);
}
+
if (!empty($a->profile['dob'])
&& $a->profile['dob'] > '0001-01-01'
&& $age = age($a->profile['dob'], $a->profile['timezone'], '')
) {
- $profile['age'] = array( t('Age:'), $age );
+ $profile['age'] = array(t('Age:'), $age);
}
if ($a->profile['marital']) {
- $profile['marital'] = array( t('Status:'), $a->profile['marital']);
+ $profile['marital'] = array(t('Status:'), $a->profile['marital']);
}
/// @TODO Maybe use x() here, plus below?
}
if ($a->profile['sexual']) {
- $profile['sexual'] = array( t('Sexual Preference:'), $a->profile['sexual'] );
+ $profile['sexual'] = array(t('Sexual Preference:'), $a->profile['sexual']);
}
if ($a->profile['homepage']) {
- $profile['homepage'] = array( t('Homepage:'), linkify($a->profile['homepage']) );
+ $profile['homepage'] = array(t('Homepage:'), linkify($a->profile['homepage']));
}
if ($a->profile['hometown']) {
- $profile['hometown'] = array( t('Hometown:'), linkify($a->profile['hometown']) );
+ $profile['hometown'] = array(t('Hometown:'), linkify($a->profile['hometown']));
}
if ($a->profile['pub_keywords']) {
- $profile['pub_keywords'] = array( t('Tags:'), $a->profile['pub_keywords']);
+ $profile['pub_keywords'] = array(t('Tags:'), $a->profile['pub_keywords']);
}
if ($a->profile['politic']) {
- $profile['politic'] = array( t('Political Views:'), $a->profile['politic']);
+ $profile['politic'] = array(t('Political Views:'), $a->profile['politic']);
}
if ($a->profile['religion']) {
- $profile['religion'] = array( t('Religion:'), $a->profile['religion']);
+ $profile['religion'] = array(t('Religion:'), $a->profile['religion']);
}
if ($txt = prepare_text($a->profile['about'])) {
- $profile['about'] = array( t('About:'), $txt );
+ $profile['about'] = array(t('About:'), $txt);
}
if ($txt = prepare_text($a->profile['interest'])) {
- $profile['interest'] = array( t('Hobbies/Interests:'), $txt);
+ $profile['interest'] = array(t('Hobbies/Interests:'), $txt);
}
if ($txt = prepare_text($a->profile['likes'])) {
- $profile['likes'] = array( t('Likes:'), $txt);
+ $profile['likes'] = array(t('Likes:'), $txt);
}
if ($txt = prepare_text($a->profile['dislikes'])) {
- $profile['dislikes'] = array( t('Dislikes:'), $txt);
+ $profile['dislikes'] = array(t('Dislikes:'), $txt);
}
if ($txt = prepare_text($a->profile['contact'])) {
- $profile['contact'] = array( t('Contact information and Social Networks:'), $txt);
+ $profile['contact'] = array(t('Contact information and Social Networks:'), $txt);
}
if ($txt = prepare_text($a->profile['music'])) {
- $profile['music'] = array( t('Musical interests:'), $txt);
+ $profile['music'] = array(t('Musical interests:'), $txt);
}
if ($txt = prepare_text($a->profile['book'])) {
- $profile['book'] = array( t('Books, literature:'), $txt);
+ $profile['book'] = array(t('Books, literature:'), $txt);
}
if ($txt = prepare_text($a->profile['tv'])) {
- $profile['tv'] = array( t('Television:'), $txt);
+ $profile['tv'] = array(t('Television:'), $txt);
}
if ($txt = prepare_text($a->profile['film'])) {
- $profile['film'] = array( t('Film/dance/culture/entertainment:'), $txt);
+ $profile['film'] = array(t('Film/dance/culture/entertainment:'), $txt);
}
if ($txt = prepare_text($a->profile['romance'])) {
- $profile['romance'] = array( t('Love/Romance:'), $txt);
+ $profile['romance'] = array(t('Love/Romance:'), $txt);
}
if ($txt = prepare_text($a->profile['work'])) {
- $profile['work'] = array( t('Work/employment:'), $txt);
+ $profile['work'] = array(t('Work/employment:'), $txt);
}
if ($txt = prepare_text($a->profile['education'])) {
- $profile['education'] = array( t('School/education:'), $txt );
+ $profile['education'] = array(t('School/education:'), $txt);
}
//show subcribed forum if it is enabled in the usersettings
if (Feature::isEnabled($uid, 'forumlist_profile')) {
- $profile['forumlist'] = array( t('Forums:'), ForumManager::profileAdvanced($uid));
+ $profile['forumlist'] = array(t('Forums:'), ForumManager::profileAdvanced($uid));
}
if ($a->profile['uid'] == local_user()) {
- $profile['edit'] = array(System::baseUrl(). '/profiles/'.$a->profile['id'], t('Edit profile'),"", t('Edit profile'));
+ $profile['edit'] = array(System::baseUrl() . '/profiles/' . $a->profile['id'], t('Edit profile'), '', t('Edit profile'));
}
- return replace_macros(
- $tpl,
- array(
+ return replace_macros($tpl, array(
'$title' => t('Profile'),
'$basic' => t('Basic'),
'$advanced' => t('Advanced'),
'$profile' => $profile
- )
- );
+ ));
}
return '';
function profile_tabs($a, $is_owner = false, $nickname = null)
{
- //echo "<pre>"; var_dump($a->user); killme();
-
if (is_null($nickname)) {
- $nickname = $a->user['nickname'];
+ $nickname = $a->user['nickname'];
}
+ $tab = false;
if (x($_GET, 'tab')) {
$tab = notags(trim($_GET['tab']));
}
$tabs = array(
array(
- 'label'=>t('Status'),
- 'url' => $url,
- 'sel' => ((!isset($tab) && $a->argv[0]=='profile') ? 'active' : ''),
+ 'label' => t('Status'),
+ 'url' => $url,
+ 'sel' => !$tab && $a->argv[0] == 'profile' ? 'active' : '',
'title' => t('Status Messages and Posts'),
- 'id' => 'status-tab',
+ 'id' => 'status-tab',
'accesskey' => 'm',
),
array(
'label' => t('Profile'),
- 'url' => $url.'/?tab=profile',
- 'sel' => ((isset($tab) && $tab=='profile') ? 'active' : ''),
+ 'url' => $url . '/?tab=profile',
+ 'sel' => $tab == 'profile' ? 'active' : '',
'title' => t('Profile Details'),
- 'id' => 'profile-tab',
+ 'id' => 'profile-tab',
'accesskey' => 'r',
),
array(
'label' => t('Photos'),
- 'url' => System::baseUrl() . '/photos/' . $nickname,
- 'sel' => ((!isset($tab) && $a->argv[0]=='photos') ? 'active' : ''),
+ 'url' => System::baseUrl() . '/photos/' . $nickname,
+ 'sel' => !$tab && $a->argv[0] == 'photos' ? 'active' : '',
'title' => t('Photo Albums'),
- 'id' => 'photo-tab',
+ 'id' => 'photo-tab',
'accesskey' => 'h',
),
array(
'label' => t('Videos'),
- 'url' => System::baseUrl() . '/videos/' . $nickname,
- 'sel' => ((!isset($tab) && $a->argv[0]=='videos') ? 'active' : ''),
+ 'url' => System::baseUrl() . '/videos/' . $nickname,
+ 'sel' => !$tab && $a->argv[0] == 'videos' ? 'active' : '',
'title' => t('Videos'),
- 'id' => 'video-tab',
+ 'id' => 'video-tab',
'accesskey' => 'v',
),
);
// the calendar link for the full featured events calendar
if ($is_owner && $a->theme_events_in_profile) {
- $tabs[] = array(
- 'label' => t('Events'),
- 'url' => System::baseUrl() . '/events',
- 'sel' =>((!isset($tab) && $a->argv[0]=='events') ? 'active' : ''),
- 'title' => t('Events and Calendar'),
- 'id' => 'events-tab',
- 'accesskey' => 'e',
- );
+ $tabs[] = array(
+ 'label' => t('Events'),
+ 'url' => System::baseUrl() . '/events',
+ 'sel' => !$tab && $a->argv[0] == 'events' ? 'active' : '',
+ 'title' => t('Events and Calendar'),
+ 'id' => 'events-tab',
+ 'accesskey' => 'e',
+ );
// if the user is not the owner of the calendar we only show a calendar
// with the public events of the calendar owner
- } elseif (! $is_owner) {
+ } elseif (!$is_owner) {
$tabs[] = array(
- 'label' => t('Events'),
- 'url' => System::baseUrl() . '/cal/' . $nickname,
- 'sel' =>((!isset($tab) && $a->argv[0]=='cal') ? 'active' : ''),
- 'title' => t('Events and Calendar'),
- 'id' => 'events-tab',
- 'accesskey' => 'e',
- );
+ 'label' => t('Events'),
+ 'url' => System::baseUrl() . '/cal/' . $nickname,
+ 'sel' => !$tab && $a->argv[0] == 'cal' ? 'active' : '',
+ 'title' => t('Events and Calendar'),
+ 'id' => 'events-tab',
+ 'accesskey' => 'e',
+ );
}
if ($is_owner) {
$tabs[] = array(
'label' => t('Personal Notes'),
- 'url' => System::baseUrl() . '/notes',
- 'sel' =>((!isset($tab) && $a->argv[0]=='notes') ? 'active' : ''),
+ 'url' => System::baseUrl() . '/notes',
+ 'sel' => !$tab && $a->argv[0] == 'notes' ? 'active' : '',
'title' => t('Only You Can See This'),
- 'id' => 'notes-tab',
+ 'id' => 'notes-tab',
'accesskey' => 't',
);
}
- if ((! $is_owner) && ((count($a->profile)) || (! $a->profile['hide-friends']))) {
+ if ((!$is_owner) && ((count($a->profile)) || (!$a->profile['hide-friends']))) {
$tabs[] = array(
'label' => t('Contacts'),
- 'url' => System::baseUrl() . '/viewcontacts/' . $nickname,
- 'sel' => ((!isset($tab) && $a->argv[0]=='viewcontacts') ? 'active' : ''),
+ 'url' => System::baseUrl() . '/viewcontacts/' . $nickname,
+ 'sel' => !$tab && $a->argv[0] == 'viewcontacts' ? 'active' : '',
'title' => t('Contacts'),
- 'id' => 'viewcontacts-tab',
+ 'id' => 'viewcontacts-tab',
'accesskey' => 'k',
);
}
- $arr = array('is_owner' => $is_owner, 'nickname' => $nickname, 'tab' => (($tab) ? $tab : false), 'tabs' => $tabs);
+ $arr = array('is_owner' => $is_owner, 'nickname' => $nickname, 'tab' => $tab, 'tabs' => $tabs);
call_hooks('profile_tabs', $arr);
$tpl = get_markup_template('common_tabs.tpl');
function zrl_init(App $a)
{
- $tmp_str = get_my_url();
- if (validate_url($tmp_str)) {
+ $my_url = get_my_url();
+ $my_url = validate_url($my_url);
+ if ($my_url) {
// Is it a DDoS attempt?
// The check fetches the cached value from gprobe to reduce the load for this system
- $urlparts = parse_url($tmp_str);
+ $urlparts = parse_url($my_url);
- $result = Cache::get("gprobe:" . $urlparts["host"]);
- if ((!is_null($result)) && (in_array($result["network"], array(NETWORK_FEED, NETWORK_PHANTOM)))) {
- logger("DDoS attempt detected for " . $urlparts["host"] . " by " . $_SERVER["REMOTE_ADDR"] . ". server data: " . print_r($_SERVER, true), LOGGER_DEBUG);
+ $result = Cache::get('gprobe:' . $urlparts['host']);
+ if ((!is_null($result)) && (in_array($result['network'], array(NETWORK_FEED, NETWORK_PHANTOM)))) {
+ logger('DDoS attempt detected for ' . $urlparts['host'] . ' by ' . $_SERVER['REMOTE_ADDR'] . '. server data: ' . print_r($_SERVER, true), LOGGER_DEBUG);
return;
}
- Worker::add(PRIORITY_LOW, 'GProbe', $tmp_str);
- $arr = array('zrl' => $tmp_str, 'url' => $a->cmd);
+ Worker::add(PRIORITY_LOW, 'GProbe', $my_url);
+ $arr = array('zrl' => $my_url, 'url' => $a->cmd);
call_hooks('zrl_init', $arr);
}
}
function zrl($s, $force = false)
{
- if (! strlen($s)) {
+ if (!strlen($s)) {
return $s;
}
- if ((! strpos($s, '/profile/')) && (! $force)) {
+ if ((!strpos($s, '/profile/')) && (!$force)) {
return $s;
}
if ($force && substr($s, -1, 1) !== '/') {
}
$achar = strpos($s, '?') ? '&' : '?';
$mine = get_my_url();
- if ($mine && ! link_compare($mine, $s)) {
+ if ($mine && !link_compare($mine, $s)) {
return $s . $achar . 'zrl=' . urlencode($mine);
}
return $s;
function get_theme_uid()
{
$uid = ((!empty($_REQUEST['puid'])) ? intval($_REQUEST['puid']) : 0);
- if ((local_user()) && ((PConfig::get(local_user(), 'system', 'always_my_theme')) || (! $uid))) {
+ if ((local_user()) && ((PConfig::get(local_user(), 'system', 'always_my_theme')) || (!$uid))) {
return local_user();
}
use Friendica\Core\Config;
use Friendica\Core\Worker;
use Friendica\Database\DBM;
+use Friendica\Module\Login;
require_once 'boot.php';
session_start();
$a->save_timestamp($stamp1, "parser");
} else {
+ $_SESSION = [];
Worker::executeIfIdle();
}
// header('Link: <' . System::baseUrl() . '/amcd>; rel="acct-mgmt";');
-if (x($_COOKIE, "Friendica") || (x($_SESSION, 'authenticated')) || (x($_POST, 'auth-params')) || ($a->module === 'login')) {
- require "include/auth.php";
-}
+Login::sessionAuth();
if (! x($_SESSION, 'authenticated')) {
header('X-Account-Management-Status: none');
<?php
+
/**
* @file mod/dfrn_poll.php
*/
use Friendica\Core\Config;
use Friendica\Core\System;
use Friendica\Database\DBM;
+use Friendica\Module\Login;
use Friendica\Protocol\DFRN;
use Friendica\Protocol\OStatus;
require_once 'include/items.php';
-require_once 'include/auth.php';
- function dfrn_poll_init(App $a) {
+ function dfrn_poll_init(App $a)
+ {
- $dfrn_id = x($_GET,'dfrn_id') ? $_GET['dfrn_id'] : '';
- $type = x($_GET,'type') ? $_GET['type'] : 'data';
- $last_update = x($_GET,'last_update') ? $_GET['last_update'] : '';
- $destination_url = x($_GET,'destination_url') ? $_GET['destination_url'] : '';
- $challenge = x($_GET,'challenge') ? $_GET['challenge'] : '';
- $sec = x($_GET,'sec') ? $_GET['sec'] : '';
- $dfrn_version = x($_GET,'dfrn_version') ? (float) $_GET['dfrn_version'] : 2.0;
- $perm = x($_GET,'perm') ? $_GET['perm'] : 'r';
- $quiet = x($_GET,'quiet') ? true : false;
+ Login::sessionAuth();
+
- $dfrn_id = ((x($_GET,'dfrn_id')) ? $_GET['dfrn_id'] : '');
- $type = ((x($_GET,'type')) ? $_GET['type'] : 'data');
- $last_update = ((x($_GET,'last_update')) ? $_GET['last_update'] : '');
- $destination_url = ((x($_GET,'destination_url')) ? $_GET['destination_url'] : '');
- $challenge = ((x($_GET,'challenge')) ? $_GET['challenge'] : '');
- $sec = ((x($_GET,'sec')) ? $_GET['sec'] : '');
- $dfrn_version = ((x($_GET,'dfrn_version')) ? (float) $_GET['dfrn_version'] : 2.0);
- $perm = ((x($_GET,'perm')) ? $_GET['perm'] : 'r');
- $quiet = ((x($_GET,'quiet')) ? true : false);
++ $dfrn_id = defaults($_GET, 'dfrn_id' , '');
++ $type = defaults($_GET, 'type' , 'data');
++ $last_update = defaults($_GET, 'last_update' , '');
++ $destination_url = defaults($_GET, 'destination_url', '');
++ $challenge = defaults($_GET, 'challenge' , '');
++ $sec = defaults($_GET, 'sec' , '');
++ $dfrn_version = defaults($_GET, 'dfrn_version' , 2.0);
++ $perm = defaults($_GET, 'perm' , 'r');
++ $quiet = x($_GET, 'quiet');
// Possibly it is an OStatus compatible server that requests a user feed
if (($a->argc > 1) && ($dfrn_id == '') && !strstr($_SERVER["HTTP_USER_AGENT"], 'Friendica')) {
$nickname = $a->argv[1];
header("Content-type: application/atom+xml");
- echo OStatus::feed($a, $nickname, $last_update, 10);
+ echo OStatus::feed($nickname, $last_update, 10);
killme();
}
- $direction = (-1);
-
+ $direction = -1;
- if(strpos($dfrn_id,':') == 1) {
- $direction = intval(substr($dfrn_id,0,1));
- $dfrn_id = substr($dfrn_id,2);
+ if (strpos($dfrn_id, ':') == 1) {
+ $direction = intval(substr($dfrn_id, 0, 1));
+ $dfrn_id = substr($dfrn_id, 2);
}
$hidewall = false;
- if(($dfrn_id === '') && (! x($_POST,'dfrn_id'))) {
- if((Config::get('system','block_public')) && (! local_user()) && (! remote_user())) {
+ if (($dfrn_id === '') && (!x($_POST, 'dfrn_id'))) {
+ if (Config::get('system', 'block_public') && !local_user() && !remote_user()) {
http_status_exit(403);
}
$user = '';
- if($a->argc > 1) {
+ if ($a->argc > 1) {
$r = q("SELECT `hidewall`,`nickname` FROM `user` WHERE `user`.`nickname` = '%s' LIMIT 1",
dbesc($a->argv[1])
);
- if (!$r)
+ if (!$r) {
http_status_exit(404);
+ }
$hidewall = ($r[0]['hidewall'] && !local_user());
logger('dfrn_poll: public feed request from ' . $_SERVER['REMOTE_ADDR'] . ' for ' . $user);
header("Content-type: application/atom+xml");
- echo DFRN::feed('', $user,$last_update, 0, $hidewall);
+ echo DFRN::feed('', $user, $last_update, 0, $hidewall);
killme();
}
- if(($type === 'profile') && (! strlen($sec))) {
-
+ if (($type === 'profile') && (!strlen($sec))) {
$sql_extra = '';
- switch($direction) {
- case (-1):
- $sql_extra = sprintf(" AND ( `dfrn-id` = '%s' OR `issued-id` = '%s' ) ", dbesc($dfrn_id),dbesc($dfrn_id));
+ switch ($direction) {
+ case -1:
+ $sql_extra = sprintf(" AND ( `dfrn-id` = '%s' OR `issued-id` = '%s' ) ", dbesc($dfrn_id), dbesc($dfrn_id));
$my_id = $dfrn_id;
break;
case 0:
);
if (DBM::is_result($r)) {
-
$s = fetch_url($r[0]['poll'] . '?dfrn_id=' . $my_id . '&type=profile-check');
logger("dfrn_poll: old profile returns " . $s, LOGGER_DATA);
- if(strlen($s)) {
-
+ if (strlen($s)) {
$xml = parse_xml_string($s);
- if((int) $xml->status == 1) {
+ if ((int) $xml->status === 1) {
$_SESSION['authenticated'] = 1;
- if(! x($_SESSION,'remote'))
+ if (!x($_SESSION, 'remote')) {
$_SESSION['remote'] = array();
+ }
- $_SESSION['remote'][] = array('cid' => $r[0]['id'],'uid' => $r[0]['uid'],'url' => $r[0]['url']);
+ $_SESSION['remote'][] = array('cid' => $r[0]['id'], 'uid' => $r[0]['uid'], 'url' => $r[0]['url']);
$_SESSION['visitor_id'] = $r[0]['id'];
$_SESSION['visitor_home'] = $r[0]['url'];
$_SESSION['visitor_handle'] = $r[0]['addr'];
$_SESSION['visitor_visiting'] = $r[0]['uid'];
- if(!$quiet)
- info( sprintf(t('%1$s welcomes %2$s'), $r[0]['username'] , $r[0]['name']) . EOL);
+ if (!$quiet) {
+ info(sprintf(t('%1$s welcomes %2$s'), $r[0]['username'], $r[0]['name']) . EOL);
+ }
+
// Visitors get 1 day session.
$session_id = session_id();
$expire = time() + 86400;
goaway((strlen($destination_url)) ? $destination_url : System::baseUrl() . '/profile/' . $profile);
}
goaway(System::baseUrl());
-
}
- if($type === 'profile-check' && $dfrn_version < 2.2 ) {
-
- if((strlen($challenge)) && (strlen($sec))) {
-
+ if ($type === 'profile-check' && $dfrn_version < 2.2) {
+ if ((strlen($challenge)) && (strlen($sec))) {
q("DELETE FROM `profile_check` WHERE `expire` < " . intval(time()));
$r = q("SELECT * FROM `profile_check` WHERE `sec` = '%s' ORDER BY `expire` DESC LIMIT 1",
dbesc($sec)
);
- if (! DBM::is_result($r)) {
+ if (!DBM::is_result($r)) {
xml_status(3, 'No ticket');
// NOTREACHED
}
+
$orig_id = $r[0]['dfrn_id'];
- if(strpos($orig_id, ':'))
- $orig_id = substr($orig_id,2);
+ if (strpos($orig_id, ':')) {
+ $orig_id = substr($orig_id, 2);
+ }
$c = q("SELECT * FROM `contact` WHERE `id` = %d LIMIT 1",
intval($r[0]['cid'])
);
- if (! DBM::is_result($c)) {
+ if (!DBM::is_result($c)) {
xml_status(3, 'No profile');
}
+
$contact = $c[0];
$sent_dfrn_id = hex2bin($dfrn_id);
- $challenge = hex2bin($challenge);
+ $challenge = hex2bin($challenge);
$final_dfrn_id = '';
- if(($contact['duplex']) && strlen($contact['prvkey'])) {
- openssl_private_decrypt($sent_dfrn_id,$final_dfrn_id,$contact['prvkey']);
- openssl_private_decrypt($challenge,$decoded_challenge,$contact['prvkey']);
- }
- else {
- openssl_public_decrypt($sent_dfrn_id,$final_dfrn_id,$contact['pubkey']);
- openssl_public_decrypt($challenge,$decoded_challenge,$contact['pubkey']);
+ if (($contact['duplex']) && strlen($contact['prvkey'])) {
+ openssl_private_decrypt($sent_dfrn_id, $final_dfrn_id, $contact['prvkey']);
+ openssl_private_decrypt($challenge, $decoded_challenge, $contact['prvkey']);
+ } else {
+ openssl_public_decrypt($sent_dfrn_id, $final_dfrn_id, $contact['pubkey']);
+ openssl_public_decrypt($challenge, $decoded_challenge, $contact['pubkey']);
}
$final_dfrn_id = substr($final_dfrn_id, 0, strpos($final_dfrn_id, '.'));
- if(strpos($final_dfrn_id,':') == 1)
- $final_dfrn_id = substr($final_dfrn_id,2);
+ if (strpos($final_dfrn_id, ':') == 1) {
+ $final_dfrn_id = substr($final_dfrn_id, 2);
+ }
- if($final_dfrn_id != $orig_id) {
+ if ($final_dfrn_id != $orig_id) {
logger('profile_check: ' . $final_dfrn_id . ' != ' . $orig_id, LOGGER_DEBUG);
// did not decode properly - cannot trust this site
xml_status(3, 'Bad decryption');
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?><dfrn_poll><status>0</status><challenge>$decoded_challenge</challenge><sec>$sec</sec></dfrn_poll>";
killme();
// NOTREACHED
- }
- else {
- // old protocol
-
- switch($direction) {
+ } else {
+ // old protocol
+ switch ($direction) {
case 1:
$dfrn_id = '0:' . $dfrn_id;
break;
break;
}
-
q("DELETE FROM `profile_check` WHERE `expire` < " . intval(time()));
$r = q("SELECT * FROM `profile_check` WHERE `dfrn_id` = '%s' ORDER BY `expire` DESC",
dbesc($dfrn_id));
return; // NOTREACHED
}
}
-
}
-
-
- function dfrn_poll_post(App $a) {
-
- $dfrn_id = ((x($_POST,'dfrn_id')) ? $_POST['dfrn_id'] : '');
- $challenge = ((x($_POST,'challenge')) ? $_POST['challenge'] : '');
- $url = ((x($_POST,'url')) ? $_POST['url'] : '');
- $sec = ((x($_POST,'sec')) ? $_POST['sec'] : '');
- $ptype = ((x($_POST,'type')) ? $_POST['type'] : '');
- $dfrn_version = ((x($_POST,'dfrn_version')) ? (float) $_POST['dfrn_version'] : 2.0);
- $perm = ((x($_POST,'perm')) ? $_POST['perm'] : 'r');
-
- if($ptype === 'profile-check') {
-
- if((strlen($challenge)) && (strlen($sec))) {
-
+ function dfrn_poll_post(App $a)
+ {
+ $dfrn_id = x($_POST,'dfrn_id') ? $_POST['dfrn_id'] : '';
+ $challenge = x($_POST,'challenge') ? $_POST['challenge'] : '';
+ $url = x($_POST,'url') ? $_POST['url'] : '';
+ $sec = x($_POST,'sec') ? $_POST['sec'] : '';
+ $ptype = x($_POST,'type') ? $_POST['type'] : '';
+ $dfrn_version = x($_POST,'dfrn_version') ? (float) $_POST['dfrn_version'] : 2.0;
+ $perm = x($_POST,'perm') ? $_POST['perm'] : 'r';
+
+ if ($ptype === 'profile-check') {
+ if (strlen($challenge) && strlen($sec)) {
logger('dfrn_poll: POST: profile-check');
q("DELETE FROM `profile_check` WHERE `expire` < " . intval(time()));
$r = q("SELECT * FROM `profile_check` WHERE `sec` = '%s' ORDER BY `expire` DESC LIMIT 1",
dbesc($sec)
);
- if (! DBM::is_result($r)) {
+ if (!DBM::is_result($r)) {
xml_status(3, 'No ticket');
// NOTREACHED
}
+
$orig_id = $r[0]['dfrn_id'];
- if(strpos($orig_id, ':'))
- $orig_id = substr($orig_id,2);
+ if (strpos($orig_id, ':')) {
+ $orig_id = substr($orig_id, 2);
+ }
$c = q("SELECT * FROM `contact` WHERE `id` = %d LIMIT 1",
intval($r[0]['cid'])
);
- if (! DBM::is_result($c)) {
+ if (!DBM::is_result($c)) {
xml_status(3, 'No profile');
}
+
$contact = $c[0];
$sent_dfrn_id = hex2bin($dfrn_id);
- $challenge = hex2bin($challenge);
+ $challenge = hex2bin($challenge);
$final_dfrn_id = '';
- if(($contact['duplex']) && strlen($contact['prvkey'])) {
- openssl_private_decrypt($sent_dfrn_id,$final_dfrn_id,$contact['prvkey']);
- openssl_private_decrypt($challenge,$decoded_challenge,$contact['prvkey']);
- }
- else {
- openssl_public_decrypt($sent_dfrn_id,$final_dfrn_id,$contact['pubkey']);
- openssl_public_decrypt($challenge,$decoded_challenge,$contact['pubkey']);
+ if ($contact['duplex'] && strlen($contact['prvkey'])) {
+ openssl_private_decrypt($sent_dfrn_id, $final_dfrn_id, $contact['prvkey']);
+ openssl_private_decrypt($challenge, $decoded_challenge, $contact['prvkey']);
+ } else {
+ openssl_public_decrypt($sent_dfrn_id, $final_dfrn_id, $contact['pubkey']);
+ openssl_public_decrypt($challenge, $decoded_challenge, $contact['pubkey']);
}
$final_dfrn_id = substr($final_dfrn_id, 0, strpos($final_dfrn_id, '.'));
- if(strpos($final_dfrn_id,':') == 1)
- $final_dfrn_id = substr($final_dfrn_id,2);
+ if (strpos($final_dfrn_id, ':') == 1) {
+ $final_dfrn_id = substr($final_dfrn_id, 2);
+ }
- if($final_dfrn_id != $orig_id) {
+ if ($final_dfrn_id != $orig_id) {
logger('profile_check: ' . $final_dfrn_id . ' != ' . $orig_id, LOGGER_DEBUG);
// did not decode properly - cannot trust this site
xml_status(3, 'Bad decryption');
killme();
// NOTREACHED
}
-
}
- $direction = (-1);
- if(strpos($dfrn_id,':') == 1) {
- $direction = intval(substr($dfrn_id,0,1));
- $dfrn_id = substr($dfrn_id,2);
+ $direction = -1;
+ if (strpos($dfrn_id, ':') == 1) {
+ $direction = intval(substr($dfrn_id, 0, 1));
+ $dfrn_id = substr($dfrn_id, 2);
}
-
$r = q("SELECT * FROM `challenge` WHERE `dfrn-id` = '%s' AND `challenge` = '%s' LIMIT 1",
dbesc($dfrn_id),
dbesc($challenge)
);
- if (! DBM::is_result($r)) {
+ if (!DBM::is_result($r)) {
killme();
}
$sql_extra = '';
- switch($direction) {
- case (-1):
+ switch ($direction) {
+ case -1:
$sql_extra = sprintf(" AND `issued-id` = '%s' ", dbesc($dfrn_id));
$my_id = $dfrn_id;
break;
break; // NOTREACHED
}
-
$r = q("SELECT * FROM `contact` WHERE `blocked` = 0 AND `pending` = 0 $sql_extra LIMIT 1");
-
-
- if (! DBM::is_result($r)) {
+ if (!DBM::is_result($r)) {
killme();
}
$owner_uid = $r[0]['uid'];
$contact_id = $r[0]['id'];
-
- if($type === 'reputation' && strlen($url)) {
+ if ($type === 'reputation' && strlen($url)) {
$r = q("SELECT * FROM `contact` WHERE `url` = '%s' AND `uid` = %d LIMIT 1",
dbesc($url),
intval($owner_uid)
$reputation = $r[0]['rating'];
$text = $r[0]['reason'];
- if($r[0]['id'] == $contact_id) { // inquiring about own reputation not allowed
+ if ($r[0]['id'] == $contact_id) { // inquiring about own reputation not allowed
$reputation = 0;
$text = '';
}
";
killme();
// NOTREACHED
- }
- else {
-
+ } else {
// Update the writable flag if it changed
- logger('dfrn_poll: post request feed: ' . print_r($_POST,true),LOGGER_DATA);
- if($dfrn_version >= 2.21) {
- if($perm === 'rw')
+ logger('dfrn_poll: post request feed: ' . print_r($_POST, true), LOGGER_DATA);
+ if ($dfrn_version >= 2.21) {
+ if ($perm === 'rw') {
$writable = 1;
- else
+ } else {
$writable = 0;
+ }
- if($writable != $contact['writable']) {
+ if ($writable != $contact['writable']) {
q("UPDATE `contact` SET `writable` = %d WHERE `id` = %d",
intval($writable),
intval($contact_id)
$o = DFRN::feed($dfrn_id, $a->argv[1], $last_update, $direction);
echo $o;
killme();
-
}
}
- function dfrn_poll_content(App $a) {
-
- $dfrn_id = ((x($_GET,'dfrn_id')) ? $_GET['dfrn_id'] : '');
- $type = ((x($_GET,'type')) ? $_GET['type'] : 'data');
- $last_update = ((x($_GET,'last_update')) ? $_GET['last_update'] : '');
- $destination_url = ((x($_GET,'destination_url')) ? $_GET['destination_url'] : '');
- $sec = ((x($_GET,'sec')) ? $_GET['sec'] : '');
- $dfrn_version = ((x($_GET,'dfrn_version')) ? (float) $_GET['dfrn_version'] : 2.0);
- $perm = ((x($_GET,'perm')) ? $_GET['perm'] : 'r');
- $quiet = ((x($_GET,'quiet')) ? true : false);
-
- $direction = (-1);
- if(strpos($dfrn_id,':') == 1) {
- $direction = intval(substr($dfrn_id,0,1));
- $dfrn_id = substr($dfrn_id,2);
+ function dfrn_poll_content(App $a)
+ {
+ $dfrn_id = x($_GET,'dfrn_id') ? $_GET['dfrn_id'] : '';
+ $type = x($_GET,'type') ? $_GET['type'] : 'data';
+ $last_update = x($_GET,'last_update') ? $_GET['last_update'] : '';
+ $destination_url = x($_GET,'destination_url') ? $_GET['destination_url'] : '';
+ $sec = x($_GET,'sec') ? $_GET['sec'] : '';
+ $dfrn_version = x($_GET,'dfrn_version') ? (float) $_GET['dfrn_version'] : 2.0;
+ $perm = x($_GET,'perm') ? $_GET['perm'] : 'r';
+ $quiet = x($_GET,'quiet') ? true : false;
+
+ $direction = -1;
+ if (strpos($dfrn_id, ':') == 1) {
+ $direction = intval(substr($dfrn_id, 0, 1));
+ $dfrn_id = substr($dfrn_id, 2);
}
-
- if($dfrn_id != '') {
+ if ($dfrn_id != '') {
// initial communication from external contact
$hash = random_string();
$r = q("DELETE FROM `challenge` WHERE `expire` < " . intval(time()));
- if($type !== 'profile') {
+ if ($type !== 'profile') {
$r = q("INSERT INTO `challenge` ( `challenge`, `dfrn-id`, `expire` , `type`, `last_update` )
VALUES( '%s', '%s', '%s', '%s', '%s' ) ",
dbesc($hash),
dbesc($last_update)
);
}
+
$sql_extra = '';
- switch($direction) {
- case (-1):
- if($type === 'profile')
- $sql_extra = sprintf(" AND ( `dfrn-id` = '%s' OR `issued-id` = '%s' ) ", dbesc($dfrn_id),dbesc($dfrn_id));
- else
+ switch ($direction) {
+ case -1:
+ if ($type === 'profile') {
+ $sql_extra = sprintf(" AND ( `dfrn-id` = '%s' OR `issued-id` = '%s' ) ", dbesc($dfrn_id), dbesc($dfrn_id));
+ } else {
$sql_extra = sprintf(" AND `issued-id` = '%s' ", dbesc($dfrn_id));
+ }
+
$my_id = $dfrn_id;
break;
case 0:
AND `user`.`nickname` = '%s' $sql_extra LIMIT 1",
dbesc($nickname)
);
-
if (DBM::is_result($r)) {
-
$challenge = '';
$encrypted_id = '';
- $id_str = $my_id . '.' . mt_rand(1000,9999);
-
- if(($r[0]['duplex'] && strlen($r[0]['pubkey'])) || (! strlen($r[0]['prvkey']))) {
- openssl_public_encrypt($hash,$challenge,$r[0]['pubkey']);
- openssl_public_encrypt($id_str,$encrypted_id,$r[0]['pubkey']);
- }
- else {
- openssl_private_encrypt($hash,$challenge,$r[0]['prvkey']);
- openssl_private_encrypt($id_str,$encrypted_id,$r[0]['prvkey']);
+ $id_str = $my_id . '.' . mt_rand(1000, 9999);
+
+ if (($r[0]['duplex'] && strlen($r[0]['pubkey'])) || !strlen($r[0]['prvkey'])) {
+ openssl_public_encrypt($hash, $challenge, $r[0]['pubkey']);
+ openssl_public_encrypt($id_str, $encrypted_id, $r[0]['pubkey']);
+ } else {
+ openssl_private_encrypt($hash, $challenge, $r[0]['prvkey']);
+ openssl_private_encrypt($id_str, $encrypted_id, $r[0]['prvkey']);
}
$challenge = bin2hex($challenge);
$encrypted_id = bin2hex($encrypted_id);
- }
- else {
+ } else {
$status = 1;
$challenge = '';
$encrypted_id = '';
}
- if(($type === 'profile') && (strlen($sec))) {
-
+ if (($type === 'profile') && (strlen($sec))) {
// URL reply
-
- if($dfrn_version < 2.2) {
+ if ($dfrn_version < 2.2) {
$s = fetch_url($r[0]['poll']
. '?dfrn_id=' . $encrypted_id
. '&type=profile-check'
. '&challenge=' . $challenge
. '&sec=' . $sec
);
- }
- else {
+ } else {
$s = post_url($r[0]['poll'], array(
'dfrn_id' => $encrypted_id,
'type' => 'profile-check',
$profile = ((DBM::is_result($r) && $r[0]['nickname']) ? $r[0]['nickname'] : $nickname);
- switch($destination_url) {
+ switch ($destination_url) {
case 'profile':
$dest = System::baseUrl() . '/profile/' . $profile . '?f=&tab=profile';
break;
logger("dfrn_poll: sec profile: " . $s, LOGGER_DATA);
- if(strlen($s) && strstr($s,'<?xml')) {
-
+ if (strlen($s) && strstr($s, '<?xml')) {
$xml = parse_xml_string($s);
- logger('dfrn_poll: profile: parsed xml: ' . print_r($xml,true), LOGGER_DATA);
+ logger('dfrn_poll: profile: parsed xml: ' . print_r($xml, true), LOGGER_DATA);
logger('dfrn_poll: secure profile: challenge: ' . $xml->challenge . ' expecting ' . $hash);
logger('dfrn_poll: secure profile: sec: ' . $xml->sec . ' expecting ' . $sec);
-
- if(((int) $xml->status == 0) && ($xml->challenge == $hash) && ($xml->sec == $sec)) {
+ if (((int) $xml->status == 0) && ($xml->challenge == $hash) && ($xml->sec == $sec)) {
$_SESSION['authenticated'] = 1;
- if(! x($_SESSION,'remote'))
+ if (!x($_SESSION, 'remote')) {
$_SESSION['remote'] = array();
- $_SESSION['remote'][] = array('cid' => $r[0]['id'],'uid' => $r[0]['uid'],'url' => $r[0]['url']);
+ }
+
+ $_SESSION['remote'][] = array('cid' => $r[0]['id'], 'uid' => $r[0]['uid'], 'url' => $r[0]['url']);
$_SESSION['visitor_id'] = $r[0]['id'];
$_SESSION['visitor_home'] = $r[0]['url'];
$_SESSION['visitor_visiting'] = $r[0]['uid'];
- if(!$quiet)
- info( sprintf(t('%1$s welcomes %2$s'), $r[0]['username'] , $r[0]['name']) . EOL);
+ if (!$quiet) {
+ info(sprintf(t('%1$s welcomes %2$s'), $r[0]['username'], $r[0]['name']) . EOL);
+ }
+
// Visitors get 1 day session.
$session_id = session_id();
$expire = time() + 86400;
}
goaway($dest);
// NOTREACHED
-
- }
- else {
+ } else {
// XML reply
header("Content-type: text/xml");
echo '<?xml version="1.0" encoding="UTF-8"?>' . "\r\n"
. "\t" . '<dfrn_version>' . DFRN_PROTOCOL_VERSION . '</dfrn_version>' . "\r\n"
. "\t" . '<dfrn_id>' . $encrypted_id . '</dfrn_id>' . "\r\n"
. "\t" . '<challenge>' . $challenge . '</challenge>' . "\r\n"
- . '</dfrn_poll>' . "\r\n" ;
+ . '</dfrn_poll>' . "\r\n";
killme();
// NOTREACHED
}
use Friendica\Core\System;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
+use Friendica\Model\Group;
use Friendica\Protocol\DFRN;
function display_init(App $a) {
if ($update) {
$item_id = $_REQUEST['item_id'];
- $item = dba::select('item', ['uid'], ['id' => $item_id], ['limit' => 1]);
+ $item = dba::select('item', ['uid', 'parent'], ['id' => $item_id], ['limit' => 1]);
$a->profile = array('uid' => intval($item['uid']), 'profile_uid' => intval($item['uid']));
+ $item_parent = $item['parent'];
} else {
$item_id = (($a->argc > 2) ? $a->argv[2] : 0);
$contact_id = 0;
- if (is_array($_SESSION['remote'])) {
+ if (x($_SESSION, 'remote') && is_array($_SESSION['remote'])) {
foreach ($_SESSION['remote'] as $v) {
if ($v['uid'] == $a->profile['uid']) {
$contact_id = $v['cid'];
}
if ($contact_id) {
- $groups = init_groups_visitor($contact_id);
+ $groups = Group::getIdsByContactId($contact_id);
$r = dba::fetch_first("SELECT * FROM `contact` WHERE `id` = ? AND `uid` = ? LIMIT 1",
$contact_id,
$a->profile['uid']
}
$is_owner = (local_user() && (in_array($a->profile['profile_uid'], [local_user(), 0])) ? true : false);
- if ($a->profile['hidewall'] && !$is_owner && !$remote_contact) {
+ if (x($a->profile, 'hidewall') && !$is_owner && !$remote_contact) {
notice(t('Access to this profile has been restricted.') . EOL);
return;
}
use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Model\Group;
+use Friendica\Module\Login;
require_once 'include/conversation.php';
require_once 'include/contact_widgets.php';
// Set this so that the conversation function can find out contact info for our wall-wall items
$a->page_contact = $a->contact;
- $o .= conversation($a, $items, $mode, $update);
+ $o = conversation($a, $items, $mode, $update);
if (!$update) {
if (PConfig::get(local_user(), 'system', 'infinite_scroll')) {
function network_content(App $a, $update = 0) {
if (!local_user()) {
- $_SESSION['return_url'] = $a->query_string;
- return login(false);
+ return Login::form();
}
/// @TODO Is this really necessary? $a is already available to hooks
if ($group) {
if (($t = Contact::getOStatusCountByGroupId($group)) && !PConfig::get(local_user(), 'system', 'nowarn_insecure')) {
- notice(sprintf(tt("Warning: This group contains %s member from a network that doesn't allow non public messages.",
+ notice(tt("Warning: This group contains %s member from a network that doesn't allow non public messages.",
"Warning: This group contains %s members from a network that doesn't allow non public messages.",
- $t), $t).EOL);
+ $t) . EOL);
notice(t("Messages in this group won't be send to these receivers.").EOL);
}
}
}
$o = replace_macros(get_markup_template("section_title.tpl"),array(
- '$title' => sprintf(t('Group: %s'), $r['name'])
+ '$title' => t('Group: %s', $r['name'])
)) . $o;
} elseif ($cid) {
$sql_order = "";
$order_mode = "received";
- if (strlen($file)) {
- $sql_post_table .= sprintf("INNER JOIN (SELECT `oid` FROM `term` WHERE `term` = '%s' AND `otype` = %d AND `type` = %d AND `uid` = %d ORDER BY `tid` DESC) AS `term` ON `item`.`id` = `term`.`oid` ",
- dbesc(protect_sprintf($file)), intval(TERM_OBJ_POST), intval(TERM_FILE), intval(local_user()));
- $sql_order = "`item`.`id`";
- $order_mode = "id";
- }
-
if ($conv) {
$sql_extra3 .= " AND $sql_table.`mention`";
}
$sql_order = "$sql_table.$ordering";
}
- if (($_GET["offset"] != "")) {
+ if (x($_GET, 'offset')) {
$sql_extra3 .= sprintf(" AND $sql_order <= '%s'", dbesc($_GET["offset"]));
}
$parents_str = '';
$date_offset = "";
+ $items = array();
if (DBM::is_result($r)) {
foreach ($r as $rr) {
- if (!in_array($rr['item_id'],$parents_arr)) {
+ if (!in_array($rr['item_id'], $parents_arr)) {
$parents_arr[] = $rr['item_id'];
}
}
$max_comments = 100;
}
- $items = array();
-
foreach ($parents_arr AS $parents) {
- $thread_items = dba::p(item_query()." AND `item`.`uid` = ?
+ $thread_items = dba::p(item_query() . " AND `item`.`uid` = ?
AND `item`.`parent` = ?
- ORDER BY `item`.`commented` DESC LIMIT ".intval($max_comments + 1),
+ ORDER BY `item`.`commented` DESC LIMIT " . intval($max_comments + 1),
local_user(),
$parents
);
$items = array_merge($items, dba::inArray($thread_items));
}
}
- $items = conv_sort($items,$ordering);
- } else {
- $items = array();
+ $items = conv_sort($items, $ordering);
}
- if ($_GET["offset"] == "") {
+ if (x($_GET, 'offset')) {
+ $date_offset = $_GET["offset"];
+ } elseif(count($items)) {
$date_offset = $items[0][$order_mode];
} else {
- $date_offset = $_GET["offset"];
+ $date_offset = '';
}
$a->page_offset = $date_offset;
use Friendica\Core\Worker;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
+use Friendica\Model\Group;
use Friendica\Model\Photo;
use Friendica\Network\Probe;
use Friendica\Object\Image;
$tpl = get_markup_template("vcard-widget.tpl");
- $vcard_widget .= replace_macros($tpl, array(
+ $vcard_widget = replace_macros($tpl, array(
'$name' => $profile['name'],
'$photo' => $profile['photo'],
- '$addr' => (($profile['addr'] != "") ? $profile['addr'] : ""),
+ '$addr' => defaults($profile, 'addr', ''),
'$account_type' => $account_type,
- '$pdesc' => (($profile['pdesc'] != "") ? $profile['pdesc'] : ""),
+ '$pdesc' => defaults($profile, 'pdesc', ''),
));
$albums = photo_albums($a->data['user']['uid']);
}
}
- $albums = $ret;
-
if (local_user() && $a->data['user']['uid'] == local_user()) {
$can_post = true;
}
- if ($albums['success']) {
+ if ($ret['success']) {
$photo_albums_widget = replace_macros(get_markup_template('photo_albums.tpl'), array(
'$nick' => $a->data['user']['nickname'],
'$title' => t('Photo Albums'),
'$recent' => t('Recent Photos'),
- '$albums' => $albums['albums'],
+ '$albums' => $ret['albums'],
'$baseurl' => System::baseUrl(),
'$upload' => array(t('Upload New Photos'), 'photos/' . $a->data['user']['nickname'] . '/upload'),
'$can_post' => $can_post
$a->page['aside'] .= $vcard_widget;
$a->page['aside'] .= $photo_albums_widget;
-
$tpl = get_markup_template("photos_head.tpl");
$a->page['htmlhead'] .= replace_macros($tpl,array(
'$ispublic' => t('everybody')
));
-
}
return;
}
-
-
- function photos_post(App $a) {
-
+ function photos_post(App $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);
+ logger('mod_photos: REQUEST ' . print_r($_REQUEST, true), LOGGER_DATA);
+ logger('mod_photos: FILES ' . print_r($_FILES, true), LOGGER_DATA);
$phototypes = Image::supportedTypes();
$visitor = 0;
$page_owner_uid = $a->data['user']['uid'];
- $community_page = (($a->data['user']['page-flags'] == PAGE_COMMUNITY) ? true : false);
+ $community_page = $a->data['user']['page-flags'] == PAGE_COMMUNITY;
if (local_user() && (local_user() == $page_owner_uid)) {
$can_post = true;
} else {
if ($community_page && remote_user()) {
$contact_id = 0;
- if (is_array($_SESSION['remote'])) {
+ if (x($_SESSION, 'remote') && is_array($_SESSION['remote'])) {
foreach ($_SESSION['remote'] as $v) {
if ($v['uid'] == $page_owner_uid) {
$contact_id = $v['cid'];
}
}
if ($contact_id) {
-
$r = q("SELECT `uid` FROM `contact` WHERE `blocked` = 0 AND `pending` = 0 AND `id` = %d AND `uid` = %d LIMIT 1",
intval($contact_id),
intval($page_owner_uid)
$owner_record = $r[0];
-
- if (($a->argc > 3) && ($a->argv[2] === 'album')) {
+ if ($a->argc > 3 && $a->argv[2] === 'album') {
$album = hex2bin($a->argv[3]);
if ($album === t('Profile Photos') || $album === 'Contact Photos' || $album === t('Contact Photos')) {
goaway($_SESSION['photo_return']);
}
- /*
- * RENAME photo album
- */
-
+ // RENAME photo album
$newalbum = notags(trim($_POST['albumname']));
if ($newalbum != $album) {
q("UPDATE `photo` SET `album` = '%s' WHERE `album` = '%s' AND `uid` = %d",
// Update the photo albums cache
photo_albums($page_owner_uid, true);
- $newurl = str_replace(bin2hex($album),bin2hex($newalbum),$_SESSION['photo_return']);
+ $newurl = str_replace(bin2hex($album), bin2hex($newalbum), $_SESSION['photo_return']);
goaway($newurl);
return; // NOTREACHED
}
*/
if ($_POST['dropalbum'] == t('Delete Album')) {
-
// Check if we should do HTML-based delete confirmation
- if ($_REQUEST['confirm']) {
+ if (x($_REQUEST, 'confirm')) {
$drop_url = $a->query_string;
$extra_inputs = array(
array('name' => 'albumname', 'value' => $_POST['albumname']),
$str_res = implode(',', $res);
// remove the associated photos
-
q("DELETE FROM `photo` WHERE `resource-id` IN ( $str_res ) AND `uid` = %d",
intval($page_owner_uid)
);
// find and delete the corresponding item with all the comments and likes/dislikes
-
- $r = q("SELECT `parent-uri` FROM `item` WHERE `resource-id` IN ( $str_res ) AND `uid` = %d",
+ $r = q("SELECT `id`, `parent-uri`, `visible` FROM `item` WHERE `resource-id` IN ( $str_res ) AND `uid` = %d",
intval($page_owner_uid)
);
if (DBM::is_result($r)) {
$drop_id = intval($rr['id']);
// send the notification upstream/downstream as the case may be
-
if ($rr['visible']) {
Worker::add(PRIORITY_HIGH, "Notifier", "drop", $drop_id);
}
// Check if the user has responded to a delete confirmation query for a single photo
- if (($a->argc > 2) && $_REQUEST['canceled']) {
+ if ($a->argc > 2 && x($_REQUEST, 'canceled')) {
goaway($_SESSION['photo_return']);
}
- if (($a->argc > 2) && (x($_POST,'delete')) && ($_POST['delete'] == t('Delete Photo'))) {
+ if ($a->argc > 2 && defaults($_POST, 'delete', '') === t('Delete Photo')) {
// same as above but remove single photo
// Check if we should do HTML-based delete confirmation
- if ($_REQUEST['confirm']) {
+ if (x($_REQUEST, 'confirm')) {
$drop_url = $a->query_string;
$a->page['content'] = replace_macros(get_markup_template('confirm.tpl'), array(
'$method' => 'post',
intval($page_owner_uid),
dbesc($r[0]['resource-id'])
);
- $i = q("SELECT * FROM `item` WHERE `resource-id` = '%s' AND `uid` = %d LIMIT 1",
+ $i = q("SELECT `id`, `uri`, `visible` FROM `item` WHERE `resource-id` = '%s' AND `uid` = %d LIMIT 1",
dbesc($r[0]['resource-id']),
intval($page_owner_uid)
);
return; // NOTREACHED
}
- if (($a->argc > 2) && ((x($_POST,'desc') !== false) || (x($_POST,'newtag') !== false)) || (x($_POST,'albname') !== false)) {
-
- $desc = (x($_POST,'desc') ? notags(trim($_POST['desc'])) : '');
- $rawtags = (x($_POST,'newtag') ? notags(trim($_POST['newtag'])) : '');
- $item_id = (x($_POST,'item_id') ? intval($_POST['item_id']) : 0);
- $albname = (x($_POST,'albname') ? notags(trim($_POST['albname'])) : '');
- $origaname = (x($_POST,'origaname') ? notags(trim($_POST['origaname'])) : '');
+ if ($a->argc > 2 && (x($_POST, 'desc') !== false || x($_POST, 'newtag') !== false || x($_POST, 'albname') !== false)) {
+ $desc = x($_POST, 'desc') ? notags(trim($_POST['desc'])) : '';
+ $rawtags = x($_POST, 'newtag') ? notags(trim($_POST['newtag'])) : '';
+ $item_id = x($_POST, 'item_id') ? intval($_POST['item_id']) : 0;
+ $albname = x($_POST, 'albname') ? notags(trim($_POST['albname'])) : '';
+ $origaname = x($_POST, 'origaname') ? notags(trim($_POST['origaname'])) : '';
$str_group_allow = perms2str($_POST['group_allow']);
$str_contact_allow = perms2str($_POST['contact_allow']);
$str_group_deny = perms2str($_POST['group_deny']);
$albname = datetime_convert('UTC',date_default_timezone_get(),'now', 'Y');
}
-
- if ((x($_POST,'rotate') !== false) &&
- ( (intval($_POST['rotate']) == 1) || (intval($_POST['rotate']) == 2) )) {
+ if (x($_POST,'rotate') !== false &&
+ (intval($_POST['rotate']) == 1 || intval($_POST['rotate']) == 2)) {
logger('rotate');
$r = q("SELECT * FROM `photo` WHERE `resource-id` = '%s' AND `uid` = %d AND `scale` = 0 LIMIT 1",
}
if (!$item_id) {
-
// Create item container
-
$title = '';
$uri = item_new_uri($a->get_hostname(),$page_owner_uid);
. '[/url]';
$item_id = item_store($arr);
-
}
if ($item_id) {
}
if (strlen($rawtags)) {
-
$str_tags = '';
$inform = '';
// if the new tag doesn't have a namespace specifier (@foo or #foo) give it a hashtag
-
- $x = substr($rawtags,0,1);
+ $x = substr($rawtags, 0, 1);
if ($x !== '@' && $x !== '#') {
$rawtags = '#' . $rawtags;
}
if (count($tags)) {
foreach ($tags as $tag) {
- if (isset($profile)) {
- unset($profile);
- }
if (strpos($tag, '@') === 0) {
+ $profile = '';
$name = substr($tag,1);
if ((strpos($name, '@')) || (strpos($name, 'http://'))) {
$newname = $name;
if (count($taginfo)) {
foreach ($taginfo as $tagged) {
-
- $uri = item_new_uri($a->get_hostname(),$page_owner_uid);
+ $uri = item_new_uri($a->get_hostname(), $page_owner_uid);
$arr = array();
$arr['guid'] = get_guid(32);
}
- /**
- * default post action - upload a photo
- */
-
+ // default post action - upload a photo
call_hooks('photo_post_init', $_POST);
- /**
- * Determine the album to use
- */
-
- $album = notags(trim($_REQUEST['album']));
- $newalbum = notags(trim($_REQUEST['newalbum']));
+ // Determine the album to use
+ $album = x($_REQUEST, 'album') ? notags(trim($_REQUEST['album'])) : '';
+ $newalbum = x($_REQUEST, 'newalbum') ? notags(trim($_REQUEST['newalbum'])) : '';
logger('mod/photos.php: photos_post(): album= ' . $album . ' newalbum= ' . $newalbum , LOGGER_DEBUG);
$visible = 0;
}
- if (intval($_REQUEST['not_visible']) || $_REQUEST['not_visible'] === 'true') {
+ if (x($_REQUEST, 'not_visible') && $_REQUEST['not_visible'] !== 'false') {
$visible = 0;
}
- $str_group_allow = perms2str((is_array($_REQUEST['group_allow']) ? $_REQUEST['group_allow'] : explode(',', $_REQUEST['group_allow'])));
- $str_contact_allow = perms2str((is_array($_REQUEST['contact_allow']) ? $_REQUEST['contact_allow'] : explode(',', $_REQUEST['contact_allow'])));
- $str_group_deny = perms2str((is_array($_REQUEST['group_deny']) ? $_REQUEST['group_deny'] : explode(',', $_REQUEST['group_deny'])));
- $str_contact_deny = perms2str((is_array($_REQUEST['contact_deny']) ? $_REQUEST['contact_deny'] : explode(',', $_REQUEST['contact_deny'])));
+ $group_allow = defaults($_REQUEST, 'group_allow' , []);
+ $contact_allow = defaults($_REQUEST, 'contact_allow', []);
+ $group_deny = defaults($_REQUEST, 'group_deny' , []);
+ $contact_deny = defaults($_REQUEST, 'contact_deny' , []);
+
+ $str_group_allow = perms2str(is_array($group_allow) ? $group_allow : explode(',', $group_allow));
+ $str_contact_allow = perms2str(is_array($contact_allow) ? $contact_allow : explode(',', $contact_allow));
+ $str_group_deny = perms2str(is_array($group_deny) ? $group_deny : explode(',', $group_deny));
+ $str_contact_deny = perms2str(is_array($contact_deny) ? $contact_deny : explode(',', $contact_deny));
$ret = array('src' => '', 'filename' => '', 'filesize' => 0, 'type' => '');
- call_hooks('photo_post_file',$ret);
+ call_hooks('photo_post_file', $ret);
- if (x($ret,'src') && x($ret,'filesize')) {
+ if (x($ret, 'src') && x($ret, 'filesize')) {
$src = $ret['src'];
$filename = $ret['filename'];
$filesize = $ret['filesize'];
$type = $ret['type'];
+ $error = UPLOAD_ERR_OK;
} else {
- $src = $_FILES['userfile']['tmp_name'];
- $filename = basename($_FILES['userfile']['name']);
- $filesize = intval($_FILES['userfile']['size']);
- $type = $_FILES['userfile']['type'];
+ $src = $_FILES['userfile']['tmp_name'];
+ $filename = basename($_FILES['userfile']['name']);
+ $filesize = intval($_FILES['userfile']['size']);
+ $type = $_FILES['userfile']['type'];
+ $error = $_FILES['userfile']['error'];
}
+
+ if ($error !== UPLOAD_ERR_OK) {
+ switch ($error) {
+ case UPLOAD_ERR_INI_SIZE:
+ notice(t('Image exceeds size limit of %s', ini_get('upload_max_filesize')) . EOL);
+ break;
+ case UPLOAD_ERR_FORM_SIZE:
+ notice(t('Image exceeds size limit of %s', formatBytes(defaults($_REQUEST, 'MAX_FILE_SIZE', 0))) . EOL);
+ break;
+ case UPLOAD_ERR_PARTIAL:
+ notice(t('Image upload didn\'t complete, please try again') . EOL);
+ break;
+ case UPLOAD_ERR_NO_FILE:
+ notice(t('Image file is missing') . EOL);
+ break;
+ case UPLOAD_ERR_NO_TMP_DIR:
+ case UPLOAD_ERR_CANT_WRITE:
+ case UPLOAD_ERR_EXTENSION:
+ notice(t('Server can\'t accept new file upload at this time, please contact your administrator') . EOL);
+ break;
+ }
+ @unlink($src);
+ $foo = 0;
+ call_hooks('photo_post_end', $foo);
+ return;
+ }
+
if ($type == "") {
$type = Image::guessType($filename);
}
logger('photos: upload: received file: ' . $filename . ' as ' . $src . ' ('. $type . ') ' . $filesize . ' bytes', LOGGER_DEBUG);
- $maximagesize = Config::get('system','maximagesize');
+ $maximagesize = Config::get('system', 'maximagesize');
if ($maximagesize && ($filesize > $maximagesize)) {
- notice( sprintf(t('Image exceeds size limit of %s'), formatBytes($maximagesize)) . EOL);
+ notice(t('Image exceeds size limit of %s', formatBytes($maximagesize)) . EOL);
@unlink($src);
$foo = 0;
- call_hooks('photo_post_end',$foo);
+ call_hooks('photo_post_end', $foo);
return;
}
if (!$filesize) {
- notice( t('Image file is empty.') . EOL);
+ notice(t('Image file is empty.') . EOL);
@unlink($src);
$foo = 0;
- call_hooks('photo_post_end',$foo);
+ call_hooks('photo_post_end', $foo);
return;
}
if (!$Image->isValid()) {
logger('mod/photos.php: photos_post(): unable to process image' , LOGGER_DEBUG);
- notice( t('Unable to process image.') . EOL );
+ notice(t('Unable to process image.') . EOL);
@unlink($src);
$foo = 0;
call_hooks('photo_post_end',$foo);
if (!$r) {
logger('mod/photos.php: photos_post(): image store failed' , LOGGER_DEBUG);
- notice( t('Image upload failed.') . EOL );
+ notice(t('Image upload failed.') . EOL);
killme();
}
$smallest = 2;
}
- $basename = basename($filename);
$uri = item_new_uri($a->get_hostname(), $page_owner_uid);
// Create item container
-
$lat = $lon = null;
-
- /// @TODO merge these 2 if() into one?
- if ($exif && $exif['GPS']) {
- if (Feature::isEnabled($channel_id,'photo_location')) {
- $lat = getGps($exif['GPS']['GPSLatitude'], $exif['GPS']['GPSLatitudeRef']);
- $lon = getGps($exif['GPS']['GPSLongitude'], $exif['GPS']['GPSLongitudeRef']);
- }
+ if ($exif && $exif['GPS'] && Feature::isEnabled($channel_id, 'photo_location')) {
+ $lat = getGps($exif['GPS']['GPSLatitude'], $exif['GPS']['GPSLatitudeRef']);
+ $lon = getGps($exif['GPS']['GPSLongitude'], $exif['GPS']['GPSLongitudeRef']);
}
$arr = array();
-
if ($lat && $lon) {
$arr['coord'] = $lat . ' ' . $lon;
}
call_hooks('photo_post_end',intval($item_id));
- /*
- * addon uploaders should call "killme()" [e.g. exit] within the photo_post_end hook
- * if they do not wish to be redirected
- */
+ // addon uploaders should call "killme()" [e.g. exit] within the photo_post_end hook
+ // if they do not wish to be redirected
goaway($_SESSION['photo_return']);
// NOTREACHED
}
- function photos_content(App $a) {
-
+ function photos_content(App $a)
+ {
// URLs:
// photos/name
// photos/name/upload
// photos/name/image/xxxxx
// photos/name/image/xxxxx/edit
-
if (Config::get('system', 'block_public') && !local_user() && !remote_user()) {
notice( t('Public access denied.') . EOL);
return;
$_SESSION['photo_return'] = $a->cmd;
- //
// Parse arguments
- //
-
+ $datum = null;
if ($a->argc > 3) {
$datatype = $a->argv[2];
$datum = $a->argv[3];
$cmd = 'view';
}
- //
// Setup permissions structures
- //
-
$can_post = false;
$visitor = 0;
$contact = null;
}
}
- // perhaps they're visiting - but not a community page, so they wouldn't have write access
+ $groups = [];
+ // perhaps they're visiting - but not a community page, so they wouldn't have write access
if (remote_user() && !$visitor) {
$contact_id = 0;
if (is_array($_SESSION['remote'])) {
}
}
if ($contact_id) {
- $groups = init_groups_visitor($contact_id);
+ $groups = Group::getIdsByContactId($contact_id);
$r = q("SELECT * FROM `contact` WHERE `blocked` = 0 AND `pending` = 0 AND `id` = %d AND `uid` = %d LIMIT 1",
intval($contact_id),
intval($owner_uid)
}
}
- /// @TODO merge these 2 if() into one?
- if (!$remote_contact) {
- if (local_user()) {
- $contact_id = $_SESSION['cid'];
- $contact = $a->contact;
- }
+ if (!$remote_contact && local_user()) {
+ $contact_id = $_SESSION['cid'];
+ $contact = $a->contact;
}
if ($a->data['user']['hidewall'] && (local_user() != $owner_uid) && !$remote_contact) {
return;
}
- $sql_extra = permissions_sql($owner_uid,$remote_contact,$groups);
+ $sql_extra = permissions_sql($owner_uid, $remote_contact, $groups);
$o = "";
$is_owner = (local_user() && (local_user() == $owner_uid));
$o .= profile_tabs($a, $is_owner, $a->data['user']['nickname']);
- /**
- * Display upload form
- */
-
+ // Display upload form
if ($datatype === 'upload') {
if (!$can_post) {
notice(t('Permission denied.'));
return;
}
-
- $selname = ($datum ? hex2bin($datum) : '');
-
+ $selname = $datum ? hex2bin($datum) : '';
$albumselect = '';
-
$albumselect .= '<option value="" ' . (!$selname ? ' selected="selected" ' : '') . '> </option>';
if (count($a->data['albums'])) {
foreach ($a->data['albums'] as $album) {
$usage_message = '';
- // Private/public post links for the non-JS ACL form
- $private_post = 1;
- if ($_REQUEST['public']) {
- $private_post = 0;
- }
-
- $query_str = $a->query_string;
- if (strpos($query_str, 'public=1') !== false) {
- $query_str = str_replace(array('?public=1', '&public=1'), array('', ''), $query_str);
- }
-
- /*
- * I think $a->query_string may never have ? in it, but I could be wrong
- * It looks like it's from the index.php?q=[etc] rewrite that the web
- * server does, which converts any ? to &, e.g. suggest&ignore=61 for suggest?ignore=61
- */
- if (strpos($query_str, '?') === false) {
- $public_post_link = '?public=1';
- } else {
- $public_post_link = '&public=1';
- }
-
$tpl = get_markup_template('photos_upload.tpl');
- $albumselect_e = $albumselect;
$aclselect_e = ($visitor ? '' : populate_acl($a->user));
$o .= replace_macros($tpl,array(
'$newalbum' => t('New album name: '),
'$existalbumtext' => t('or existing album name: '),
'$nosharetext' => t('Do not show a status post for this upload'),
- '$albumselect' => $albumselect_e,
+ '$albumselect' => $albumselect,
'$permissions' => t('Permissions'),
'$aclselect' => $aclselect_e,
'$alt_uploader' => $ret['addon_text'],
'$acl_data' => construct_acl_data($a, $a->user), // For non-Javascript ACL selector
'$group_perms' => t('Show to Groups'),
'$contact_perms' => t('Show to Contacts'),
- '$private' => t('Private Photo'),
- '$public' => t('Public Photo'),
- '$is_private' => $private_post,
- '$return_path' => $query_str,
- '$public_link' => $public_post_link,
-
+ '$return_path' => $a->query_string,
));
return $o;
}
- /*
- * Display a single photo album
- */
-
+ // Display a single photo album
if ($datatype === 'album') {
-
$album = hex2bin($datum);
$r = q("SELECT `resource-id`, max(`scale`) AS `scale` FROM `photo` WHERE `uid` = %d AND `album` = '%s'
}
/// @TODO I have seen this many times, maybe generalize it script-wide and encapsulate it?
- if ($_GET['order'] === 'posted') {
+ $order_field = defaults($_GET, 'order', '');
+ if ($order_field === 'posted') {
$order = 'ASC';
} else {
$order = 'DESC';
}
}
- if ($_GET['order'] === 'posted') {
+ if ($order_field === 'posted') {
$order = array(t('Show Newest First'), 'photos/' . $a->data['user']['nickname'] . '/album/' . bin2hex($album));
} else {
$order = array(t('Show Oldest First'), 'photos/' . $a->data['user']['nickname'] . '/album/' . bin2hex($album) . '?f=&order=posted');
$photos = array();
- if (DBM::is_result($r))
+ if (DBM::is_result($r)) {
// "Twist" is only used for the duepunto theme with style "slackr"
$twist = false;
foreach ($r as $rr) {
'id' => $rr['id'],
'twist' => ' ' . ($twist ? 'rotleft' : 'rotright') . rand(2,4),
'link' => 'photos/' . $a->data['user']['nickname'] . '/image/' . $rr['resource-id']
- . (($_GET['order'] === 'posted') ? '?f=&order=posted' : ''),
+ . ($order_field === 'posted' ? '?f=&order=posted' : ''),
'title' => t('View Photo'),
'src' => 'photo/' . $rr['resource-id'] . '-' . $rr['scale'] . '.' .$ext,
'alt' => $imgalt_e,
'desc'=> $desc_e,
'ext' => $ext,
- 'hash'=> $rr['resource_id'],
+ 'hash'=> $rr['resource-id'],
);
+ }
}
$tpl = get_markup_template('photo_album.tpl');
}
- /*
- * Display one photo
- */
+ // Display one photo
if ($datatype === 'image') {
-
- //$o = '';
// fetch image, item containing image, then comments
-
$ph = q("SELECT * FROM `photo` WHERE `uid` = %d AND `resource-id` = '%s'
$sql_extra ORDER BY `scale` ASC ",
intval($owner_uid),
// The query leads to a really intense used index.
// By now we hide it if someone wants to.
if (!Config::get('system', 'no_count', false)) {
- if ($_GET['order'] === 'posted') {
+ $order_field = defaults($_GET, 'order', '');
+ if ($order_field === 'posted') {
$order = 'ASC';
} else {
$order = 'DESC';
}
}
$edit_suffix = ((($cmd === 'edit') && $can_post) ? '/edit' : '');
- $prevlink = 'photos/' . $a->data['user']['nickname'] . '/image/' . $prvnxt[$prv]['resource-id'] . $edit_suffix . (($_GET['order'] === 'posted') ? '?f=&order=posted' : '');
- $nextlink = 'photos/' . $a->data['user']['nickname'] . '/image/' . $prvnxt[$nxt]['resource-id'] . $edit_suffix . (($_GET['order'] === 'posted') ? '?f=&order=posted' : '');
+ $prevlink = 'photos/' . $a->data['user']['nickname'] . '/image/' . $prvnxt[$prv]['resource-id'] . $edit_suffix . ($order_field === 'posted' ? '?f=&order=posted' : '');
+ $nextlink = 'photos/' . $a->data['user']['nickname'] . '/image/' . $prvnxt[$nxt]['resource-id'] . $edit_suffix . ($order_field === 'posted' ? '?f=&order=posted' : '');
}
}
);
$map = null;
+ $link_item = [];
if (DBM::is_result($linked_items)) {
$link_item = $linked_items[0];
$edit = Null;
- if (($cmd === 'edit') && $can_post) {
+ if ($cmd === 'edit' && $can_post) {
$edit_tpl = get_markup_template('photo_edit.tpl');
- // Private/public post links for the non-JS ACL form
- $private_post = 1;
- if ($_REQUEST['public']) {
- $private_post = 0;
- }
-
- $query_str = $a->query_string;
- if (strpos($query_str, 'public=1') !== false) {
- $query_str = str_replace(array('?public=1', '&public=1'), array('', ''), $query_str);
- }
-
- /*
- * I think $a->query_string may never have ? in it, but I could be wrong
- * It looks like it's from the index.php?q=[etc] rewrite that the web
- * server does, which converts any ? to &, e.g. suggest&ignore=61 for suggest?ignore=61
- */
- if (strpos($query_str, '?') === false) {
- $public_post_link = '?public=1';
- } else {
- $public_post_link = '&public=1';
- }
-
$album_e = $ph[0]['album'];
$caption_e = $ph[0]['desc'];
$aclselect_e = populate_acl($ph[0]);
'$permissions' => t('Permissions'),
'$aclselect' => $aclselect_e,
- '$item_id' => (count($linked_items) ? $link_item['id'] : 0),
+ '$item_id' => defaults($link_item, 'id', 0),
'$submit' => t('Submit'),
'$delete' => t('Delete Photo'),
'$acl_data' => construct_acl_data($a, $ph[0]), // For non-Javascript ACL selector
'$group_perms' => t('Show to Groups'),
'$contact_perms' => t('Show to Contacts'),
- '$private' => t('Private photo'),
- '$public' => t('Public photo'),
- '$is_private' => $private_post,
- '$return_path' => $query_str,
- '$public_link' => $public_post_link,
+ '$return_path' => $a->query_string,
));
}
- if (count($linked_items)) {
+ $like = '';
+ $dislike = '';
+ $likebuttons = '';
+ $comments = '';
+ $paginate = '';
+ $responses = '';
+ if (count($linked_items)) {
$cmnt_tpl = get_markup_template('comment_item.tpl');
$tpl = get_markup_template('photo_item.tpl');
$return_url = $a->cmd;
- $like_tpl = get_markup_template('like_noshare.tpl');
-
- $likebuttons = '';
-
if ($can_post || can_write_wall($a, $owner_uid)) {
+ $like_tpl = get_markup_template('like_noshare.tpl');
$likebuttons = replace_macros($like_tpl, array(
'$id' => $link_item['id'],
'$likethis' => t("I like this \x28toggle\x29"),
));
}
- $comments = '';
if (!DBM::is_result($r)) {
if (($can_post || can_write_wall($a, $owner_uid)) && $link_item['last-child']) {
$comments .= replace_macros($cmnt_tpl, array(
}
}
- $alike = array();
- $dlike = array();
-
- $like = '';
- $dislike = '';
-
$conv_responses = array(
'like' => array('title' => t('Likes','title')),'dislike' => array('title' => t('Dislikes','title')),
'attendyes' => array('title' => t('Attending','title')), 'attendno' => array('title' => t('Not attending','title')), 'attendmaybe' => array('title' => t('Might attend','title'))
// display comments
if (DBM::is_result($r)) {
-
foreach ($r as $item) {
builtin_activity_puller($item, $conv_responses);
}
- $like = (x($conv_responses['like'], $link_item['uri']) ? format_like($conv_responses['like'][$link_item['uri']], $conv_responses['like'][$link_item['uri'] . '-l'], 'like',$link_item['id']) : '');
- $dislike = (x($conv_responses['dislike'], $link_item['uri']) ? format_like($conv_responses['dislike'][$link_item['uri']], $conv_responses['dislike'][$link_item['uri'] . '-l'], 'dislike',$link_item['id']) : '');
+ if (x($conv_responses['like'], $link_item['uri'])) {
+ $like = format_like($conv_responses['like'][$link_item['uri']], $conv_responses['like'][$link_item['uri'] . '-l'], 'like', $link_item['id']);
+ }
+ if (x($conv_responses['dislike'], $link_item['uri'])) {
+ $dislike = format_like($conv_responses['dislike'][$link_item['uri']], $conv_responses['dislike'][$link_item['uri'] . '-l'], 'dislike', $link_item['id']);
+ }
if (($can_post || can_write_wall($a, $owner_uid)) && $link_item['last-child']) {
$comments .= replace_macros($cmnt_tpl,array(
));
}
-
foreach ($r as $item) {
$comment = '';
$template = $tpl;
$sparkle = '';
- if ((activity_match($item['verb'], ACTIVITY_LIKE) || activity_match($item['verb'], ACTIVITY_DISLIKE)) && ($item['id'] != $item['parent']))
+ if ((activity_match($item['verb'], ACTIVITY_LIKE) || activity_match($item['verb'], ACTIVITY_DISLIKE)) && ($item['id'] != $item['parent'])) {
continue;
+ }
$redirect_url = 'redir/' . $item['cid'];
-
if (local_user() && ($item['contact-uid'] == local_user())
&& ($item['network'] == NETWORK_DFRN) && !$item['self']) {
$profile_url = $redirect_url;
}
}
}
+ $response_verbs = array('like');
+ if (Feature::isEnabled($owner_uid, 'dislike')) {
+ $response_verbs[] = 'dislike';
+ }
+ $responses = get_responses($conv_responses, $response_verbs, '', $link_item);
$paginate = paginate($a);
}
-
- $response_verbs = array('like');
- if (Feature::isEnabled($owner_uid, 'dislike')) {
- $response_verbs[] = 'dislike';
- }
- $responses = get_responses($conv_responses,$response_verbs, '', $link_item);
-
$photo_tpl = get_markup_template('photo_view.tpl');
-
- $album_e = array($album_link, $ph[0]['album']);
- $tags_e = $tags;
- $like_e = $like;
- $dislike_e = $dislike;
-
$o .= replace_macros($photo_tpl, array(
'$id' => $ph[0]['id'],
- '$album' => $album_e,
+ '$album' => [$album_link, $ph[0]['album']],
'$tools' => $tools,
'$lock' => $lock,
'$photo' => $photo,
'$prevlink' => $prevlink,
'$nextlink' => $nextlink,
'$desc' => $ph[0]['desc'],
- '$tags' => $tags_e,
+ '$tags' => $tags,
'$edit' => $edit,
'$map' => $map,
'$map_text' => t('Map'),
'$likebuttons' => $likebuttons,
- '$like' => $like_e,
- '$dislike' => $dikslike_e,
+ '$like' => $like,
+ '$dislike' => $dislike,
'responses' => $responses,
'$comments' => $comments,
'$paginate' => $paginate,
use Friendica\Core\PConfig;
use Friendica\Core\System;
use Friendica\Database\DBM;
+use Friendica\Model\Group;
+use Friendica\Module\Login;
- require_once('include/contact_widgets.php');
- require_once('include/redir.php');
+ require_once 'include/contact_widgets.php';
+ require_once 'include/redir.php';
- function profile_init(App $a) {
-
- if(! x($a->page,'aside'))
+ function profile_init(App $a)
+ {
+ if (!x($a->page, 'aside')) {
$a->page['aside'] = '';
+ }
- if($a->argc > 1)
+ if ($a->argc > 1) {
$which = htmlspecialchars($a->argv[1]);
- else {
- $r = q("select nickname from user where blocked = 0 and account_expired = 0 and account_removed = 0 and verified = 1 order by rand() limit 1");
+ } else {
+ $r = q("SELECT `nickname` FROM `user` WHERE `blocked` = 0 AND `account_expired` = 0 AND `account_removed` = 0 AND `verified` = 1 ORDER BY RAND() LIMIT 1");
if (DBM::is_result($r)) {
goaway(System::baseUrl() . '/profile/' . $r[0]['nickname']);
- }
- else {
+ } else {
logger('profile error: mod_profile ' . $a->query_string, LOGGER_DEBUG);
- notice( t('Requested profile is not available.') . EOL );
+ notice(t('Requested profile is not available.') . EOL);
$a->error = 404;
return;
}
}
$profile = 0;
- if((local_user()) && ($a->argc > 2) && ($a->argv[2] === 'view')) {
+ if (local_user() && $a->argc > 2 && $a->argv[2] === 'view') {
$which = $a->user['nickname'];
$profile = htmlspecialchars($a->argv[1]);
- }
- else {
+ } else {
auto_redir($a, $which);
}
- profile_load($a,$which,$profile);
+ profile_load($a, $which, $profile);
- $blocked = (((Config::get('system','block_public')) && (! local_user()) && (! remote_user())) ? true : false);
- $userblock = (($a->profile['hidewall'] && (! local_user()) && (! remote_user())) ? true : false);
+ $blocked = !local_user() && !remote_user() && Config::get('system', 'block_public');
+ $userblock = !local_user() && !remote_user() && $a->profile['hidewall'];
- if((x($a->profile,'page-flags')) && ($a->profile['page-flags'] == PAGE_COMMUNITY)) {
+ if (x($a->profile, 'page-flags') && $a->profile['page-flags'] == PAGE_COMMUNITY) {
$a->page['htmlhead'] .= '<meta name="friendica.community" content="true" />';
}
- if (x($a->profile,'openidserver')) {
+
+ if (x($a->profile, 'openidserver')) {
$a->page['htmlhead'] .= '<link rel="openid.server" href="' . $a->profile['openidserver'] . '" />' . "\r\n";
}
- if (x($a->profile,'openid')) {
- $delegate = ((strstr($a->profile['openid'],'://')) ? $a->profile['openid'] : 'https://' . $a->profile['openid']);
+
+ if (x($a->profile, 'openid')) {
+ $delegate = strstr($a->profile['openid'], '://') ? $a->profile['openid'] : 'https://' . $a->profile['openid'];
$a->page['htmlhead'] .= '<link rel="openid.delegate" href="' . $delegate . '" />' . "\r\n";
}
+
// site block
- if ((! $blocked) && (! $userblock)) {
- $keywords = ((x($a->profile,'pub_keywords')) ? $a->profile['pub_keywords'] : '');
- $keywords = str_replace(array('#',',',' ',',,'),array('',' ',',',','),$keywords);
- if(strlen($keywords))
- $a->page['htmlhead'] .= '<meta name="keywords" content="' . $keywords . '" />' . "\r\n" ;
+ if (!$blocked && !$userblock) {
+ $keywords = str_replace(array('#', ',', ' ', ',,'), array('', ' ', ',', ','), defaults($a->profile, 'pub_keywords', ''));
+ if (strlen($keywords)) {
+ $a->page['htmlhead'] .= '<meta name="keywords" content="' . $keywords . '" />' . "\r\n";
+ }
}
- $a->page['htmlhead'] .= '<meta name="dfrn-global-visibility" content="' . (($a->profile['net-publish']) ? 'true' : 'false') . '" />' . "\r\n" ;
- $a->page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . System::baseUrl() . '/dfrn_poll/' . $which .'" />' . "\r\n" ;
- $uri = urlencode('acct:' . $a->profile['nickname'] . '@' . $a->get_hostname() . (($a->path) ? '/' . $a->path : ''));
+ $a->page['htmlhead'] .= '<meta name="dfrn-global-visibility" content="' . ($a->profile['net-publish'] ? 'true' : 'false') . '" />' . "\r\n";
+ $a->page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . System::baseUrl() . '/feed/' . $which . '/" title="' . t('%s\'s posts', $a->profile['username']) . '"/>' . "\r\n";
+ $a->page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . System::baseUrl() . '/feed/' . $which . '/comments" title="' . t('%s\'s comments', $a->profile['username']) . '"/>' . "\r\n";
+ $a->page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . System::baseUrl() . '/feed/' . $which . '/activity" title="' . t('%s\'s timeline', $a->profile['username']) . '"/>' . "\r\n";
+ $uri = urlencode('acct:' . $a->profile['nickname'] . '@' . $a->get_hostname() . ($a->path ? '/' . $a->path : ''));
$a->page['htmlhead'] .= '<link rel="lrdd" type="application/xrd+xml" href="' . System::baseUrl() . '/xrd/?uri=' . $uri . '" />' . "\r\n";
header('Link: <' . System::baseUrl() . '/xrd/?uri=' . $uri . '>; rel="lrdd"; type="application/xrd+xml"', false);
$dfrn_pages = array('request', 'confirm', 'notify', 'poll');
foreach ($dfrn_pages as $dfrn) {
- $a->page['htmlhead'] .= "<link rel=\"dfrn-{$dfrn}\" href=\"".System::baseUrl()."/dfrn_{$dfrn}/{$which}\" />\r\n";
+ $a->page['htmlhead'] .= "<link rel=\"dfrn-{$dfrn}\" href=\"" . System::baseUrl() . "/dfrn_{$dfrn}/{$which}\" />\r\n";
}
- $a->page['htmlhead'] .= "<link rel=\"dfrn-poco\" href=\"".System::baseUrl()."/poco/{$which}\" />\r\n";
-
+ $a->page['htmlhead'] .= '<link rel="dfrn-poco" href="' . System::baseUrl() . "/poco/{$which}\" />\r\n";
}
-
- function profile_content(App $a, $update = 0) {
-
+ function profile_content(App $a, $update = 0)
+ {
$category = $datequery = $datequery2 = '';
if ($a->argc > 2) {
}
}
- if (! x($category)) {
- $category = ((x($_GET,'category')) ? $_GET['category'] : '');
+ if (!x($category)) {
+ $category = defaults($_GET, 'category', '');
}
- $hashtags = (x($_GET, 'tag') ? $_GET['tag'] : '');
+ $hashtags = defaults($_GET, 'tag', '');
- if (Config::get('system','block_public') && (! local_user()) && (! remote_user())) {
+ if (Config::get('system', 'block_public') && !local_user() && !remote_user()) {
- return login();
+ return Login::form();
}
- require_once("include/bbcode.php");
- require_once('include/security.php');
- require_once('include/conversation.php');
- require_once('include/acl_selectors.php');
- require_once('include/items.php');
+ require_once 'include/bbcode.php';
+ require_once 'include/security.php';
+ require_once 'include/conversation.php';
+ require_once 'include/acl_selectors.php';
+ require_once 'include/items.php';
$groups = array();
$contact_id = 0;
- if (is_array($_SESSION['remote'])) {
+ if (x($_SESSION, 'remote') && is_array($_SESSION['remote'])) {
foreach ($_SESSION['remote'] as $v) {
if ($v['uid'] == $a->profile['profile_uid']) {
$contact_id = $v['cid'];
}
if ($contact_id) {
- $groups = init_groups_visitor($contact_id);
+ $groups = Group::getIdsByContactId($contact_id);
$r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($contact_id),
intval($a->profile['profile_uid'])
}
}
- if (! $remote_contact) {
+ if (!$remote_contact) {
if (local_user()) {
$contact_id = $_SESSION['cid'];
$contact = $a->contact;
}
}
- $is_owner = ((local_user()) && (local_user() == $a->profile['profile_uid']) ? true : false);
+ $is_owner = local_user() == $a->profile['profile_uid'];
$last_updated_key = "profile:" . $a->profile['profile_uid'] . ":" . local_user() . ":" . remote_user();
- if ($a->profile['hidewall'] && (! $is_owner) && (! $remote_contact)) {
- notice( t('Access to this profile has been restricted.') . EOL);
+ if (x($a->profile, 'hidewall') && !$is_owner && !$remote_contact) {
+ notice(t('Access to this profile has been restricted.') . EOL);
return;
}
- if (! $update) {
- if (x($_GET,'tab')) {
+ if (!$update) {
+ $tab = false;
+ if (x($_GET, 'tab')) {
$tab = notags(trim($_GET['tab']));
}
- $o.=profile_tabs($a, $is_owner, $a->profile['nickname']);
+ $o .= profile_tabs($a, $is_owner, $a->profile['nickname']);
if ($tab === 'profile') {
$o .= advanced_profile($a);
- call_hooks('profile_advanced',$o);
+ call_hooks('profile_advanced', $o);
return $o;
}
$o .= common_friends_visitor_widget($a->profile['profile_uid']);
- if (x($_SESSION,'new_member') && $_SESSION['new_member'] && $is_owner) {
+ if (x($_SESSION, 'new_member') && $is_owner) {
$o .= '<a href="newmember" id="newmember-tips" style="font-size: 1.2em;"><b>' . t('Tips for New Members') . '</b></a>' . EOL;
}
- $commpage = (($a->profile['page-flags'] == PAGE_COMMUNITY) ? true : false);
- $commvisitor = (($commpage && $remote_contact == true) ? true : false);
+ $commpage = $a->profile['page-flags'] == PAGE_COMMUNITY;
+ $commvisitor = $commpage && $remote_contact;
- $a->page['aside'] .= posted_date_widget(System::baseUrl(true) . '/profile/' . $a->profile['nickname'],$a->profile['profile_uid'],true);
- $a->page['aside'] .= categories_widget(System::baseUrl(true) . '/profile/' . $a->profile['nickname'],(x($category) ? xmlify($category) : ''));
+ $a->page['aside'] .= posted_date_widget(System::baseUrl(true) . '/profile/' . $a->profile['nickname'], $a->profile['profile_uid'], true);
+ $a->page['aside'] .= categories_widget(System::baseUrl(true) . '/profile/' . $a->profile['nickname'], (x($category) ? xmlify($category) : ''));
$a->page['aside'] .= tagcloud_wall_widget();
- if (can_write_wall($a,$a->profile['profile_uid'])) {
-
+ if (can_write_wall($a, $a->profile['profile_uid'])) {
$x = array(
'is_owner' => $is_owner,
- 'allow_location' => ((($is_owner || $commvisitor) && $a->profile['allow_location']) ? true : false),
- 'default_location' => (($is_owner) ? $a->user['default-location'] : ''),
+ 'allow_location' => ($is_owner || $commvisitor) && $a->profile['allow_location'],
+ 'default_location' => $is_owner ? $a->user['default-location'] : '',
'nickname' => $a->profile['nickname'],
- 'lockstate' => (((is_array($a->user) && ((strlen($a->user['allow_cid'])) ||
- (strlen($a->user['allow_gid'])) || (strlen($a->user['deny_cid'])) ||
- (strlen($a->user['deny_gid']))))) ? 'lock' : 'unlock'),
- 'acl' => (($is_owner) ? populate_acl($a->user, true) : ''),
+ 'lockstate' => is_array($a->user)
+ && (strlen($a->user['allow_cid'])
+ || strlen($a->user['allow_gid'])
+ || strlen($a->user['deny_cid'])
+ || strlen($a->user['deny_gid'])
+ ) ? 'lock' : 'unlock',
+ 'acl' => $is_owner ? populate_acl($a->user, true) : '',
'bang' => '',
- 'visitor' => (($is_owner || $commvisitor) ? 'block' : 'none'),
+ 'visitor' => $is_owner || $commvisitor ? 'block' : 'none',
'profile_uid' => $a->profile['profile_uid'],
- 'acl_data' => ( $is_owner ? construct_acl_data($a, $a->user) : '' ), // For non-Javascript ACL selector
+ 'acl_data' => $is_owner ? construct_acl_data($a, $a->user) : '', // For non-Javascript ACL selector
);
- $o .= status_editor($a,$x);
+ $o .= status_editor($a, $x);
}
}
- /**
- * Get permissions SQL - if $remote_contact is true, our remote user has been pre-verified and we already have fetched his/her groups
- */
- $sql_extra = item_permissions_sql($a->profile['profile_uid'],$remote_contact,$groups);
-
+ // Get permissions SQL - if $remote_contact is true, our remote user has been pre-verified and we already have fetched his/her groups
+ $sql_extra = item_permissions_sql($a->profile['profile_uid'], $remote_contact, $groups);
+ $sql_extra2 = '';
if ($update) {
$last_updated = (x($_SESSION['last_updated'], $last_updated_key) ? $_SESSION['last_updated'][$last_updated_key] : 0);
FROM `item` INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND
- (`item`.`deleted` = 0 OR item.verb = '" . ACTIVITY_LIKE ."'
+ (`item`.`deleted` = 0 OR item.verb = '" . ACTIVITY_LIKE . "'
OR item.verb = '" . ACTIVITY_DISLIKE . "' OR item.verb = '" . ACTIVITY_ATTEND . "'
OR item.verb = '" . ACTIVITY_ATTENDNO . "' OR item.verb = '" . ACTIVITY_ATTENDMAYBE . "')
AND `item`.`moderated` = 0
if (!DBM::is_result($r)) {
return '';
}
-
} else {
$sql_post_table = "";
if (x($category)) {
$sql_post_table = sprintf("INNER JOIN (SELECT `oid` FROM `term` WHERE `term` = '%s' AND `otype` = %d AND `type` = %d AND `uid` = %d ORDER BY `tid` DESC) AS `term` ON `item`.`id` = `term`.`oid` ",
dbesc(protect_sprintf($category)), intval(TERM_OBJ_POST), intval(TERM_CATEGORY), intval($a->profile['profile_uid']));
- //$sql_extra .= protect_sprintf(file_tag_file_query('item',$category,'category'));
}
if (x($hashtags)) {
}
if ($datequery) {
- $sql_extra2 .= protect_sprintf(sprintf(" AND `thread`.`created` <= '%s' ", dbesc(datetime_convert(date_default_timezone_get(),'',$datequery))));
+ $sql_extra2 .= protect_sprintf(sprintf(" AND `thread`.`created` <= '%s' ", dbesc(datetime_convert(date_default_timezone_get(), '', $datequery))));
}
if ($datequery2) {
- $sql_extra2 .= protect_sprintf(sprintf(" AND `thread`.`created` >= '%s' ", dbesc(datetime_convert(date_default_timezone_get(),'',$datequery2))));
+ $sql_extra2 .= protect_sprintf(sprintf(" AND `thread`.`created` >= '%s' ", dbesc(datetime_convert(date_default_timezone_get(), '', $datequery2))));
}
// Belongs the profile page to a forum?
$r = q("SELECT `uid` FROM `user` WHERE `uid` = %d AND `page-flags` IN (%d, %d)",
intval($a->profile['profile_uid']),
intval(PAGE_COMMUNITY),
- intval(PAGE_PRVGROUP));
+ intval(PAGE_PRVGROUP)
+ );
if (!DBM::is_result($r)) {
$sql_extra3 = sprintf(" AND `thread`.`contact-id` = %d ", intval(intval($a->profile['contact_id'])));
// check if we serve a mobile device and get the user settings
// accordingly
if ($a->is_mobile) {
- $itemspage_network = PConfig::get(local_user(),'system','itemspage_mobile_network');
- $itemspage_network = ((intval($itemspage_network)) ? $itemspage_network : 10);
+ $itemspage_network = PConfig::get(local_user(), 'system', 'itemspage_mobile_network', 10);
} else {
- $itemspage_network = PConfig::get(local_user(),'system','itemspage_network');
- $itemspage_network = ((intval($itemspage_network)) ? $itemspage_network : 20);
+ $itemspage_network = PConfig::get(local_user(), 'system', 'itemspage_network', 20);
}
+
// now that we have the user settings, see if the theme forces
// a maximum item number which is lower then the user choice
- if(($a->force_max_items > 0) && ($a->force_max_items < $itemspage_network))
+ if (($a->force_max_items > 0) && ($a->force_max_items < $itemspage_network)) {
$itemspage_network = $a->force_max_items;
+ }
$a->set_pager_itemspage($itemspage_network);
- $pager_sql = sprintf(" LIMIT %d, %d ",intval($a->pager['start']), intval($a->pager['itemspage']));
+ $pager_sql = sprintf(" LIMIT %d, %d ", intval($a->pager['start']), intval($a->pager['itemspage']));
$r = q("SELECT `thread`.`iid` AS `item_id`, `thread`.`network` AS `item_network`
FROM `thread`
ORDER BY `thread`.`created` DESC $pager_sql",
intval($a->profile['profile_uid'])
);
-
}
$parents_arr = array();
$_SESSION['last_updated'][$last_updated_key] = time();
if (DBM::is_result($r)) {
- foreach($r as $rr)
+ foreach ($r as $rr) {
$parents_arr[] = $rr['item_id'];
+ }
+
$parents_str = implode(', ', $parents_arr);
- $items = q(item_query()." AND `item`.`uid` = %d
+ $items = q(item_query() . " AND `item`.`uid` = %d
AND `item`.`parent` IN (%s)
$sql_extra ",
intval($a->profile['profile_uid']),
dbesc($parents_str)
);
- $items = conv_sort($items,'created');
+ $items = conv_sort($items, 'created');
} else {
$items = array();
}
- if($is_owner && (! $update) && (! Config::get('theme','hide_eventlist'))) {
+ if ($is_owner && !$update && !Config::get('theme', 'hide_eventlist')) {
$o .= get_birthdays();
$o .= get_events();
}
use Friendica\Core\Worker;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
+use Friendica\Model\Group;
- require_once('include/items.php');
- require_once('include/acl_selectors.php');
- require_once('include/bbcode.php');
- require_once('include/security.php');
- require_once('include/redir.php');
+ require_once 'include/items.php';
+ require_once 'include/acl_selectors.php';
+ require_once 'include/bbcode.php';
+ require_once 'include/security.php';
+ require_once 'include/redir.php';
function videos_init(App $a) {
$tpl = get_markup_template("vcard-widget.tpl");
- $vcard_widget .= replace_macros($tpl, array(
+ $vcard_widget = replace_macros($tpl, array(
'$name' => $profile['name'],
'$photo' => $profile['photo'],
- '$addr' => (($profile['addr'] != "") ? $profile['addr'] : ""),
+ '$addr' => defaults($profile, 'addr', ''),
'$account_type' => $account_type,
- '$pdesc' => (($profile['pdesc'] != "") ? $profile['pdesc'] : ""),
+ '$pdesc' => defaults($profile, 'pdesc', ''),
));
}
}
- // perhaps they're visiting - but not a community page, so they wouldn't have write access
+ $groups = [];
+ // perhaps they're visiting - but not a community page, so they wouldn't have write access
if(remote_user() && (! $visitor)) {
$contact_id = 0;
if(is_array($_SESSION['remote'])) {
}
}
if($contact_id) {
- $groups = init_groups_visitor($contact_id);
+ $groups = Group::getIdsByContactId($contact_id);
$r = q("SELECT * FROM `contact` WHERE `blocked` = 0 AND `pending` = 0 AND `id` = %d AND `uid` = %d LIMIT 1",
intval($contact_id),
intval($owner_uid)
return;
}
- $sql_extra = permissions_sql($owner_uid,$remote_contact,$groups);
+ $sql_extra = permissions_sql($owner_uid, $remote_contact, $groups);
$o = "";
use Friendica\Model\Group;
use Friendica\Model\Photo;
use Friendica\Object\Image;
+ use Friendica\Util\Crypto;
use dba;
use Exception;
require_once 'boot.php';
- require_once 'include/crypto.php';
require_once 'include/dba.php';
require_once 'include/enotify.php';
require_once 'include/network.php';
$password = $password1;
}
- $tmp_str = $openid_url;
-
if ($using_invites) {
if (!$invite_id) {
throw new Exception(t('An invitation is required.'));
if (!x($username) || !x($email) || !x($nickname)) {
if ($openid_url) {
- if (!validate_url($tmp_str)) {
+ if (!validate_url($openid_url)) {
throw new Exception(t('Invalid OpenID url'));
}
$_SESSION['register'] = 1;
throw new Exception(t('Please enter the required information.'));
}
- if (!validate_url($tmp_str)) {
+ if (!validate_url($openid_url)) {
$openid_url = '';
}
$return['password'] = $new_password;
- $keys = new_keypair(4096);
+ $keys = Crypto::newKeypair(4096);
if ($keys === false) {
throw new Exception(t('SERIOUS ERROR: Generation of security keys failed.'));
}
$pubkey = $keys['pubkey'];
// Create another keypair for signing/verifying salmon protocol messages.
- $sres = new_keypair(512);
+ $sres = Crypto::newKeypair(512);
$sprvkey = $sres['prvkey'];
$spubkey = $sres['pubkey'];
*/
namespace Friendica\Protocol;
+ use Friendica\Content\OEmbed;
use Friendica\Core\Config;
use Friendica\Core\System;
use Friendica\Core\Worker;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Model\GContact;
+use Friendica\Model\Group;
use Friendica\Model\Profile;
use Friendica\Model\User;
use Friendica\Object\Image;
require_once "include/files.php";
require_once "include/event.php";
require_once "include/text.php";
- require_once "include/oembed.php";
require_once "include/html2bbcode.php";
require_once "include/bbcode.php";
$contact = $r[0];
include_once 'include/security.php';
- $groups = init_groups_visitor($contact['id']);
+ $groups = Group::getIdsByContactId($contact['id']);
if (count($groups)) {
for ($x = 0; $x < count($groups); $x ++)
/* get site pubkey. this could be a new installation with no site keys*/
$pubkey = Config::get('system', 'site_pubkey');
if (! $pubkey) {
- $res = new_keypair(1024);
+ $res = Crypto::newKeypair(1024);
Config::set('system', 'site_prvkey', $res['prvkey']);
Config::set('system', 'site_pubkey', $res['pubkey']);
}
$item['body'] = html2bb_video($item['body']);
- $item['body'] = oembed_html2bbcode($item['body']);
+ $item['body'] = OEmbed::HTML2BBCode($item['body']);
$config = \HTMLPurifier_Config::createDefault();
$config->set('Cache.DefinitionImpl', null);