コード例 #1
0
ファイル: index.php プロジェクト: ArcherSys/ArcherSysOSCloud7
			$act = 'acquire';
			$arg = OC_Shorty_Type::req_argument($key,OC_Shorty_Type::URL,FALSE);
			break 2; // skip switch AND foreach

		// no recognizable key but something else, hm...
		// this _might_ be some unexcepted argument, or:
		// it is an expected argument, but without recognizable key, so we try to guess by examining the content
		// we restrict this 'guessing' to cases where only a single argument is specified
		default:
			if (  (1==sizeof($_GET))  // only one single request argument
				&&( ! reset($_GET)) ) // no value, so maybe just an id
			{
				// use that source instead of $key, since $key contains replaced chars (php specific exceptions due to var name problems)
				$raw = urldecode($_SERVER['QUERY_STRING']);
				// now try to interpret its content
				if (NULL!==($value=OC_Shorty_Type::normalize($raw,OC_Shorty_Type::URL,FALSE)))
				{
					// the query string is a url, acquire it as a new shorty
					$act = 'acquire';
					$arg = $raw;
					break 2;
				}
				else
				{
					// no pattern recognized, so we assume an ordinary index action
					$act = 'index';
					break 2;
				}
			} // if
			$act='index';
			break 2;
コード例 #2
0
		case 'id':
		case 'shorty':
			// this looks like the request refers to a Shortys ID, lets see if we know that one
			$id     = OC_Shorty_Type::req_argument($key,OC_Shorty_Type::ID,FALSE);
			$param  = array ( ':id' => OC_Shorty_Type::normalize($id,OC_Shorty_Type::ID) );
			$query  = OCP\DB::prepare ( OC_Shorty_Query::URL_BY_ID );
			break 2; // skip switch AND foreach, we have all details we need...
		case 'url':
		case 'uri':
		case 'ref':
		case 'source':
		case 'target':
			// this looks like the request refers to a full url, lets see if we know that one as a Shortys source
			$source = OC_Shorty_Type::req_argument($key,OC_Shorty_Type::URL,FALSE);
			$param  = array ( ':source' => OC_Shorty_Type::normalize($source,OC_Shorty_Type::URL) );
			$query  = OCP\DB::prepare ( OC_Shorty_Query::URL_BY_SOURCE );
			break 2; // skip switch AND foreach, we have all details we need...
	} // switch
} // foreach

// generate qrcode for the specified id/url, IF it exists and has not expired in the database
try
{
	if ( $query )
	{
		$result = $query->execute($param)->FetchAll();
		if ( FALSE===$result )
			throw new OC_Shorty_HttpException ( 500 );
		elseif ( ! is_array($result) )
			throw new OC_Shorty_HttpException ( 500 );
コード例 #3
0
ファイル: relay.php プロジェクト: ArcherSys/ArcherSysOSCloud7
	}
	// an id was specified, ordinary or special meaning ?
	if ( '0000000000'==$arg )
	{
		// this is a pseudo id, used to test the setup, so just return a positive message.
		// this is used to test the setup of the static backend, shorty calls itself from there
		OCP\Util::writeLog( 'shorty', "Positiv validation of static backend base url.", OCP\Util::DEBUG );
		// we have to react to a jsonp request, so we have to reply valid jsonp manually:
		// note that we use 'static' jsonp, so no callback parameter is provided, instead it is hard coded here
		// this reduces the complexity of setting up the backend, since no additional parameter has to be handled
		echo sprintf ( 'verifyStaticBackend(%s)', json_encode(array('status'=>'success')) );
		exit();
	}

	// detect requested shorty id from request
	$p_id = trim ( OC_Shorty_Type::normalize($arg,OC_Shorty_Type::ID) ) ;
	if ( $p_id )
	{
		$param   = array ( 'id' => $p_id );
		$query   = OCP\DB::prepare ( OC_Shorty_Query::URL_RELAY );
		$result  = $query->execute($param)->FetchAll();
		$request = array (
		'address' => $_SERVER['REMOTE_ADDR'],
		'host'    => isset($_SERVER['REMOTE_HOST'])?$_SERVER['REMOTE_HOST']:gethostbyaddr($_SERVER['REMOTE_ADDR']),
		'time'    => $_SERVER['REQUEST_TIME'],
		'user'    => OCP\User::getUser(),
		);
		if ( FALSE===$result )
			throw new OC_Shorty_HttpException ( 500 );
		elseif ( ! is_array($result) )
			throw new OC_Shorty_HttpException ( 500 );