- if($r !== NULL && (count($r))) {
- $im = new Photo($r[0]['data']);
- $im->cropImage(175,$srcX,$srcY,$srcW,$srcH);
- $s = $im->imageString();
- $x = $im->getWidth();
- $y = $im->getHeight();
-
- $ret = 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($_SESSION['uid']),
- dbesc($r[0]['resource-id']),
- datetime_convert(),
- datetime_convert(),
- dbesc($r[0]['filename']),
- intval($y),
- intval($x),
- dbesc($s));
- if($r === NULL)
- $_SESSION['sysmsg'] .= "Image size reduction (175) failed." . EOL;
-
- $im->scaleImage(80);
- $s = $im->imageString();
- $x = $im->getWidth();
- $y = $im->getHeight();
- $ret = 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($_SESSION['uid']),
- dbesc($r[0]['resource-id']),
- datetime_convert(),
- datetime_convert(),
- dbesc($r[0]['filename']),
- intval($y),
- intval($x),
- dbesc($s));
- if($r === NULL)
- $_SESSION['sysmsg'] .= "Image size reduction (80) failed." . EOL;
- $r = q("UPDATE `profile` SET `photo` = '%s', `thumb` = '%s' WHERE `id` = %d LIMIT 1",
- dbesc($a->get_baseurl() . '/photo/' . $image_id . '-4.jpg'),
- dbesc($a->get_baseurl() . '/photo/' . $image_id . '-5.jpg'),
- intval($profile_id)
- );
- if($r === false)
- $_SESSION['sysmsg'] .= "Failed to add image to profile." . EOL;
-// We should really only do this if requested, or if it is the default profile. The contact
-//table images are used in coversations.
- $r = q("UPDATE `contact` SET `photo` = '%s', `thumb` = '%s' WHERE `uid` = %d AND `self` = 1 LIMIT 1",
- dbesc($a->get_baseurl() . '/photo/' . $image_id . '-4.jpg'),
- dbesc($a->get_baseurl() . '/photo/' . $image_id . '-5.jpg'),
- intval($_SESSION['uid'])
- );
- if($r ===false)
- notice("Failed to add photo to contact table." .EOL );