*
* @todo Automatically detect if incoming data is HTML or BBCode
*/
-
use Friendica\App;
+use Friendica\Content\Features;
use Friendica\Core\System;
use Friendica\Core\Config;
use Friendica\Core\NotificationsManager;
use Friendica\Core\Worker;
use Friendica\Database\DBM;
+use Friendica\Model\User;
+use Friendica\Network\HTTPException;
+use Friendica\Network\HTTPException\BadRequestException;
+use Friendica\Network\HTTPException\ForbiddenException;
+use Friendica\Network\HTTPException\InternalServerErrorException;
+use Friendica\Network\HTTPException\MethodNotAllowedException;
+use Friendica\Network\HTTPException\NotFoundException;
+use Friendica\Network\HTTPException\NotImplementedException;
+use Friendica\Network\HTTPException\UnauthorizedException;
+use Friendica\Network\HTTPException\TooManyRequestsException;
+use Friendica\Object\Contact;
+use Friendica\Object\Photo;
use Friendica\Protocol\Diaspora;
use Friendica\Util\XML;
-require_once 'include/HTTPExceptions.php';
require_once 'include/bbcode.php';
require_once 'include/datetime.php';
require_once 'include/conversation.php';
require_once 'include/oauth.php';
require_once 'include/html2plain.php';
require_once 'mod/share.php';
-require_once 'include/Photo.php';
require_once 'mod/item.php';
require_once 'include/security.php';
require_once 'include/contact_selectors.php';
$user = $_SERVER['PHP_AUTH_USER'];
$password = $_SERVER['PHP_AUTH_PW'];
- $encrypted = hash('whirlpool', trim($password));
// allow "user@server" login (but ignore 'server' part)
$at = strstr($user, "@", true);
if (($addon_auth['authenticated']) && (count($addon_auth['user_record']))) {
$record = $addon_auth['user_record'];
} else {
- // process normal login request
- $r = q(
- "SELECT * FROM `user` WHERE (`email` = '%s' OR `nickname` = '%s')
- AND `password` = '%s' AND NOT `blocked` AND NOT `account_expired` AND NOT `account_removed` AND `verified` LIMIT 1",
- dbesc(trim($user)),
- dbesc(trim($user)),
- dbesc($encrypted)
- );
- if (DBM::is_result($r)) {
- $record = $r[0];
+ $user_id = User::authenticate(trim($user), trim($password));
+ if ($user_id) {
+ $record = dba::select('user', [], ['uid' => $user_id], ['limit' => 1]);
}
}
'notifications' => false,
'statusnet_profile_url' => $r[0]["url"],
'uid' => 0,
- 'cid' => get_contact($r[0]["url"], api_user(), true),
+ 'cid' => Contact::getIdForURL($r[0]["url"], api_user(), true),
'self' => 0,
'network' => $r[0]["network"],
);
$network_name = network_to_name($uinfo[0]['network'], $uinfo[0]['url']);
- $pcontact_id = get_contact($uinfo[0]['url'], 0, true);
+ $pcontact_id = Contact::getIdForURL($uinfo[0]['url'], 0, true);
$ret = array(
'id' => intval($pcontact_id),
$data3 = array($root_element => $data2);
- $ret = XML::from_array($data3, $xml, false, $namespaces);
+ $ret = XML::fromArray($data3, $xml, false, $namespaces);
return $ret;
}
$attachments = array();
foreach ($images[1] as $image) {
- $imagedata = get_photo_info($image);
+ $imagedata = Photo::getInfoFromURL($image);
if ($imagedata) {
$attachments[] = array("url" => $image, "mimetype" => $imagedata["mime"], "size" => $imagedata["size"]);
$start = iconv_strpos($text, $url, $offset, "UTF-8");
if (!($start === false)) {
- $image = get_photo_info($url);
+ $image = Photo::getInfoFromURL($url);
if ($image) {
// If image cache is activated, then use the following sizes:
// thumb (150), small (340), medium (600) and large (1024)
$media_url = proxy_url($url);
$sizes = array();
- $scale = scale_image($image[0], $image[1], 150);
+ $scale = Photo::scaleImageTo($image[0], $image[1], 150);
$sizes["thumb"] = array("w" => $scale["width"], "h" => $scale["height"], "resize" => "fit");
if (($image[0] > 150) || ($image[1] > 150)) {
- $scale = scale_image($image[0], $image[1], 340);
+ $scale = Photo::scaleImageTo($image[0], $image[1], 340);
$sizes["small"] = array("w" => $scale["width"], "h" => $scale["height"], "resize" => "fit");
}
- $scale = scale_image($image[0], $image[1], 600);
+ $scale = Photo::scaleImageTo($image[0], $image[1], 600);
$sizes["medium"] = array("w" => $scale["width"], "h" => $scale["height"], "resize" => "fit");
if (($image[0] > 600) || ($image[1] > 600)) {
- $scale = scale_image($image[0], $image[1], 1024);
+ $scale = Photo::scaleImageTo($image[0], $image[1], 1024);
$sizes["large"] = array("w" => $scale["width"], "h" => $scale["height"], "resize" => "fit");
}
} else {
}
// now let's delete all photos from the album
- $result = q(
- "DELETE FROM `photo` WHERE `uid` = %d AND `album` = '%s'",
- intval(api_user()),
- dbesc($album)
- );
+ $result = dba::delete('photo', array('uid' => api_user(), 'album' => $album));
// return success of deletion or error message
if ($result) {
throw new BadRequestException("photo not available");
}
// now we can perform on the deletion of the photo
- $result = q(
- "DELETE FROM `photo` WHERE `uid` = %d AND `resource-id` = '%s'",
- intval(api_user()),
- dbesc($photo_id)
- );
+ $result = dba::delete('photo', array('uid' => api_user(), 'resource-id' => $photo_id));
// return success of deletion or error message
if ($result) {
}
if ($filetype == "") {
- $filetype=guess_image_type($filename);
+ $filetype=Photo::guessImageType($filename);
}
$imagedata = getimagesize($src);
if ($imagedata) {
// create Photo instance with the data of the image
$imagedata = @file_get_contents($src);
$ph = new Photo($imagedata, $filetype);
- if (! $ph->is_valid()) {
+ if (! $ph->isValid()) {
throw new InternalServerErrorException("unable to process image data");
}
{
$body = trim($item["body"]);
- if (Diaspora::is_reshare($body, false)===false) {
+ if (Diaspora::isReshare($body, false)===false) {
return false;
}
$attributes = preg_replace("/\[share(.*?)\]\s?(.*?)\s?\[\/share\]\s?/ism", "$1", $body);
/*
* Skip if there is no shared message in there
- * we already checked this in diaspora::is_reshare()
+ * we already checked this in diaspora::isReshare()
* but better one more than one less...
*/
if ($body == $attributes) {
$profileid = (x($_REQUEST, 'profile_id') ? $_REQUEST['profile_id'] : 0);
// retrieve general information about profiles for user
- $multi_profiles = feature_enabled(api_user(), 'multi_profiles');
+ $multi_profiles = Features::isEnabled(api_user(), 'multi_profiles');
$directory = Config::get('system', 'directory');
// get data of the specified profile id or all profiles of the user if not specified