Skip to content

Instantly share code, notes, and snippets.

@webosk
webosk / in_multi_array.php
Created November 25, 2013 05:10
in_array for multi-dimension array
$in_array = (bool)strpos(serialize($haystack),$needle);
if ($in_array)
return;
@webosk
webosk / get_module_params_in
Created June 25, 2013 13:16
Joomla get module parameters from inside module
$param = $params->get('paramName', 'defaultValue');
@webosk
webosk / get_module_params_outside
Created June 25, 2013 13:15
Joomla fet module parameters from outside module
$module = &JModuleHelper::getModule('example');
$moduleParams = new JParameter($module->params);
$param = $moduleParams->get('paramName', 'defaultValue');
@webosk
webosk / curl function
Created June 24, 2013 18:56
PHP curl funcion
function curl_get_contents($url)
{
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
$data = curl_exec($curl);
curl_close($curl);
return $data;
@webosk
webosk / JSloader
Created June 22, 2013 19:30
Javascript check for script on page, add script or return bollean
function isScriptLoaded(url, trueFalse)
{
if (!url)
return;
var found = false,
scripts = document.getElementsByTagName('script');
for (var i = scripts.length; i--;) {
if (scripts[i].src == url)
@webosk
webosk / Email validation regex
Created May 30, 2013 00:58
Regex code for email validation.
$ValidEmailRegex = "/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/";
@webosk
webosk / new_gist_file
Created May 23, 2013 19:03
CMD command to map a network drive on another computer
net use *\\{ipaddress}\{folder} /user:{domain}\{user}
@webosk
webosk / send_email.php
Created April 12, 2013 11:50
send a html email with or without an attachment
private function send_email($name, $email, $to_mail, $subject, $msg, $attachment = "") {
$sending = true;
if(!empty($attachment['tmp_name']) && !empty($attachment['error'])) $attachment['tmp_name'] = "";
if(!empty($name) && !empty($email) && !empty($to_mail) && !empty($subject) && !empty($msg)) {
$from_name = $name;
$from_mail = $email;
$sending = true;
}
@webosk
webosk / defaultIE.js
Created March 28, 2013 14:36
Prevent default for old Ie
if(event.preventDefault) { event.preventDefault(); }
else { event.returnValue = false; }