Example #1
0
function blox_parse_audio_hook($atts, $content = null)
{
    extract(shortcode_atts(array('title' => '', 'color' => '#3a87ad', 'animation' => '', 'extra_class' => '', 'visibility' => ''), $atts));
    $title = $title != '' ? '<h3 class="element-title">' . $title . '</h3>' : '';
    $visibility = str_replace(',', ' ', $visibility);
    $extra_class = $extra_class . ' ' . $visibility;
    if (validateURL($content)) {
        return get_audio_player(array('url' => $content, 'title' => $title, 'color' => $color, 'extra_class' => $extra_class));
    } else {
        return "<div class='blox-element audio audio_embed {$extra_class}'>" . $title . $content . "</div>";
    }
    return '';
}
Example #2
0
function blox_parse_video_hook($atts, $content = null)
{
    extract(shortcode_atts(array('title' => '', 'image' => '', 'color' => '#3a87ad', 'animation' => '', 'extra_class' => '', 'visibility' => ''), $atts));
    $title = $title != '' ? '<h3 class="element-title">' . $title . '</h3>' : '';
    $visibility = str_replace(',', ' ', $visibility);
    $extra_class = $extra_class . ' ' . $visibility;
    $result = '';
    if (validateURL($content)) {
        if (wp_oembed_get($content) !== false) {
            return "<div class='blox-element video video_embed {$extra_class}'>" . $title . wp_oembed_get($content) . "</div>";
        } else {
            return get_video_player(array('url' => $content, 'title' => $title, 'poster' => $image, 'color' => $color, 'extra_class' => $extra_class));
        }
    } else {
        return "<div class='blox-element video video_embed {$extra_class}'>" . $title . $content . "</div>";
    }
    return $result;
}
Example #3
0
function blox_parse_service_hook($atts, $content = null)
{
    extract(shortcode_atts(array('layout' => 'default', 'alignment' => 'left', 'title' => '', 'heading' => 'h3', 'icon' => '', 'icon_size' => 'md', 'icon_location' => 'left', 'icon_link' => '', 'skin' => 'default', 'animation' => 'none', 'extra_class' => '', 'visibility' => ''), $atts));
    $service_title = "<{$heading} class='service-title'>{$title}</{$heading}>";
    $is_animate = $animation != 'none' && $animation != '' ? 'animate' : '';
    // Link
    $box_link = $box_link_close = '';
    if (($skin == 'boxed' || $skin == 'bordered') && $icon_link != '') {
        $box_link = "<a href='{$icon_link}'>";
        $box_link_close = "</a>";
        $icon_link = '';
    }
    $skin = $skin == 'default' ? '' : $skin;
    $visibility = str_replace(',', ' ', $visibility);
    $extra_class .= ' ' . $visibility;
    $service_icon = "<span class='blox-icon {$icon_size} {$icon}'></span>";
    $service_icon = validateURL($icon) ? "<span class='service-image'><img src='{$icon}' alt='service-image' class='img-responsive' /></span>" : $service_icon;
    $service_icon = $icon_link != '' ? "<a href='{$icon_link}'>" . $service_icon . "</a>" : $service_icon;
    $icon_top = $icon_location == 'top' ? $service_icon : '';
    $icon_middle = $icon_location == 'middle' ? $service_icon : '';
    $icon_bottom = $icon_location == 'bottom' ? $service_icon : '';
    $content = fix_shortcode_paragraph($content);
    $find_p = strpos($content, '</p>');
    if ($find_p === false) {
        $content = "<p>" . trim($content) . "</p>";
    }
    $html = '';
    if ($layout == 'small_icon') {
        $html = "<div class='blox-element service-icon-title {$skin} {$is_animate} {$extra_class}' data-animate='{$animation}'><{$heading}>{$service_icon}{$title}</{$heading}>" . do_shortcode($content) . "</div>";
    } else {
        if ($layout == 'left_icon') {
            $html = "<div class='blox-element service-icon-left {$skin} {$is_animate} {$extra_class}' data-animate='{$animation}'>" . $service_icon . $service_title . do_shortcode($content) . "</div>";
        } else {
            // $layout=='default'
            $html = "<div class='blox-element service-block text-{$alignment} {$skin} {$is_animate} {$extra_class}' data-animate='{$animation}'>" . $icon_top . $service_title . $icon_middle . do_shortcode($content) . $icon_bottom . "</div>";
        }
    }
    return $box_link . $html . $box_link_close;
}
Example #4
0
 //		otherResponseBytes
 // o	score
 // l	-
 // r	numberResources
 // t	-
 $core_metrics = array();
 // processed data will be stored in this array
 $rules = array();
 // indicates if data was successfully gathered and we can store it
 $got_data = false;
 $sdk_version = null;
 if (!is_null($pageSpeedOnlineAPIKey) && array_key_exists('api', $_GET)) {
     // map of rule => metric relationships
     $rule_metric_map = array('AvoidBadRequests' => 'pBadReqs', 'LeverageBrowserCaching' => 'pBrowserCache', 'SpecifyACacheValidator' => 'pCacheValid', 'SpecifyCharsetEarly' => 'pCharsetEarly', 'CombineExternalCSS' => 'pCombineCSS', 'CombineExternalJavaScript' => 'pCombineJS', 'AvoidCssImport' => 'pCssImport', 'PutCssInTheDocumentHead' => 'pCssInHead', 'OptimizeTheOrderOfStylesAndScripts' => 'pCssJsOrder', 'AvoidDocumentWrite' => 'pDocWrite', 'ServeResourcesFromAConsistentUrl' => 'pDupeRsrc', 'EnableGzipCompression' => 'pGzip', 'SpecifyImageDimensions' => 'pImgDims', 'MinimizeDnsLookups' => 'pMinDns', 'MinifyCss' => 'pMinifyCSS', 'MinifyHTML' => 'pMinifyHTML', 'MinifyJavaScript' => 'pMinifyJS', 'MinimizeRedirects' => 'pMinRedirect', 'MinimizeRequestSize' => 'pMinReqSize', 'ServeStaticContentFromACookielessDomain' => 'pNoCookie', 'OptimizeImages' => 'pOptImgs', 'ParallelizeDownloadsAcrossHostnames' => 'pParallelDl', 'PreferAsyncResources' => 'pPreferAsync', 'RemoveQueryStringsFromStaticResources' => 'pRemoveQuery', 'ServeScaledImages' => 'pScaleImgs', 'SpriteImages' => 'pSprite', 'SpecifyAVaryAcceptEncodingHeader' => 'pVaryAE');
     // making an API call
     $apicall = 'https://www.googleapis.com/pagespeedonline/v1/runPagespeed?url=' . urlencode(validateURL($_GET['u'])) . '&key=' . $pageSpeedOnlineAPIKey;
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, $apicall);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     $output = curl_exec($ch);
     if (empty($output)) {
         $err = curl_error($ch);
         curl_close($ch);
         failWithMessage("API call ({$apicall}) failed: " . $err);
     }
     $code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
     if ($code != 200) {
         curl_close($ch);
         failWithMessage("API returns error code other then 200: {$code}");
     }
     curl_close($ch);
