/** * Adds the limit parameter to the criteria * * @param int $limit * @param int $offset * @return Phalcon\Mvc\Model\CriteriaInterface */ PHP_METHOD(Phalcon_Mvc_Model_Criteria, limit){ zval *limit, *offset = NULL, *limit_clause; PHALCON_MM_GROW(); phalcon_fetch_params(1, 1, 1, &limit, &offset); if (!offset) { offset = PHALCON_GLOBAL(z_null); } if (!phalcon_is_numeric(limit)) { PHALCON_THROW_EXCEPTION_STR(phalcon_mvc_model_exception_ce, "Row limit parameter must be integer"); return; } if (Z_TYPE_P(offset) == IS_NULL) { phalcon_update_property_array_string(this_ptr, SL("_params"), ISS(limit), limit TSRMLS_CC); } else { PHALCON_INIT_VAR(limit_clause); array_init_size(limit_clause, 2); phalcon_array_update_string(&limit_clause, ISL(number), limit, PH_COPY); phalcon_array_update_string(&limit_clause, ISL(offset), offset, PH_COPY); phalcon_update_property_array_string(this_ptr, SL("_params"), ISS(limit), limit_clause TSRMLS_CC); } RETURN_THIS(); }
/* * -- updateofs * * updates type and offset information in the pkt_t data structure. * requires the type of interface as input. */ __inline__ void updateofs(pkt_t * pkt, int type) { pkt->type = type; pkt->l2type = 0xFFFF; /* implies field unused */ switch (pkt->type) { case COMOTYPE_ETH: if (H16(ETH(type)) == ETHERTYPE_VLAN) { pkt->type = COMOTYPE_VLAN; pkt->l3type = H16(VLAN(ethtype)); } else if (isISL(pkt)) { pkt->type = COMOTYPE_ISL; pkt->l3type = H16(ISL(ethtype)); } else { pkt->l3type = H16(ETH(type)); } break; case COMOTYPE_HDLC: pkt->l3type = H16(HDLC(type)); break; case COMOTYPE_80211: pkt->l2type = H16(IEEE80211_HDR(fc)); if (FCTRL_TYPE(pkt->l2type) == WLANTYPE_DATA) pkt->l3type = H16(LLC_HDR(type)); else pkt->l3type = 0; break; case COMOTYPE_RADIO: pkt->l2type = H16(IEEE80211_HDR(fc)); /* 802.11 + XX byte capture hdr */ if (FCTRL_TYPE(pkt->l2type) == WLANTYPE_DATA) pkt->l3type = H16(LLC_HDR(type)); else pkt->l3type = 0; break; default: pkt->l3type = 0; break; } updatel4(pkt); }
/** * Sends the cookie to the HTTP client * Stores the cookie definition in session * * @return Phalcon\Http\Cookie */ PHP_METHOD(Phalcon_Http_Cookie, send){ zval *name, *value, *expire, *domain, *path, *secure; zval *http_only, *dependency_injector, *definition; zval *service = NULL, *session = NULL, *key, *encryption, *crypt = NULL; zval *encrypt_value = NULL, *has_session = NULL; PHALCON_MM_GROW(); PHALCON_OBS_VAR(name); phalcon_read_property_this(&name, this_ptr, SL("_name"), PH_NOISY TSRMLS_CC); PHALCON_OBS_VAR(value); phalcon_read_property_this(&value, this_ptr, SL("_value"), PH_NOISY TSRMLS_CC); PHALCON_OBS_VAR(expire); phalcon_read_property_this(&expire, this_ptr, SL("_expire"), PH_NOISY TSRMLS_CC); PHALCON_OBS_VAR(domain); phalcon_read_property_this(&domain, this_ptr, SL("_domain"), PH_NOISY TSRMLS_CC); PHALCON_OBS_VAR(path); phalcon_read_property_this(&path, this_ptr, SL("_path"), PH_NOISY TSRMLS_CC); PHALCON_OBS_VAR(secure); phalcon_read_property_this(&secure, this_ptr, SL("_secure"), PH_NOISY TSRMLS_CC); PHALCON_OBS_VAR(http_only); phalcon_read_property_this(&http_only, this_ptr, SL("_httpOnly"), PH_NOISY TSRMLS_CC); PHALCON_OBS_VAR(dependency_injector); phalcon_read_property_this(&dependency_injector, this_ptr, SL("_dependencyInjector"), PH_NOISY TSRMLS_CC); if (Z_TYPE_P(dependency_injector) == IS_OBJECT) { PHALCON_INIT_VAR(service); PHALCON_ZVAL_MAYBE_INTERNED_STRING(service, phalcon_interned_session); PHALCON_CALL_METHOD(&has_session, dependency_injector, "has", service); if (zend_is_true(has_session)) { PHALCON_INIT_VAR(definition); array_init(definition); if (!PHALCON_IS_LONG(expire, 0)) { phalcon_array_update_string(&definition, SL("expire"), expire, PH_COPY); } if (PHALCON_IS_NOT_EMPTY(path)) { phalcon_array_update_string(&definition, SL("path"), path, PH_COPY); } if (PHALCON_IS_NOT_EMPTY(domain)) { phalcon_array_update_string(&definition, ISL(domain), domain, PH_COPY); } if (PHALCON_IS_NOT_EMPTY(secure)) { phalcon_array_update_string(&definition, SL("secure"), secure, PH_COPY); } if (PHALCON_IS_NOT_EMPTY(http_only)) { phalcon_array_update_string(&definition, SL("httpOnly"), http_only, PH_COPY); } /** * The definition is stored in session */ if (phalcon_fast_count_ev(definition TSRMLS_CC)) { PHALCON_CALL_METHOD(&session, dependency_injector, "getshared", service); if (Z_TYPE_P(session) != IS_NULL) { PHALCON_VERIFY_INTERFACE(session, phalcon_session_adapterinterface_ce); PHALCON_INIT_VAR(key); PHALCON_CONCAT_SV(key, "_PHCOOKIE_", name); PHALCON_CALL_METHOD(NULL, session, "set", key, definition); } } } } PHALCON_OBS_VAR(encryption); phalcon_read_property_this(&encryption, this_ptr, SL("_useEncryption"), PH_NOISY TSRMLS_CC); if (zend_is_true(encryption) && PHALCON_IS_NOT_EMPTY(value)) { if (Z_TYPE_P(dependency_injector) != IS_OBJECT) { PHALCON_THROW_EXCEPTION_STR(phalcon_http_cookie_exception_ce, "A dependency injection object is required to access the 'filter' service"); return; } PHALCON_INIT_NVAR(service); ZVAL_STRING(service, "crypt", 1); PHALCON_CALL_METHOD(&crypt, dependency_injector, "getshared", service); PHALCON_VERIFY_INTERFACE(crypt, phalcon_cryptinterface_ce); /** * Encrypt the value also coding it with base64 */ PHALCON_CALL_METHOD(&encrypt_value, crypt, "encryptbase64", value); } else { PHALCON_CPY_WRT(encrypt_value, value); } /** * Sets the cookie using the standard 'setcookie' function */ convert_to_string_ex(&name); convert_to_string_ex(&encrypt_value); convert_to_long_ex(&expire); convert_to_string_ex(&path); convert_to_string_ex(&domain); convert_to_long_ex(&secure); convert_to_long_ex(&http_only); php_setcookie( Z_STRVAL_P(name), Z_STRLEN_P(name), Z_STRVAL_P(encrypt_value), Z_STRLEN_P(encrypt_value), Z_LVAL_P(expire), Z_STRVAL_P(path), Z_STRLEN_P(path), Z_STRVAL_P(domain), Z_STRLEN_P(domain), Z_LVAL_P(secure), 1, Z_LVAL_P(http_only) TSRMLS_CC ); RETURN_THIS(); }