/** * 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']; }
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']; }
** 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 [tagname] => a [text] => Feedback ) */ }
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); } } } }
$array[0]['tagname'] = 'title'; $array[0]['text'] = 'example 1'; $array[1]['tagname'] = 'link'; $array[1]['text'] = 'http://www.example.org/'; $array[2]['tagname'] = 'description'; $array[2]['text'] = 'description bla'; $array[2]['fulltext'] = '1'; // additional attribute -> to: $array['title']['text'] = 'example 1'; $array[1]['link']['text'] = 'http://www.example.org/'; $array[2]['description']['text'] = 'description bla'; $array[2]['description']['fulltext'] = '1'; // additional attribute this makes the array easier to access */ // fetch item as array: $item = $sub_wsql->fetch_array(); // format the extracted links as HTML links and output them: print "<a href=\"" . $item['link']['text'] . "\">"; print $item['title']['text'] . "</a><br/>\n"; // also available: // description, pubDate }
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; }
* 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; } $ips_arr = $wsql->fetch_array(); //print_r( $ips_arr ); //exit; if (!$wsql->query('SELECT * FROM a')) { print "Query error: " . $wsql->error;
/** * @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; }
Този цикъл тук ни трябва, защото понеже вземаме послените новини, а те са повече от 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(); // $news[] = array('text' => $news_text[0]['text']); } //print_r( $news ); //Можете да видите как да си изпринтим съдържанието в index.php файла.