Esempio n. 1
0
/**
 * CacheGetOne: cached GetOne
 *
 * @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 mixed
 */
PHP_METHOD(ADOdb_Connection, cacheGetOne) {

    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_INIT_BNVAR(_0);
    ZVAL_LONG(_0, 0);
    zephir_call_method_p1(return_value, st, "fetchcolumn", _0);
    RETURN_MM();

}
Esempio n. 2
0
/**
 * CacheGetCol: cached GetCol
 * @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
 */
PHP_METHOD(ADOdb_Connection, cacheGetCol) {

    zval *vars = NULL;
    zval *statement = NULL;
    zval *timeout_param = NULL, *statement_param = NULL, *vars_param = NULL, *col, *val = NULL, *st, *_0 = NULL;
    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_INIT_VAR(col);
    array_init(col);
    ZEPHIR_INIT_BNVAR(_0);
    ZVAL_LONG(_0, 0);
    ZEPHIR_INIT_VAR(val);
    zephir_call_method_p1(val, st, "fetchcolumn", _0);
    while (1) {
        if (!(zephir_is_true(val))) {
            break;
        }
        zephir_array_append(&col, val, PH_SEPARATE);
        ZEPHIR_INIT_NVAR(_0);
        ZVAL_LONG(_0, 0);
        ZEPHIR_INIT_NVAR(val);
        zephir_call_method_p1(val, st, "fetchcolumn", _0);
    }
    RETURN_CCTOR(col);

}
Esempio n. 3
0
PHP_METHOD(ADOdb_Connection, getAttribute) {

    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);


    _0 = zephir_fetch_nproperty_this(this_ptr, SL("dso"), PH_NOISY_CC);
    zephir_call_method_p1(return_value, _0, "getoption", name);
    RETURN_MM();

}
Esempio n. 4
0
/**
 * Run a command that will talk to the connection
 *
 * @param Command command
 * @return boolean
 */
PHP_METHOD(ADOdb_Connection, execCommand) {

    zval *command;

    ZEPHIR_MM_GROW();
    zephir_fetch_params(1, 1, 0, &command);



    if (!(zephir_is_instance_of(command, SL("ADOdb\\Command") TSRMLS_CC))) {
        ZEPHIR_THROW_EXCEPTION_STR(spl_ce_InvalidArgumentException, "Parameter 'command' must be an instance of 'ADOdb\\Command'");
        return;
    }
    zephir_call_method_p1(return_value, command, "execute", this_ptr);
    RETURN_MM();

}
Esempio n. 5
0
/**
 * @param int fetchMode
 * @return type
 * @throws ConnectionException
 */
PHP_METHOD(ADOdb_Connection, setFetchMode) {

    zval *fetchMode, *_0;

    ZEPHIR_MM_GROW();
    zephir_fetch_params(1, 1, 0, &fetchMode);



    zephir_call_method_noret(this_ptr, "checkconnected");
    do {
        if (ZEPHIR_IS_LONG(fetchMode, 0) || ZEPHIR_IS_LONG(fetchMode, 2) || ZEPHIR_IS_LONG(fetchMode, 1) || ZEPHIR_IS_LONG(fetchMode, 3)) {
            _0 = zephir_fetch_nproperty_this(this_ptr, SL("connection"), PH_NOISY_CC);
            zephir_call_method_p1(return_value, _0, "setfetchmode", fetchMode);
            RETURN_MM();
        }
        ZEPHIR_THROW_EXCEPTION_STR(adodb_connectionexception_ce, "Invalid fetch mode value");
        return;
    } while(0);

    ZEPHIR_MM_RESTORE();

}
Esempio n. 6
0
/**
 * GetRow: return array of value of first row
 *
 * @param string statement String query to execute
 * @param array vars Array of variables to bind [optional]
 * @return array
 */
