/** * createShare * Create a public url that can be used by anyone to stream media. * Takes the file id with optional description and expires parameters. */ public static function createshare($input) { self::check_version($input, "1.6.0"); $id = self::check_parameter($input, 'id'); $description = $input['description']; if (AmpConfig::get('share')) { if (isset($input['expires'])) { $expires = $input['expires']; // Parse as a string to work on 32-bit computers if (strlen($expires) > 3) { $expires = intval(substr($expires, 0, -3)); } $expire_days = round(($expires - time()) / 86400, 0, PHP_ROUND_HALF_EVEN); } else { $expire_days = AmpConfig::get('share_expire'); } $object_id = Subsonic_XML_Data::getAmpacheId($id); if (Subsonic_XML_Data::isAlbum($id)) { $object_type = 'album'; } else { if (Subsonic_XML_Data::isSong($id)) { $object_type = 'song'; } } if (!empty($object_type)) { $r = Subsonic_XML_Data::createSuccessResponse(); $shares = array(); $shares[] = Share::create_share($object_type, $object_id, true, Access::check_function('download'), $expire_days, Share::generate_secret(), 0, $description); Subsonic_XML_Data::addShares($r, $shares); } else { $r = Subsonic_XML_Data::createError(Subsonic_XML_Data::SSERROR_DATA_NOTFOUND); } } else { $r = Subsonic_XML_Data::createError(Subsonic_XML_Data::SSERROR_UNAUTHORIZED); } self::apiOutput($input, $r); }