Esempio n. 1
0
 /**
  * Extracts an Array off of HTML input.
  *
  * @access		private
  *
  * @param 		string 		$tag 		String, containing the html tag to select
  * @param 		string 		$attr 		String, containing the attribute used on the WHERE condition
  * @param 		string 		$value 		String, containing the value used on the WHERE condition
  * @param 		string 		$site 		Input string
  *
  * @return 		array 					Returns an array of results.
  */
 public static function extractMulti($tag, $attr, $value, $uri)
 {
     // external helper classs
     include_once "ext/htmlsql.class.php";
     $wsql = new htmlsql();
     $wsql->connect('string', SEOstats_Alexa::_alexa($uri));
     $wsql->query('SELECT * FROM ' . $tag . ' WHERE $' . $attr . ' == "' . $value . '"');
     $results = array();
     foreach ($wsql->fetch_array() as $row) {
         $results[] = $row['text'];
     }
     return $results;
 }
 /**
  * Highlights a string as php code
  * @param string $address The php code to highlight
  * @return array lat, long
  * @soapmethod
  */
 public static function getLatAndLong($address)
 {
     $address = urlencode($address);
     $apiKey = Prado::getApplication()->Parameters['GMapApiKey'];
     $apiUrl = "http://maps.google.com/maps/geo?&output=xml&key=" . $apiKey . "&q=" . $address;
     $wsql = new htmlsql();
     // connect to a URL
     if (!$wsql->connect('url', $apiUrl)) {
         print 'Error while connecting: ' . $wsql->error;
     }
     if (!$wsql->query('SELECT * FROM coordinates')) {
         print "Query error: " . $wsql->error;
     }
     $temp = $wsql->fetch_array();
     return $temp[0]['text'];
 }
Esempio n. 3
0
 public function getTicketHTMLSQL($username)
 {
     $this->urlxml = "http://" . $this->Application->Parameters['QlikViewHost'] . "/ticketWebserviceSecure/Service.asmx?wsdl";
     $this->url = "http://" . $this->Application->Parameters['QlikViewHost'] . "/ticketWebservicesecure/service.asmx/GetTicket?";
     $address = urldecode($this->url);
     $apiKey = $username;
     $apiUrl = $address . "UserID=" . $apiKey;
     $wsql = new htmlsql();
     // connect to a URL
     if (!$wsql->connect('url', $apiUrl)) {
         print 'Error while connecting: ' . $wsql->error;
     }
     if (!$wsql->query('SELECT * FROM string')) {
         print "Query error: " . $wsql->error;
     }
     $temp = $wsql->fetch_array();
     return $temp[0]['text'];
 }
Esempio n. 4
0
<?php

/*
 ** htmlSQL - Example 12
 **
 ** Shows how to replace the user agent and the referer with
 ** custom values
 */
include_once "../snoopy.class.php";
include_once "../htmlsql.class.php";
$wsql = new htmlsql();
// set a individual agent:
$wsql->set_user_agent('MyAgentName/0.9');
// set a new referer:
$wsql->set_referer('http://www.jonasjohn.de/custom/referer/');
// connect to a URL
if (!$wsql->connect('url', 'http://codedump.jonasjohn.de/')) {
    print 'Error while connecting: ' . $wsql->error;
    exit;
}
/* execute a query:
      
      This query returns all links:
   */
