code
stringlengths 17
247k
| docstring
stringlengths 30
30.3k
| func_name
stringlengths 1
89
| language
stringclasses 1
value | repo
stringlengths 7
63
| path
stringlengths 7
153
| url
stringlengths 51
209
| license
stringclasses 4
values |
---|---|---|---|---|---|---|---|
public function format_number($n = '')
{
return ($n === '') ? '' : number_format( (float) $n, 2, '.', ',');
} | Format Number
Returns the supplied number with commas and a decimal point.
@param float
@return string | format_number | php | ronknight/InventorySystem | system/libraries/Cart.php | https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Cart.php | MIT |
public function attachment_cid($filename)
{
for ($i = 0, $c = count($this->_attachments); $i < $c; $i++)
{
if ($this->_attachments[$i]['name'][0] === $filename)
{
$this->_attachments[$i]['multipart'] = 'related';
$this->_attachments[$i]['cid'] = uniqid(basename($this->_attachments[$i]['name'][0]).'@');
return $this->_attachments[$i]['cid'];
}
}
return FALSE;
} | Set and return attachment Content-ID
Useful for attached inline pictures
@param string $filename
@return string | attachment_cid | php | ronknight/InventorySystem | system/libraries/Email.php | https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Email.php | MIT |
protected function _get_content_type()
{
if ($this->mailtype === 'html')
{
return empty($this->_attachments) ? 'html' : 'html-attach';
}
elseif ($this->mailtype === 'text' && ! empty($this->_attachments))
{
return 'plain-attach';
}
else
{
return 'plain';
}
} | Get content type (text/html/attachment)
@return string | _get_content_type | php | ronknight/InventorySystem | system/libraries/Email.php | https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Email.php | MIT |
protected function _get_alt_message()
{
if ( ! empty($this->alt_message))
{
return ($this->wordwrap)
? $this->word_wrap($this->alt_message, 76)
: $this->alt_message;
}
$body = preg_match('/\<body.*?\>(.*)\<\/body\>/si', $this->_body, $match) ? $match[1] : $this->_body;
$body = str_replace("\t", '', preg_replace('#<!--(.*)--\>#', '', trim(strip_tags($body))));
for ($i = 20; $i >= 3; $i--)
{
$body = str_replace(str_repeat("\n", $i), "\n\n", $body);
}
// Reduce multiple spaces
$body = preg_replace('| +|', ' ', $body);
return ($this->wordwrap)
? $this->word_wrap($body, 76)
: $body;
} | Build alternative plain text message
Provides the raw message for use in plain-text headers of
HTML-formatted emails.
If the user hasn't specified his own alternative message
it creates one by stripping the HTML
@return string | _get_alt_message | php | ronknight/InventorySystem | system/libraries/Email.php | https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Email.php | MIT |
protected function _build_message()
{
if ($this->wordwrap === TRUE && $this->mailtype !== 'html')
{
$this->_body = $this->word_wrap($this->_body);
}
$this->_write_headers();
$hdr = ($this->_get_protocol() === 'mail') ? $this->newline : '';
$body = '';
switch ($this->_get_content_type())
{
case 'plain':
$hdr .= 'Content-Type: text/plain; charset='.$this->charset.$this->newline
.'Content-Transfer-Encoding: '.$this->_get_encoding();
if ($this->_get_protocol() === 'mail')
{
$this->_header_str .= $hdr;
$this->_finalbody = $this->_body;
}
else
{
$this->_finalbody = $hdr.$this->newline.$this->newline.$this->_body;
}
return;
case 'html':
if ($this->send_multipart === FALSE)
{
$hdr .= 'Content-Type: text/html; charset='.$this->charset.$this->newline
.'Content-Transfer-Encoding: quoted-printable';
}
else
{
$boundary = uniqid('B_ALT_');
$hdr .= 'Content-Type: multipart/alternative; boundary="'.$boundary.'"';
$body .= $this->_get_mime_message().$this->newline.$this->newline
.'--'.$boundary.$this->newline
.'Content-Type: text/plain; charset='.$this->charset.$this->newline
.'Content-Transfer-Encoding: '.$this->_get_encoding().$this->newline.$this->newline
.$this->_get_alt_message().$this->newline.$this->newline
.'--'.$boundary.$this->newline
.'Content-Type: text/html; charset='.$this->charset.$this->newline
.'Content-Transfer-Encoding: quoted-printable'.$this->newline.$this->newline;
}
$this->_finalbody = $body.$this->_prep_quoted_printable($this->_body).$this->newline.$this->newline;
if ($this->_get_protocol() === 'mail')
{
$this->_header_str .= $hdr;
}
else
{
$this->_finalbody = $hdr.$this->newline.$this->newline.$this->_finalbody;
}
if ($this->send_multipart !== FALSE)
{
$this->_finalbody .= '--'.$boundary.'--';
}
return;
case 'plain-attach':
$boundary = uniqid('B_ATC_');
$hdr .= 'Content-Type: multipart/mixed; boundary="'.$boundary.'"';
if ($this->_get_protocol() === 'mail')
{
$this->_header_str .= $hdr;
}
$body .= $this->_get_mime_message().$this->newline
.$this->newline
.'--'.$boundary.$this->newline
.'Content-Type: text/plain; charset='.$this->charset.$this->newline
.'Content-Transfer-Encoding: '.$this->_get_encoding().$this->newline
.$this->newline
.$this->_body.$this->newline.$this->newline;
$this->_append_attachments($body, $boundary);
break;
case 'html-attach':
$alt_boundary = uniqid('B_ALT_');
$last_boundary = NULL;
if ($this->_attachments_have_multipart('mixed'))
{
$atc_boundary = uniqid('B_ATC_');
$hdr .= 'Content-Type: multipart/mixed; boundary="'.$atc_boundary.'"';
$last_boundary = $atc_boundary;
}
if ($this->_attachments_have_multipart('related'))
{
$rel_boundary = uniqid('B_REL_');
$rel_boundary_header = 'Content-Type: multipart/related; boundary="'.$rel_boundary.'"';
if (isset($last_boundary))
{
$body .= '--'.$last_boundary.$this->newline.$rel_boundary_header;
}
else
{
$hdr .= $rel_boundary_header;
}
$last_boundary = $rel_boundary;
}
if ($this->_get_protocol() === 'mail')
{
$this->_header_str .= $hdr;
}
self::strlen($body) && $body .= $this->newline.$this->newline;
$body .= $this->_get_mime_message().$this->newline.$this->newline
.'--'.$last_boundary.$this->newline
.'Content-Type: multipart/alternative; boundary="'.$alt_boundary.'"'.$this->newline.$this->newline
.'--'.$alt_boundary.$this->newline
.'Content-Type: text/plain; charset='.$this->charset.$this->newline
.'Content-Transfer-Encoding: '.$this->_get_encoding().$this->newline.$this->newline
.$this->_get_alt_message().$this->newline.$this->newline
.'--'.$alt_boundary.$this->newline
.'Content-Type: text/html; charset='.$this->charset.$this->newline
.'Content-Transfer-Encoding: quoted-printable'.$this->newline.$this->newline
.$this->_prep_quoted_printable($this->_body).$this->newline.$this->newline
.'--'.$alt_boundary.'--'.$this->newline.$this->newline;
if ( ! empty($rel_boundary))
{
$body .= $this->newline.$this->newline;
$this->_append_attachments($body, $rel_boundary, 'related');
}
// multipart/mixed attachments
if ( ! empty($atc_boundary))
{
$body .= $this->newline.$this->newline;
$this->_append_attachments($body, $atc_boundary, 'mixed');
}
break;
}
$this->_finalbody = ($this->_get_protocol() === 'mail')
? $body
: $hdr.$this->newline.$this->newline.$body;
return TRUE;
} | Build Final Body and attachments
@return bool | _build_message | php | ronknight/InventorySystem | system/libraries/Email.php | https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Email.php | MIT |
public function batch_bcc_send()
{
$float = $this->bcc_batch_size - 1;
$set = '';
$chunk = array();
for ($i = 0, $c = count($this->_bcc_array); $i < $c; $i++)
{
if (isset($this->_bcc_array[$i]))
{
$set .= ', '.$this->_bcc_array[$i];
}
if ($i === $float)
{
$chunk[] = self::substr($set, 1);
$float += $this->bcc_batch_size;
$set = '';
}
if ($i === $c-1)
{
$chunk[] = self::substr($set, 1);
}
}
for ($i = 0, $c = count($chunk); $i < $c; $i++)
{
unset($this->_headers['Bcc']);
$bcc = $this->clean_email($this->_str_to_array($chunk[$i]));
if ($this->protocol !== 'smtp')
{
$this->set_header('Bcc', implode(', ', $bcc));
}
else
{
$this->_bcc_array = $bcc;
}
if ($this->_build_message() === FALSE)
{
return FALSE;
}
$this->_spool_email();
}
} | Batch Bcc Send. Sends groups of BCCs in batches
@return void | batch_bcc_send | php | ronknight/InventorySystem | system/libraries/Email.php | https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Email.php | MIT |
protected function _remove_nl_callback($matches)
{
if (strpos($matches[1], "\r") !== FALSE OR strpos($matches[1], "\n") !== FALSE)
{
$matches[1] = str_replace(array("\r\n", "\r", "\n"), '', $matches[1]);
}
return $matches[1];
} | Strip line-breaks via callback
@param string $matches
@return string | _remove_nl_callback | php | ronknight/InventorySystem | system/libraries/Email.php | https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Email.php | MIT |
protected function _validate_email_for_shell(&$email)
{
if (function_exists('idn_to_ascii') && $atpos = strpos($email, '@'))
{
$email = self::substr($email, 0, ++$atpos).idn_to_ascii(self::substr($email, $atpos));
}
return (filter_var($email, FILTER_VALIDATE_EMAIL) === $email && preg_match('#\A[a-z0-9._+-]+@[a-z0-9.-]{1,253}\z#i', $email));
} | Validate email for shell
Applies stricter, shell-safe validation to email addresses.
Introduced to prevent RCE via sendmail's -f option.
@see https://github.com/bcit-ci/CodeIgniter/issues/4963
@see https://gist.github.com/Zenexer/40d02da5e07f151adeaeeaa11af9ab36
@license https://creativecommons.org/publicdomain/zero/1.0/ CC0 1.0, Public Domain
Credits for the base concept go to Paul Buonopane <[email protected]>
@param string $email
@return bool | _validate_email_for_shell | php | ronknight/InventorySystem | system/libraries/Email.php | https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Email.php | MIT |
protected function _smtp_end()
{
($this->smtp_keepalive)
? $this->_send_command('reset')
: $this->_send_command('quit');
} | SMTP End
Shortcut to send RSET or QUIT depending on keep-alive
@return void | _smtp_end | php | ronknight/InventorySystem | system/libraries/Email.php | https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Email.php | MIT |
protected function _get_hostname()
{
if (isset($_SERVER['SERVER_NAME']))
{
return $_SERVER['SERVER_NAME'];
}
return isset($_SERVER['SERVER_ADDR']) ? '['.$_SERVER['SERVER_ADDR'].']' : '[127.0.0.1]';
} | Get Hostname
There are only two legal types of hostname - either a fully
qualified domain name (eg: "mail.example.com") or an IP literal
(eg: "[1.2.3.4]").
@link https://tools.ietf.org/html/rfc5321#section-2.3.5
@link http://cbl.abuseat.org/namingproblems.html
@return string | _get_hostname | php | ronknight/InventorySystem | system/libraries/Email.php | https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Email.php | MIT |
public function __construct()
{
isset(self::$func_overload) OR self::$func_overload = (extension_loaded('mbstring') && ini_get('mbstring.func_overload'));
$this->now = time();
log_message('info', 'Zip Compression Class Initialized');
} | Initialize zip compression class
@return void | __construct | php | ronknight/InventorySystem | system/libraries/Zip.php | https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Zip.php | MIT |
protected function _get_mod_time($dir)
{
// filemtime() may return false, but raises an error for non-existing files
$date = file_exists($dir) ? getdate(filemtime($dir)) : getdate($this->now);
return array(
'file_mtime' => ($date['hours'] << 11) + ($date['minutes'] << 5) + $date['seconds'] / 2,
'file_mdate' => (($date['year'] - 1980) << 9) + ($date['mon'] << 5) + $date['mday']
);
} | Get file/directory modification time
If this is a newly created file/dir, we will set the time to 'now'
@param string $dir path to file
@return array filemtime/filemdate | _get_mod_time | php | ronknight/InventorySystem | system/libraries/Zip.php | https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Zip.php | MIT |
public function read_file($path, $archive_filepath = FALSE)
{
if (file_exists($path) && FALSE !== ($data = file_get_contents($path)))
{
if (is_string($archive_filepath))
{
$name = str_replace('\\', '/', $archive_filepath);
}
else
{
$name = str_replace('\\', '/', $path);
if ($archive_filepath === FALSE)
{
$name = preg_replace('|.*/(.+)|', '\\1', $name);
}
}
$this->add_data($name, $data);
return TRUE;
}
return FALSE;
} | Read the contents of a file and add it to the zip
@param string $path
@param bool $archive_filepath
@return bool | read_file | php | ronknight/InventorySystem | system/libraries/Zip.php | https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Zip.php | MIT |
public function archive($filepath)
{
if ( ! ($fp = @fopen($filepath, 'w+b')))
{
return FALSE;
}
flock($fp, LOCK_EX);
for ($result = $written = 0, $data = $this->get_zip(), $length = self::strlen($data); $written < $length; $written += $result)
{
if (($result = fwrite($fp, self::substr($data, $written))) === FALSE)
{
break;
}
}
flock($fp, LOCK_UN);
fclose($fp);
return is_int($result);
} | Write File to the specified directory
Lets you write a file
@param string $filepath the file name
@return bool | archive | php | ronknight/InventorySystem | system/libraries/Zip.php | https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Zip.php | MIT |
public function clear_data()
{
$this->zipdata = '';
$this->directory = '';
$this->entries = 0;
$this->file_num = 0;
$this->offset = 0;
return $this;
} | Initialize Data
Lets you clear current zip data. Useful if you need to create
multiple zips with different data.
@return CI_Zip | clear_data | php | ronknight/InventorySystem | system/libraries/Zip.php | https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Zip.php | MIT |
protected function _cipher_alias(&$cipher)
{
static $dictionary;
if (empty($dictionary))
{
$dictionary = array(
'mcrypt' => array(
'aes-128' => 'rijndael-128',
'aes-192' => 'rijndael-128',
'aes-256' => 'rijndael-128',
'des3-ede3' => 'tripledes',
'bf' => 'blowfish',
'cast5' => 'cast-128',
'rc4' => 'arcfour',
'rc4-40' => 'arcfour'
),
'openssl' => array(
'rijndael-128' => 'aes-128',
'tripledes' => 'des-ede3',
'blowfish' => 'bf',
'cast-128' => 'cast5',
'arcfour' => 'rc4-40',
'rc4' => 'rc4-40'
)
);
// Notes:
//
// - Rijndael-128 is, at the same time all three of AES-128,
// AES-192 and AES-256. The only difference between them is
// the key size. Rijndael-192, Rijndael-256 on the other hand
// also have different block sizes and are NOT AES-compatible.
//
// - Blowfish is said to be supporting key sizes between
// 4 and 56 bytes, but it appears that between MCrypt and
// OpenSSL, only those of 16 and more bytes are compatible.
// Also, don't know what MCrypt's 'blowfish-compat' is.
//
// - CAST-128/CAST5 produces a longer cipher when encrypted via
// OpenSSL, but (strangely enough) can be decrypted by either
// extension anyway.
// Also, it appears that OpenSSL uses 16 rounds regardless of
// the key size, while RFC2144 says that for key sizes lower
// than 11 bytes, only 12 rounds should be used. This makes
// it portable only with keys of between 11 and 16 bytes.
//
// - RC4 (ARCFour) has a strange implementation under OpenSSL.
// Its 'rc4-40' cipher method seems to work flawlessly, yet
// there's another one, 'rc4' that only works with a 16-byte key.
//
// - DES is compatible, but doesn't need an alias.
//
// Other seemingly matching ciphers between MCrypt, OpenSSL:
//
// - RC2 is NOT compatible and only an obscure forum post
// confirms that it is MCrypt's fault.
}
if (isset($dictionary[$this->_driver][$cipher]))
{
$cipher = $dictionary[$this->_driver][$cipher];
}
} | Cipher alias
Tries to translate cipher names between MCrypt and OpenSSL's "dialects".
@param string $cipher Cipher name
@return void | _cipher_alias | php | ronknight/InventorySystem | system/libraries/Encryption.php | https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Encryption.php | MIT |
public function __construct()
{
$this->_load_agent_file();
if (isset($_SERVER['HTTP_USER_AGENT']))
{
$this->agent = trim($_SERVER['HTTP_USER_AGENT']);
$this->_compile_data();
}
log_message('info', 'User Agent Class Initialized');
} | Constructor
Sets the User Agent and runs the compilation routine
@return void | __construct | php | ronknight/InventorySystem | system/libraries/User_agent.php | https://github.com/ronknight/InventorySystem/blob/master/system/libraries/User_agent.php | MIT |
protected function _set_charsets()
{
if ((count($this->charsets) === 0) && ! empty($_SERVER['HTTP_ACCEPT_CHARSET']))
{
$this->charsets = explode(',', preg_replace('/(;\s?q=.+)|\s/i', '', strtolower(trim($_SERVER['HTTP_ACCEPT_CHARSET']))));
}
if (count($this->charsets) === 0)
{
$this->charsets = array('Undefined');
}
} | Set the accepted character sets
@return void | _set_charsets | php | ronknight/InventorySystem | system/libraries/User_agent.php | https://github.com/ronknight/InventorySystem/blob/master/system/libraries/User_agent.php | MIT |
public function is_referral()
{
if ( ! isset($this->referer))
{
if (empty($_SERVER['HTTP_REFERER']))
{
$this->referer = FALSE;
}
else
{
$referer_host = @parse_url($_SERVER['HTTP_REFERER'], PHP_URL_HOST);
$own_host = parse_url(config_item('base_url'), PHP_URL_HOST);
$this->referer = ($referer_host && $referer_host !== $own_host);
}
}
return $this->referer;
} | Is this a referral from another site?
@return bool | is_referral | php | ronknight/InventorySystem | system/libraries/User_agent.php | https://github.com/ronknight/InventorySystem/blob/master/system/libraries/User_agent.php | MIT |
public function charsets()
{
if (count($this->charsets) === 0)
{
$this->_set_charsets();
}
return $this->charsets;
} | Get the accepted Character Sets
@return array | charsets | php | ronknight/InventorySystem | system/libraries/User_agent.php | https://github.com/ronknight/InventorySystem/blob/master/system/libraries/User_agent.php | MIT |
public function accept_lang($lang = 'en')
{
return in_array(strtolower($lang), $this->languages(), TRUE);
} | Test for a particular language
@param string $lang
@return bool | accept_lang | php | ronknight/InventorySystem | system/libraries/User_agent.php | https://github.com/ronknight/InventorySystem/blob/master/system/libraries/User_agent.php | MIT |
public function accept_charset($charset = 'utf-8')
{
return in_array(strtolower($charset), $this->charsets(), TRUE);
} | Test for a particular character set
@param string $charset
@return bool | accept_charset | php | ronknight/InventorySystem | system/libraries/User_agent.php | https://github.com/ronknight/InventorySystem/blob/master/system/libraries/User_agent.php | MIT |
public function parse($string)
{
// Reset values
$this->is_browser = FALSE;
$this->is_robot = FALSE;
$this->is_mobile = FALSE;
$this->browser = '';
$this->version = '';
$this->mobile = '';
$this->robot = '';
// Set the new user-agent string and parse it, unless empty
$this->agent = $string;
if ( ! empty($string))
{
$this->_compile_data();
}
} | Parse a custom user-agent string
@param string $string
@return void | parse | php | ronknight/InventorySystem | system/libraries/User_agent.php | https://github.com/ronknight/InventorySystem/blob/master/system/libraries/User_agent.php | MIT |
public function send_error($message = 'Incomplete Information')
{
exit('<?xml version="1.0" encoding="utf-8"?'.">\n<response>\n<error>1</error>\n<message>".$message."</message>\n</response>");
} | Send Trackback Error Message
Allows custom errors to be set. By default it
sends the "incomplete information" error, as that's
the most common one.
@param string
@return void | send_error | php | ronknight/InventorySystem | system/libraries/Trackback.php | https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Trackback.php | MIT |
public function send_success()
{
exit('<?xml version="1.0" encoding="utf-8"?'.">\n<response>\n<error>0</error>\n</response>");
} | Send Trackback Success Message
This should be called when a trackback has been
successfully received and inserted.
@return void | send_success | php | ronknight/InventorySystem | system/libraries/Trackback.php | https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Trackback.php | MIT |
public function process($url, $data)
{
$target = parse_url($url);
// Open the socket
if ( ! $fp = @fsockopen($target['host'], 80))
{
$this->set_error('Invalid Connection: '.$url);
return FALSE;
}
// Build the path
$path = isset($target['path']) ? $target['path'] : $url;
empty($target['query']) OR $path .= '?'.$target['query'];
// Add the Trackback ID to the data string
if ($id = $this->get_id($url))
{
$data = 'tb_id='.$id.'&'.$data;
}
// Transfer the data
fputs($fp, 'POST '.$path." HTTP/1.0\r\n");
fputs($fp, 'Host: '.$target['host']."\r\n");
fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n");
fputs($fp, 'Content-length: '.strlen($data)."\r\n");
fputs($fp, "Connection: close\r\n\r\n");
fputs($fp, $data);
// Was it successful?
$this->response = '';
while ( ! feof($fp))
{
$this->response .= fgets($fp, 128);
}
@fclose($fp);
if (stripos($this->response, '<error>0</error>') === FALSE)
{
$message = preg_match('/<message>(.*?)<\/message>/is', $this->response, $match)
? trim($match[1])
: 'An unknown error was encountered';
$this->set_error($message);
return FALSE;
}
return TRUE;
} | Process Trackback
Opens a socket connection and passes the data to
the server. Returns TRUE on success, FALSE on failure
@param string
@param string
@return bool | process | php | ronknight/InventorySystem | system/libraries/Trackback.php | https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Trackback.php | MIT |
public function extract_urls($urls)
{
// Remove the pesky white space and replace with a comma, then replace doubles.
$urls = str_replace(',,', ',', preg_replace('/\s*(\S+)\s*/', '\\1,', $urls));
// Break into an array via commas and remove duplicates
$urls = array_unique(preg_split('/[,]/', rtrim($urls, ',')));
array_walk($urls, array($this, 'validate_url'));
return $urls;
} | Extract Trackback URLs
This function lets multiple trackbacks be sent.
It takes a string of URLs (separated by comma or
space) and puts each URL into an array
@param string
@return string | extract_urls | php | ronknight/InventorySystem | system/libraries/Trackback.php | https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Trackback.php | MIT |
public function validate_url(&$url)
{
$url = trim($url);
if (stripos($url, 'http') !== 0)
{
$url = 'http://'.$url;
}
} | Validate URL
Simply adds "http://" if missing
@param string
@return void | validate_url | php | ronknight/InventorySystem | system/libraries/Trackback.php | https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Trackback.php | MIT |
public function convert_xml($str)
{
$temp = '__TEMP_AMPERSANDS__';
$str = preg_replace(array('/&#(\d+);/', '/&(\w+);/'), $temp.'\\1;', $str);
$str = str_replace(array('&', '<', '>', '"', "'", '-'),
array('&', '<', '>', '"', ''', '-'),
$str);
return preg_replace(array('/'.$temp.'(\d+);/', '/'.$temp.'(\w+);/'), array('&#\\1;', '&\\1;'), $str);
} | Convert Reserved XML characters to Entities
@param string
@return string | convert_xml | php | ronknight/InventorySystem | system/libraries/Trackback.php | https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Trackback.php | MIT |
public function limit_characters($str, $n = 500, $end_char = '…')
{
if (strlen($str) < $n)
{
return $str;
}
$str = preg_replace('/\s+/', ' ', str_replace(array("\r\n", "\r", "\n"), ' ', $str));
if (strlen($str) <= $n)
{
return $str;
}
$out = '';
foreach (explode(' ', trim($str)) as $val)
{
$out .= $val.' ';
if (strlen($out) >= $n)
{
return rtrim($out).$end_char;
}
}
} | Character limiter
Limits the string based on the character count. Will preserve complete words.
@param string
@param int
@param string
@return string | limit_characters | php | ronknight/InventorySystem | system/libraries/Trackback.php | https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Trackback.php | MIT |
public function convert_ascii($str)
{
$count = 1;
$out = '';
$temp = array();
for ($i = 0, $s = strlen($str); $i < $s; $i++)
{
$ordinal = ord($str[$i]);
if ($ordinal < 128)
{
$out .= $str[$i];
}
else
{
if (count($temp) === 0)
{
$count = ($ordinal < 224) ? 2 : 3;
}
$temp[] = $ordinal;
if (count($temp) === $count)
{
$number = ($count === 3)
? (($temp[0] % 16) * 4096) + (($temp[1] % 64) * 64) + ($temp[2] % 64)
: (($temp[0] % 32) * 64) + ($temp[1] % 64);
$out .= '&#'.$number.';';
$count = 1;
$temp = array();
}
}
}
return $out;
} | High ASCII to Entities
Converts Hight ascii text and MS Word special chars
to character entities
@param string
@return string | convert_ascii | php | ronknight/InventorySystem | system/libraries/Trackback.php | https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Trackback.php | MIT |
public function clear()
{
$props = array('thumb_marker', 'library_path', 'source_image', 'new_image', 'width', 'height', 'rotation_angle', 'x_axis', 'y_axis', 'wm_text', 'wm_overlay_path', 'wm_font_path', 'wm_shadow_color', 'source_folder', 'dest_folder', 'mime_type', 'orig_width', 'orig_height', 'image_type', 'size_str', 'full_src_path', 'full_dst_path');
foreach ($props as $val)
{
$this->$val = '';
}
$this->image_library = 'gd2';
$this->dynamic_output = FALSE;
$this->quality = 90;
$this->create_thumb = FALSE;
$this->thumb_marker = '_thumb';
$this->maintain_ratio = TRUE;
$this->master_dim = 'auto';
$this->wm_type = 'text';
$this->wm_x_transp = 4;
$this->wm_y_transp = 4;
$this->wm_font_size = 17;
$this->wm_vrt_alignment = 'B';
$this->wm_hor_alignment = 'C';
$this->wm_padding = 0;
$this->wm_hor_offset = 0;
$this->wm_vrt_offset = 0;
$this->wm_font_color = '#ffffff';
$this->wm_shadow_distance = 2;
$this->wm_opacity = 50;
$this->create_fnc = 'imagecreatetruecolor';
$this->copy_fnc = 'imagecopyresampled';
$this->error_msg = array();
$this->wm_use_drop_shadow = FALSE;
$this->wm_use_truetype = FALSE;
} | Initialize image properties
Resets values in case this class is used in a loop
@return void | clear | php | ronknight/InventorySystem | system/libraries/Image_lib.php | https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Image_lib.php | MIT |
public function resize()
{
$protocol = ($this->image_library === 'gd2') ? 'image_process_gd' : 'image_process_'.$this->image_library;
return $this->$protocol('resize');
} | Image Resize
This is a wrapper function that chooses the proper
resize function based on the protocol specified
@return bool | resize | php | ronknight/InventorySystem | system/libraries/Image_lib.php | https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Image_lib.php | MIT |
public function crop()
{
$protocol = ($this->image_library === 'gd2') ? 'image_process_gd' : 'image_process_'.$this->image_library;
return $this->$protocol('crop');
} | Image Crop
This is a wrapper function that chooses the proper
cropping function based on the protocol specified
@return bool | crop | php | ronknight/InventorySystem | system/libraries/Image_lib.php | https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Image_lib.php | MIT |
public function rotate()
{
// Allowed rotation values
$degs = array(90, 180, 270, 'vrt', 'hor');
if ($this->rotation_angle === '' OR ! in_array($this->rotation_angle, $degs))
{
$this->set_error('imglib_rotation_angle_required');
return FALSE;
}
// Reassign the width and height
if ($this->rotation_angle === 90 OR $this->rotation_angle === 270)
{
$this->width = $this->orig_height;
$this->height = $this->orig_width;
}
else
{
$this->width = $this->orig_width;
$this->height = $this->orig_height;
}
// Choose resizing function
if ($this->image_library === 'imagemagick' OR $this->image_library === 'netpbm')
{
$protocol = 'image_process_'.$this->image_library;
return $this->$protocol('rotate');
}
return ($this->rotation_angle === 'hor' OR $this->rotation_angle === 'vrt')
? $this->image_mirror_gd()
: $this->image_rotate_gd();
} | Image Rotate
This is a wrapper function that chooses the proper
rotation function based on the protocol specified
@return bool | rotate | php | ronknight/InventorySystem | system/libraries/Image_lib.php | https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Image_lib.php | MIT |
public function image_process_gd($action = 'resize')
{
$v2_override = FALSE;
// If the target width/height match the source, AND if the new file name is not equal to the old file name
// we'll simply make a copy of the original with the new name... assuming dynamic rendering is off.
if ($this->dynamic_output === FALSE && $this->orig_width === $this->width && $this->orig_height === $this->height)
{
if ($this->source_image !== $this->new_image && @copy($this->full_src_path, $this->full_dst_path))
{
chmod($this->full_dst_path, $this->file_permissions);
}
return TRUE;
}
// Let's set up our values based on the action
if ($action === 'crop')
{
// Reassign the source width/height if cropping
$this->orig_width = $this->width;
$this->orig_height = $this->height;
// GD 2.0 has a cropping bug so we'll test for it
if ($this->gd_version() !== FALSE)
{
$gd_version = str_replace('0', '', $this->gd_version());
$v2_override = ($gd_version == 2);
}
}
else
{
// If resizing the x/y axis must be zero
$this->x_axis = 0;
$this->y_axis = 0;
}
// Create the image handle
if ( ! ($src_img = $this->image_create_gd()))
{
return FALSE;
}
/* Create the image
*
* Old conditional which users report cause problems with shared GD libs who report themselves as "2.0 or greater"
* it appears that this is no longer the issue that it was in 2004, so we've removed it, retaining it in the comment
* below should that ever prove inaccurate.
*
* if ($this->image_library === 'gd2' && function_exists('imagecreatetruecolor') && $v2_override === FALSE)
*/
if ($this->image_library === 'gd2' && function_exists('imagecreatetruecolor'))
{
$create = 'imagecreatetruecolor';
$copy = 'imagecopyresampled';
}
else
{
$create = 'imagecreate';
$copy = 'imagecopyresized';
}
$dst_img = $create($this->width, $this->height);
if ($this->image_type === 3) // png we can actually preserve transparency
{
imagealphablending($dst_img, FALSE);
imagesavealpha($dst_img, TRUE);
}
$copy($dst_img, $src_img, 0, 0, $this->x_axis, $this->y_axis, $this->width, $this->height, $this->orig_width, $this->orig_height);
// Show the image
if ($this->dynamic_output === TRUE)
{
$this->image_display_gd($dst_img);
}
elseif ( ! $this->image_save_gd($dst_img)) // Or save it
{
return FALSE;
}
// Kill the file handles
imagedestroy($dst_img);
imagedestroy($src_img);
chmod($this->full_dst_path, $this->file_permissions);
return TRUE;
} | Image Process Using GD/GD2
This function will resize or crop
@param string
@return bool | image_process_gd | php | ronknight/InventorySystem | system/libraries/Image_lib.php | https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Image_lib.php | MIT |
public function image_process_netpbm($action = 'resize')
{
if ($this->library_path === '')
{
$this->set_error('imglib_libpath_invalid');
return FALSE;
}
// Build the resizing command
switch ($this->image_type)
{
case 1 :
$cmd_in = 'giftopnm';
$cmd_out = 'ppmtogif';
break;
case 2 :
$cmd_in = 'jpegtopnm';
$cmd_out = 'ppmtojpeg';
break;
case 3 :
$cmd_in = 'pngtopnm';
$cmd_out = 'ppmtopng';
break;
}
if ($action === 'crop')
{
$cmd_inner = 'pnmcut -left '.$this->x_axis.' -top '.$this->y_axis.' -width '.$this->width.' -height '.$this->height;
}
elseif ($action === 'rotate')
{
switch ($this->rotation_angle)
{
case 90: $angle = 'r270';
break;
case 180: $angle = 'r180';
break;
case 270: $angle = 'r90';
break;
case 'vrt': $angle = 'tb';
break;
case 'hor': $angle = 'lr';
break;
}
$cmd_inner = 'pnmflip -'.$angle.' ';
}
else // Resize
{
$cmd_inner = 'pnmscale -xysize '.$this->width.' '.$this->height;
}
$cmd = $this->library_path.$cmd_in.' '.escapeshellarg($this->full_src_path).' | '.$cmd_inner.' | '.$cmd_out.' > '.$this->dest_folder.'netpbm.tmp';
$retval = 1;
// exec() might be disabled
if (function_usable('exec'))
{
@exec($cmd, $output, $retval);
}
// Did it work?
if ($retval > 0)
{
$this->set_error('imglib_image_process_failed');
return FALSE;
}
// With NetPBM we have to create a temporary image.
// If you try manipulating the original it fails so
// we have to rename the temp file.
copy($this->dest_folder.'netpbm.tmp', $this->full_dst_path);
unlink($this->dest_folder.'netpbm.tmp');
chmod($this->full_dst_path, $this->file_permissions);
return TRUE;
} | Image Process Using NetPBM
This function will resize, crop or rotate
@param string
@return bool | image_process_netpbm | php | ronknight/InventorySystem | system/libraries/Image_lib.php | https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Image_lib.php | MIT |
public function image_mirror_gd()
{
if ( ! $src_img = $this->image_create_gd())
{
return FALSE;
}
$width = $this->orig_width;
$height = $this->orig_height;
if ($this->rotation_angle === 'hor')
{
for ($i = 0; $i < $height; $i++)
{
$left = 0;
$right = $width - 1;
while ($left < $right)
{
$cl = imagecolorat($src_img, $left, $i);
$cr = imagecolorat($src_img, $right, $i);
imagesetpixel($src_img, $left, $i, $cr);
imagesetpixel($src_img, $right, $i, $cl);
$left++;
$right--;
}
}
}
else
{
for ($i = 0; $i < $width; $i++)
{
$top = 0;
$bottom = $height - 1;
while ($top < $bottom)
{
$ct = imagecolorat($src_img, $i, $top);
$cb = imagecolorat($src_img, $i, $bottom);
imagesetpixel($src_img, $i, $top, $cb);
imagesetpixel($src_img, $i, $bottom, $ct);
$top++;
$bottom--;
}
}
}
// Show the image
if ($this->dynamic_output === TRUE)
{
$this->image_display_gd($src_img);
}
elseif ( ! $this->image_save_gd($src_img)) // ... or save it
{
return FALSE;
}
// Kill the file handles
imagedestroy($src_img);
chmod($this->full_dst_path, $this->file_permissions);
return TRUE;
} | Create Mirror Image using GD
This function will flip horizontal or vertical
@return bool | image_mirror_gd | php | ronknight/InventorySystem | system/libraries/Image_lib.php | https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Image_lib.php | MIT |
public function watermark()
{
return ($this->wm_type === 'overlay') ? $this->overlay_watermark() : $this->text_watermark();
} | Image Watermark
This is a wrapper function that chooses the type
of watermarking based on the specified preference.
@return bool | watermark | php | ronknight/InventorySystem | system/libraries/Image_lib.php | https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Image_lib.php | MIT |
public function image_create_gd($path = '', $image_type = '')
{
if ($path === '')
{
$path = $this->full_src_path;
}
if ($image_type === '')
{
$image_type = $this->image_type;
}
switch ($image_type)
{
case 1:
if ( ! function_exists('imagecreatefromgif'))
{
$this->set_error(array('imglib_unsupported_imagecreate', 'imglib_gif_not_supported'));
return FALSE;
}
return imagecreatefromgif($path);
case 2:
if ( ! function_exists('imagecreatefromjpeg'))
{
$this->set_error(array('imglib_unsupported_imagecreate', 'imglib_jpg_not_supported'));
return FALSE;
}
return imagecreatefromjpeg($path);
case 3:
if ( ! function_exists('imagecreatefrompng'))
{
$this->set_error(array('imglib_unsupported_imagecreate', 'imglib_png_not_supported'));
return FALSE;
}
return imagecreatefrompng($path);
default:
$this->set_error(array('imglib_unsupported_imagecreate'));
return FALSE;
}
} | Create Image - GD
This simply creates an image resource handle
based on the type of image being processed
@param string
@param string
@return resource | image_create_gd | php | ronknight/InventorySystem | system/libraries/Image_lib.php | https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Image_lib.php | MIT |
public function image_save_gd($resource)
{
switch ($this->image_type)
{
case 1:
if ( ! function_exists('imagegif'))
{
$this->set_error(array('imglib_unsupported_imagecreate', 'imglib_gif_not_supported'));
return FALSE;
}
if ( ! @imagegif($resource, $this->full_dst_path))
{
$this->set_error('imglib_save_failed');
return FALSE;
}
break;
case 2:
if ( ! function_exists('imagejpeg'))
{
$this->set_error(array('imglib_unsupported_imagecreate', 'imglib_jpg_not_supported'));
return FALSE;
}
if ( ! @imagejpeg($resource, $this->full_dst_path, $this->quality))
{
$this->set_error('imglib_save_failed');
return FALSE;
}
break;
case 3:
if ( ! function_exists('imagepng'))
{
$this->set_error(array('imglib_unsupported_imagecreate', 'imglib_png_not_supported'));
return FALSE;
}
if ( ! @imagepng($resource, $this->full_dst_path))
{
$this->set_error('imglib_save_failed');
return FALSE;
}
break;
default:
$this->set_error(array('imglib_unsupported_imagecreate'));
return FALSE;
break;
}
return TRUE;
} | Write image file to disk - GD
Takes an image resource as input and writes the file
to the specified destination
@param resource
@return bool | image_save_gd | php | ronknight/InventorySystem | system/libraries/Image_lib.php | https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Image_lib.php | MIT |
public function image_reproportion()
{
if (($this->width === 0 && $this->height === 0) OR $this->orig_width === 0 OR $this->orig_height === 0
OR ( ! ctype_digit((string) $this->width) && ! ctype_digit((string) $this->height))
OR ! ctype_digit((string) $this->orig_width) OR ! ctype_digit((string) $this->orig_height))
{
return;
}
// Sanitize
$this->width = (int) $this->width;
$this->height = (int) $this->height;
if ($this->master_dim !== 'width' && $this->master_dim !== 'height')
{
if ($this->width > 0 && $this->height > 0)
{
$this->master_dim = ((($this->orig_height/$this->orig_width) - ($this->height/$this->width)) < 0)
? 'width' : 'height';
}
else
{
$this->master_dim = ($this->height === 0) ? 'width' : 'height';
}
}
elseif (($this->master_dim === 'width' && $this->width === 0)
OR ($this->master_dim === 'height' && $this->height === 0))
{
return;
}
if ($this->master_dim === 'width')
{
$this->height = (int) ceil($this->width*$this->orig_height/$this->orig_width);
}
else
{
$this->width = (int) ceil($this->orig_width*$this->height/$this->orig_height);
}
} | Re-proportion Image Width/Height
When creating thumbs, the desired width/height
can end up warping the image due to an incorrect
ratio between the full-sized image and the thumb.
This function lets us re-proportion the width/height
if users choose to maintain the aspect ratio when resizing.
@return void | image_reproportion | php | ronknight/InventorySystem | system/libraries/Image_lib.php | https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Image_lib.php | MIT |
public function get($id)
{
return $this->{$this->_adapter}->get($this->key_prefix.$id);
} | Get
Look for a value in the cache. If it exists, return the data
if not, return FALSE
@param string $id
@return mixed value matching $id or FALSE on failure | get | php | ronknight/InventorySystem | system/libraries/Cache/Cache.php | https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Cache/Cache.php | MIT |
public function is_supported($driver)
{
static $support;
if ( ! isset($support, $support[$driver]))
{
$support[$driver] = $this->{$driver}->is_supported();
}
return $support[$driver];
} | Is the requested driver supported in this environment?
@param string $driver The driver to test
@return array | is_supported | php | ronknight/InventorySystem | system/libraries/Cache/Cache.php | https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Cache/Cache.php | MIT |
public function __construct()
{
if ( ! $this->is_supported())
{
log_message('error', 'Cache: Failed to initialize Wincache; extension not loaded/enabled?');
}
} | Class constructor
Only present so that an error message is logged
if APC is not available.
@return void | __construct | php | ronknight/InventorySystem | system/libraries/Cache/drivers/Cache_wincache.php | https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Cache/drivers/Cache_wincache.php | MIT |
public function get($id)
{
$success = FALSE;
$data = wincache_ucache_get($id, $success);
// Success returned by reference from wincache_ucache_get()
return ($success) ? $data : FALSE;
} | Get
Look for a value in the cache. If it exists, return the data,
if not, return FALSE
@param string $id Cache Ide
@return mixed Value that is stored/FALSE on failure | get | php | ronknight/InventorySystem | system/libraries/Cache/drivers/Cache_wincache.php | https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Cache/drivers/Cache_wincache.php | MIT |
public function is_supported()
{
return (extension_loaded('wincache') && ini_get('wincache.ucenabled'));
} | is_supported()
Check to see if WinCache is available on this system, bail if it isn't.
@return bool | is_supported | php | ronknight/InventorySystem | system/libraries/Cache/drivers/Cache_wincache.php | https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Cache/drivers/Cache_wincache.php | MIT |
public function is_supported()
{
return (extension_loaded('memcached') OR extension_loaded('memcache'));
} | Is supported
Returns FALSE if memcached is not supported on the system.
If it is, we setup the memcached object & return TRUE
@return bool | is_supported | php | ronknight/InventorySystem | system/libraries/Cache/drivers/Cache_memcached.php | https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Cache/drivers/Cache_memcached.php | MIT |
public function get($id)
{
return FALSE;
} | Get
Since this is the dummy class, it's always going to return FALSE.
@param string
@return bool FALSE | get | php | ronknight/InventorySystem | system/libraries/Cache/drivers/Cache_dummy.php | https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Cache/drivers/Cache_dummy.php | MIT |
public function is_supported()
{
return TRUE;
} | Is this caching driver supported on the system?
Of course this one is.
@return bool TRUE | is_supported | php | ronknight/InventorySystem | system/libraries/Cache/drivers/Cache_dummy.php | https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Cache/drivers/Cache_dummy.php | MIT |
public function get($id)
{
$success = FALSE;
$data = apc_fetch($id, $success);
return ($success === TRUE) ? $data : FALSE;
} | Get
Look for a value in the cache. If it exists, return the data
if not, return FALSE
@param string
@return mixed value that is stored/FALSE on failure | get | php | ronknight/InventorySystem | system/libraries/Cache/drivers/Cache_apc.php | https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Cache/drivers/Cache_apc.php | MIT |
public function is_supported()
{
return (extension_loaded('apc') && ini_get('apc.enabled'));
} | is_supported()
Check to see if APC is available on this system, bail if it isn't.
@return bool | is_supported | php | ronknight/InventorySystem | system/libraries/Cache/drivers/Cache_apc.php | https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Cache/drivers/Cache_apc.php | MIT |
public function __construct()
{
if ( ! $this->is_supported())
{
log_message('error', 'Cache: Failed to create Redis object; extension not loaded?');
return;
}
$CI =& get_instance();
if ($CI->config->load('redis', TRUE, TRUE))
{
$config = array_merge(self::$_default_config, $CI->config->item('redis'));
}
else
{
$config = self::$_default_config;
}
$this->_redis = new Redis();
try
{
if ($config['socket_type'] === 'unix')
{
$success = $this->_redis->connect($config['socket']);
}
else // tcp socket
{
$success = $this->_redis->connect($config['host'], $config['port'], $config['timeout']);
}
if ( ! $success)
{
log_message('error', 'Cache: Redis connection failed. Check your configuration.');
}
if (isset($config['password']) && ! $this->_redis->auth($config['password']))
{
log_message('error', 'Cache: Redis authentication failed.');
}
}
catch (RedisException $e)
{
log_message('error', 'Cache: Redis connection refused ('.$e->getMessage().')');
}
// Initialize the index of serialized values.
$serialized = $this->_redis->sMembers('_ci_redis_serialized');
empty($serialized) OR $this->_serialized = array_flip($serialized);
} | Class constructor
Setup Redis
Loads Redis config file if present. Will halt execution
if a Redis connection can't be established.
@return void
@see Redis::connect() | __construct | php | ronknight/InventorySystem | system/libraries/Cache/drivers/Cache_redis.php | https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Cache/drivers/Cache_redis.php | MIT |
public function cache_info($type = NULL)
{
return $this->_redis->info();
} | Get cache driver info
@param string $type Not supported in Redis.
Only included in order to offer a
consistent cache API.
@return array
@see Redis::info() | cache_info | php | ronknight/InventorySystem | system/libraries/Cache/drivers/Cache_redis.php | https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Cache/drivers/Cache_redis.php | MIT |
public function is_supported()
{
return extension_loaded('redis');
} | Check if Redis driver is supported
@return bool | is_supported | php | ronknight/InventorySystem | system/libraries/Cache/drivers/Cache_redis.php | https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Cache/drivers/Cache_redis.php | MIT |
public function __destruct()
{
if ($this->_redis)
{
$this->_redis->close();
}
} | Class destructor
Closes the connection to Redis if present.
@return void | __destruct | php | ronknight/InventorySystem | system/libraries/Cache/drivers/Cache_redis.php | https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Cache/drivers/Cache_redis.php | MIT |
public function cache_info($type = NULL)
{
return get_dir_file_info($this->_cache_path);
} | Cache Info
Not supported by file-based caching
@param string user/filehits
@return mixed FALSE | cache_info | php | ronknight/InventorySystem | system/libraries/Cache/drivers/Cache_file.php | https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Cache/drivers/Cache_file.php | MIT |
public function is_supported()
{
return is_really_writable($this->_cache_path);
} | Is supported
In the file driver, check to see that the cache directory is indeed writable
@return bool | is_supported | php | ronknight/InventorySystem | system/libraries/Cache/drivers/Cache_file.php | https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Cache/drivers/Cache_file.php | MIT |
protected function _get($id)
{
if ( ! is_file($this->_cache_path.$id))
{
return FALSE;
}
$data = unserialize(file_get_contents($this->_cache_path.$id));
if ($data['ttl'] > 0 && time() > $data['time'] + $data['ttl'])
{
unlink($this->_cache_path.$id);
return FALSE;
}
return $data;
} | Get all data
Internal method to get all the relevant data about a cache item
@param string $id Cache ID
@return mixed Data array on success or FALSE on failure | _get | php | ronknight/InventorySystem | system/libraries/Cache/drivers/Cache_file.php | https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Cache/drivers/Cache_file.php | MIT |
protected function _cookie_destroy()
{
return setcookie(
$this->_config['cookie_name'],
NULL,
1,
$this->_config['cookie_path'],
$this->_config['cookie_domain'],
$this->_config['cookie_secure'],
TRUE
);
} | Cookie destroy
Internal method to force removal of a cookie by the client
when session_destroy() is called.
@return bool | _cookie_destroy | php | ronknight/InventorySystem | system/libraries/Session/Session_driver.php | https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Session/Session_driver.php | MIT |
protected function _get_lock($session_id)
{
$this->_lock = TRUE;
return TRUE;
} | Get lock
A dummy method allowing drivers with no locking functionality
(databases other than PostgreSQL and MySQL) to act as if they
do acquire a lock.
@param string $session_id
@return bool | _get_lock | php | ronknight/InventorySystem | system/libraries/Session/Session_driver.php | https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Session/Session_driver.php | MIT |
protected function _fail()
{
ini_set('session.save_path', config_item('sess_save_path'));
return $this->_failure;
} | Fail
Drivers other than the 'files' one don't (need to) use the
session.save_path INI setting, but that leads to confusing
error messages emitted by PHP when open() or write() fail,
as the message contains session.save_path ...
To work around the problem, the drivers will call this method
so that the INI is set just in time for the error message to
be properly generated.
@return mixed | _fail | php | ronknight/InventorySystem | system/libraries/Session/Session_driver.php | https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Session/Session_driver.php | MIT |
protected function _ci_load_classes($driver)
{
// PHP 5.4 compatibility
interface_exists('SessionHandlerInterface', FALSE) OR require_once(BASEPATH.'libraries/Session/SessionHandlerInterface.php');
$prefix = config_item('subclass_prefix');
if ( ! class_exists('CI_Session_driver', FALSE))
{
require_once(
file_exists(APPPATH.'libraries/Session/Session_driver.php')
? APPPATH.'libraries/Session/Session_driver.php'
: BASEPATH.'libraries/Session/Session_driver.php'
);
if (file_exists($file_path = APPPATH.'libraries/Session/'.$prefix.'Session_driver.php'))
{
require_once($file_path);
}
}
$class = 'Session_'.$driver.'_driver';
// Allow custom drivers without the CI_ or MY_ prefix
if ( ! class_exists($class, FALSE) && file_exists($file_path = APPPATH.'libraries/Session/drivers/'.$class.'.php'))
{
require_once($file_path);
if (class_exists($class, FALSE))
{
return $class;
}
}
if ( ! class_exists('CI_'.$class, FALSE))
{
if (file_exists($file_path = APPPATH.'libraries/Session/drivers/'.$class.'.php') OR file_exists($file_path = BASEPATH.'libraries/Session/drivers/'.$class.'.php'))
{
require_once($file_path);
}
if ( ! class_exists('CI_'.$class, FALSE) && ! class_exists($class, FALSE))
{
throw new UnexpectedValueException("Session: Configured driver '".$driver."' was not found. Aborting.");
}
}
if ( ! class_exists($prefix.$class, FALSE) && file_exists($file_path = APPPATH.'libraries/Session/drivers/'.$prefix.$class.'.php'))
{
require_once($file_path);
if (class_exists($prefix.$class, FALSE))
{
return $prefix.$class;
}
else
{
log_message('debug', 'Session: '.$prefix.$class.".php found but it doesn't declare class ".$prefix.$class.'.');
}
}
return 'CI_'.$class;
} | CI Load Classes
An internal method to load all possible dependency and extension
classes. It kind of emulates the CI_Driver library, but is
self-sufficient.
@param string $driver Driver name
@return string Driver class name | _ci_load_classes | php | ronknight/InventorySystem | system/libraries/Session/Session.php | https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Session/Session.php | MIT |
protected function _configure(&$params)
{
$expiration = config_item('sess_expiration');
if (isset($params['cookie_lifetime']))
{
$params['cookie_lifetime'] = (int) $params['cookie_lifetime'];
}
else
{
$params['cookie_lifetime'] = ( ! isset($expiration) && config_item('sess_expire_on_close'))
? 0 : (int) $expiration;
}
isset($params['cookie_name']) OR $params['cookie_name'] = config_item('sess_cookie_name');
if (empty($params['cookie_name']))
{
$params['cookie_name'] = ini_get('session.name');
}
else
{
ini_set('session.name', $params['cookie_name']);
}
isset($params['cookie_path']) OR $params['cookie_path'] = config_item('cookie_path');
isset($params['cookie_domain']) OR $params['cookie_domain'] = config_item('cookie_domain');
isset($params['cookie_secure']) OR $params['cookie_secure'] = (bool) config_item('cookie_secure');
session_set_cookie_params(
$params['cookie_lifetime'],
$params['cookie_path'],
$params['cookie_domain'],
$params['cookie_secure'],
TRUE // HttpOnly; Yes, this is intentional and not configurable for security reasons
);
if (empty($expiration))
{
$params['expiration'] = (int) ini_get('session.gc_maxlifetime');
}
else
{
$params['expiration'] = (int) $expiration;
ini_set('session.gc_maxlifetime', $expiration);
}
$params['match_ip'] = (bool) (isset($params['match_ip']) ? $params['match_ip'] : config_item('sess_match_ip'));
isset($params['save_path']) OR $params['save_path'] = config_item('sess_save_path');
$this->_config = $params;
// Security is king
ini_set('session.use_trans_sid', 0);
ini_set('session.use_strict_mode', 1);
ini_set('session.use_cookies', 1);
ini_set('session.use_only_cookies', 1);
$this->_configure_sid_length();
} | Configuration
Handle input parameters and configuration defaults
@param array &$params Input parameters
@return void | _configure | php | ronknight/InventorySystem | system/libraries/Session/Session.php | https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Session/Session.php | MIT |
protected function _ci_init_vars()
{
if ( ! empty($_SESSION['__ci_vars']))
{
$current_time = time();
foreach ($_SESSION['__ci_vars'] as $key => &$value)
{
if ($value === 'new')
{
$_SESSION['__ci_vars'][$key] = 'old';
}
// Hacky, but 'old' will (implicitly) always be less than time() ;)
// DO NOT move this above the 'new' check!
elseif ($value < $current_time)
{
unset($_SESSION[$key], $_SESSION['__ci_vars'][$key]);
}
}
if (empty($_SESSION['__ci_vars']))
{
unset($_SESSION['__ci_vars']);
}
}
$this->userdata =& $_SESSION;
} | Handle temporary variables
Clears old "flash" data, marks the new one for deletion and handles
"temp" data deletion.
@return void | _ci_init_vars | php | ronknight/InventorySystem | system/libraries/Session/Session.php | https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Session/Session.php | MIT |
public function sess_destroy()
{
session_destroy();
} | Session destroy
Legacy CI_Session compatibility method
@return void | sess_destroy | php | ronknight/InventorySystem | system/libraries/Session/Session.php | https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Session/Session.php | MIT |
public function sess_regenerate($destroy = FALSE)
{
$_SESSION['__ci_last_regenerate'] = time();
session_regenerate_id($destroy);
} | Session regenerate
Legacy CI_Session compatibility method
@param bool $destroy Destroy old session data flag
@return void | sess_regenerate | php | ronknight/InventorySystem | system/libraries/Session/Session.php | https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Session/Session.php | MIT |
public function &get_userdata()
{
return $_SESSION;
} | Get userdata reference
Legacy CI_Session compatibility method
@returns array | get_userdata | php | ronknight/InventorySystem | system/libraries/Session/Session.php | https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Session/Session.php | MIT |
public function set_userdata($data, $value = NULL)
{
if (is_array($data))
{
foreach ($data as $key => &$value)
{
$_SESSION[$key] = $value;
}
return;
}
$_SESSION[$data] = $value;
} | Set userdata
Legacy CI_Session compatibility method
@param mixed $data Session data key or an associative array
@param mixed $value Value to store
@return void | set_userdata | php | ronknight/InventorySystem | system/libraries/Session/Session.php | https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Session/Session.php | MIT |
public function all_userdata()
{
return $this->userdata();
} | All userdata (fetch)
Legacy CI_Session compatibility method
@return array $_SESSION, excluding flash data items | all_userdata | php | ronknight/InventorySystem | system/libraries/Session/Session.php | https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Session/Session.php | MIT |
public function has_userdata($key)
{
return isset($_SESSION[$key]);
} | Has userdata
Legacy CI_Session compatibility method
@param string $key Session data key
@return bool | has_userdata | php | ronknight/InventorySystem | system/libraries/Session/Session.php | https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Session/Session.php | MIT |
public function set_flashdata($data, $value = NULL)
{
$this->set_userdata($data, $value);
$this->mark_as_flash(is_array($data) ? array_keys($data) : $data);
} | Set flashdata
Legacy CI_Session compatibility method
@param mixed $data Session data key or an associative array
@param mixed $value Value to store
@return void | set_flashdata | php | ronknight/InventorySystem | system/libraries/Session/Session.php | https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Session/Session.php | MIT |
public function keep_flashdata($key)
{
$this->mark_as_flash($key);
} | Keep flashdata
Legacy CI_Session compatibility method
@param mixed $key Session data key(s)
@return void | keep_flashdata | php | ronknight/InventorySystem | system/libraries/Session/Session.php | https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Session/Session.php | MIT |
public function set_tempdata($data, $value = NULL, $ttl = 300)
{
$this->set_userdata($data, $value);
$this->mark_as_temp(is_array($data) ? array_keys($data) : $data, $ttl);
} | Set tempdata
Legacy CI_Session compatibility method
@param mixed $data Session data key or an associative array of items
@param mixed $value Value to store
@param int $ttl Time-to-live in seconds
@return void | set_tempdata | php | ronknight/InventorySystem | system/libraries/Session/Session.php | https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Session/Session.php | MIT |
public function unset_tempdata($key)
{
$this->unmark_temp($key);
} | Unset tempdata
Legacy CI_Session compatibility method
@param mixed $data Session data key(s)
@return void | unset_tempdata | php | ronknight/InventorySystem | system/libraries/Session/Session.php | https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Session/Session.php | MIT |
public function read($session_id)
{
// This might seem weird, but PHP 5.6 introduces session_reset(),
// which re-reads session data
if ($this->_file_handle === NULL)
{
$this->_file_new = ! file_exists($this->_file_path.$session_id);
if (($this->_file_handle = fopen($this->_file_path.$session_id, 'c+b')) === FALSE)
{
log_message('error', "Session: Unable to open file '".$this->_file_path.$session_id."'.");
return $this->_failure;
}
if (flock($this->_file_handle, LOCK_EX) === FALSE)
{
log_message('error', "Session: Unable to obtain lock for file '".$this->_file_path.$session_id."'.");
fclose($this->_file_handle);
$this->_file_handle = NULL;
return $this->_failure;
}
// Needed by write() to detect session_regenerate_id() calls
$this->_session_id = $session_id;
if ($this->_file_new)
{
chmod($this->_file_path.$session_id, 0600);
$this->_fingerprint = md5('');
return '';
}
}
// We shouldn't need this, but apparently we do ...
// See https://github.com/bcit-ci/CodeIgniter/issues/4039
elseif ($this->_file_handle === FALSE)
{
return $this->_failure;
}
else
{
rewind($this->_file_handle);
}
$session_data = '';
for ($read = 0, $length = filesize($this->_file_path.$session_id); $read < $length; $read += self::strlen($buffer))
{
if (($buffer = fread($this->_file_handle, $length - $read)) === FALSE)
{
break;
}
$session_data .= $buffer;
}
$this->_fingerprint = md5($session_data);
return $session_data;
} | Read
Reads session data and acquires a lock
@param string $session_id Session ID
@return string Serialized session data | read | php | ronknight/InventorySystem | system/libraries/Session/drivers/Session_files_driver.php | https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Session/drivers/Session_files_driver.php | MIT |
public function close()
{
if (is_resource($this->_file_handle))
{
flock($this->_file_handle, LOCK_UN);
fclose($this->_file_handle);
$this->_file_handle = $this->_file_new = $this->_session_id = NULL;
}
return $this->_success;
} | Close
Releases locks and closes file descriptor.
@return bool | close | php | ronknight/InventorySystem | system/libraries/Session/drivers/Session_files_driver.php | https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Session/drivers/Session_files_driver.php | MIT |
public function gc($maxlifetime)
{
if ( ! is_dir($this->_config['save_path']) OR ($directory = opendir($this->_config['save_path'])) === FALSE)
{
log_message('debug', "Session: Garbage collector couldn't list files under directory '".$this->_config['save_path']."'.");
return $this->_failure;
}
$ts = time() - $maxlifetime;
$pattern = ($this->_config['match_ip'] === TRUE)
? '[0-9a-f]{32}'
: '';
$pattern = sprintf(
'#\A%s'.$pattern.$this->_sid_regexp.'\z#',
preg_quote($this->_config['cookie_name'])
);
while (($file = readdir($directory)) !== FALSE)
{
// If the filename doesn't match this pattern, it's either not a session file or is not ours
if ( ! preg_match($pattern, $file)
OR ! is_file($this->_config['save_path'].DIRECTORY_SEPARATOR.$file)
OR ($mtime = filemtime($this->_config['save_path'].DIRECTORY_SEPARATOR.$file)) === FALSE
OR $mtime > $ts)
{
continue;
}
unlink($this->_config['save_path'].DIRECTORY_SEPARATOR.$file);
}
closedir($directory);
return $this->_success;
} | Garbage Collector
Deletes expired sessions
@param int $maxlifetime Maximum lifetime of sessions
@return bool | gc | php | ronknight/InventorySystem | system/libraries/Session/drivers/Session_files_driver.php | https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Session/drivers/Session_files_driver.php | MIT |
public function write($session_id, $session_data)
{
if ( ! isset($this->_redis, $this->_lock_key))
{
return $this->_fail();
}
// Was the ID regenerated?
elseif ($session_id !== $this->_session_id)
{
if ( ! $this->_release_lock() OR ! $this->_get_lock($session_id))
{
return $this->_fail();
}
$this->_key_exists = FALSE;
$this->_session_id = $session_id;
}
$this->_redis->setTimeout($this->_lock_key, 300);
if ($this->_fingerprint !== ($fingerprint = md5($session_data)) OR $this->_key_exists === FALSE)
{
if ($this->_redis->set($this->_key_prefix.$session_id, $session_data, $this->_config['expiration']))
{
$this->_fingerprint = $fingerprint;
$this->_key_exists = TRUE;
return $this->_success;
}
return $this->_fail();
}
return ($this->_redis->setTimeout($this->_key_prefix.$session_id, $this->_config['expiration']))
? $this->_success
: $this->_fail();
} | Write
Writes (create / update) session data
@param string $session_id Session ID
@param string $session_data Serialized session data
@return bool | write | php | ronknight/InventorySystem | system/libraries/Session/drivers/Session_redis_driver.php | https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Session/drivers/Session_redis_driver.php | MIT |
public function close()
{
if (isset($this->_redis))
{
try {
if ($this->_redis->ping() === '+PONG')
{
$this->_release_lock();
if ($this->_redis->close() === FALSE)
{
return $this->_fail();
}
}
}
catch (RedisException $e)
{
log_message('error', 'Session: Got RedisException on close(): '.$e->getMessage());
}
$this->_redis = NULL;
return $this->_success;
}
return $this->_success;
} | Close
Releases locks and closes connection.
@return bool | close | php | ronknight/InventorySystem | system/libraries/Session/drivers/Session_redis_driver.php | https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Session/drivers/Session_redis_driver.php | MIT |
public function destroy($session_id)
{
if (isset($this->_redis, $this->_lock_key))
{
if (($result = $this->_redis->delete($this->_key_prefix.$session_id)) !== 1)
{
log_message('debug', 'Session: Redis::delete() expected to return 1, got '.var_export($result, TRUE).' instead.');
}
$this->_cookie_destroy();
return $this->_success;
}
return $this->_fail();
} | Destroy
Destroys the current session.
@param string $session_id Session ID
@return bool | destroy | php | ronknight/InventorySystem | system/libraries/Session/drivers/Session_redis_driver.php | https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Session/drivers/Session_redis_driver.php | MIT |
protected function _release_lock()
{
if (isset($this->_redis, $this->_lock_key) && $this->_lock)
{
if ( ! $this->_redis->delete($this->_lock_key))
{
log_message('error', 'Session: Error while trying to free lock for '.$this->_lock_key);
return FALSE;
}
$this->_lock_key = NULL;
$this->_lock = FALSE;
}
return TRUE;
} | Release lock
Releases a previously acquired lock
@return bool | _release_lock | php | ronknight/InventorySystem | system/libraries/Session/drivers/Session_redis_driver.php | https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Session/drivers/Session_redis_driver.php | MIT |
public function open($save_path, $name)
{
if (empty($this->_db->conn_id) && ! $this->_db->db_connect())
{
return $this->_fail();
}
return $this->_success;
} | Open
Initializes the database connection
@param string $save_path Table name
@param string $name Session cookie name, unused
@return bool | open | php | ronknight/InventorySystem | system/libraries/Session/drivers/Session_database_driver.php | https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Session/drivers/Session_database_driver.php | MIT |
protected function _get_lock($session_id)
{
if ($this->_platform === 'mysql')
{
$arg = md5($session_id.($this->_config['match_ip'] ? '_'.$_SERVER['REMOTE_ADDR'] : ''));
if ($this->_db->query("SELECT GET_LOCK('".$arg."', 300) AS ci_session_lock")->row()->ci_session_lock)
{
$this->_lock = $arg;
return TRUE;
}
return FALSE;
} | Get lock
Acquires a lock, depending on the underlying platform.
@param string $session_id Session ID
@return bool | _get_lock | php | ronknight/InventorySystem | system/libraries/Session/drivers/Session_database_driver.php | https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Session/drivers/Session_database_driver.php | MIT |
public function open($save_path, $name)
{
$this->_memcached = new Memcached();
$this->_memcached->setOption(Memcached::OPT_BINARY_PROTOCOL, TRUE); // required for touch() usage
$server_list = array();
foreach ($this->_memcached->getServerList() as $server)
{
$server_list[] = $server['host'].':'.$server['port'];
}
if ( ! preg_match_all('#,?([^,:]+)\:(\d{1,5})(?:\:(\d+))?#', $this->_config['save_path'], $matches, PREG_SET_ORDER))
{
$this->_memcached = NULL;
log_message('error', 'Session: Invalid Memcached save path format: '.$this->_config['save_path']);
return $this->_fail();
}
foreach ($matches as $match)
{
// If Memcached already has this server (or if the port is invalid), skip it
if (in_array($match[1].':'.$match[2], $server_list, TRUE))
{
log_message('debug', 'Session: Memcached server pool already has '.$match[1].':'.$match[2]);
continue;
}
if ( ! $this->_memcached->addServer($match[1], $match[2], isset($match[3]) ? $match[3] : 0))
{
log_message('error', 'Could not add '.$match[1].':'.$match[2].' to Memcached server pool.');
}
else
{
$server_list[] = $match[1].':'.$match[2];
}
}
if (empty($server_list))
{
log_message('error', 'Session: Memcached server pool is empty.');
return $this->_fail();
}
return $this->_success;
} | Open
Sanitizes save_path and initializes connections.
@param string $save_path Server path(s)
@param string $name Session cookie name, unused
@return bool | open | php | ronknight/InventorySystem | system/libraries/Session/drivers/Session_memcached_driver.php | https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Session/drivers/Session_memcached_driver.php | MIT |
protected function _get_lock($session_id)
{
// PHP 7 reuses the SessionHandler object on regeneration,
// so we need to check here if the lock key is for the
// correct session ID.
if ($this->_lock_key === $this->_key_prefix.$session_id.':lock')
{
if ( ! $this->_memcached->replace($this->_lock_key, time(), 300))
{
return ($this->_memcached->getResultCode() === Memcached::RES_NOTFOUND)
? $this->_memcached->add($this->_lock_key, time(), 300)
: FALSE;
}
}
// 30 attempts to obtain a lock, in case another request already has it
$lock_key = $this->_key_prefix.$session_id.':lock';
$attempt = 0;
do
{
if ($this->_memcached->get($lock_key))
{
sleep(1);
continue;
}
$method = ($this->_memcached->getResultCode() === Memcached::RES_NOTFOUND) ? 'add' : 'set';
if ( ! $this->_memcached->$method($lock_key, time(), 300))
{
log_message('error', 'Session: Error while trying to obtain lock for '.$this->_key_prefix.$session_id);
return FALSE;
}
$this->_lock_key = $lock_key;
break;
}
while (++$attempt < 30);
if ($attempt === 30)
{
log_message('error', 'Session: Unable to obtain lock for '.$this->_key_prefix.$session_id.' after 30 attempts, aborting.');
return FALSE;
}
$this->_lock = TRUE;
return TRUE;
} | Get lock
Acquires an (emulated) lock.
@param string $session_id Session ID
@return bool | _get_lock | php | ronknight/InventorySystem | system/libraries/Session/drivers/Session_memcached_driver.php | https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Session/drivers/Session_memcached_driver.php | MIT |
protected function _blur($element = 'this', $js = '')
{
return $this->_add_event($element, $js, 'blur');
} | Blur
Outputs a jQuery blur event
@param string The element to attach the event to
@param string The code to execute
@return string | _blur | php | ronknight/InventorySystem | system/libraries/Javascript/Jquery.php | https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Javascript/Jquery.php | MIT |
protected function _change($element = 'this', $js = '')
{
return $this->_add_event($element, $js, 'change');
} | Change
Outputs a jQuery change event
@param string The element to attach the event to
@param string The code to execute
@return string | _change | php | ronknight/InventorySystem | system/libraries/Javascript/Jquery.php | https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Javascript/Jquery.php | MIT |
protected function _click($element = 'this', $js = '', $ret_false = TRUE)
{
is_array($js) OR $js = array($js);
if ($ret_false)
{
$js[] = 'return false;';
}
return $this->_add_event($element, $js, 'click');
} | Click
Outputs a jQuery click event
@param string The element to attach the event to
@param string The code to execute
@param bool whether or not to return false
@return string | _click | php | ronknight/InventorySystem | system/libraries/Javascript/Jquery.php | https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Javascript/Jquery.php | MIT |
protected function _dblclick($element = 'this', $js = '')
{
return $this->_add_event($element, $js, 'dblclick');
} | Double Click
Outputs a jQuery dblclick event
@param string The element to attach the event to
@param string The code to execute
@return string | _dblclick | php | ronknight/InventorySystem | system/libraries/Javascript/Jquery.php | https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Javascript/Jquery.php | MIT |
protected function _error($element = 'this', $js = '')
{
return $this->_add_event($element, $js, 'error');
} | Error
Outputs a jQuery error event
@param string The element to attach the event to
@param string The code to execute
@return string | _error | php | ronknight/InventorySystem | system/libraries/Javascript/Jquery.php | https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Javascript/Jquery.php | MIT |
protected function _focus($element = 'this', $js = '')
{
return $this->_add_event($element, $js, 'focus');
} | Focus
Outputs a jQuery focus event
@param string The element to attach the event to
@param string The code to execute
@return string | _focus | php | ronknight/InventorySystem | system/libraries/Javascript/Jquery.php | https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Javascript/Jquery.php | MIT |
protected function _hover($element = 'this', $over = '', $out = '')
{
$event = "\n\t$(".$this->_prep_element($element).").hover(\n\t\tfunction()\n\t\t{\n\t\t\t{$over}\n\t\t}, \n\t\tfunction()\n\t\t{\n\t\t\t{$out}\n\t\t});\n";
$this->jquery_code_for_compile[] = $event;
return $event;
} | Hover
Outputs a jQuery hover event
@param string - element
@param string - Javascript code for mouse over
@param string - Javascript code for mouse out
@return string | _hover | php | ronknight/InventorySystem | system/libraries/Javascript/Jquery.php | https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Javascript/Jquery.php | MIT |
protected function _keydown($element = 'this', $js = '')
{
return $this->_add_event($element, $js, 'keydown');
} | Keydown
Outputs a jQuery keydown event
@param string The element to attach the event to
@param string The code to execute
@return string | _keydown | php | ronknight/InventorySystem | system/libraries/Javascript/Jquery.php | https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Javascript/Jquery.php | MIT |
protected function _keyup($element = 'this', $js = '')
{
return $this->_add_event($element, $js, 'keyup');
} | Keyup
Outputs a jQuery keydown event
@param string The element to attach the event to
@param string The code to execute
@return string | _keyup | php | ronknight/InventorySystem | system/libraries/Javascript/Jquery.php | https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Javascript/Jquery.php | MIT |
protected function _load($element = 'this', $js = '')
{
return $this->_add_event($element, $js, 'load');
} | Load
Outputs a jQuery load event
@param string The element to attach the event to
@param string The code to execute
@return string | _load | php | ronknight/InventorySystem | system/libraries/Javascript/Jquery.php | https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Javascript/Jquery.php | MIT |
protected function _mousedown($element = 'this', $js = '')
{
return $this->_add_event($element, $js, 'mousedown');
} | Mousedown
Outputs a jQuery mousedown event
@param string The element to attach the event to
@param string The code to execute
@return string | _mousedown | php | ronknight/InventorySystem | system/libraries/Javascript/Jquery.php | https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Javascript/Jquery.php | MIT |
protected function _mouseout($element = 'this', $js = '')
{
return $this->_add_event($element, $js, 'mouseout');
} | Mouse Out
Outputs a jQuery mouseout event
@param string The element to attach the event to
@param string The code to execute
@return string | _mouseout | php | ronknight/InventorySystem | system/libraries/Javascript/Jquery.php | https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Javascript/Jquery.php | MIT |
protected function _mouseover($element = 'this', $js = '')
{
return $this->_add_event($element, $js, 'mouseover');
} | Mouse Over
Outputs a jQuery mouseover event
@param string The element to attach the event to
@param string The code to execute
@return string | _mouseover | php | ronknight/InventorySystem | system/libraries/Javascript/Jquery.php | https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Javascript/Jquery.php | MIT |
protected function _mouseup($element = 'this', $js = '')
{
return $this->_add_event($element, $js, 'mouseup');
} | Mouseup
Outputs a jQuery mouseup event
@param string The element to attach the event to
@param string The code to execute
@return string | _mouseup | php | ronknight/InventorySystem | system/libraries/Javascript/Jquery.php | https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Javascript/Jquery.php | MIT |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.