Example #1
0
function redirect($value, $permanent)
{
    if ($permanent == true) {
        header('HTTP/1.1 301 Moved Permanently');
    }
    header('Location: ' . checkLink($value));
}
Example #2
0
 public function init()
 {
     parent::init();
     if (Module::isEnabled('aimultidimensions')) {
         if (Tools::getIsset('add') && $this->context->cart->id) {
             require_once _PS_ROOT_DIR_ . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR . 'aimultidimensions' . DIRECTORY_SEPARATOR . 'aimultidimensions.php';
             require_once _PS_ROOT_DIR_ . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR . 'aimultidimensions' . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'config.php';
             require_once _PS_ROOT_DIR_ . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR . 'aimultidimensions' . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'functions' . $GLOBALS['aimd_config_suffix'] . '.php';
             $add = 1;
             $idProduct = (int) Tools::getValue('id_product', NULL);
             if (checkLink($idProduct)) {
                 $idProductAttribute = (int) Tools::getValue('id_product_attribute', Tools::getValue('ipa'));
                 $customizationId = (int) Tools::getValue('id_customization', 0);
                 $qty = (int) abs(Tools::getValue('qty', 1));
                 if ($add && $qty >= 0 && getProducts($idProduct)) {
                     $quantity = (int) Db::getInstance()->getValue('SELECT quantity FROM ' . _DB_PREFIX_ . 'cart_product WHERE id_cart = ' . $this->context->cart->id . ' AND id_product = ' . $idProduct . ' AND ' . 'id_product_attribute = ' . $idProductAttribute);
                     if (Tools::getValue('op', 'up') == 'up') {
                         $quantity += (int) $qty;
                     } else {
                         $quantity -= (int) $qty;
                     }
                     $cookie = $this->context->cookie;
                     $cart = $this->context->cart;
                     include_once 'modules/aimultidimensions/includes/cart.php';
                     Product::flushPriceCache();
                 }
             }
         }
     }
 }
Example #3
0
#!/usr/bin/env php
<?php 
// require(dirname(dirname(__FILE__)) . '/lib/autoload.php');
$links = array('https://dlib-adidp.ucs.ed.ac.uk:442/Images/EdinaLogo110x58px.jpg', 'https://idem.ced.inaf.it/LogoINAF100.png', 'https://idp.dante.net/idp/images/80x60-DANTE.jpg', 'https://idem.univpm.it/idp/shibboleth');
function url_get_contents($Url)
{
    if (!function_exists('curl_init')) {
        die('CURL is not installed!');
    }
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2);
    curl_setopt($ch, CURLOPT_TIMEOUT, 2);
    //timeout in seconds
    curl_setopt($ch, CURLOPT_URL, $Url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $output = curl_exec($ch);
    curl_close($ch);
    return $output;
}
function checkLink($url)
{
    // $data = file_get_contents($url);
    $data = url_get_contents($url);
}
foreach ($links as $link) {
    echo "Process " . $link . "\n";
    checkLink($link);
}
Example #4
0
 public static function import($jsonDatas, $keep_ids = FALSE, $logged = FALSE)
 {
     global $_CONFIG;
     if (!$logged) {
         die('You are not authorized to import books.');
     }
     $datas = json_decode($jsonDatas, TRUE);
     if (!isset($datas['books']) || !isset($datas['posters'])) {
         return FALSE;
     }
     $booksDatas = $datas['books'];
     $images = $datas['posters'];
     $id = time();
     $i = 0;
     $books = new Books($logged);
     foreach ($booksDatas as $book) {
         $id = $keep_ids && isset($book['id']) ? $book['id'] : $id;
         while (isset($books[$id])) {
             $id--;
         }
         $inputs = array('id' => $id, 'title' => isset($book['title']) ? trim(self::html_escaped($book['title'])) : NULL, 'author' => isset($book['author']) ? trim(self::html_escaped($book['author'])) : NULL, 'summary' => isset($book['summary']) ? checkNewLineContent(preg_replace('#<br( /)?>#', '', $book['summary'])) : NULL, 'publisher' => isset($book['publisher']) ? trim(self::html_escaped($book['publisher'])) : NULL, 'status' => isset($book['status']) && $book['status'] != NULL ? Book::SEEN : NULL, 'note' => isset($book['note']) ? checkRatingNote($book['note'], isset($book['status']) && $book['status'] != NULL ? Book::SEEN : NULL) : NULL, 'read_date' => isset($book['read_date']) ? checkInputDate($book['read_date']) : NULL, 'review' => isset($book['review']) ? checkNewLineContent(preg_replace('#<br( /)?>#', '', $book['review'])) : NULL, 'genre' => isset($book['genre']) ? checkGenre($book['genre']) : NULL, 'publication_year' => isset($book['release_date']) ? checkInputYear($book['release_date']) : NULL, 'pages' => isset($book['pages']) ? checkPages($book['pages']) : NULL, 'country' => isset($book['country']) ? checkCountry($book['country']) : NULL, 'link_website' => isset($book['link_website']) ? checkLink($book['link_website']) : NULL, 'link_image' => NULL);
         if (empty($inputs['title']) && empty($inputs['author']) && empty($inputs['summary'])) {
             continue;
         }
         if (function_exists('imagecreatefromjpeg') && !empty($images[$i])) {
             $image = explode(',', $images[$i]);
             if (!isset($image[1])) {
                 continue;
             }
             $imported = file_put_contents($_CONFIG['images'] . '/' . $id . '.jpg', base64_decode($image[1]));
             if ($imported == false) {
                 continue;
             }
             $inputs['link_image'] = $_CONFIG['images'] . '/' . $id . '.jpg';
         }
         $books[$id] = $inputs;
         $i++;
     }
     $books->save();
     return TRUE;
 }
