function get_encoding($strHTML, $header = false)
{
    $enc = "";
    if ($header) {
        //try to pull encoding from header information
        $strHeader = substr($strHTML, 0, strpos($strHTML, "<"));
        //looking for line Content-Type: text/html; charset=utf-8
        $pos = strpos($strHeader, "charset=");
        if ($pos !== FALSE) {
            $pos2 = strpos($strHeader, "\n", $pos);
            $enc = substr($strHeader, $pos + 8, $pos2 - $pos - 8);
        }
    }
    #$head_section = return_between($string=$strHTML, $start="<head>", $end="</head>", $type=EXCL);
    # Create an array of all the meta tags
    $meta_tag_array = parse_array($strHTML, $beg_tag = "<meta", $close_tag = ">");
    $new_page = "";
    # Examine each meta tag for a redirection command
    for ($xx = 0; $xx < count($meta_tag_array); $xx++) {
        # Look for http-equiv attribute
        $meta_attribute = get_attribute($meta_tag_array[$xx], $attribute = "http-equiv");
        #echo $meta_tag_array[$xx] . "\n";
        if (strtolower($meta_attribute) == "content-type") {
            #echo "HERE!";
            $new_page = return_between($meta_tag_array[$xx], $start = "charset", $end = ">", $type = EXCL);
            # Clean up URL
            $new_page = trim(str_replace("", "", $new_page));
            $new_page = str_replace("/", "", $new_page);
            $new_page = str_replace("=", "", $new_page);
            $new_page = str_replace("\"", "", $new_page);
            $new_page = str_replace("'", "", $new_page);
            $new_page = str_replace(" ", "", $new_page);
            break;
        }
    }
    if (strlen($enc) > 0 && strlen($new_page) > 0) {
        return $enc . "," . $new_page;
    } elseif (strlen($new_page) > 0) {
        return $new_page;
    } elseif (strlen($enc) > 0) {
        return $enc;
    } else {
        return "";
    }
}
Esempio n. 2
0
 public function getInfo()
 {
     $rawInfo = self::getRaw($this->action, $this->ref, $this->data);
     //import('SHD.simple_html_dom');
     $infoArray = parse_array($rawInfo['FILE'], '<tr>', '</tr>');
     $tr = [];
     $this->page = end($infoArray);
     foreach ($infoArray as $k => $v) {
         $tb = parse_array($v, '<td', '</td>');
         $temp = get_attribute($tb[7], 'href');
         $temp = split_string($temp, 'proj_idDes=', AFTER, EXCL);
         $tb[7] = remove($tb[7], '<a', '>');
         $tb[7] = remove($tb[7], '</a', '>');
         $temp2 = $tb[7];
         $tb[7] = [];
         $tb[7][] = $temp2;
         $tb[7][] = $temp;
         $temp4 = get_attribute($tb[8], 'href');
         $temp4 = split_string($temp4, 'proj_idDes=', AFTER, EXCL);
         $tb[8] = remove($tb[8], '<a', '>');
         $tb[8] = remove($tb[8], '</a', '>');
         $temp3 = $tb[8];
         $tb[8] = [];
         $tb[8][] = $temp3;
         $tb[8][] = $temp4;
         $tr[] = $tb;
         //parse_array($v,'<td','</td>');
         //var_dump($tr);
     }
     /*
              [4]=> array(9) { [0]=> string(37) "3" [1]=> string(30) "信息" [2]=> string(49) "201510613089 " [3]=> string(78) "基于人体肢体语言的机械臂操控" [4]=> string(62) "15国家创新训练项目" [5]=> string(45) "张翠芳" [6]=> string(185) "20132235 刘炳楠
     20132312 覃勇杰
     20132230 李晓芳
     20132169 涂敏
     " [7]=> string(145) "查看 " [8]=> string(158) " 成果展" }
     */
     /*$html=new simple_html_dom();
             $html->load($rawInfo["FILE"]);
             //var_dump($html);
     //return $rawInfo;
             $infoArray = $html->find('tr');*/
     return $tr;
 }