PHP_METHOD(ADOdb_Connection, getRow) {

    zval *vars = NULL;
    zval *statement, *vars_param = NULL, *st, *_0;

    ZEPHIR_MM_GROW();
    zephir_fetch_params(1, 1, 1, &statement, &vars_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_INIT_VAR(_0);
    ZVAL_LONG(_0, 0);
    zephir_call_method_p1(return_value, st, "fetch", _0);
    RETURN_MM();

}
Esempio n. 7
0
/**
 * Reconfigure the route adding a new pattern and a set of paths
 *
 * @param string pattern
 * @param array paths
 */
PHP_METHOD(Test_Router_Route, reConfigure) {

	int _1;
	zval *pattern, *paths = NULL, *moduleName = NULL, *controllerName = NULL, *actionName = NULL, *parts, *routePaths = NULL, *realClassName = NULL, *namespaceName, *pcrePattern = NULL, *compiledPattern = NULL, *extracted, _0, *_2 = NULL, *_3;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 1, 1, &pattern, &paths);

	if (!paths) {
		ZEPHIR_CPY_WRT(paths, ZEPHIR_GLOBAL(global_null));
	}


	if ((Z_TYPE_P(pattern) != IS_STRING)) {
		ZEPHIR_THROW_EXCEPTION_STR(test_router_exception_ce, "The pattern must be string");
		return;
	}
	if ((Z_TYPE_P(paths) != IS_NULL)) {
		if ((Z_TYPE_P(paths) == IS_STRING)) {
			ZEPHIR_INIT_VAR(moduleName);
			ZVAL_NULL(moduleName);
			ZEPHIR_INIT_VAR(controllerName);
			ZVAL_NULL(controllerName);
			ZEPHIR_INIT_VAR(actionName);
			ZVAL_NULL(actionName);
			ZEPHIR_SINIT_VAR(_0);
			ZVAL_STRING(&_0, "::", 0);
			ZEPHIR_INIT_VAR(parts);
			zephir_call_func_p2(parts, "explode", &_0, paths);
			do {
				_1 = zephir_fast_count_int(parts TSRMLS_CC);
				if ((_1 == 3)) {
					ZEPHIR_OBS_NVAR(moduleName);
					zephir_array_fetch_long(&moduleName, parts, 0, PH_NOISY TSRMLS_CC);
					ZEPHIR_OBS_NVAR(controllerName);
					zephir_array_fetch_long(&controllerName, parts, 1, PH_NOISY TSRMLS_CC);
					ZEPHIR_OBS_NVAR(actionName);
					zephir_array_fetch_long(&actionName, parts, 2, PH_NOISY TSRMLS_CC);
					break;
				}
				if ((_1 == 2)) {
					ZEPHIR_OBS_NVAR(controllerName);
					zephir_array_fetch_long(&controllerName, parts, 0, PH_NOISY TSRMLS_CC);
					ZEPHIR_OBS_NVAR(actionName);
					zephir_array_fetch_long(&actionName, parts, 1, PH_NOISY TSRMLS_CC);
					break;
				}
				if ((_1 == 1)) {
					ZEPHIR_OBS_NVAR(controllerName);
					zephir_array_fetch_long(&controllerName, parts, 0, PH_NOISY TSRMLS_CC);
					break;
				}
			} while(0);

			ZEPHIR_INIT_VAR(routePaths);
			array_init(routePaths);
			if ((Z_TYPE_P(moduleName) != IS_NULL)) {
				zephir_array_update_string(&routePaths, SL("module"), &moduleName, PH_COPY | PH_SEPARATE);
			}
			if ((Z_TYPE_P(controllerName) != IS_NULL)) {
				if (zephir_memnstr_str(controllerName, SL("\\"), "test/router/route.zep", 313)) {
					ZEPHIR_INIT_VAR(realClassName);
					zephir_call_func_p1(realClassName, "get_class_ns", controllerName);
					ZEPHIR_INIT_VAR(namespaceName);
					zephir_call_func_p1(namespaceName, "get_ns_class", controllerName);
					if (zephir_is_true(namespaceName)) {
						zephir_array_update_string(&routePaths, SL("namespace"), &namespaceName, PH_COPY | PH_SEPARATE);
					}
				} else {
					ZEPHIR_CPY_WRT(realClassName, controllerName);
				}
				ZEPHIR_INIT_VAR(_2);
				zephir_uncamelize(_2, realClassName);
				zephir_array_update_string(&routePaths, SL("controller"), &_2, PH_COPY | PH_SEPARATE);
			}
			if ((Z_TYPE_P(actionName) != IS_NULL)) {
				zephir_array_update_string(&routePaths, SL("action"), &actionName, PH_COPY | PH_SEPARATE);
			}
		} else {
			ZEPHIR_CPY_WRT(routePaths, paths);
		}
	} else {
		ZEPHIR_INIT_NVAR(routePaths);
		array_init(routePaths);
	}
	if ((Z_TYPE_P(routePaths) != IS_ARRAY)) {
		ZEPHIR_THROW_EXCEPTION_STR(test_router_exception_ce, "The route contains invalid paths");
		return;
	}
	if (!(zephir_start_with_str(pattern, SL("#")))) {
		if (zephir_memnstr_str(pattern, SL("{"), "test/router/route.zep", 351)) {
			ZEPHIR_INIT_VAR(extracted);
			zephir_call_method_p1(extracted, this_ptr, "extractnamedparams", pattern);
			ZEPHIR_OBS_VAR(pcrePattern);
			zephir_array_fetch_long(&pcrePattern, extracted, 0, PH_NOISY TSRMLS_CC);
			ZEPHIR_INIT_NVAR(_2);
			zephir_array_fetch_long(&_3, extracted, 1, PH_NOISY | PH_READONLY TSRMLS_CC);
			zephir_fast_array_merge(_2, &(routePaths), &(_3) TSRMLS_CC);
			ZEPHIR_CPY_WRT(routePaths, _2);
		} else {
			ZEPHIR_CPY_WRT(pcrePattern, pattern);
		}
		ZEPHIR_INIT_VAR(compiledPattern);
		zephir_call_method_p1(compiledPattern, this_ptr, "compilepattern", pcrePattern);
	} else {
		ZEPHIR_CPY_WRT(compiledPattern, pattern);
	}
	zephir_update_property_this(this_ptr, SL("_pattern"), pattern TSRMLS_CC);
	zephir_update_property_this(this_ptr, SL("_compiledPattern"), compiledPattern TSRMLS_CC);
	zephir_update_property_this(this_ptr, SL("_paths"), routePaths TSRMLS_CC);
	ZEPHIR_MM_RESTORE();

}
Esempio n. 8
0
PHP_METHOD(Test_SpectralNorm, Au) {

	zend_function *_9 = NULL;
	zend_bool _0, _3;
	zval *n_param = NULL, *u, *v, *_6 = NULL, *_7 = NULL, *_8 = NULL, *_10 = NULL;
	int n, t, i, j, _1, _2, _4, _5;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 3, 0, &n_param, &u, &v);

		n = zephir_get_intval(n_param);


	_2 = (n - 1);
	_1 = 0;
	_0 = 0;
	if ((_1 <= _2)) {
		while (1) {
			if (_0) {
				_1++;
				if (!((_1 <= _2))) {
					break;
				}
			} else {
				_0 = 1;
			}
			i = _1;
			t = 0;
			_5 = (n - 1);
			_4 = 0;
			_3 = 0;
			if ((_4 <= _5)) {
				while (1) {
					if (_3) {
						_4++;
						if (!((_4 <= _5))) {
							break;
						}
					} else {
						_3 = 1;
					}
					j = _4;
					ZEPHIR_INIT_NVAR(_6);
					ZEPHIR_INIT_NVAR(_7);
					ZVAL_LONG(_7, i);
					ZEPHIR_INIT_NVAR(_8);
					ZVAL_LONG(_8, j);
					zephir_call_method_p2_cache(_6, this_ptr, "ax", &_9, _7, _8);
					ZEPHIR_INIT_NVAR(_7);
					ZEPHIR_INIT_NVAR(_8);
					ZVAL_LONG(_8, j);
					zephir_call_method_p1(_7, u, "offsetge", _8);
					ZEPHIR_INIT_LNVAR(_10);
					mul_function(_10, _6, _7 TSRMLS_CC);
					t += zephir_get_numberval(_10);
				}
			}
			ZEPHIR_INIT_NVAR(_6);
			ZVAL_LONG(_6, i);
			ZEPHIR_INIT_NVAR(_7);
			ZVAL_LONG(_7, t);
			zephir_call_method_p2_noret(v, "offsetset", _6, _7);
		}
	}
	ZEPHIR_MM_RESTORE();

}
Esempio n. 9
0
/**
 * 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(&paramsStr, 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();

}
Esempio n. 10
0
/**
 * 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, &params, &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);

}