if (!$wsql->query('SELECT * FROM a')) {
    print "Query error: " . $wsql->error;
    exit;
}
// fetch results as array
foreach ($wsql->fetch_array() as $row) {
    print_r($row);
Esempio n. 5
0
<?php

/*
 ** htmlSQL - Example 3
 **
 ** Shows how to connect to a file and a simple query
 */
include_once "../snoopy.class.php";
include_once "../htmlsql.class.php";
$wsql = new htmlsql();
// connect to a file
if (!$wsql->connect('file', 'demo_data.htm')) {
    print 'Error while connecting: ' . $wsql->error;
    exit;
}
/* execute a query:
      
      This query searches in all tags for the id == header and returns
      the tag
   */
if (!$wsql->query('SELECT * FROM * WHERE $id == "header"')) {
    print "Query error: " . $wsql->error;
    exit;
}
// show results:
foreach ($wsql->fetch_array() as $row) {
    print_r($row);
}
Esempio n. 6
0
<?php

/*
 ** htmlSQL - Example 2
 **
 ** Shows a simple query and the "href as url" usage
 */
include_once "../snoopy.class.php";
include_once "../htmlsql.class.php";
$wsql = new htmlsql();
// connect to a file
if (!$wsql->connect('file', 'demo_data.htm')) {
    print 'Error while connecting: ' . $wsql->error;
    exit;
}
/* execute a query:
      
      This query extracts all links from the document
      and just returns href (as url) and text
   */
if (!$wsql->query('SELECT href as url, text FROM a')) {
    print "Query error: " . $wsql->error;
    exit;
}
// show results:
foreach ($wsql->fetch_array() as $row) {
    print "Link-URL: " . $row['url'] . "\n";
    print "Link-Text: " . trim($row['text']) . "\n\n";
}
Esempio n. 7
0
<?php

/*
 ** htmlSQL - Example 5
 **
 ** Shows a advanced query (with substr)
 */
include_once "../snoopy.class.php";
include_once "../htmlsql.class.php";
$wsql = new htmlsql();
// connect to a URL
if (!$wsql->connect('url', 'http://codedump.jonasjohn.de/links.htm')) {
    print 'Error while connecting: ' . $wsql->error;
    exit;
}
/* execute a query:
      
      This query returns all links of an document that not start with / 
      ( / = internal links)
   */
if (!$wsql->query('SELECT * FROM a WHERE substr($href,0,1) != "/"')) {
    print "Query error: " . $wsql->error;
    exit;
}
// fetch results as object and format as HTML links:
foreach ($wsql->fetch_objects() as $obj) {
    print '<a href="' . $obj->href . '">' . $obj->text . '</a><br/>';
    print "\n";
}
Esempio n. 8
0
<?php

/*
 ** htmlSQL - Example 11
 **
 ** Shows how to query a simple XML file
 */
include_once "../snoopy.class.php";
include_once "../htmlsql.class.php";
$wsql = new htmlsql();
// connect to the demo XML file:
if (!$wsql->connect('file', 'demo_xml.xml')) {
    print 'Error while connecting: ' . $wsql->error;
    exit;
}
/* execute a query:
      
      This query returns the id, name and password of all active users
   */
if (!$wsql->query('SELECT id, name, password FROM user WHERE $status == "active"')) {
    print "Query error: " . $wsql->error;
    exit;
}
// fetch results as array
foreach ($wsql->fetch_array() as $row) {
    print_r($row);
}
Esempio n. 9
0
 /**
  * @desc  Get the template layouts html by dir name
  * @param string dir name under the layouts subdir on your active template
  * @return string
  * @author	Microweber Dev Team
  * @version 1.0
  * @since Version 1.0
  */
 function layoutGetHTMLByDirName($layout_name)
 {
     CI::helper('directory');
     //$path = BASEPATH . 'content/templates/';
     $the_active_site_template = CI::model('core')->optionsGetByKey('curent_template');
     $path = TEMPLATEFILES . '' . $the_active_site_template . '/layouts/';
     //	print $path;
     //exit;
     $filename = $path . $layout_name . DIRECTORY_SEPARATOR . 'layout.php';
     if (is_file($filename)) {
         $html = cache_file_memory_storage($filename);
         if ($html != '') {
             require_once 'htmlsql-v0.5/htmlsql.class.php';
             require_once "htmlsql-v0.5/snoopy.class.php";
             $wsql = new htmlsql();
             // connect to a string
             if (!$wsql->connect('string', $html)) {
                 print 'Error while connecting: ' . $wsql->error;
                 exit;
             }
             if (!$wsql->query('SELECT * FROM img')) {
                 print "Query error: " . $wsql->error;
                 exit;
             }
             $path_styles = TEMPLATEFILES . '' . $the_active_site_template . '/layouts/' . $layout_name . '/styles/';
             if (is_dir($path_styles) == false) {
                 $path_styles = TEMPLATEFILES . '' . $the_active_site_template . '/layouts/' . $layout_name . '/';
             }
             if (is_dir($path_styles) == false) {
                 $path_styles = TEMPLATEFILES . '' . $the_active_site_template . '/layouts/';
             }
             // fetch results as array and output them:
             $arr = $wsql->fetch_array();
             if (!empty($arr)) {
                 foreach ($arr as $row) {
                     if (stristr($row['src'], 'http://') == false or stristr($row['src'], 'https://') == false or stristr($row['src'], 'ftp://') == false) {
                         $url = pathToURL($path_styles . $row['src']);
                         $html = str_ireplace($row['src'], $url, $html);
                     }
                 }
             }
         }
     }
     return $html;
 }
Esempio n. 10
0
<?php

/*
 ** htmlSQL - Example 4
 **
 ** Shows a advanced query with preg_match
 */
include_once "../snoopy.class.php";
include_once "../htmlsql.class.php";
$wsql = new htmlsql();
// connect to a URL
if (!$wsql->connect('url', 'http://codedump.jonasjohn.de/links.htm')) {
    print 'Error while connecting: ' . $wsql->error;
    exit;
}
/* execute a query:
      
      This query returns all links of an document that start with http://
   */
if (!$wsql->query('SELECT * FROM a WHERE preg_match("/^http:\\/\\//", $href)')) {
    print "Query error: " . $wsql->error;
    exit;
}
// show results:
foreach ($wsql->fetch_array() as $row) {
    print_r($row);
}
Esempio n. 11
0
<?php

/*
 ** htmlSQL - Example 7
 **
 ** Shows a complex query
 */
include_once "../snoopy.class.php";
include_once "../htmlsql.class.php";
$wsql = new htmlsql();
// connect to a URL
if (!$wsql->connect('url', 'http://codedump.jonasjohn.de/browse/lang/php/')) {
    print 'Error while connecting: ' . $wsql->error;
    exit;
}
/* execute a query:
      
      This query searches all links where the URL starts with /snippets and the text starts with 
      "array_" => so all links to array functions will be returned
   */
if (!$wsql->query('SELECT * FROM a WHERE preg_match("/^\\/snippets/i", $href) and preg_match("/^array_/i", $text)')) {
    print "Query error: " . $wsql->error;
    exit;
}
// fetch results as array return them:
foreach ($wsql->fetch_array() as $row) {
    print_r($row);
}
Esempio n. 12
0
if (!$wsql->connect('url', 'http://codedump.jonasjohn.de/rss/')) {
    print 'Error while connecting: ' . $wsql->error;
    exit;
}
/* execute a query:
      
      select the text attribute (alias for the tag content) from the <item> tag
   */
if (!$wsql->query('SELECT text FROM item')) {
    print "Query error: " . $wsql->error;
    exit;
}
// fetch all results as objects:
foreach ($wsql->fetch_objects() as $obj) {
    // create a new htmlsql object:
    $sub_wsql = new htmlsql();
    // connect to the <item> content:
    $sub_wsql->connect('string', $obj->text);
    // fetch all attributes of all tags:
    if (!$sub_wsql->query('SELECT * FROM *')) {
        print "Query error: " . $wsql->error;
        exit;
    }
    // this "special" function converts tagnames to keys
    $sub_wsql->convert_tagname_to_key();
    /* this function converts an array that looks like this:
       
           $array[0]['tagname'] = 'title';
           $array[0]['text'] = 'example 1';
           
           $array[1]['tagname'] = 'link';
Esempio n. 13
0
<?php

/*
 ** htmlSQL - Example 9
 **
 ** Shows how to use the "select" function
 */
include_once "../snoopy.class.php";
include_once "../htmlsql.class.php";
$wsql = new htmlsql();
// connect to a URL
if (!$wsql->connect('url', 'http://codedump.jonasjohn.de/')) {
    print 'Error while connecting: ' . $wsql->error;
    exit;
}
// restricts the search process to the content between
// <body> and </body>
// this also works with other tags like: head or html, or table
$wsql->select('body');
/*
    other examples:

    $wsql->select('div',3); <-- selects the third <div>
    
    $wsql->select('table',0); <-- selects the first table        
                        ^ default is also = 0
*/
/* execute a query:
      
      This query returns all <h1> headers
   */
Esempio n. 14
0
function find_followers($page)
{
    $folli = array();
    $wsql = new htmlsql();
    // connect to a URL
    if (!$wsql->connect('string', connect_to_url('http://www.tumblr.com/followers/page/' . $page))) {
        print 'Error while connecting: ' . $wsql->error;
        exit;
    }
    if (!$wsql->query('SELECT text FROM div WHERE $class="name"')) {
        print "Query error: " . $wsql->error;
        exit;
    }
    foreach ($wsql->fetch_array() as $row) {
        $t = trim($row['text']);
        $cut_from = strpos($t, '<img class="avatar"');
        if (strpos($t, '<a href') == 0 && $cut_from) {
            $folli[] = substr($t, 9, $cut_from - 11);
        }
    }
    return $folli;
}
Esempio n. 15
0
<?php

/*
 * Прост скрипт с който можем да вземем статистиката за ключовите от Tyxo.bg
 * Author: Marian Ignev
 * Web: http://m.ignev.net/
 * e-Mail: m[at]ignev[dot]net
 */
$web_url = 'http://tyxo.bg/?ID=86937&show=lastse';
include_once "snoopy.class.php";
include_once "htmlsql.class.php";
//Създаваме инстанция на класа
$wsql = new htmlsql();
if (!$wsql->connect('url', $web_url)) {
    print 'Error while connecting: ' . $wsql->error;
    exit;
}
if (!$wsql->query('SELECT * FROM table')) {
    print "Query error: " . $wsql->error;
    exit;
}
$arr = $wsql->fetch_array();
//Това е масива в които се намира информацията за нашата таблица от която извличаме инфото
//print_r( $arr[15]['text'] );
if (!$wsql->connect('string', $arr[15]['text'])) {
    print 'Error while connecting: ' . $wsql->error;
    exit;
}
if (!$wsql->query('SELECT * FROM font WHERE $color == "#F56800"')) {
    print "Query error: " . $wsql->error;
    exit;
Esempio n. 16
0
<?php

/*
 ** htmlSQL - Example 10
 **
 ** Shows how to use the "isolate_content" function
 */
include_once "../snoopy.class.php";
include_once "../htmlsql.class.php";
$wsql = new htmlsql();
// connect to a URL
if (!$wsql->connect('url', 'http://codedump.jonasjohn.de/')) {
    print 'Error while connecting: ' . $wsql->error;
    exit;
}
/*
 ** The isolate_content functions works like the select function,
 ** but you can specify custom HTML parts, the content between
 ** these two strings will be used for the query process
 **
 ** In this case we select all content between "<h1>New snippets</h1>"
 ** and "<p id="rss">" this returns all snippet links, and no other links
 ** (like header or navigation links)
 */
$wsql->isolate_content('<h1>New snippets</h1>', '<p id="rss">');
/*
    other examples:

    $wsql->isolate_content('<body>', '</body>');
    $wsql->isolate_content('<!--content:start-->', '<!--end-->');
*/
Esempio n. 17
0
<?php

/*
 ** htmlSQL - Example 6
 **
 ** Show how to connect to a string
 */
include_once "../snoopy.class.php";
include_once "../htmlsql.class.php";
$some_html = '<a href="link1.htm">link1</a> <b>foobar</b> ';
$some_html .= '<a href="link2.htm">link2</a> <hr/>';
$wsql = new htmlsql();
// connect to a string
if (!$wsql->connect('string', $some_html)) {
    print 'Error while connecting: ' . $wsql->error;
    exit;
}
/* execute a query:
      
      This query returns all links of the given HTML
   */
if (!$wsql->query('SELECT * FROM a')) {
    print "Query error: " . $wsql->error;
    exit;
}
// fetch results as array and output them:
foreach ($wsql->fetch_array() as $row) {
    print_r($row);
}
Esempio n. 18
0
 function _pre_insert($do)
 {
     $this->load->library('snoopy');
     $this->load->library('htmlsql');
     $do->set('estampa', date('Ymdhis'));
     $codigos = explode(';', $do->get('codigo'));
     $codigos = array_unique($codigos);
     $nombre = $do->get('nombre');
     $do->set('codigo', implode(';', $codigos));
     $html = $do->get('contenido');
     $wsql = new htmlsql();
     if (!$wsql->connect('string', $html)) {
         print 'Error while connecting: ' . $wsql->error;
         exit;
     }
     if (!$wsql->query('SELECT src FROM img')) {
         print "Query error: " . $wsql->error;
         exit;
     }
     foreach ($wsql->fetch_array() as $row) {
         foreach ($codigos as $codigo) {
             $cant = $this->datasis->dameval("SELECT COUNT(*) FROM sinvfot WHERE codigo='{$codigo}' AND nombre='{$nombre}'");
             if ($cant == 0) {
                 $id = $this->datasis->dameval("SELECT id FROM sinv WHERE codigo='{$codigo}'");
                 $data = array('codigo' => $codigo, 'nombre' => basename($row['src']), 'ruta' => $this->upload_path . 'Image', 'sinv_id' => $id);
                 $mSQL = $this->db->insert_string('sinvfot', $data);
                 $mSQL = str_replace('INSERT INTO', 'INSERT IGNORE INTO', $mSQL);
                 $this->db->simple_query($mSQL);
             }
         }
     }
 }
Esempio n. 19
0
<?php

/*
 ** htmlSQL - Example 1
 **
 ** Shows a simple query
 */
include_once "../snoopy.class.php";
include_once "../htmlsql.class.php";
$wsql = new htmlsql();
// connect to a URL
if (!$wsql->connect('url', 'http://codedump.jonasjohn.de/')) {
    print 'Error while connecting: ' . $wsql->error;
    exit;
}
/* execute a query:
       
      This query extracts all links with the classname = nav_item   
   */
if (!$wsql->query('SELECT * FROM a WHERE $class == "nav_item"')) {
    print "Query error: " . $wsql->error;
    exit;
}
// show results:
foreach ($wsql->fetch_array() as $row) {
    print_r($row);
    /* 
    $row is an array and looks like this:
    Array (
        [href] => /feedback.htm
        [class] => nav_item
Esempio n. 20
0
*/
//print_r( $wsql );
$news = array();
/* Така можем да си видим резултата от нашето творение:
		
		Този цикъл тук ни трябва, защото понеже вземаме послените новини, а те са повече от 1.
		Не винаги е нужно да циклите резултата който ни връща fetch_array или fetch_objects,
		Най-добре си го var_dump-нете и си вижте какво се случва.
		
	*/
foreach ($wsql->fetch_array() as $row) {
    //Виждаме какво ни връща. Полезно при писане на скрипта.
    //print_r($row);
    $news_name = $row['text'];
    $news_real_link = $web_url . $news_query_string;
    $news_content = new htmlsql();
    $news_content->connect('url', $news_real_link);
    /*
    	Ако не ви е станало ясно тук взема всичко от всички елементи които имат id="textsize".
    	
    	Идеята в случая FROM * го правя така, защото в един красив слънчев ден вече този елемент
    	не е <div> а е <p> ще продължи да си работи.
    */
    if (!$news_content->query('SELECT * FROM * WHERE $class=="wfCurrentTemp"')) {
        print "Query error: " . $news_content->error;
        exit;
    }
    //Виждаме какво ни връща. Полезно при писане на скрипта.
    //print_r( $news_content->fetch_array() );
    //exit;
    $news_text = $news_content->fetch_array();