function harvest_links($url)
{
    # Initialize
    global $DELAY;
    $link_array = array();
    # Get page base for $url
    $page_base = get_base_page_address($url);
    # Download webpage
    sleep($DELAY);
    $downloaded_page = http_get($url, "");
    $anchor_tags = parse_array($downloaded_page['FILE'], "<a", "</a>", EXCL);
    # Put http attributes for each tag into an array
    for ($xx = 0; $xx < count($anchor_tags); $xx++) {
        $href = get_attribute($anchor_tags[$xx], "href");
        $resolved_addres = resolve_address($href, $page_base);
        $link_array[] = $resolved_addres;
        echo "Harvested: " . $resolved_addres . " \n";
    }
    return $link_array;
}
define("USER", YOUR_EMAIL_ADDRESS);
// Your POP3 email address
define("PASS", YOUR_PASSWORD);
// Your POP3 password
// Connect to POP3 server
$connection_array = POP3_connect(SERVER, USER, PASS);
$POP3_connection = $connection_array['handle'];
$list_array = POP3_list($POP3_connection);
$message = POP3_retr($POP3_connection, 1);
$ret_path = return_between($message, "Return-Path: ", "\n", EXCL);
$deliver_to = return_between($message, "Delivered-To: ", "\n", EXCL);
$date = return_between($message, "Date: ", "\n", EXCL);
$from = return_between($message, "From: ", "\n", EXCL);
$subject = return_between($message, "Subject: ", "\n", EXCL);
$content_type = return_between($message, "Content-Type: ", "\n", EXCL);
$boundary = get_attribute($content_type, "boundary");
$raw_msg = return_between($message, "--" . $boundary, "--" . $boundary, EXCL);
$clean_msg = return_between($raw_msg, chr(13) . chr(10) . chr(13) . chr(10), chr(13) . chr(10) . chr(13) . chr(10), EXCL);
echo "<xmp>ret_path   = {$ret_path}</xmp>";
echo "<xmp>deliver_to   = {$deliver_to}</xmp>";
echo "<xmp>date   = {$date}</xmp>";
echo "<xmp>subject  = {$subject}</xmp>";
echo "<xmp>content_type   = {$content_type} </xmp>";
echo "<xmp>boundary  = {$boundary} </xmp>";
echo "<xmp>clean_msg = {$clean_msg}</xmp>";
?>
<xmp><?php 
var_dump($message);
?>
</xmp>
</body>
Esempio n. 5
0
 /**
  * Merges the existing attributes with the new ones
  *
  * @param array|string $attributes Array of attribute 'name' => 'value' pairs
  *                                 or HTML attribute string
  * @param array|string $attributes Array of attribute 'name' => 'value' pairs
  *                                 or HTML attribute string
  *
  * @return string A string containing merged attributes
  */
 function merge_attributes_and_classes($attributes, $extra_attributes)
 {
     $attributes = prepare_attributes($attributes);
     $extra_attributes = prepare_attributes($extra_attributes);
     $class_extra = get_attribute($extra_attributes, 'class');
     $attributes = add_class($attributes, get_attribute($extra_attributes, 'class'));
     $extra_attributes = remove_attribute($extra_attributes, 'class');
     return merge_attributes($attributes, $extra_attributes);
 }
 /**
  * @param string $atts
  * @return string|void
  */
 public function call($atts = "")
 {
     global $post, $property;
     $this_property = $property;
     if (empty($this_property) && $post->post_type == 'property') {
         $this_property = $post;
     }
     $this_property = (array) $this_property;
     if (!$atts) {
         $atts = array();
     }
     $defaults = array('property_id' => $this_property['ID'], 'attribute' => '', 'before' => '', 'after' => '', 'if_empty' => '', 'do_not_format' => '', 'make_terms_links' => 'false', 'separator' => ' ', 'strip_tags' => '');
     $args = array_merge($defaults, $atts);
     if (empty($args['attribute'])) {
         return false;
     }
     $attribute = $args['attribute'];
     if ($args['property_id'] != $this_property['ID']) {
         $this_property = WPP_F::get_property($args['property_id']);
         if ($args['do_not_format'] != "true") {
             $this_property = prepare_property_for_display($this_property);
         }
     }
     if (taxonomy_exists($attribute) && is_object_in_taxonomy('property', $attribute)) {
         foreach (wp_get_object_terms($this_property['ID'], $attribute) as $term_data) {
             if ($args['make_terms_links'] == 'true') {
                 $terms[] = '<a class="wpp_term_link" href="' . get_term_link($term_data, $attribute) . '"><span class="wpp_term">' . $term_data->name . '</span></a>';
             } else {
                 $terms[] = '<span class="wpp_term">' . $term_data->name . '</span>';
             }
         }
         if (isset($terms) && is_array($terms) && !empty($terms)) {
             $value = implode($args['separator'], $terms);
         }
     }
     //** Try to get value using get get_attribute() function */
     if (!isset($value) || !$value && function_exists('get_attribute')) {
         $value = get_attribute($attribute, array('return' => 'true', 'property_object' => $this_property));
     }
     if (!empty($args['before'])) {
         $return['before'] = html_entity_decode($args['before']);
     }
     $return['value'] = apply_filters('wpp_property_attribute_shortcode', $value, $this_property);
     if ($args['strip_tags'] == "true" && !empty($return['value'])) {
         $return['value'] = strip_tags($return['value']);
     }
     if (!empty($args['after'])) {
         $return['after'] = html_entity_decode($args['after']);
     }
     //** When no value is found */
     if (empty($return['value'])) {
         if (!empty($args['if_empty'])) {
             return $args['if_empty'];
         } else {
             return false;
         }
     }
     if (is_array($return)) {
         return implode('', $return);
     }
     return false;
 }
