Skip to content
This repository was archived by the owner on Nov 18, 2025. It is now read-only.

Commit abbc69f

Browse files
committed
🔨 improve post, get, and stream methods
Signed-off-by: otengkwame <[email protected]>
1 parent b5f8f6d commit abbc69f

File tree

1 file changed

+104
-2
lines changed

1 file changed

+104
-2
lines changed

framework/core/Input.php

Lines changed: 104 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,18 @@ public function post_get($index, $xss_clean = false)
262262
: $this->get($index, $xss_clean);
263263
}
264264

265+
/**
266+
* Alias To Method Above
267+
*
268+
* @param string $index
269+
* @param bool $xss_clean
270+
* @return mixed
271+
*/
272+
public function postGet($index, $xss_clean = false)
273+
{
274+
return $this->post_get($index, $xss_clean);
275+
}
276+
265277
// --------------------------------------------------------------------
266278

267279
/**
@@ -278,6 +290,18 @@ public function get_post($index, $xss_clean = false)
278290
: $this->post($index, $xss_clean);
279291
}
280292

293+
/**
294+
* Alias To Method Above
295+
*
296+
* @param string $index
297+
* @param bool $xss_clean
298+
* @return mixed
299+
*/
300+
public function getPost($index, $xss_clean = false)
301+
{
302+
return $this->get_post($index, $xss_clean);
303+
}
304+
281305
// --------------------------------------------------------------------
282306

283307
/**
@@ -330,6 +354,18 @@ public function input_stream($index = null, $xss_clean = false)
330354
return $this->_fetch_from_array($this->_input_stream, $index, $xss_clean);
331355
}
332356

357+
/**
358+
* Alias To Method Above
359+
*
360+
* @param string $index Index for item to be fetched
361+
* @param bool $xss_clean Whether to apply XSS filtering
362+
* @return mixed
363+
*/
364+
public function inputStream($index = null, $xss_clean = false)
365+
{
366+
return $this->input_stream($index, $xss_clean);
367+
}
368+
333369
// ------------------------------------------------------------------------
334370

335371
/**
@@ -380,8 +416,8 @@ public function set_cookie($name, $value = '', $expire = 0, $domain = '', $path
380416
? (bool) config_item('cookie_httponly')
381417
: (bool) $httponly;
382418

383-
if (!is_numeric($expire) or $expire < 0) {
384-
$expire = 1;
419+
if (!is_numeric($expire)) {
420+
$expire = time() - 86500;
385421
} else {
386422
$expire = ($expire > 0) ? time() + $expire : 0;
387423
}
@@ -541,6 +577,16 @@ public function ip_address()
541577
return $this->ip_address;
542578
}
543579

580+
/**
581+
* Alias To Method Above
582+
*
583+
* @return string IP address
584+
*/
585+
public function ipAddress()
586+
{
587+
return $this->ip_address();
588+
}
589+
544590
// --------------------------------------------------------------------
545591

546592
/**
@@ -567,6 +613,18 @@ public function valid_ip($ip = '', $which = '')
567613
return (bool) filter_var($ip, FILTER_VALIDATE_IP, $which);
568614
}
569615

616+
/**
617+
* Alias To Method Above
618+
*
619+
* @param string $ip IP address
620+
* @param string $which IP protocol: 'ipv4' or 'ipv6'
621+
* @return bool
622+
*/
623+
public function validIp($ip = '', $which = '')
624+
{
625+
return $this->valid_ip($ip, $which);
626+
}
627+
570628
// --------------------------------------------------------------------
571629

572630
/**
@@ -579,6 +637,17 @@ public function user_agent($xss_clean = false)
579637
return $this->_fetch_from_array($_SERVER, 'HTTP_USER_AGENT', $xss_clean);
580638
}
581639

640+
/**
641+
* Alias To Method Above
642+
*
643+
* @param bool $xss_clean
644+
* @return string|null
645+
*/
646+
public function userAgent($xss_clean = false)
647+
{
648+
return $this->user_agent($xss_clean);
649+
}
650+
582651
// --------------------------------------------------------------------
583652

584653
/**
@@ -745,6 +814,17 @@ public function request_headers($xss_clean = false)
745814
return $this->_fetch_from_array($this->headers, null, $xss_clean);
746815
}
747816

817+
/**
818+
* Alias To Method Above
819+
*
820+
* @param bool $xss_clean
821+
* @return array
822+
*/
823+
public function requestHeaders($xss_clean = false)
824+
{
825+
return $this->request_headers($xss_clean);
826+
}
827+
748828
// --------------------------------------------------------------------
749829

750830
/**
@@ -778,6 +858,18 @@ public function get_request_header($index, $xss_clean = false)
778858
: $headers[$index];
779859
}
780860

861+
/**
862+
* Alias To Method Above
863+
*
864+
* @param string $index
865+
* @param bool $xss_clean
866+
* @return string|null
867+
*/
868+
public function getRequestHeader($index, $xss_clean = false)
869+
{
870+
return $this->get_request_header($index, $xss_clean);
871+
}
872+
781873
// --------------------------------------------------------------------
782874

783875
/**
@@ -792,6 +884,16 @@ public function is_ajax_request()
792884
return (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) === 'xmlhttprequest');
793885
}
794886

887+
/**
888+
* Alias To Method Above
889+
*
890+
* @return bool
891+
*/
892+
public function isAjaxRequest()
893+
{
894+
return $this->is_ajax_request();
895+
}
896+
795897
// --------------------------------------------------------------------
796898

797899
/**

0 commit comments

Comments
 (0)