Example #5
0
<?php

require_once dirname(dirname(dirname(__FILE__))) . '/global.php';
if (array_key_exists('title', $_GET) && $_GET['title'] != '' && array_key_exists('url_prefix', $_GET) && filter_var($_GET['url_prefix'], FILTER_VALIDATE_URL) !== false) {
    $url = validateURL($_GET['url_prefix'], $outputerror);
    $type = array_key_exists('type', $_GET) && $_GET['type'] != '' ? $_GET['type'] : FALSE;
    $start = array_key_exists('start', $_GET) && $_GET['start'] != '' ? $_GET['start'] : FALSE;
    $end = array_key_exists('end', $_GET) && $_GET['type'] != '' ? $_GET['end'] : FALSE;
    $resource_url = filter_var($_GET['resource_url'], FILTER_VALIDATE_URL);
    $query = sprintf('INSERT INTO event (
			url_prefix,
			title,
			start' . ($type !== FALSE ? ', type' : '') . ($end !== FALSE ? ', end' : '') . ($resource_url !== FALSE ? ', resource_url' : '') . ") VALUES (\n\t\t\t'%s',\n\t\t\t'%s',\n\t\t\t'%s'" . ($type !== FALSE ? ", '%s'" : '') . ($end !== FALSE ? ", '%s'" : '') . ($resource_url !== FALSE ? ", '%s'" : '') . ')', mysql_real_escape_string($url), mysql_real_escape_string($_GET['title']), mysql_real_escape_string($start), mysql_real_escape_string($type), mysql_real_escape_string($end), mysql_real_escape_string($resource_url));
    if (!mysql_query($query)) {
        beaconError(mysql_error());
    }
    # updating last_event_update for the matching URLs
    $query = sprintf("UPDATE urls SET last_event_update = NOW() WHERE INSTR(url, '%s') = 1", mysql_real_escape_string($url));
    $result = mysql_query($query);
    if (!$result) {
        beaconError(mysql_error());
    }
    if (array_key_exists('manual', $_GET)) {
        ?>
<html>
<head>
<title>Event added</title>
</head>
<body>
<h1>Event added</h1>
<p>Event successfully added.</p>
Example #6
0
function validateNewBuyerProfile($form)
{
    if (checkEmpty($form['firstname'])) {
        $msg = str_replace('field', _LBL_FIRST_NAME, _ALRT_REQUIRED_FIELD);
        return $msg;
    }
    if (!checkEmpty($form['firstname']) && !checkLength($form['firstname'], 255)) {
        $msg = str_replace('%field%', _LBL_FIRST_NAME, _ALRT_CHECK_LENGTH);
        return $msg;
    }
    if (checkEmpty($form['lastname'])) {
        $msg = str_replace('field', _LBL_LAST_NAME, _ALRT_REQUIRED_FIELD);
        return $msg;
    }
    if (!checkEmpty($form['lastname']) && !checkLength($form['lastname'], 255)) {
        $msg = str_replace('%field%', _LBL_LAST_NAME, _ALRT_CHECK_LENGTH);
        return $msg;
    }
    /*if(checkEmpty($form['companyname']))
    	{
    		$msg = str_replace('field',_LBL_COMPANY_NAME,_ALRT_REQUIRED_FIELD);
    		return $msg;
    	}*/
    if (!checkEmpty($form['companyname']) && !checkLength($form['companyname'], 100)) {
        $msg = str_replace('%field%', _LBL_COMPANY_NAME, _ALRT_CHECK_LENGTH);
        return $msg;
    }
    if (checkEmpty($form['type_entertainment'])) {
        $msg = str_replace('field', _LBL_TYPE_OF_ENT, _ALRT_REQUIRED_FIELD);
        return $msg;
    }
    /*if(checkEmpty($form['contactname']))
    	{
    		$msg = str_replace('field',_LBL_CON_PERSON,_ALRT_REQUIRED_FIELD);
    		return $msg;
    	}*/
    if (!checkEmpty($form['phone']) && !checkLength($form['phone'], 20)) {
        $msg = str_replace('%field%', _LBL_PH_NO, _ALRT_CHECK_LENGTH);
        return $msg;
    }
    if (!checkEmpty($form['phone']) && !validatePhone($form['phone'])) {
        $msg = str_replace('%field%', _LBL_PH_NO, _ALRT_CHECK_PHONE);
        return $msg;
    }
    if (!checkEmpty($form['jobtitle']) && !checkLength($form['jobtitle'], 100)) {
        $msg = str_replace('%field%', _LBL_JOB_TITLE, _ALRT_CHECK_LENGTH);
        return $msg;
    }
    /*if(checkEmpty($form['yearfound']))
    	{
    		$msg = str_replace('field',_LBL_YR_FOUNDED,_ALRT_REQUIRED_FIELD);
    		return $msg;
    	}*/
    if (!checkEmpty($form['yearfound']) && !checkLength($form['yearfound'], 4)) {
        $msg = str_replace('%field%', 'Year Started', _ALRT_CHECK_LENGTH);
        return $msg;
    }
    if (!checkEmpty($form['yearfound']) && !checkValidYear($form['yearfound'])) {
        $msg = str_replace('field', 'Year Started', _ALRT_VALID_FIELD);
        return $msg;
    }
    if (!checkEmpty($form['fax']) && !checkLength($form['fax'], 20)) {
        $msg = str_replace('%field%', _LBL_FAX_NO, _ALRT_CHECK_LENGTH);
        return $msg;
    }
    if (!checkEmpty($form['fax']) && !validateFax($form['fax'])) {
        $msg = str_replace('%field%', _LBL_FAX_NO, _ALRT_CHECK_VALID);
        return $msg;
    }
    if (!checkEmpty($form['web']) && !checkLength($form['web'], 200)) {
        $msg = str_replace('%field%', _LBL_COMP_URL, _ALRT_CHECK_LENGTH);
        return $msg;
    }
    if (!checkEmpty($form['web']) && !validateURL($form['web'])) {
        $msg = str_replace('%field%', _LBL_COMP_URL, _ALRT_CHECK_URL);
        $show_tab_type = 'COMPANY_INFO';
        return $msg;
    }
    if (checkEmpty($form['city'])) {
        $msg = str_replace('field', _CITY, _ALRT_REQUIRED_FIELD);
        return $msg;
    }
    if (!checkEmpty($form['city']) && !checkLength($form['city'], 80)) {
        $msg = str_replace('%field%', _CITY, _ALRT_CHECK_LENGTH);
        return $msg;
    }
    if (checkEmpty($form['state'])) {
        $msg = str_replace('field', _LBL_STATE, _ALRT_REQUIRED_FIELD);
        $show_tab_type = 'CONTACT_INFO';
        return $msg;
    }
    if (!checkEmpty($form['state']) && !checkLength($form['state'], 80)) {
        $msg = str_replace('%field%', _LBL_STATE, _ALRT_CHECK_LENGTH);
        return $msg;
    }
    if (checkEmpty($form['zip'])) {
        $msg = str_replace('field', _LBL_ZIP_POSTALCODE, _ALRT_REQUIRED_FIELD);
        return $msg;
    }
    if (!checkEmpty($form['zip']) && !checkLength($form['zip'], 15)) {
        $msg = str_replace('%field%', _LBL_ZIP_POSTALCODE, _ALRT_CHECK_LENGTH);
        return $msg;
    }
    if (!checkEmpty($form['zip']) && !validateZip($form['zip'])) {
        $msg = str_replace('%field%', _LBL_ZIP_POSTALCODE, _ALRT_CHECK_ZIP);
        return $msg;
    }
    return true;
}
Example #7
0
function hover_featured_image(array $options = array())
{
    $options = array_merge(array('overlay' => 'none', 'width' => '600', 'height' => '350'), $options);
    global $post;
    $tmp_post = get_post($post->ID);
    $result = '';
    $post_format = get_post_format();
    $post_format = $post_format != '' ? $post_format : 'standard';
    if (check_post_format($post) && in_array($post_format, array('video', 'audio', 'gallery', 'quote'))) {
        return call_user_func('blox_format_' . $post_format);
    }
    /* Get featured image
       ====================================================*/
    $image = $image_source = '';
    $alt = 'Image';
    if (has_post_thumbnail($post->ID)) {
        $image_source = wp_get_attachment_url(get_post_thumbnail_id($post->ID));
        $image = blox_aq_resize($image_source, $options['width'], $options['height'], true);
        $alt = get_post_meta(get_post_thumbnail_id($post->ID), '_wp_attachment_image_alt', true);
    }
    /* Overlay icons
       ====================================================*/
    $popup_link = $image_source;
    if (get_post_type($post) == 'portfolio') {
        if (tt_getmeta('portfolio_video_mp4') != '') {
            $popup_link = tt_getmeta('portfolio_video_mp4');
        }
    } else {
        if (get_post_type($post) == 'post' && $post_format == 'video') {
            if (tt_getmeta('format_video_embed') != '' && validateURL(tt_getmeta('format_video_embed'))) {
                $popup_link = tt_getmeta('format_video_embed');
            }
        }
    }
    $icon_link = '';
    $icon_popup = '';
    if (in_array($options['overlay'], array('permalink', 'both'))) {
        $icon_link = '<div class="hover-icon"><a href="' . permalink() . '" title="" class=""><i class="fa fa-link"></i></a></div>';
    }
    if (in_array($options['overlay'], array('lightbox', 'both'))) {
        $icon_popup = '<div class="hover-icon"><a href="' . $popup_link . '" class="lightbox" title=""><i class="fa fa-expand"></i></a></div>';
    }
    $icon_link .= $icon_popup;
    $icon_link = $icon_link != '' ? '<div class="entry-hover">' . $icon_link . '</div>' : '';
    /* Entry media
       ====================================================*/
    if (in_array($options['overlay'], array('permalink', 'lightbox', 'both')) && $image != '') {
        $result = '<div class="entry-media">
                        ' . $icon_link . '
                        <img itemprop="image" src="' . $image . '" alt="' . $alt . '" class="img-responsive" />
                    </div>';
    } else {
        if ($image != '') {
            $result = '<div class="entry-media">
                        <a href="' . permalink() . '"><img itemprop="image" src="' . $image . '" alt="' . $alt . '" class="img-responsive" /></a>
                    </div>';
        }
    }
    return $result;
}
Example #8
0
function getUrlId($url, $outputerror = true)
{
    global $dropQueryStrings;
    $url = validateURL($url, $outputerror);
    if (is_null($url)) {
        return null;
    }
    if ($dropQueryStrings) {
        $drop = false;
        if (is_array($dropQueryStrings)) {
            foreach ($dropQueryStrings as $prefix) {
                if (substr($url, 0, strlen($prefix)) == $prefix) {
                    $drop = true;
                    break;
                }
            }
        } else {
            $drop = true;
        }
        if ($drop) {
            $querypos = strpos($url, '?');
            if ($querypos !== false) {
                $url = substr($url, 0, $querypos);
            }
        }
    }
    $query = sprintf("INSERT IGNORE INTO urls (url, url_md5) VALUES ('%s', UNHEX(MD5('%s')))", mysql_real_escape_string($url), mysql_real_escape_string($url));
    $result = mysql_query($query);
    # get URL id
    $query = sprintf("SELECT id FROM urls WHERE url_md5 = UNHEX(MD5('%s'))", mysql_real_escape_string($url));
    $result = mysql_query($query);
    if (!$result) {
        beaconError(mysql_error());
    }
    if (mysql_num_rows($result) > 1) {
        beaconError('More then one entry found for the URL even though MD5 is the same');
    } else {
        if (mysql_num_rows($result) == 0) {
            beaconError('No entries found for the URL even though we just inserted it');
        }
    }
    $row = mysql_fetch_assoc($result);
    return $row['id'];
}
Example #9
0
    }
}
/*
	Only URL and rank will be mandatory - the rest will be optional
*/
if (array_key_exists('url', $_POST) && array_key_exists('stats', $_POST)) {
    checkBeaconKey('dommonster');
    $url_id = getUrlId(urldecode($_POST['url']));
    $stats = json_decode($_POST['stats'], true);
    # adding new entry
    $query = sprintf("INSERT INTO dommonster (\n\t\tversion, url_id,\n\t\telements,\n\t\tnodecount,\n\t\ttextnodes,\n\t\ttextnodessize,\n\t\tcontentpercent,\n\t\taverage,\n\t\tdomsize,\n\t\tbodycount\n\t)\n\tVALUES (\n\t\t'%s', '%d',\n\t\t'%d',\n\t\t'%d',\n\t\t'%d',\n\t\t'%d',\n\t\t'%f',\n\t\t'%f',\n\t\t'%d',\n\t\t'%d'\n\t)", mysql_real_escape_string(array_key_exists('version', $_POST) ? $_POST['version'] : null), mysql_real_escape_string($url_id), mysql_real_escape_string(array_key_exists('elements', $stats) ? $stats['elements'] : null), mysql_real_escape_string(array_key_exists('nodecount', $stats) ? $stats['nodecount'] : null), mysql_real_escape_string(array_key_exists('textnodes', $stats) ? $stats['textnodes'] : null), mysql_real_escape_string(array_key_exists('textnodessize', $stats) ? $stats['textnodessize'] : null), mysql_real_escape_string(array_key_exists('contentpercent', $stats) ? $stats['contentpercent'] : null), mysql_real_escape_string(array_key_exists('average', $stats) ? $stats['average'] : null), mysql_real_escape_string(array_key_exists('domsize', $stats) ? $stats['domsize'] : null), mysql_real_escape_string(array_key_exists('bodycount', $stats) ? $stats['bodycount'] * 1000 : null));
    if (!mysql_query($query)) {
        beaconError(mysql_error());
    }
    updateUrlAggregates($url_id, mysql_insert_id());
    $url = validateURL($_POST['url']);
    ?>
<html><head><script>
	if (confirm('Sucess: data is saved to Show Slow (<?php 
    echo $showslow_base;
    ?>
)\nWould you like to open the resuls page?')) {
		top.location = '<?php 
    echo $showslow_base;
    ?>
details/?url=' + encodeURIComponent('<?php 
    echo $url;
    ?>
');
	}
</script></head><body></body></html>
Example #10
0
	/**
	* Checks if the url to look for is in the actual format of the matches found. <br />
	*    http://wwww.domain.com/file.php can still match non absolute url like /file.php
	* 
	* @param $link (String) url of the match to compare
	* @param $url (String) url to look for.	
	* 
	* @return (String) fixed format of the match
	*/ 
	function validateMatch( $link,$url ){
		if ( validateURL( $link ) == 0 ){
			if ( $link[0] == "/" ){
				$link = $url . $link;				
			}else{						
				if ( $link[0] == "." ){
					$link = $url. substr($link, 1);						
				}else{
					$link = $url . "/" . $link;									
				}
			}		
		}
		return $link;		
	}
Example #11
0
function processImg($match)
{
    if (validateURL($match[1])) {
        return '<img src="' . $match[1] . '"></img>';
    }
    return $match[1];
}
Example #12
0
 public function save()
 {
     if (!isset($this->contact_name) || empty($this->contact_name)) {
         $this->errors[] = "Contact Name is Required";
     }
     if (isset($this->contact_telephone) && !empty($this->contact_telephone)) {
         $this->contact_telephone = phone_number($this->contact_telephone);
         if (!$this->contact_telephone) {
             $this->errors[] = "Invalid phone number " . $this->contact_telephone;
         }
     }
     if (!isset($this->poster_email) || empty($this->poster_email)) {
         $this->errors[] = "Email address is Required";
     }
     if (isset($this->poster_email) && !empty($this->poster_email)) {
         $this->poster_email = check_email($this->poster_email);
         if ($this->poster_email == "") {
             $this->errors[] = "Invalid email address e.g user@domain.com/co.uk/net";
         }
     }
     if (!empty($this->site_link)) {
         if (validateURL($this->site_link)) {
             $this->site_link = check_http($this->site_link);
         } else {
             $this->errors[] = "Invalid URL address e.g www.domain.com/co.uk/net";
         }
     }
     if (!isset($this->job_title) || empty($this->job_title)) {
         $this->errors[] = "Job Title is Required";
     }
     $allowedTags = '<p><strong><em><u><img><span><style><blockquote>';
     $allowedTags .= '<li><ol><ul><span><div><br><ins><del><a><span>';
     $this->job_description = strip_tags(stripslashes($this->job_description), $allowedTags);
     if (!isset($this->job_description) || empty($this->job_description)) {
         $this->errors[] = "Job Description is Required";
     }
     if (!isset($this->job_type) || empty($this->job_type) || $this->job_type <= 0) {
         $this->errors[] = "Job Type is Required";
     }
     if (!isset($this->j_status) || empty($this->j_status) || $this->j_status <= 0) {
         $this->errors[] = "Job Status is Required";
     }
     if (empty($this->state_province) || empty($this->county) || (!isset($this->city) || empty($this->city))) {
         $this->errors[] = "Job Location is Required";
     }
     if (!isset($this->category) || empty($this->category) || $this->category <= 0) {
         $this->errors[] = "Job Category is Required";
     }
     if ($this->category > 10) {
         $this->errors[] = "MAX 10 categories allowed";
     }
     if (sizeof($this->errors) == 0) {
         // A new record won't have an id yet.
         if (isset($this->id)) {
             return $this->update();
         } else {
             $this->var_name = $this->mod_write_check($this->job_title, null);
             if (ENABLE_NEW_JOBS == "Y" || ENABLE_NEW_JOBS == "1") {
                 $this->is_active = "Y";
             }
             if (APPROVE_JOB == "Y" || APPROVE_JOB == "1") {
                 $this->job_status = "approved";
             }
             $this->created_at = strftime(" %Y-%m-%d %H:%M:%S ", time());
             if ($this->create()) {
                 return true;
             } else {
                 $this->errors[] = "Problem occur.Please make sure all fields have been complated";
                 return false;
             }
         }
     }
 }
 public function save()
 {
     /** company_name **/
     if (empty($this->company_name)) {
         $this->errors[] = "Please enter company name";
     }
     if (!empty($this->temp_path) && !empty($this->filename)) {
         $this->company_logo = $this->username . "." . $this->exe;
         // Determine the target_path
         $target_path = COM_IMAGES_PATH . DS . $this->company_logo;
         $size = getimagesize($this->temp_path);
         $width = $size[0];
         $height = $size[1];
         if ($width > PIC_WIDTH || $height > PIC_HEIGHT) {
             $this->errors[] = "File size needs to be smaller then " . PIC_WIDTH . "x" . PIC_HEIGHT;
         }
         // Make sure a file doesn't already exist in the target location
         if (file_exists($target_path)) {
             $this->errors[] = "The file {$this->filename} already exists.";
             //return false;
         }
     }
     if (!empty($this->site_link)) {
         if (validateURL($this->site_link)) {
             $this->site_link = check_http($this->site_link);
         } else {
             $this->errors[] = "Please enter valid URL e.g. http://wwww.domain.com/uk/org";
         }
     }
     if (empty($this->country) || $this->country == 'AA') {
         $this->errors[] = "Please select country from list";
     }
     if (!empty($this->phone_number)) {
         $this->phone_number = phone_number($this->phone_number);
         if (!$this->phone_number) {
             $this->errors[] = "Please enter vaild phone number";
         }
     }
     // A new record won't have an id yet.
     if (isset($this->id)) {
         if (empty($this->contact_name)) {
             $this->errors[] = "Please enter contact name";
         }
         if (empty($this->address)) {
             $this->errors[] = "Please enter first line of address";
         }
         if (empty($this->state_province)) {
             $this->errors[] = "Please select state from list";
         }
         if (empty($this->county)) {
             $this->errors[] = "Please select county from list";
         }
         if (empty($this->city)) {
             $this->errors[] = "Please select city from list";
         }
         if (empty($this->phone_number)) {
             $this->errors[] = "Please enter contact telephone number";
         }
         if (!empty($this->phone_number)) {
             $this->phone_number = phone_number($this->phone_number);
             if (!$this->phone_number) {
                 $this->errors[] = "Please enter vaild phone number";
             }
         }
         if (sizeof($this->errors) == 0) {
             if (!empty($this->temp_path) && !empty($this->filename)) {
                 // Attempt to move the file
                 if (!move_uploaded_file($this->temp_path, $target_path)) {
                     $this->errors[] = "Unable to save company logo";
                     return false;
                 }
             }
             // if no errors update
             if ($this->update()) {
                 // We are done with temp_path, the file isn't there anymore
                 unset($this->temp_path);
                 return true;
             } else {
                 // File was not moved.
                 $this->errors[] = "Problem try to update your details. Please make sure all fields have been complated";
                 return false;
             }
         }
         //add new record
     } else {
         if (empty($this->username)) {
             $this->errors[] = "Please enter username";
         }
         //if username enter check username
         if (!empty($this->username)) {
             $username_found = self::check_username($this->username);
             if ($username_found && $username_found->username != $_SESSION['uname']) {
                 $this->errors[] = "Username already existed";
             }
             if (!check_username($this->username)) {
                 $this->errors[] = "The username should contain only letters, numbers and underscores";
             }
             if (strlen($this->username) < 4 || strlen($this->username) > 30) {
                 $this->errors[] = "The username must be between 4 - 30 characters";
             }
         }
         /*** Email validation */
         if (empty($this->email_address)) {
             $this->errors[] = "Please enter email address";
         }
         /* email**/
         if (!empty($this->email_address)) {
             if (!check_email($this->email_address)) {
                 $this->errors[] = "Invalid Email address e.g user@domain.com/co.uk/net";
             } else {
                 $email_found = self::check_email($this->email_address);
                 if ($email_found && $email_found->email_address != $_SESSION['email']) {
                     $this->errors[] = "Email address already existed";
                 }
             }
         }
         /** check password and conform password **/
         if ($this->passwd != $this->confirm_password || empty($this->passwd)) {
             $this->errors[] = "Password and Confirm Password does not match";
         }
         if (strlen($this->passwd) < 6 || strlen($this->passwd) > 20) {
             $this->errors[] = "Password must be between 6 - 20 characters ";
         }
         /*** check code */
         if (!$this->CAPTCHA) {
             $this->errors[] = "The security code you entered does not match the image.";
         }
         if ($this->terms == "" || empty($this->terms)) {
             $this->errors[] = "Please accept <a href='" . BASE_URL . "employer/page/terms/'>Terms of Use</a>";
         }
         if (sizeof($this->errors) == 0) {
             if (!empty($this->temp_path) && !empty($this->filename)) {
                 // Attempt to move the file
                 if (!move_uploaded_file($this->temp_path, $target_path)) {
                     $this->errors[] = "Unable to save company logo";
                     return false;
                 }
             }
             /** add credits to user account */
             $this->job_qty = START_CREDIT_POST;
             $this->cv_qty = START_CREDIT_CV_SEARCH;
             $this->spotlight_qty = START_CREDIT_SPOTLIGHT;
             $this->is_active = ACTIVE_EMPLOYER_AUTO;
             $this->passwd = md5($this->passwd);
             $this->date_register = strftime(" %Y-%m-%d %H:%M:%S ", time());
             $this->actkey = md5(session_id());
             if ($this->create()) {
                 // We are done with temp_path, the file isn't there anymore
                 unset($this->temp_path);
                 return true;
             } else {
                 // File was not moved.
                 $this->errors[] = "Problem try to register your details. \r\n\t\t\t\t\t\t\t\t\t\tPlease make sure all fields have been complated";
                 return false;
             }
         }
     }
 }
Example #14
0
        } else {
            if ($_GET['beacon'] == 'dynatrace') {
                $query = "SELECT DISTINCT url FROM urls WHERE dt_refresh_request <> 0";
            }
        }
    }
} else {
    if ($new) {
        $query = "SELECT DISTINCT url FROM urls INNER JOIN user_urls on user_urls.url_id = urls.id WHERE DATE_ADD(added, INTERVAL %d HOUR) > NOW()";
        foreach ($all_metrics as $provider_name => $provider) {
            $query .= " AND " . $provider['table'] . '_last_id IS NULL';
        }
        $query = sprintf($query, $monitoringPeriod);
    } else {
        $query = "SELECT DISTINCT url FROM urls INNER JOIN user_urls on user_urls.url_id = urls.id";
    }
}
$result = mysql_query($query);
if (!$result) {
    error_log(mysql_error());
}
$urls = array();
while ($row = mysql_fetch_assoc($result)) {
    $url = validateURL($row['url'], false);
    if (is_null($url)) {
        continue;
    }
    $urls[] = $url;
}
mysql_free_result($result);
echo implode("\n", $urls);
Example #15
0
function getUrlId($url, $outputerror = true)
{
    global $dropQueryStrings;
    $url = validateURL($url, $outputerror);
    if (is_null($url)) {
        return null;
    }
    if ($dropQueryStrings) {
        $drop = false;
        if (is_array($dropQueryStrings)) {
            foreach ($dropQueryStrings as $prefix) {
                if (substr($url, 0, strlen($prefix)) == $prefix) {
                    $drop = true;
                    break;
                }
            }
        } else {
            $drop = true;
        }
        if ($drop) {
            $querypos = strpos($url, '?');
            if ($querypos !== false) {
                $url = substr($url, 0, $querypos);
            }
        }
    }
    # get URL id
    $query = sprintf("SELECT id FROM urls WHERE url = '%s'", mysql_real_escape_string($url));
    $result = mysql_query($query);
    if (!$result) {
        beaconError(mysql_error());
    }
    if (mysql_num_rows($result) == 1) {
        $row = mysql_fetch_assoc($result);
        return $row['id'];
    } else {
        if (mysql_num_rows($result) == 0) {
            // Emulating unique index on a blob with unlimited length by locking the table on write
            // locking only when we're about to insert so we don't block the whole thing on every read
            // locking the table to make sure we pass it only by one concurrent process
            $result = mysql_query('LOCK TABLES urls WRITE');
            if (!$result) {
                beaconError(mysql_error());
            }
            // selecting the URL again to make sure there was no concurrent insert for this URL
            $query = sprintf("SELECT id FROM urls WHERE url = '%s'", mysql_real_escape_string($url));
            $result = mysql_query($query);
            if (!$result) {
                $mysql_err = mysql_error();
                mysql_query('UNLOCK TABLES');
                // unlocking the table if in trouble
                beaconError($mysql_err);
            }
            // repeating the check
            if (mysql_num_rows($result) == 1) {
                $row = mysql_fetch_assoc($result);
                $url_id = $row['id'];
            } else {
                if (mysql_num_rows($result) == 0) {
                    $query = sprintf("INSERT INTO urls (url) VALUES ('%s')", mysql_real_escape_string($url));
                    $result = mysql_query($query);
                    if (!$result) {
                        $mysql_err = mysql_error();
                        mysql_query('UNLOCK TABLES');
                        // unlocking the table if in trouble
                        beaconError($mysql_err);
                    }
                    $url_id = mysql_insert_id();
                } else {
                    if (mysql_num_rows($result) > 1) {
                        mysql_query('UNLOCK TABLES');
                        // unlocking the table if in trouble
                        beaconError('more then one entry found for the URL (when lock is aquired)');
                    }
                }
            }
            $result = mysql_query('UNLOCK TABLES');
            // now concurrent thread can try reading again
            if (!$result) {
                beaconError(mysql_error());
            }
            return $url_id;
        } else {
            beaconError('more then one entry found for the URL');
        }
    }
}
Example #16
0
function get_video($options)
{
    global $post;
    $featured_image = '';
    if (has_post_thumbnail(get_the_ID())) {
        $image = wp_get_attachment_image_src(get_post_thumbnail_id(get_the_ID()), 'blog');
        $featured_image = $image[0];
    }
    $options = array_merge(array('video' => '', 'poster' => $featured_image), $options);
    if (validateURL($options['video'])) {
        $oembed = wp_oembed_get($options['video'], array());
        if ($oembed !== false) {
            return $oembed;
        } else {
            return get_video_player(array('url' => $options['video'], 'poster' => $options['poster']));
        }
    } else {
        return $options['video'];
    }
}
Example #17
0
            $row['contactWebsite'] = "Not provided. Please update contact.";
        }
        if (is_null($row['contactNotes']) || empty($row['contactNotes'])) {
            $row['contactNotes'] = "Not provided. Please update contact.";
        }
        //output results to contact page
        echo "<div class='indContacts''>\n                    <h3 class='idHead'>ID: {$row['id']}</h3>\n                    <div class='contactImg'>\n                    <img src='{$row['contactImage']}'>\n                    </div>\n                    <div class='contactInfo'>\n                    <h2> {$row['firstname']} {$row['lastname']}</h2>\n                    <h5><span>Phone:</span> {$row['contactPhone']}</h5>\n                    <h5><span>Primary Email:</span> {$row['contactEmail']}</h5>\n                    <h5><span>Other Email:</span> {$row['altEmail']}</h5>\n                    <h5><span>Website:</span> {$row['contactWebsite']}</h5>\n                    <h5><span>Notes:</span> {$row['contactNotes']}</h5>\n                    </div>\n                    <div class='actionBtn'>\n                    <a href='updateContact.php?id={$row['id']}'><button class='updateBtn'>Update</button></a>\n                    <!-- uses Delete button uses javascript confirm() for delete confirmation alert -->\n                    <a href='deleteContact.php?id={$row['id']}' onclick=\"return confirm('Delete this contact?')\"><button class='deleteBtn'>Delete</button></a>\n                    </div>\n                </div>";
    }
}
//End function libraries
//start logic - Validation and Query Database on server request
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    //call validation functions instances
    $primEmailValidate = validateEmail($_POST['prim_email']);
    $otherEmailValidate = validateEmail($_POST['other_email']);
    $urlValidate = validateURL($_POST['website']);
    //email and url validation logic
    if ($primEmailValidate == false || $urlValidate == false || $otherEmailValidate == false) {
        if ($primEmailValidate == false) {
            echo "<div class='error_msg'>Please Enter Valid Primary Email. You Entered {$_POST['prim_email']}</div>";
        }
        if ($otherEmailValidate == false) {
            echo "<div class='error_msg'>Please Enter Valid Other Email. You Entered {$_POST['other_email']}</div>";
        }
        if ($urlValidate == true) {
            echo "<div class='error_msg'>Please Enter Valid URL using \"http://www.\" format. You Entered: {$_POST['website']}</div>";
        }
    } else {
        //set $_POST data variables
        $firstName = $_POST['first_name'];
        $lastName = $_POST['last_name'];