Example #5
0
}
$webaddress = $_POST["website_url"];
$target_url = $webaddress;
$userAgent = 'Googlebot/2.1 (http://www.googlebot.com/bot.html)';
// make the cURL request to $target_url
$ch = curl_init();
curl_setopt($ch, CURLOPT_USERAGENT, $userAgent);
curl_setopt($ch, CURLOPT_URL, $target_url);
curl_setopt($ch, CURLOPT_FAILONERROR, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
$html = curl_exec($ch);
if (!$html) {
    echo "<br />cURL error number:" . curl_errno($ch);
    echo "<br />cURL error:" . curl_error($ch);
    exit;
}
// parse the html into a DOMDocument
$dom = new DOMDocument();
@$dom->loadHTML($html);
//grab titles and all the things
// grab all the on the page
$xpath = new DOMXPath($dom);
$hrefs = $xpath->evaluate("/html/body//a");
for ($i = 0; $i < $hrefs->length; $i++) {
    $href = $hrefs->item($i);
    $url = $href->getAttribute('href');
    checkLink($url, $target_url);
}
Example #6
0
	/**
	* Formats and populates the tables
	* 
	* @param $site (Array) URL or sets of URLs to crawl.
	* @param $query (String) link url to look for.
	* @param $return (String) specifies what data to return.
	*		1. matches - all matches found.
	*		2. no matches - list of urls that did not have any match
	*		3. invalid urls - urls with pages that cannot be found, not existing or malformed.
	* 
	* @return (Array) matches/no matches/invalid urls
	*/ 	
	function getData( $site, $query, $request ){
		
		$rows = array();
		$false_rows = array();
		$invalid_rows = array();
		$data = array();
		
		$urls = explode( "\r\n", $site ); 
		
		// validates each url and crawls them one by one for validated links.
		for( $i = 0; $i <= count($urls)-1; $i++ ){	
			if ( substr( $urls[$i], -1 ) == "/"){
				$urls[$i] = substr( $urls[$i], 0, -1);
			}
						
			if( validateURL( $urls[$i] ) == 1){						
				array_push( $data, checkLink( $urls[$i], $query ) ); 				
			}else{				
				array_push( $invalid_rows, $urls[$i] );								
			}
		}	
		
		// separates data for urls with matches and urls without matches.
		for ( $i = 0; $i <= count( $data )-1; $i++ ){		
			for ( $ii = 0; $ii <= count( $data[$i] )-1; $ii++ ){			
				if( $data[$i][$ii][1] == "not found" ){		
					array_push( $false_rows, $data[$i][$ii] ); 	
				}else{	
					array_push( $rows, $data[$i][$ii]);	
				}				
			}				
		}
		
		switch( $request ){
			case "matches":
				return $rows;
			break;
			case "no_matches":
				return $false_rows;
			break;
			case "invalid_urls":
				return $invalid_urls;
			break;
			case "all":
			default:
				$all_data = array(
					"matches" => $rows ,
					"no_matches" => $false_rows,
					"invalid_urls" => $invalid_rows
					);
				return $all_data;
		}
		
	}
Example #7
0
 public function checkLink($value, $protocol = 'http://')
 {
     return checkLink($value, $protocol);
 }