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';
define('FRIENDICA_CODENAME', 'Asparagus');
define('FRIENDICA_VERSION', '3.6-dev');
define('DFRN_PROTOCOL_VERSION', '2.23');
-define('DB_UPDATE_VERSION', 1238);
+define('DB_UPDATE_VERSION', 1239);
define('NEW_UPDATE_ROUTINE_VERSION', 1170);
/**
* Type of the community page
* @{
*/
-define('CP_NO_COMMUNITY_PAGE', -1);
+define('CP_NO_COMMUNITY_PAGE', -1);
define('CP_USERS_ON_SERVER', 0);
define('CP_GLOBAL_COMMUNITY', 1);
+define('CP_USERS_AND_GLOBAL', 2);
/**
* @}
*/
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');
}
if ($build != DB_UPDATE_VERSION) {
// When we cannot execute the database update via the worker, we will do it directly
if (!Worker::add(PRIORITY_CRITICAL, 'DBUpdate') && $via_worker) {
- update_db(get_app());
+ update_db();
}
}
}
// and www.example.com vs example.com.
// We will only change the url to an ip address if there is no existing setting
- if (empty($url)) {
- $url = Config::set('system', 'url', System::baseUrl());
- }
- if ((!link_compare($url, System::baseUrl())) && (!preg_match("/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/", $a->get_hostname))) {
- $url = Config::set('system', 'url', System::baseUrl());
+ if (empty($url) || (!link_compare($url, System::baseUrl())) && (!preg_match("/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/", $a->get_hostname))) {
+ Config::set('system', 'url', System::baseUrl());
}
return;
* @brief Automatic database updates
* @param object $a App
*/
-function update_db(App $a)
+function update_db()
{
$build = Config::get('system', 'build');
Config::set('system', 'build', $x + 1);
return true;
}
- return true;
}
/**
}
}
-/**
- * @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();
}
if ($is_mobile) {
if (isset($_SESSION['show-mobile']) && !$_SESSION['show-mobile']) {
- $system_theme = $standard_system_theme;
$theme_name = $standard_theme_name;
} else {
$system_theme = Config::get('system', 'mobile-theme', '');
if ($theme_name === '---') {
// user has selected to have the mobile theme be the same as the normal one
- $system_theme = $standard_system_theme;
$theme_name = $standard_theme_name;
if ($page_theme) {
}
}
} else {
- $system_theme = $standard_system_theme;
$theme_name = $standard_theme_name;
if ($page_theme) {