function download_images_for_page($target)
{
    echo "target = {$target}\n";
    # Download the web page
    $web_page = http_get($target, $referer = "");
    # Update the target in case there was a redirection
    $target = $web_page['STATUS']['url'];
    # Strip file name off target for use as page base
    $page_base = get_base_page_address($target);
    # Identify the directory where iamges are to be saved
    $save_image_directory = "saved_images_" . str_replace("http://", "", $page_base);
    # Parse the image tags
    $img_tag_array = parse_array($web_page['FILE'], "<img", ">");
    if (count($img_tag_array) == 0) {
        echo "No images found at {$target}\n";
        exit;
    }
    # Echo the image source attribute from each image tag
    for ($xx = 0; $xx < count($img_tag_array); $xx++) {
        $image_path = get_attribute($img_tag_array[$xx], $attribute = "src");
        echo " image: " . $image_path;
        $image_url = resolve_address($image_path, $page_base);
        if (get_base_domain_address($page_base) == get_base_domain_address($image_url)) {
            # Make image storage directory for image, if one doesn't exist
            $directory = substr($image_path, 0, strrpos($image_path, "/"));
            $directory = str_replace(":", "-", $directory);
            $image_path = str_replace(":", "-", $image_path);
            clearstatcache();
            // clear cache to get accurate directory status
            if (!is_dir($save_image_directory . "/" . $directory)) {
                mkpath($save_image_directory . "/" . $directory);
            }
            # Download the image, report image size
            $this_image_file = download_binary_file($image_url, $ref = "");
            echo " size: " . strlen($this_image_file);
            # Save the image
            if (stristr($image_url, ".jpg") || stristr($image_url, ".gif") || stristr($image_url, ".png")) {
                $fp = fopen($save_image_directory . "/" . $image_path, "w");
                fputs($fp, $this_image_file);
                fclose($fp);
                echo "\n";
            }
        } else {
            echo "\nSkipping off-domain image.\n";
        }
    }
}
include_once "LIB_simple_spider.php";
// spider routines used by this app.
include_once "LIB_db_functions.php";
include_once "LIB_encoding.php";
set_time_limit(0);
// Don't let PHP timeout
db_connect();
//Before starting, check the domains fields of the database and fill in any missing entries
//Also fill in missing
//$strSQL="SELECT strURL,strDomain,strHTML FROM tblPages WHERE bolProcessed=0 AND bolCentral=1";
//$result = mysql_query($strSQL,$GLOBALS["db"]) or die('Query failed: ' . mysql_error());
$seed = db_get_next_to_process();
while ($seed != null) {
    $domain = $seed['strDomain'];
    $html = $seed['strHTML'];
    $atags = parse_array($html, "<a", "</a>");
    foreach ($atags as $tag) {
        $destURL = get_attribute($tag, "href");
        //echo "destURL: $destURL\n";
        if (strpos($destURL, "http://") !== false || strpos($destURL, "https://") !== false) {
            $destDomain = get_domain($destURL);
            //echo "Saving To-From: $domain - $destDomain\n";
            db_update_domain_links($domain, $destDomain);
        }
    }
    db_marked_processed($seed);
    $seed = db_get_next_to_process();
}
db_close();
echo "Done.\n";
mail($operator_email, "Parse Success", "Finished parsing external linked domains: " . date('Y-m-d H:i:s') . "\n", "FROM: " . $operator_email);
Esempio n. 9
0
$page_base = "https://www.nostarch.com/";
$headers = get_headers($target, 1);
if ($headers['Server'] == "cloudflare-nginx") {
    $cloudflare = 1;
    $target = str_replace("www", "ftp", $target);
    $referer = str_replace("www", "ftp", $referer);
    $page_base = str_replace("www", "ftp", $page_base);
}
$save_image_directory = "saved_images_" . preg_replace("/(http:\\/\\/|https:\\/\\/)/i", "", $page_base);
$web_page = http_get($target, $referer);
$books = array();
$bookCount = 0;
$html = new simple_html_dom();
$html->load($web_page['FILE']);
foreach ($html->find('div.views-field-field-image-cache-fid') as $image) {
    $books[$bookCount]['imageUrl'] = str_replace("www", "ftp", get_attribute($image->find('img', 0), 'src'));
    $bookCount++;
}
$bookCount = 0;
foreach ($html->find('div.views-field-title') as $title) {
    $books[$bookCount]['title'] = trim($title->plaintext);
    $links = $title->find('a');
    foreach ($links as $link) {
        $books[$bookCount]['pageUrl'] = resolve_address($link->href, $page_base);
    }
    $bookPage = http_get($books[$bookCount]['pageUrl'], $target);
    $bookHTML = new simple_html_dom();
    $bookHTML->load($bookPage['FILE']);
    foreach ($bookHTML->find('div.product-body') as $summary) {
        $books[$bookCount]['summary'] = remove($summary->outertext, '<img', '/>');
    }
Esempio n. 10
0
     if (!is_dir($save_image_directory)) {
         mkpath($save_image_directory);
     }
     $this_image_file = download_binary_file($books[$bookCount]['imageUrl'], $ref = "");
     if (stristr($books[$bookCount]['imageUrl'], ".jpg") || stristr($books[$bookCount]['imageUrl'], ".gif") || stristr($books[$bookCount]['imageUrl'], ".png")) {
         file_put_contents($save_image_directory . basename($books[$bookCount]['imageUrl']), $this_image_file);
     }
 }
 $divClass = 'views-field-title';
 if (stristr($div, $divClass)) {
     $books[$bookCount]['title'] = trim(strip_tags($div));
     $aTag = parse_array($div, '<a', '</a>');
     if ($cloudflare == 1) {
         $books[$bookCount]['bookUrl'] = resolve_address(str_replace("www", "ftp", get_attribute($aTag[0], $attribute = "href")), $page_base);
     } else {
         $books[$bookCount]['bookUrl'] = resolve_address(get_attribute($aTag[0], $attribute = "href"), $page_base);
     }
     $bookPage[$bookCount] = http_get($books[$bookCount]['bookUrl'], $target);
     $bookDivs[$bookCount] = parse_array($bookPage[$bookCount]['FILE'], "<div class=\"product-body\"", "</div>");
     $books[$bookCount]['summary'] = $bookDivs[$bookCount][0];
 }
 $divClass = 'views-field-field-author-value';
 if (stristr($div, $divClass)) {
     $books[$bookCount]['author'] = trim(strip_tags($div));
 }
 $divClass = 'views-field-field-isbn13-value';
 if (stristr($div, $divClass)) {
     $books[$bookCount]['ISBN13'] = trim(strip_tags($div));
 }
 $divClass = 'views-field-field-released-value';
 if (stristr($div, $divClass)) {
Esempio n. 11
0
    $result = curl_exec($ch);
    curl_close($ch);
    return $result;
}
$result = array();
$url = filter_input(INPUT_POST, "input-link");
$last_position = strripos($url, '/');
$last_position += 1;
$url_dir = substr($url, 0, $last_position);
$web_page = http_get($url, $ref = "");
$web_page = $web_page["FILE"];
$a_tag = parse_array($web_page, "<a ", ">");
$count = 0;
foreach ($a_tag as $val) {
    if (stristr($val, "playAudioBarPlay")) {
        $href_str = trim(get_attribute($val, "href"));
        $href_str = str_replace("'", "", $href_str);
        $href_str = str_replace("(", "", $href_str);
        $href_str = str_replace(")", "", $href_str);
        $href_arr = explode(",", $href_str);
        $href_str = str_replace("javascript:playAudioBarPlay", "", $href_arr[0]);
        if (!file_exists("audio/" . $href_str)) {
            $audio_file = download_audio($url_dir . 'aumpo/' . $href_str);
            file_put_contents("audio/" . $href_str, $audio_file);
            $file_size = filesize("audio/" . $href_str, $audio_file);
            if ($file_size === false || $file_size <= 0) {
                $result["result"] = "error download audio form link";
            }
        }
        $result["file_arr"][$count]["file_path"] = "../audio/" . $href_str;
        $count++;
Esempio n. 12
0
                                                }
                                                else {
                                                    echo get_uuid_dump($uuid, 'variable_gateway');
                                                } ?>
                        </td>
                        <td align="center"><?php if (get_attribute('direction') == 'inbound') {
                            echo "Caller Network";
                        }
                        else {
							if (get_uuid_dump($uuid, 'Caller-Channel-Progress-Media-Time') > 0) {
                            $diff = get_uuid_dump($uuid, 'Caller-Channel-Progress-Media-Time') - get_uuid_dump($uuid, 'Caller-Channel-Created-Time'); $res = round($diff / 1000000,2); echo $res .' sec';
							}
							else echo 0;
                        } ?>
                        </td>
                        <td align="center"><?php $diff=time()-strtotime(get_attribute('created'));
                                                 $hours = floor($diff / 3600);
                                                 $mins = floor(($diff - ($hours*3600)) / 60);
                                                 $seconds = floor(($diff - ($hours*3600) - ($mins*60)));
                                                 echo $hours. ':' .$mins. ':' .$seconds; ?>
                        </td>

                        <?php if($this->session->userdata('user_type') == 'admin'){?>
                            <td align="center">
                                <a href="#" id="<?php echo $uuid; ?>" class="cutcalls"><img src="<?php echo base_url();?>assets/images/button_cancel.png" style="width:16px;border:none;cursor:pointer;" /></a>
                            </td>
                        <?php } else if($this->session->userdata('user_type') == 'sub_admin') {
                            if(sub_admin_access_any_cell($this->session->userdata('user_id'), 'cut_calls') == 1) { ?>
                                <td align="center">
                                    <a href="#" id="<?php echo $uuid;?>" class="cutcalls"><img src="<?php echo base_url();?>assets/images/button_cancel.png" style="width:16px;border:none;cursor:pointer;" /></a>
                                </td>
Esempio n. 13
0
 function get_item($i)
 {
     global $schema;
     $i['id'] = sprintf("%u", $i['id']);
     $it = $schema['items'][$i['defindex']];
     if (is_array($it['attributes'])) {
         foreach ($it['attributes'] as $a) {
             $indexed[$a['name']] = $a;
         }
     }
     $it['attributes'] = $indexed;
     if ($i['attributes']) {
         foreach ($i['attributes'] as $a) {
             // Remove existing attrs with this index
             $v = $schema['attributes'][$a['defindex']];
             $v['value'] = $a['value'];
             $v['float_value'] = $a['float_value'];
             $it['attributes'][$v['name']] = $v;
         }
     }
     foreach ($i as $key => $var) {
         if ($key != 'attributes') {
             $it[$key] = $var;
         }
     }
     $it['position'] = $i['inventory'] & 0xffff;
     //$e = get_equipped($i['inventory']);
     //$e = equipped_convert($i['equipped']);
     $it['equipped'] = $i['equipped'];
     // language keys
     /*$it['type'] = get_lang_key('ItemTypeDesc',array(
     		1 => ($it['level'] > 0) ? $it['level'] : 1,
     		2 => get_lang_key($it['item_type_name'])
     		));*/
     $it['type'] = sprintf("Level %s %s", isset($it['level']) ? $it['level'] : 1, get_lang_key($it['item_type_name']));
     $it['name'] = htmlspecialchars(get_item_name($it));
     $it['name_url'] = rawurlencode(preg_replace("/[^a-zA-Z0-9]/", "-", $it['name']));
     $it['desc'] = $it['item_description'];
     if ($i['custom_desc']) {
         $it['desc'] = htmlspecialchars($i['custom_desc']);
     }
     //$it['attributes'] = $it['attributes']['attribute'];
     $dd = 0;
     if ($it['attributes']) {
         foreach ($it['attributes'] as $a) {
             $a_class = get_attribute($a['name']);
             if ($a['class'] == 'set_item_tint_rgb') {
                 $it['color'] = attribute_value($a);
                 //echo $a['value']."<br>";
             }
             if ($a['name'] == 'set supply crate series') {
                 $series = attribute_value($a);
                 $it['crate_series'] = $series;
                 $it['tooltip_tail'] .= get_crate_tooltip($series);
                 //echo $it['tooltip_tail'];
             }
             if ($a['name'] == 'kill eater') {
                 $it['kill_eater_kills'] = attribute_value($a);
                 $it['kill_eater_rank'] = get_kill_eater_rank($a);
             }
             $value = $a['value'];
             //echo $a_class['description_string'];
             //$description = sprintf($format_string,$value);
             if ($a['hidden'] == "1" || $a_class['hidden'] == "1") {
                 continue;
             }
             $desc = get_attribute_text($value, $a_class, $a['float_value']);
             $it['attrs'][] = $desc;
             // Colors use format imagename.color.png
             //var_dump($a);
             //die();
         }
     }
     $bits = explode('/', $it['image_url']);
     $it['image'] = $bits[count($bits) - 1];
     $it['tooltip'] = backpack::generate_tooltip($it);
     if ($it['color'] && $it['image_inventory'] == 'backpack/player/items/crafting/paintcan') {
         $it['image'] = str_replace('.png', '.' . $it['color'] . '.png', $it['image']);
     }
     if ($it['equipped']) {
         foreach ($it['equipped'] as $e) {
             $cn = int_to_class($e['class']);
             $it['equipped_by'][$cn] = true;
             $this->equipped[$cn][int_to_slot($e['slot'])] = $it;
         }
     }
     return $it;
 }
Esempio n. 14
0
function get_att_list($arr, $str, $code = '')
{
    $arr2 = array();
    for ($i = 0; $i < count($arr); $i++) {
        if ($code == '' || $code == $arr[$i]['att_code']) {
            $key = $arr[$i]['att_code'];
            $arr2[$key]['id'] = $arr[$i]['att_id'];
            $arr2[$key]['code'] = $arr[$i]['att_code'];
            $arr2[$key]['name'] = $arr[$i]['att_name'];
            $arr2[$key]['value'] = get_attribute($str, $arr[$i]['att_id']);
            if ($code != '') {
                break;
            }
        }
    }
    return $arr2;
}
				$End_Tag = '"';
				$inputname = return_between($Input, $Begin_Tag, $End_Tag, EXCL);
				$inputname = str_replace(chr(34),"",$inputname);

				//$inputname = get_attribute($Input,'name');
				//echo "input name: " . $inputname . "<br />";
				$pos = strpos($inputname, '=');
				if ($pos !== false)
					{
					$inputname = "no name";
					}

				$inputtype = get_attribute($Input,'type');
				//echo "input type: " . $inputtype . "<br />";

				$inputvalue = get_attribute($Input,'value');
				//echo "input value: " . $inputvalue . "<br />";
				$pos = strpos($inputvalue, 'html');
				if ($pos !== false)
					{
					}
				else
					{
					$InputResults = array();
					$InputResults['id'] = $inputid;
					$InputResults['name'] = $inputname;
					$InputResults['type'] = $inputtype;
					$InputResults['value'] = $inputvalue;
					array_push($FormResults['inputs'], $InputResults);
					}
            // add one to compensate for listing 0
            $url_found = true;
        }
    }
    # End: Parsing content
    #-------------------------------------------------
    #-------------------------------------------------
    # Start: Get location of the next page
    // Create an array of links on this page
    $search_links = parse_array($result['FILE'], "<a", "</a>", EXCL);
    // Look for the link with the word "Next" in it, as we know this
    // link contains the address of the next page.
    for ($xx = 0; $xx < count($search_links); $xx++) {
        if (strstr($search_links[$xx], "Next")) {
            $previous_target = $target;
            $target = get_attribute($search_links[$xx], "href");
            // Remember that this path is relative to the target page,
            // so add protocol and domain
            $target = "http://www.schrenk.com/nostarch/webbots/search/" . $target;
        }
    }
    # End: Get location of the next page
    #-------------------------------------------------
    # Don't seatch forever, stop after 10 pages
    if ($page_index == 10) {
        break;
    }
}
# End: Loop
#-------------------------------------------------
#-------------------------------------------------
Esempio n. 17
0
 			$downloaded_page = http_get_withheader($seed["strURL"], "");
 			$strHeader = substr($downloaded_page['FILE'],0,strpos($downloaded_page['FILE'],"<"));
 			$strSQL = "UPDATE tblPages SET " .
 			"strHeader='" .mysql_real_escape_string($strHeader) . "' WHERE iPageID=" . $seed["iPageID"];
 			db_run_query($strSQL);
 		}*/
 /*End insert*/
 echo "Parsing....\n";
 $anchor_tags = parse_array($strHTML, "<a ", "</a>", EXCL);
 # Put http attributes for each tag into an array
 $sqlQuery = "INSERT INTO tblLinks(fkParentID,fkChildID,fkQueryID,iNumberTimes) VALUES ";
 //print "1 sqlQuery is $sqlQuery\n";
 $outputExists = false;
 for ($xx = 0; $xx < count($anchor_tags); $xx++) {
     //print "tags : ". $anchor_tags[$xx]. "\n";
     $href = get_attribute($anchor_tags[$xx], "href");
     //print "href = $href , page_base = $page_base \n";
     if ($href === false) {
         continue;
     }
     $resolved_address = resolve_address($href, $page_base);
     //echo "have address: $resolved_address\n";
     if (!exclude_link($resolved_address)) {
         try {
             $out = "";
             $out = db_store_link($seed, $resolved_address);
             if ($out != NULL && $out != "") {
                 $outputExists = true;
                 $sqlQuery = $sqlQuery . $out . ",";
                 //print "2 sqlQuery is $sqlQuery\n";
             }
# Download the web page
$downloaded_page = http_get($target, $ref = "");
# Parse the links
$link_array = parse_array($downloaded_page['FILE'], $beg_tag = "<a", $close_tag = ">");
# Verify the links
?>
<table border="1" cellpadding="1" cellspacing="0">
    <tr bgcolor="#e0e0e0">
        <th>URL</th>
        <th>HTTP CODE</th>
        <th>DOWNLOAD TIME (seconds)</th>
    </tr>
<?php 
for ($xx = 0; $xx < count($link_array); $xx++) {
    // Parse the http attribute from link
    $link = get_attribute($tag = $link_array[$xx], $attribute = "href");
    // Create a fully resolved address
    $resloved_link_address = resolve_address($link, $page_base);
    $downloaded_link = http_get($resloved_link_address, $target);
    ?>
    <tr>
        <td align="left"><?php 
    echo $downloaded_link['STATUS']['url'];
    ?>
</td>
        <td align="right"><?php 
    echo $downloaded_link['STATUS']['http_code'];
    ?>
</td>
        <td align="right"><?php 
    echo $downloaded_link['STATUS']['total_time'];
Esempio n. 19
0
$handle = opecc_convert("input.txt");
$input_str = iconv("utf-8", "big5", $handle);
$input_str = trim($input_str);
$action = "http://sunlight.iis.sinica.edu.tw/cgi-bin/text.cgi";
$data_arr = array();
$data_arr["query"] = $input_str;
$result = http($action, $ref = "", $method = "POST", $data_arr, EXCL_HEAD);
$result_str = $result["FILE"];
$result_arr = parse_array($result_str, "<META ", ">");
$res_url = get_attribute($result_arr[1], "CONTENT");
$res_url = explode("=", $res_url);
$res_url = trim($res_url[1], "'");
echo "\n" . "response_url: http://sunlight.iis.sinica.edu.tw/" . $res_url . "\n";
//parse response url
$web_page = http_get("http://sunlight.iis.sinica.edu.tw/" . $res_url, $ref = "");
$web_page = trim($web_page["FILE"], "<br>");
$response_link = parse_array($web_page, "<a ", "</a>");
$response_link2 = parse_array($web_page, "<a ", ">");
$search_arr = array("'", '"');
$counter = count($response_link);
for ($count = 0; $count < $counter; $count++) {
    $temp_str = return_between($response_link[$count], "<a>", "</a>", EXCL);
    $temp_str = explode(">", $temp_str);
    $link = "http://sunlight.iis.sinica.edu.tw/" . get_attribute(str_replace($search_arr, '"', $response_link2[$count]), "HREF");
    $web_page = http_get($link, $ref = "");
    $web_page = $web_page["FILE"];
    $plain_text = return_between($web_page, "<pre>", "</pre>", EXCL);
    $plain_text = str_replace("-", "", trim($plain_text));
    echo "\n" . $plain_text . "\n";
    echo "\n" . $plain_text . "\n";
}
function act_log($link, $action, $activity)
{
    global $session;
    /**
     * 
     */
    //----------------------------[ read parameters from url ]
    if (isset($_GET['uid'])) {
        $uid = $_GET['uid'];
    } else {
        $uid = '';
    }
    //if (isset($_GET['source'])) $source=$_GET['source']; else $source='unknown';
    //	if (isset($_GET['application'])) $source=$_GET['application'];
    //$activity="act_log:0.106;loc:cpd".$activity;
    // try to read userID from $session
    $ra = "";
    if (isset($session)) {
        $ui = $session->userinfo;
        $ra = $_SERVER['REMOTE_ADDR'];
        $uid = $ra;
        if (isset($ui["username"])) {
            $uid = $ui["username"];
        }
    }
    if (isset($activity)) {
        $act = $activity;
    } else {
        $act = '';
    }
    $act = $activity;
    $act = set_attribute($act, 'remote_addr', $_SERVER['REMOTE_ADDR']);
    $tmp = "Schneider-login_name";
    if (isset($_COOKIE[$tmp])) {
        $tmpa = $_COOKIE[$tmp];
        if (is_string($tmpa)) {
            $act = set_attribute($act, $tmp, $tmpa);
        }
    }
    if ($uid == '') {
        $uid = $_SERVER['REMOTE_ADDR'];
    }
    if ($uid == '') {
        $uid = 'unknown';
    }
    $p = "";
    if (isset($_SERVER['QUERY_STRING'])) {
        $p = libMysqlEscape($_SERVER['QUERY_STRING']);
    }
    $geo = "";
    // if (isset($_COOKIE["SECTRYCODE"])) {$geo=set_attribute($geo,"SECTRYCODE",$_COOKIE["SECTRYCODE"]);}
    $client_id = "";
    if (isset($_COOKIE["help_client_uuid"])) {
        $client_id = $_COOKIE["help_client_uuid"];
    }
    $source = 'concepts';
    $geo = set_attribute($geo, 'country', geoCountryFromIP($link, act_log_getClientIP()));
    //$query="insert into `data_rpt`.`act_log` (`source`) values ('".$source."');";
    //$result = mysqli_query($link,$query);
    $apiKey = get_attribute($activity, "apikey");
    if (isset($_GET['apiKey'])) {
        $apiKey = $_GET['apiKey'];
    }
    //$query="insert into `data_rpt`.`act_log` (`source`,`uid`,`action`,`activity`,`query_string`,`remote_addr`) values ('".$source."','".$uid."','".$action."','".$act."','".$p."','".$ra."');";
    $query = "insert into `data_rpt`.`act_log` (`source`,`uid`,`action`,`activity`,`query_string`,`remote_addr`,`getClientIP`,`api_key`,`clientGeoData`,`prod_id`,`client_id`) values ('" . $source . "','" . $uid . "','" . $action . "','" . $act . "','" . $p . "','" . $ra . "','" . act_log_getClientIP() . "','" . $apiKey . "','" . $geo . "','" . strtoupper(get_attribute($activity, "prod_id")) . "','" . $client_id . "');";
    $result = mysqli_query($link, $query);
    //echo $query;
    return 0;
}
Esempio n. 21
0
						</p>
					</div>
				</div>
				<div id="tabs" class="meta_data">
					<ul>
						<?php 
if (isset($client_attributes) && !empty($client_attributes)) {
    foreach ($client_attributes as $client_attribute) {
        $attribute_id = $client_attribute['attribute_id'];
        $attribute_name = $client_attribute['attribute_name'];
        $attribute_array_index = $client_attribute['attribute_array_index'];
        echo '	<li id="li_' . $attribute_array_index . '" class="sortable">
												<a href="#tabs-' . $attribute_id . '" class="sub_tab"><span class="editable">' . $attribute_name . '</span></a>
											</li>';
    }
}
?>
					</ul>
					<?php 
if (isset($client_attributes) && !empty($client_attributes)) {
    foreach ($client_attributes as $client_attribute) {
        echo get_attribute($client_attribute);
    }
}
?>
				</div>
			</form>
		</div>
	</div>
</div>