/** * Gets the signing key * * @return string */ PHP_METHOD(OAuth_V1_Signature, getSigningKey) { zval *signingKey, *credentials = NULL, *consumerSecret, *tokenSecret, *_0, *_1; ZEPHIR_MM_GROW(); ZEPHIR_INIT_VAR(_0); zephir_call_method(_0, this_ptr, "getcredentials"); ZEPHIR_CPY_WRT(credentials, _0); ZEPHIR_INIT_VAR(consumerSecret); zephir_call_method(consumerSecret, credentials, "getconsumersecret"); ZEPHIR_INIT_VAR(tokenSecret); zephir_call_method(tokenSecret, this_ptr, "gettokensecret"); ZEPHIR_INIT_BNVAR(_0); zephir_call_func_p1(_0, "rawurlencode", consumerSecret); ZEPHIR_INIT_VAR(signingKey); ZEPHIR_CONCAT_VS(signingKey, _0, "&"); if (!(ZEPHIR_IS_EMPTY(tokenSecret))) { ZEPHIR_INIT_VAR(_1); zephir_call_func_p1(_1, "rawurlencode", tokenSecret); zephir_concat_self(&signingKey, _1 TSRMLS_CC); } RETURN_CCTOR(signingKey); }
/** * Mounts a group of routes in the router * * @param Test\Router\Group route * @return Test\Router */ PHP_METHOD(Test_Router, mount) { HashTable *_1, *_4; HashPosition _0, _3; zval *group, *groupRoutes, *beforeMatch, *hostname, *routes, *route = NULL, **_2, **_5, *_6; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &group); if ((Z_TYPE_P(group) != IS_OBJECT)) { ZEPHIR_THROW_EXCEPTION_STR(test_router_exception_ce, "The group of routes is not valid"); return; } ZEPHIR_INIT_VAR(groupRoutes); zephir_call_method(groupRoutes, group, "getroutes"); if (!(zephir_fast_count_int(groupRoutes TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_STR(test_router_exception_ce, "The group of routes does not contain any routes"); return; } ZEPHIR_INIT_VAR(beforeMatch); zephir_call_method(beforeMatch, group, "getbeforematch"); if ((Z_TYPE_P(beforeMatch) != IS_NULL)) { zephir_is_iterable(groupRoutes, &_1, &_0, 0, 0); for ( ; zend_hash_get_current_data_ex(_1, (void**) &_2, &_0) == SUCCESS ; zend_hash_move_forward_ex(_1, &_0) ) { ZEPHIR_GET_HVALUE(route, _2); zephir_call_method_p1_noret(route, "beforematch", beforeMatch); } } ZEPHIR_INIT_VAR(hostname); zephir_call_method(hostname, group, "gethostname"); if ((Z_TYPE_P(hostname) != IS_NULL)) { zephir_is_iterable(groupRoutes, &_4, &_3, 0, 0); for ( ; zend_hash_get_current_data_ex(_4, (void**) &_5, &_3) == SUCCESS ; zend_hash_move_forward_ex(_4, &_3) ) { ZEPHIR_GET_HVALUE(route, _5); zephir_call_method_p1_noret(route, "sethostname", hostname); } } routes = zephir_fetch_nproperty_this(this_ptr, SL("_routes"), PH_NOISY_CC); if ((Z_TYPE_P(routes) == IS_ARRAY)) { ZEPHIR_INIT_VAR(_6); zephir_fast_array_merge(_6, &(routes), &(groupRoutes) TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_routes"), _6 TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_routes"), groupRoutes TSRMLS_CC); } RETURN_THIS(); }
/** * CacheGetAll: cached GetAll * * @param int timeout count of seconds for cache expiry * @param string statement String query to execute * @param array vars Array of variables to bind [optional] * @return array Array of results */ PHP_METHOD(ADOdb_Connection, cacheGetAll) { zval *vars = NULL; zval *statement = NULL; zval *timeout_param = NULL, *statement_param = NULL, *vars_param = NULL, *st, *_0; int timeout; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 1, &timeout_param, &statement_param, &vars_param); timeout = zephir_get_intval(timeout_param); zephir_get_strval(statement, statement_param); if (!vars_param) { ZEPHIR_INIT_VAR(vars); array_init(vars); } else { zephir_get_arrval(vars, vars_param); } ZEPHIR_INIT_VAR(_0); ZVAL_LONG(_0, timeout); ZEPHIR_INIT_VAR(st); zephir_call_method_p3(st, this_ptr, "cachequery", _0, statement, vars); zephir_call_method(return_value, st, "fetchall"); RETURN_MM(); }
/** * Complete transaction * * @param type success * @return boolean */ PHP_METHOD(ADOdb_Connection, completeTrans) { zval *success_param = NULL, *_0, *_1, *_2; zend_bool success; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &success_param); if (!success_param) { success = 1; } else { success = zephir_get_boolval(success_param); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("connection"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_1); zephir_call_method(_1, _0, "intransaction"); if (!zephir_is_true(_1)) { RETURN_MM_BOOL(0); } if (success) { _2 = zephir_fetch_nproperty_this(this_ptr, SL("connection"), PH_NOISY_CC); zephir_call_method_noret(_2, "commit"); } else { _2 = zephir_fetch_nproperty_this(this_ptr, SL("connection"), PH_NOISY_CC); zephir_call_method_noret(_2, "rollback"); } ZEPHIR_MM_RESTORE(); }
/** * Returns a route object by its name * * @param string name * @return Test\Router\Route */ PHP_METHOD(Test_Router, getRouteByName) { HashTable *_2; HashPosition _1; zval *name, *route = NULL, *_0, **_3, *_4 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &name); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_routes"), PH_NOISY_CC); zephir_is_iterable(_0, &_2, &_1, 0, 0); for ( ; zend_hash_get_current_data_ex(_2, (void**) &_3, &_1) == SUCCESS ; zend_hash_move_forward_ex(_2, &_1) ) { ZEPHIR_GET_HVALUE(route, _3); ZEPHIR_INIT_NVAR(_4); zephir_call_method(_4, route, "getname"); if (ZEPHIR_IS_EQUAL(_4, name)) { RETURN_CCTOR(route); } } RETURN_MM_BOOL(0); }
PHP_METHOD(Test_Mcall, testCall1) { ZEPHIR_MM_GROW(); zephir_call_method(return_value, this_ptr, "testmethod1"); RETURN_MM(); }
/** * Start new transaction * * @return type */ PHP_METHOD(ADOdb_Connection, startTrans) { zval *_0, *_1, *_2; ZEPHIR_MM_GROW(); _0 = zephir_fetch_nproperty_this(this_ptr, SL("connection"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_1); zephir_call_method(_1, _0, "intransaction"); if (!zephir_is_true(_1)) { _2 = zephir_fetch_nproperty_this(this_ptr, SL("connection"), PH_NOISY_CC); zephir_call_method(return_value, _2, "begintransaction"); RETURN_MM(); } else { RETURN_MM_BOOL(0); } ZEPHIR_MM_RESTORE(); }
PHP_METHOD(ADOdb_Connection, __get) { zval *name_param = NULL, *_0; zval *name = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &name_param); zephir_get_strval(name, name_param); do { if (ZEPHIR_IS_STRING(name, "host")) { _0 = zephir_fetch_nproperty_this(this_ptr, SL("dso"), PH_NOISY_CC); zephir_call_method(return_value, _0, "gethostname"); RETURN_MM(); } if (ZEPHIR_IS_STRING(name, "database")) { _0 = zephir_fetch_nproperty_this(this_ptr, SL("dso"), PH_NOISY_CC); zephir_call_method(return_value, _0, "getdatabase"); RETURN_MM(); } if (ZEPHIR_IS_STRING(name, "user")) { _0 = zephir_fetch_nproperty_this(this_ptr, SL("dso"), PH_NOISY_CC); zephir_call_method(return_value, _0, "getusername"); RETURN_MM(); } if (ZEPHIR_IS_STRING(name, "password")) { _0 = zephir_fetch_nproperty_this(this_ptr, SL("dso"), PH_NOISY_CC); zephir_call_method(return_value, _0, "getpassword"); RETURN_MM(); } if (ZEPHIR_IS_STRING(name, "debug")) { RETURN_MM_MEMBER(this_ptr, "debug"); } } while(0); ZEPHIR_MM_RESTORE(); }
PHP_METHOD(Test_Oo, testInstance2) { zval *o, *_0; ZEPHIR_MM_GROW(); ZEPHIR_INIT_VAR(o); object_init_ex(o, test_oo_ooconstruct_ce); ZEPHIR_INIT_VAR(_0); zephir_call_method(_0, o, "__construct"); RETURN_CCTOR(o); }
PHP_METHOD(Test_Exceptions, testException4) { zval *_0; ZEPHIR_MM_GROW(); ZEPHIR_INIT_VAR(_0); zephir_call_method(_0, this_ptr, "getexception"); zephir_throw_exception(_0 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; }
/** * Hash * * @param string data * @return string */ PHP_METHOD(OAuth_V1_Signature, hash) { zval *data_param = NULL, *algorithm = NULL, *hash, *signingKey, *_0, _1, *_2; zval *data = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &data_param); zephir_get_strval(data, data_param); ZEPHIR_INIT_VAR(algorithm); zephir_call_method(algorithm, this_ptr, "gethashingalgorithm"); ZEPHIR_INIT_VAR(_0); zephir_fast_strtoupper(_0, algorithm); ZEPHIR_CPY_WRT(algorithm, _0); do { if (ZEPHIR_IS_STRING(algorithm, "HMAC-SHA1")) { ZEPHIR_INIT_VAR(signingKey); zephir_call_method(signingKey, this_ptr, "getsigningkey"); ZEPHIR_SINIT_VAR(_1); ZVAL_STRING(&_1, "sha1", 0); ZEPHIR_INIT_VAR(hash); zephir_call_func_p4(hash, "hash_hmac", &_1, data, signingKey, ZEPHIR_GLOBAL(global_true)); break; } ZEPHIR_INIT_BNVAR(_0); object_init_ex(_0, oauth_v1_unsupportedhashalgorithmexception_ce); ZEPHIR_INIT_VAR(_2); ZEPHIR_CONCAT_SVS(_2, "Unsupported hashing algorithm (", algorithm, ") used."); zephir_call_method_p2_noret(_0, "__construct", algorithm, _2); zephir_throw_exception(_0 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } while(0); RETURN_CCTOR(hash); }
PHP_METHOD(ADOdb_Cache, serializeStatement) { zval *statement, *_0, *_1, _2; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &statement); if (!(zephir_is_instance_of(statement, SL("ADOdb\\Statement") TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_STR(spl_ce_InvalidArgumentException, "Parameter 'statement' must be an instance of 'ADOdb\\Statement'"); return; } ZEPHIR_INIT_VAR(_0); zephir_call_method(_0, statement, "dump"); ZEPHIR_INIT_VAR(_1); zephir_call_func_p1(_1, "serialize", _0); ZEPHIR_SINIT_VAR(_2); ZVAL_LONG(&_2, 3); zephir_call_func_p2(return_value, "gzcompress", _1, &_2); RETURN_MM(); }
/** * GetAll: return array of results * * @param string statement String query to execute * @param array vars Array of variables to bind [optional] * @return array Array of results */ PHP_METHOD(ADOdb_Connection, getAll) { zval *vars = NULL; zval *statement_param = NULL, *vars_param = NULL, *st; zval *statement = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &statement_param, &vars_param); zephir_get_strval(statement, statement_param); if (!vars_param) { ZEPHIR_INIT_VAR(vars); array_init(vars); } else { zephir_get_arrval(vars, vars_param); } ZEPHIR_INIT_VAR(st); zephir_call_method_p2(st, this_ptr, "query", statement, vars); zephir_call_method(return_value, st, "fetchall"); RETURN_MM(); }
/** * Handles routing information received from the rewrite engine * *<code> * //Read the info from the rewrite engine * $router->handle(); * * //Manually passing an URL * $router->handle('/posts/edit/1'); *</code> * * @param string uri */ PHP_METHOD(Test_Router, handle) { HashTable *_3, *_9; HashPosition _2, _8; zval *uri = NULL, *realUri = NULL, *request = NULL, *currentHostName = NULL, *routeFound = NULL, *parts = NULL, *params, *matches, *notFoundPaths, *vnamespace, *module, *controller, *action, *paramsStr, *strParams, *paramsMerge = NULL, *route = NULL, *methods = NULL, *dependencyInjector = NULL, *hostname = NULL, *regexHostName = NULL, *matched = NULL, *pattern = NULL, *handledUri = NULL, *beforeMatch = NULL, *paths = NULL, *converters = NULL, *part = NULL, *position = NULL, *matchPosition, *_0, *_1, **_4, *_5, *_6 = NULL, *_7 = NULL, **_10, *_11, *_12, *_13, *_14, *_15; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &uri); if (!uri) { uri = ZEPHIR_GLOBAL(global_null); } if (!(zephir_is_true(uri))) { ZEPHIR_INIT_VAR(realUri); zephir_call_method(realUri, this_ptr, "getrewriteuri"); } else { ZEPHIR_CPY_WRT(realUri, uri); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_removeExtraSlashes"), PH_NOISY_CC); if (zephir_is_true(_0)) { ZEPHIR_INIT_VAR(handledUri); zephir_call_method_p1(handledUri, this_ptr, "doremoveextraslashes", realUri); } else { ZEPHIR_CPY_WRT(handledUri, realUri); } ZEPHIR_INIT_VAR(request); ZVAL_NULL(request); ZEPHIR_INIT_VAR(currentHostName); ZVAL_NULL(currentHostName); ZEPHIR_INIT_VAR(routeFound); ZVAL_BOOL(routeFound, 0); ZEPHIR_INIT_VAR(parts); array_init(parts); ZEPHIR_INIT_VAR(params); array_init(params); ZEPHIR_INIT_VAR(matches); ZVAL_NULL(matches); zephir_update_property_this(this_ptr, SL("_wasMatched"), (0) ? ZEPHIR_GLOBAL(global_true) : ZEPHIR_GLOBAL(global_false) TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_matchedRoute"), ZEPHIR_GLOBAL(global_null) TSRMLS_CC); _1 = zephir_fetch_nproperty_this(this_ptr, SL("_routes"), PH_NOISY_CC); zephir_is_iterable(_1, &_3, &_2, 0, 1); for ( ; zend_hash_get_current_data_ex(_3, (void**) &_4, &_2) == SUCCESS ; zend_hash_move_backwards_ex(_3, &_2) ) { ZEPHIR_GET_HVALUE(route, _4); ZEPHIR_INIT_NVAR(methods); zephir_call_method(methods, route, "gethttpmethods"); if ((Z_TYPE_P(methods) != IS_NULL)) { if ((Z_TYPE_P(request) == IS_NULL)) { _5 = zephir_fetch_nproperty_this(this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); ZEPHIR_CPY_WRT(dependencyInjector, _5); if ((Z_TYPE_P(dependencyInjector) != IS_OBJECT)) { ZEPHIR_THROW_EXCEPTION_STR(test_router_exception_ce, "A dependency injection container is required to access the 'request' service"); return; } ZEPHIR_INIT_NVAR(_6); ZVAL_STRING(_6, "request", 1); ZEPHIR_INIT_NVAR(request); zephir_call_method_p1(request, dependencyInjector, "getshared", _6); } ZEPHIR_INIT_NVAR(_6); zephir_call_method_p1(_6, request, "ismethod", methods); if (ZEPHIR_IS_FALSE(_6)) { continue; } } ZEPHIR_INIT_NVAR(hostname); zephir_call_method(hostname, route, "gethostname"); if ((Z_TYPE_P(hostname) != IS_NULL)) { if ((Z_TYPE_P(request) == IS_NULL)) { ZEPHIR_OBS_NVAR(dependencyInjector); zephir_read_property_this(&dependencyInjector, this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); if ((Z_TYPE_P(dependencyInjector) != IS_OBJECT)) { ZEPHIR_THROW_EXCEPTION_STR(test_router_exception_ce, "A dependency injection container is required to access the 'request' service"); return; } ZEPHIR_INIT_NVAR(_6); ZVAL_STRING(_6, "request", 1); ZEPHIR_INIT_NVAR(request); zephir_call_method_p1(request, dependencyInjector, "getshared", _6); } if ((Z_TYPE_P(currentHostName) != IS_OBJECT)) { ZEPHIR_INIT_NVAR(currentHostName); zephir_call_method(currentHostName, request, "gethttphost"); } if ((Z_TYPE_P(currentHostName) != IS_NULL)) { continue; } ZEPHIR_INIT_NVAR(matched); if (zephir_memnstr_str(hostname, SL("("), "test/router.zep", 381)) { if (zephir_memnstr_str(hostname, SL("#"), "test/router.zep", 382)) { ZEPHIR_INIT_NVAR(regexHostName); ZEPHIR_CONCAT_SVS(regexHostName, "#^", hostname, "$#"); } else { ZEPHIR_CPY_WRT(regexHostName, hostname); } ZEPHIR_INIT_NVAR(_7); zephir_preg_match(matched, &(matched), regexHostName, currentHostName, _7, 0, 0 , 0 TSRMLS_CC); } else { ZVAL_BOOL(matched, ZEPHIR_IS_EQUAL(currentHostName, hostname)); } if (!(zephir_is_true(matched))) { continue; } } ZEPHIR_INIT_NVAR(pattern); zephir_call_method(pattern, route, "getcompiledpattern"); ZEPHIR_INIT_NVAR(routeFound); if (zephir_memnstr_str(pattern, SL("^"), "test/router.zep", 400)) { zephir_preg_match(routeFound, &(routeFound), pattern, handledUri, matches, 0, 0 , 0 TSRMLS_CC); } else { ZVAL_BOOL(routeFound, ZEPHIR_IS_EQUAL(pattern, handledUri)); } if (zephir_is_true(routeFound)) { ZEPHIR_INIT_NVAR(beforeMatch); zephir_call_method(beforeMatch, route, "getbeforematch"); if ((Z_TYPE_P(beforeMatch) != IS_NULL)) { if (zephir_is_callable(beforeMatch TSRMLS_CC)) { ZEPHIR_THROW_EXCEPTION_STR(test_router_exception_ce, "Before-Match callback is not callable in matched route"); return; } } } if (zephir_is_true(routeFound)) { ZEPHIR_INIT_NVAR(paths); zephir_call_method(paths, route, "getpaths"); ZEPHIR_CPY_WRT(parts, paths); if ((Z_TYPE_P(matches) == IS_ARRAY)) { ZEPHIR_INIT_NVAR(converters); zephir_call_method(converters, route, "getconverters"); zephir_is_iterable(paths, &_9, &_8, 0, 0); for ( ; zend_hash_get_current_data_ex(_9, (void**) &_10, &_8) == SUCCESS ; zend_hash_move_forward_ex(_9, &_8) ) { ZEPHIR_GET_HMKEY(part, _9, _8); ZEPHIR_GET_HVALUE(position, _10); if (zephir_array_isset_fetch(&matchPosition, matches, position, 1 TSRMLS_CC)) { if ((Z_TYPE_P(converters) == IS_ARRAY)) { if (zephir_array_isset(converters, part)) { continue; } } zephir_array_update_zval(&parts, part, &matchPosition, PH_COPY | PH_SEPARATE); } else { if ((Z_TYPE_P(converters) == IS_ARRAY)) { if (zephir_array_isset(converters, part)) { } } } } zephir_update_property_this(this_ptr, SL("_matches"), matches TSRMLS_CC); } zephir_update_property_this(this_ptr, SL("_matchedRoute"), route TSRMLS_CC); break; } } if (zephir_is_true(routeFound)) { zephir_update_property_this(this_ptr, SL("_wasMatched"), (1) ? ZEPHIR_GLOBAL(global_true) : ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_wasMatched"), (0) ? ZEPHIR_GLOBAL(global_true) : ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } if (!(zephir_is_true(routeFound))) { notFoundPaths = zephir_fetch_nproperty_this(this_ptr, SL("_notFoundPaths"), PH_NOISY_CC); if ((Z_TYPE_P(notFoundPaths) != IS_NULL)) { ZEPHIR_CPY_WRT(parts, notFoundPaths); ZEPHIR_INIT_BNVAR(routeFound); ZVAL_BOOL(routeFound, 1); } } if (zephir_is_true(routeFound)) { if (zephir_array_isset_string_fetch(&vnamespace, parts, SS("namespace"), 1 TSRMLS_CC)) { if (!(zephir_is_numeric(vnamespace))) { zephir_update_property_this(this_ptr, SL("_namespace"), vnamespace TSRMLS_CC); } zephir_array_fetch_string(&_11, parts, SL("namespace"), PH_NOISY | PH_READONLY TSRMLS_CC); zephir_array_unset(&parts, _11, PH_SEPARATE); } else { _5 = zephir_fetch_nproperty_this(this_ptr, SL("_defaultNamespace"), PH_NOISY_CC); zephir_update_property_this(this_ptr, SL("_namespace"), _5 TSRMLS_CC); } if (zephir_array_isset_string_fetch(&module, parts, SS("module"), 1 TSRMLS_CC)) { if (!(zephir_is_numeric(module))) { zephir_update_property_this(this_ptr, SL("_module"), module TSRMLS_CC); } zephir_array_fetch_string(&_11, parts, SL("module"), PH_NOISY | PH_READONLY TSRMLS_CC); zephir_array_unset(&parts, _11, PH_SEPARATE); } else { _5 = zephir_fetch_nproperty_this(this_ptr, SL("_defaultModule"), PH_NOISY_CC); zephir_update_property_this(this_ptr, SL("_module"), _5 TSRMLS_CC); } if (zephir_array_isset_string_fetch(&controller, parts, SS("controller"), 1 TSRMLS_CC)) { if (!(zephir_is_numeric(controller))) { zephir_update_property_this(this_ptr, SL("_controller"), controller TSRMLS_CC); } zephir_array_fetch_string(&_11, parts, SL("controller"), PH_NOISY | PH_READONLY TSRMLS_CC); zephir_array_unset(&parts, _11, PH_SEPARATE); } else { _5 = zephir_fetch_nproperty_this(this_ptr, SL("_defaultController"), PH_NOISY_CC); zephir_update_property_this(this_ptr, SL("_controller"), _5 TSRMLS_CC); } if (zephir_array_isset_string_fetch(&action, parts, SS("action"), 1 TSRMLS_CC)) { if (!(zephir_is_numeric(action))) { zephir_update_property_this(this_ptr, SL("_action"), action TSRMLS_CC); } zephir_array_fetch_string(&_11, parts, SL("action"), PH_NOISY | PH_READONLY TSRMLS_CC); zephir_array_unset(&parts, _11, PH_SEPARATE); } else { _5 = zephir_fetch_nproperty_this(this_ptr, SL("_defaultAction"), PH_NOISY_CC); zephir_update_property_this(this_ptr, SL("_action"), _5 TSRMLS_CC); } if (zephir_array_isset_string_fetch(¶msStr, parts, SS("params"), 1 TSRMLS_CC)) { ZEPHIR_INIT_VAR(strParams); zephir_substr(strParams, paramsStr, 1 , 0 ); if (zephir_is_true(strParams)) { ZEPHIR_INIT_BNVAR(params); zephir_fast_explode_str(params, SL("/"), strParams, LONG_MAX TSRMLS_CC); } zephir_array_fetch_string(&_11, parts, SL("params"), PH_NOISY | PH_READONLY TSRMLS_CC); zephir_array_unset(&parts, _11, PH_SEPARATE); } if (zephir_fast_count_int(params TSRMLS_CC)) { ZEPHIR_INIT_VAR(paramsMerge); zephir_fast_array_merge(paramsMerge, &(params), &(parts) TSRMLS_CC); } else { ZEPHIR_CPY_WRT(paramsMerge, parts); } zephir_update_property_this(this_ptr, SL("_params"), paramsMerge TSRMLS_CC); } else { _5 = zephir_fetch_nproperty_this(this_ptr, SL("_defaultNamespace"), PH_NOISY_CC); zephir_update_property_this(this_ptr, SL("_namespace"), _5 TSRMLS_CC); _12 = zephir_fetch_nproperty_this(this_ptr, SL("_defaultModule"), PH_NOISY_CC); zephir_update_property_this(this_ptr, SL("_module"), _12 TSRMLS_CC); _13 = zephir_fetch_nproperty_this(this_ptr, SL("_defaultController"), PH_NOISY_CC); zephir_update_property_this(this_ptr, SL("_controller"), _13 TSRMLS_CC); _14 = zephir_fetch_nproperty_this(this_ptr, SL("_defaultAction"), PH_NOISY_CC); zephir_update_property_this(this_ptr, SL("_action"), _14 TSRMLS_CC); _15 = zephir_fetch_nproperty_this(this_ptr, SL("_defaultParams"), PH_NOISY_CC); zephir_update_property_this(this_ptr, SL("_params"), _15 TSRMLS_CC); } ZEPHIR_MM_RESTORE(); }
/** * Mounts a group of routes in the router * * @param Test\Router\Group route * @return Test\Router */ PHP_METHOD(Test_Router, mount) { HashTable *_3, *_6; HashPosition _2, _5; zval *group, *groupRoutes, *beforeMatch, *hostname, *routes, *route = NULL, *_0 = NULL, *_1 = NULL, **_4, **_7; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &group); if ((Z_TYPE_P(group) != IS_OBJECT)) { ZEPHIR_INIT_VAR(_0); object_init_ex(_0, test_router_exception_ce); ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "The group of routes is not valid", 1); zephir_call_method_p1_noret(_0, "__construct", _1); zephir_throw_exception(_0 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_INIT_VAR(groupRoutes); zephir_call_method(groupRoutes, group, "getroutes"); if (!(zephir_fast_count_int(groupRoutes TSRMLS_CC))) { ZEPHIR_INIT_LNVAR(_0); object_init_ex(_0, test_router_exception_ce); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "The group of routes does not contain any routes", 1); zephir_call_method_p1_noret(_0, "__construct", _1); zephir_throw_exception(_0 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_INIT_VAR(beforeMatch); zephir_call_method(beforeMatch, group, "getbeforematch"); if ((Z_TYPE_P(beforeMatch) != IS_NULL)) { zephir_is_iterable(groupRoutes, &_3, &_2, 0, 0); for ( ; zend_hash_get_current_data_ex(_3, (void**) &_4, &_2) == SUCCESS ; zephir_hash_move_forward_ex(_3, &_2) ) { ZEPHIR_GET_HVALUE(route, _4); zephir_call_method_p1_noret(route, "beforematch", beforeMatch); } } ZEPHIR_INIT_VAR(hostname); zephir_call_method(hostname, group, "gethostname"); if ((Z_TYPE_P(hostname) != IS_NULL)) { zephir_is_iterable(groupRoutes, &_6, &_5, 0, 0); for ( ; zend_hash_get_current_data_ex(_6, (void**) &_7, &_5) == SUCCESS ; zephir_hash_move_forward_ex(_6, &_5) ) { ZEPHIR_GET_HVALUE(route, _7); zephir_call_method_p1_noret(route, "sethostname", hostname); } } ZEPHIR_OBS_VAR(routes); zephir_read_property_this(&routes, this_ptr, SL("_routes"), PH_NOISY_CC); if ((Z_TYPE_P(routes) == IS_ARRAY)) { ZEPHIR_INIT_NVAR(_1); zephir_fast_array_merge(_1, &(routes), &(groupRoutes) TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_routes"), _1 TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_routes"), groupRoutes TSRMLS_CC); } RETURN_THIS(); }
/** * Gets the signature * * @param OAuth\UriInterface uri * @param array params * @param string method * * @return string */ PHP_METHOD(OAuth_V1_Signature, getSignature) { HashTable *_4; HashPosition _3; zend_class_entry *_1; zval *method = NULL; zval *uri, *params, *method_param = NULL, *signature, *signatureData, *signatureString, *signatureStringEncoded, *query, *queryStringData = NULL, *queryStringKey = NULL, *queryStringValue = NULL, *queryStringKeyEncoded = NULL, *queryStringValueEncoded = NULL, *scheme, *authority, *path, *hasExplicitTrailingHostSlash, *baseUri, *baseUriEncoded, *dataString, *dataHash, *_0 = NULL, *_2, **_5; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 1, &uri, ¶ms, &method_param); if (!method_param) { ZEPHIR_INIT_VAR(method); ZVAL_STRING(method, "POST", 1); } else { zephir_get_strval(method, method_param); } ZEPHIR_INIT_VAR(query); zephir_call_method(query, uri, "getquery"); ZEPHIR_INIT_VAR(queryStringData); array_init(queryStringData); ZEPHIR_INIT_VAR(signatureData); array_init(signatureData); if ((Z_TYPE_P(params) != IS_ARRAY)) { ZEPHIR_INIT_VAR(_0); _1 = zend_fetch_class(SL("InvalidArgumentException"), ZEND_FETCH_CLASS_AUTO TSRMLS_CC); object_init_ex(_0, _1); ZEPHIR_INIT_VAR(_2); ZVAL_STRING(_2, "The params must be an Array", 1); zephir_call_method_p1_noret(_0, "__construct", _2); zephir_throw_exception(_0 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_INIT_NVAR(_0); zephir_fast_array_merge(_0, &(queryStringData), &(params) TSRMLS_CC); ZEPHIR_CPY_WRT(queryStringData, _0); Z_SET_ISREF_P(queryStringData); zephir_call_func_p2_noret("parse_str", query, queryStringData); Z_UNSET_ISREF_P(queryStringData); zephir_is_iterable(queryStringData, &_4, &_3, 0, 0); for ( ; zend_hash_get_current_data_ex(_4, (void**) &_5, &_3) == SUCCESS ; zend_hash_move_forward_ex(_4, &_3) ) { ZEPHIR_GET_HMKEY(queryStringKey, _4, _3); ZEPHIR_GET_HVALUE(queryStringValue, _5); ZEPHIR_INIT_NVAR(queryStringKeyEncoded); zephir_call_func_p1(queryStringKeyEncoded, "rawurlencode", queryStringKey); ZEPHIR_INIT_NVAR(queryStringValueEncoded); zephir_call_func_p1(queryStringValueEncoded, "rawurlencode", queryStringValue); zephir_array_update_zval(&signatureData, queryStringKeyEncoded, &queryStringValueEncoded, PH_COPY | PH_SEPARATE); } Z_SET_ISREF_P(signatureData); zephir_call_func_p1_noret("ksort", signatureData); Z_UNSET_ISREF_P(signatureData); ZEPHIR_INIT_VAR(scheme); zephir_call_method(scheme, uri, "getscheme"); ZEPHIR_INIT_VAR(authority); zephir_call_method(authority, uri, "getrawauthority"); ZEPHIR_INIT_VAR(path); zephir_call_method(path, uri, "getpath"); ZEPHIR_INIT_VAR(hasExplicitTrailingHostSlash); zephir_call_method(hasExplicitTrailingHostSlash, uri, "hasexplicittrailinghostslash"); ZEPHIR_INIT_VAR(baseUri); ZEPHIR_CONCAT_VSV(baseUri, scheme, "://", authority); if (ZEPHIR_IS_STRING(path, "/")) { if (zephir_is_true(hasExplicitTrailingHostSlash)) { zephir_concat_self_str(&baseUri, SL("/") TSRMLS_CC); } } else { zephir_concat_self(&baseUri, path TSRMLS_CC); } ZEPHIR_INIT_VAR(baseUriEncoded); zephir_call_func_p1(baseUriEncoded, "rawurlencode", baseUri); ZEPHIR_INIT_VAR(signatureString); zephir_call_method_p1(signatureString, this_ptr, "buildsignaturestring", signatureData); ZEPHIR_INIT_VAR(signatureStringEncoded); zephir_call_func_p1(signatureStringEncoded, "rawurlencode", signatureString); ZEPHIR_INIT_VAR(dataString); zephir_fast_strtoupper(dataString, method); ZEPHIR_INIT_BNVAR(dataString); ZEPHIR_CONCAT_VSVSV(dataString, dataString, "&", baseUriEncoded, "&", signatureStringEncoded); ZEPHIR_INIT_VAR(dataHash); zephir_call_method_p1(dataHash, this_ptr, "hash", dataString); ZEPHIR_INIT_VAR(signature); zephir_call_func_p1(signature, "base64_encode", dataHash); RETURN_CCTOR(signature); }