- $r = q("UPDATE `contact` SET `dfrn-id` = '%s', `pubkey` = '%s' WHERE `id` = %d LIMIT 1",
- dbesc($decrypted_dfrn_id),
- dbesc($dfrn_pubkey),
- intval($dfrn_record));
- if($r) {
-
- // We're good but now we have to scrape the profile photo and send notifications.
-
- require_once("Photo.php");
-
- $photo_failure = false;
-
- $r = q("SELECT `photo` FROM `contact` WHERE `id` = %d LIMIT 1",
- intval($dfrn_record));
- if(count($r)) {
-
- $filename = basename($r[0]['photo']);
- $img_str = fetch_url($r[0]['photo'],true);
- $img = new Photo($img_str);
- if($img) {
-
- $img->scaleImageSquare(175);
-
- $hash = hash('md5',uniqid(mt_rand(),true));
-
- $r = q("INSERT INTO `photo` ( `uid`, `resource-id`, `created`, `edited`, `filename`,
- `height`, `width`, `data`, `scale` )
- VALUES ( %d, '%s', '%s', '%s', '%s', %d, %d, '%s', 4 )",
- intval($local_uid),
- dbesc($hash),
- datetime_convert(),
- datetime_convert(),
- dbesc(basename($r[0]['photo'])),
- intval($img->getHeight()),
- intval($img->getWidth()),
- dbesc($img->imageString())
- );
- if($r === false)
- $photo_failure = true;
- $img->scaleImage(80);
- $r = q("INSERT INTO `photo` ( `uid`, `resource-id`, `created`, `edited`, `filename`,
- `height`, `width`, `data`, `scale` )
- VALUES ( %d, '%s', '%s', '%s', '%s', %d, %d, '%s', 5 )",
- intval($local_uid),
- dbesc($hash),
- datetime_convert(),
- datetime_convert(),
- dbesc(basename($r[0]['photo'])),
- intval($img->getHeight()),
- intval($img->getWidth()),
- dbesc($img->imageString())
- );
- if($r === false)
- $photo_failure = true;
-
- $photo = $a->get_baseurl() . '/photo/' . $hash . '-4.jpg';
- $thumb = $a->get_baseurl() . '/photo/' . $hash . '-5.jpg';
-
- }
- else
- $photo_failure = true;
- }
- else
- $photo_failure = true;