try { switch ($_FILES['us_signature']['type']) { case 'image/gif': $ext = 'gif'; break; case 'image/jpg': case 'image/jpeg': case 'image/pjpeg': $ext = 'jpg'; break; case 'image/png': $ext = 'png'; break; } $resizedFile = R3_TMP_DIR . md5(microtime()) . ".{$ext}"; pSimplePhoto::CreateThumb($_FILES['us_signature']['tmp_name'], $resizedFile, 350, 350, true, false); $file = file_get_contents($resizedFile); $mime = $_FILES['us_signature']['type']; $data = array($file, $mime); $sql = "UPDATE auth.users SET " . " us_signature=?, " . " us_signature_mime=? " . "WHERE " . " us_id=" . $auth->getUID(); $sth = $mdb2->prepare($sql, array('blob', 'text')); $affectedRows = $sth->execute($data); $ret['status'] = R3_REQUEST_OK; $ret['random'] = md5(microtime()); echo json_encode($ret); die; } catch (Exception $e) { if ($_FILES['us_signature']['error'] != 0) { $ret['status'] = R3_REQUEST_ERROR; $ret['error'] = _('Unknown Error.'); echo json_encode($ret);
function resizeImage($src, $dest, $width, $height) { if ($src == $dest) { throw new exception('Source and destination image are the same'); } $prev_path = dirname($dest); if (!file_exists($prev_path)) { mkdir($prev_path); } require_once R3_LIB_DIR . 'simplephoto.php'; return pSimplePhoto::CreateThumb($src, $dest, $width, $height); }