Ejemplo n.º 1
0
    array_push($rows, $row);
}
$sth->close();
$cache = array();
// find the relevant ids based on the string names we have been given, create records if needed
// insert the pool items into the real tables
foreach ($rows as $row) {
    $pool_id = $row['pool_id'];
    $network_name = $row['network_name'];
    $channel_name = $row['channel_name'];
    $nick_name = $row['nick_name'];
    $message = $row['message'];
    // remove this item from the pool now
    // if anything goes wrong trying to merge it we won't keep trying every pool update
    clean_pool($dbh, $pool_id);
    $urls = get_urls($message);
    if (count($urls) == 0) {
        exit;
    }
    echo "pool_id={$pool_id}; ";
    echo 'urls=' . count($urls) . ' ';
    $network_id = get_network_id($dbh, $cache, $network_name);
    if (!$network_id) {
        exit;
    }
    echo "{$network_name}({$network_id}) ";
    $channel_id = get_channel_id($dbh, $cache, $network_id, $channel_name);
    if (!$channel_id) {
        exit;
    }
    echo "{$channel_name}({$channel_id}) ";
Ejemplo n.º 2
0
<?php

include 'get_connection.php';
try {
    if (PHP_SAPI === 'cli') {
        $county = $argv[1];
    } else {
        $county = $_GET['county'];
    }
    get_urls($conn, $county);
} catch (PDOException $e) {
    echo "Connection failed: " . $e->getMessage();
    return;
}
$conn = null;
function get_urls($conn, $county)
{
    $stmt = "SELECT name, id FROM cities where county_id = :county";
    $sth = $conn->prepare($stmt);
    $sth->bindparam(':county', $county);
    $sth->execute();
    $result = $sth->fetchAll();
    $length = count($result);
    for ($i = 0; $i < $length; $i++) {
        $city = $result[$i][0];
        $url = "http://10.171.204.135/city-polls.html?topic=" . $result[$i]['id'];
        $city = str_replace("_", " ", $result[$i]['name']);
        $city = ucwords($city);
        echo "<a href = " . $url . " class='list-group-item'>" . $city . "</a>";
    }
}
Ejemplo n.º 3
0
<?php

require_once 'DB.php';
require_once 'config.php';
$dsn = 'mysql://*****:*****@localhost/shinyw2_spider';
$options = array('debug' => 2, 'portability' => DB_PORTABILITY_ALL);
$db =& DB::connect($dsn, $options);
if (PEAR::isError($db)) {
    die($db->getMessage());
}
$page = file_get_contents('http://www.starblast.org');
print_r(get_urls($page));
function get_urls($string)
{
    $regexp = '/' . "(href|src|url)[\\s]*=\"?[^ #\">]+\"?(?=[ #>])?" . '/';
    $regexp = '/' . "<a[\\s]+[^>]*?href[\\s]*=[\"']?[^ >]+(?=[ #>])[\"']?>([^<]+|.*?)?<\\/a>" . '/';
    preg_match_all($regexp, $string, &$matches);
    $ret = $matches;
    return $ret;
}
Ejemplo n.º 4
0
<?php

include 'get_login.php';
try {
    $servername = $login_info['servername'];
    $dbname = $login_info['dbname'];
    $conn = new PDO("mysql:host={$servername};dbname={$dbname}", $login_info['username'], $login_info['password']);
    $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    get_urls($conn);
} catch (PDOException $e) {
    echo "Connection failed: " . $e->getMessage();
    return;
}
$conn = null;
function get_urls($conn)
{
    $stmt = "SELECT name FROM states";
    $sth = $conn->prepare($stmt, array(PDO::ATTR_CURSOR => PDO::CURSOR_FWDONLY));
    $sth->execute();
    $result = $sth->fetchAll();
    $length = count($result);
    for ($i = 0; $i < $length; $i++) {
        $state = $result[$i][0];
        $url = "http://10.171.204.135/state-polls.html?topic=" . $state;
        //echo $county ."\n". $url . $county . "\n";
        $state = str_replace("_", " ", $state);
        $state = ucwords($state);
        echo "<a class='list-group-item' href = " . $url . ">" . $state . "</a>";
    }
}
Ejemplo n.º 5
0
<?php

session_start();
include "../../inc/config.php";
include "../class/manager.class.php";
include "seofunctions.php";
include "pr.class.php";
$url_group = $_GET['url_group'];
$urls = get_urls('all');
$url_pr = compute_pagerank($urls);
/*
echo '<pre>';	
print_r($url_pr);
echo '</pre>';
*/
//write to `seo_urls` table
//delete current record
$sql_delete = "delete from `{$tprefix}" . "_seo_urls`";
echo $sql_delete;
$db->query($sql_delete);
//insert into table `seo_urls`
for ($i = 0; $i < count($url_pr); $i++) {
    $sql = "insert into `{$tprefix}" . "_seo_urls` (`url`,`pagerank`) values ('" . $url_pr[$i]['url'] . "','" . $url_pr[$i]['pagerank'] . "')";
    $db->query($sql);
    echo $sql . '<br>';
}
Ejemplo n.º 6
0
<?php

include 'get_connection.php';
try {
    if (PHP_SAPI === 'cli') {
        $county_id = $argv[1];
    } else {
        $county_id = $_GET['county_id'];
    }
    get_urls($conn, $county_id);
} catch (PDOException $e) {
    echo "Connection failed: " . $e->getMessage();
    return;
}
$conn = null;
function get_urls($conn, $county_id)
{
    $county_id = strtolower($county_id);
    $stmt = "SELECT cities.name FROM counties JOIN cities ON cities.county_id = counties.id WHERE counties.id = :county_id";
    $sth = $conn->prepare($stmt);
    $sth->bindparam(':county_id', $county_id);
    $sth->execute();
    $result = $sth->fetchAll();
    $length = count($result);
    for ($i = 1; $i < $length; $i++) {
        $city = $result[$i][0];
        $city = str_replace("_", " ", $city);
        $city = ucwords($city);
        echo "<option value='" . $city . "'>" . $city . "</option>";
    }
}
Ejemplo n.º 7
0
/**
 * Add a javascript ban action icon after each url in the given content
 *
 * @param string Comment content
 * @return string the content with a ban icon after each url if the user has spamblacklist permission, the incoming content otherwise
 */
function add_ban_icons($content)
{
    global $current_User;
    if (!$current_User->check_perm('spamblacklist', 'edit')) {
        return $content;
    }
    $atags = get_atags($content);
    $imgtags = get_imgtags($content);
    $urls = get_urls($content);
    $result = '';
    $from = 0;
    // current processing position
    $length = 0;
    // current url or tag length
    $i = 0;
    // url counter
    $j = 0;
    // "a" tag counter
    $k = 0;
    // "img" tag counter
    while (isset($urls[$i])) {
        // there is unprocessed url
        $url = $urls[$i];
        if (validate_url($url, 'posting', false)) {
            // skip not valid urls
            $i++;
            continue;
        }
        while (isset($imgtags[$k]) && strpos($content, $imgtags[$k]) < $from) {
            // skipp already passed img tags
            $k++;
        }
        $pos = strpos($content, $url, $from);
        $length = evo_strlen($url);
        $i++;
        // check img tags
        if (isset($imgtags[$k]) && strpos($imgtags[$k], $url) !== false && $pos > strpos($content, $imgtags[$k], $from)) {
            // current url is inside the img tag, we need to skip this url.
            $result .= substr($content, $from, $pos + $length - $from);
            $from = $pos + $length;
            $k++;
            continue;
        }
        // check a tags
        if (isset($atags[$j])) {
            // there is unprocessed "a" tag
            $tag = $atags[$j];
            if (($urlpos = strpos($tag, $url)) !== false && $pos > strpos($content, $tag, $from)) {
                // the url is inside the current tag, we have to add ban icon after the tag
                $pos = strpos($content, $tag, $from);
                $length = strlen($tag);
                while (isset($urls[$i]) && ($urlpos = strpos($tag, $urls[$i], $urlpos + 1)) !== false) {
                    // skip all other urls from this tag
                    $i++;
                }
                $j++;
            }
        }
        // add processed part and ban icon to result and set current position
        $result .= substr($content, $from, $pos + $length - $from);
        $from = $pos + $length;
        $result .= add_jsban($url);
    }
    // add the end of the content to the result
    $result .= substr($content, $from, strlen($content) - $from);
    return $result;
}
Ejemplo n.º 8
0
</table></form><br><br><br>';
    echo $form;
    include 'data/d/footer.php';
} elseif (isset($_GET['links_for'])) {
    //Получаем домен и файл с линками дора
    $domen = urldecode($_GET["links_for"]);
    $links_file = "data/maps/{$domen}.txt";
    if (is_file($links_file)) {
        $links = file_get_contents($links_file);
        $links_arr = file($links_file);
    } else {
        $links = 'Линков нет';
        $links_arr = array();
    }
    $project_name = str_replace('.', '_', $domen);
    $urls_arr = get_urls($links_arr);
    $urls = implode("\n", $urls_arr[0]);
    $ankors = implode("\n", $urls_arr[1]);
    $bbcodes = implode("\n", $urls_arr[2]);
    $hrefs = implode("\n", $urls_arr[3]);
    $name = '{';
    $name .= implode("|", $urls_arr[1]);
    $name .= '}#gennick[dfds, 2, 4]';
    $nick_name = str_replace(' ', '', $name);
    include 'data/d/header.php';
    //Выводим форму
    $form = '<form action=' . $_SERVER['PHP_SELF'] . ' method="post">
<table width="98%" height="70px" border="0" align="center">
<tr><td colspan="3" class="title">Link for ' . $domen . '</td></tr>
<tr><td colspan="3" class="title">Xrumer Project</td></tr>
<tr><td align="left" colspan="3">Project file name:  <input type="text" size="50" value="' . $project_name . '.xml"></td></tr>
Ejemplo n.º 9
0
function _extractTemplateImages($template)
{
    $result = array();
    $urls = get_urls($template->content);
    // we're only concerned about the src urls
    foreach ($urls['src'] as $src) {
        // if it's an external link we ignore it
        // if it's an internal link, we add it
        if (!preg_match('/^http\\:/', $src)) {
            $result[] = $src;
        }
    }
    return $result;
}
Ejemplo n.º 10
0
function _extractTemplateImages($template)
{
    $result = array();
    $config = cmsms()->GetConfig();
    $urls = get_urls($template->content);
    // we're only concerned about the src urls
    foreach ($urls['src'] as $src) {
        // if it's an external link we ignore it
        // if it's an internal link, we add it
        if (!startswith($src, 'http') || startswith($src, $config['root_url'])) {
            $result[] = $src;
        }
    }
    return $result;
}
Ejemplo n.º 11
0
        $id = $row["id"];
        $index_st = explode('&', $row["index_urls"]);
        $map_st = explode('&', $row["map_urls"]);
        $page_st = explode('&', $row["page_urls"]);
        $index_urls = array_merge($index_urls, $index_st);
        $map_urls = array_merge($map_urls, $map_st);
        $page_urls = array_merge($page_urls, $page_st);
    }
    mysql_free_result($result);
    $index_urls = array_clear(array_values(array_unique($index_urls)));
    $map_urls = array_clear(array_values(array_unique($map_urls)));
    $page_urls = array_clear(array_values(array_unique($page_urls)));
    $project_name = str_replace('.', '', $domen);
    $aposter_links = implode("\n", $page_urls);
    //$urls_arr = get_urls($links_arr);
    $urls_arr = get_urls($page_urls);
    $urls = implode("\n", $urls_arr[0]);
    $ankors = implode("\n", $urls_arr[1]);
    $bbcodes = implode("\n", $urls_arr[2]);
    $hrefs = implode("\n", $urls_arr[3]);
    $name = '{';
    $name .= implode("|", $urls_arr[1]);
    $name .= '}#gennick[' . md5($domen) . ', 5, 8]';
    $nick_name = str_replace(' ', '', $name);
    include 'data/d/header.php';
    //Выводим форму
    $form = '<form action=' . $_SERVER['PHP_SELF'] . ' method="post">
<table width="98%" height="70px" border="0" align="center">
<tr><td colspan="3" class="title">Link for ' . $domen . '</td></tr>
<tr><td colspan="3" class="title">Xrumer Project</td></tr>
<tr><td align="left" colspan="3">Project file name:  <input type="text" size="50" value="' . $project_name . '.xml"></td></tr>
Ejemplo n.º 12
0
/**
 * Callback function to add a javascript ban action icon after each url in the given content
 *
 * @param string Comment content
 * @return string the content with a ban icon after each url if the user has spamblacklist permission, the incoming content otherwise
 */
function add_ban_icons_callback($content)
{
    $atags = get_atags($content);
    $imgtags = get_imgtags($content);
    $urls = get_urls($content);
    $result = '';
    $from = 0;
    // current processing position
    $length = 0;
    // current url or tag length
    $i = 0;
    // url counter
    $j = 0;
    // "a" tag counter
    $k = 0;
    // "img" tag counter
    // Remove the duplicated <a> tags from array
    $atags_fixed = array();
    foreach ($atags as $atag) {
        if (preg_match('#href="([^"]+)"#', $atag, $matches) && !isset($atags_fixed[$matches[1]])) {
            $atags_fixed[$matches[1]] = $atag;
        }
    }
    $atags = array();
    foreach ($atags_fixed as $atag) {
        $atags[] = $atag;
    }
    $used_urls = array();
    while (isset($urls[$i])) {
        // there is unprocessed url
        $url = $urls[$i];
        if (validate_url($url, 'posting', false)) {
            // skip not valid urls
            $i++;
            continue;
        }
        if (in_array($url, $used_urls)) {
            // skip already passed url
            $i++;
            continue;
        }
        $used_urls[] = $url;
        while (isset($imgtags[$k]) && strpos($content, $imgtags[$k]) < $from) {
            // skip already passed img tags
            $k++;
        }
        $pos = strpos($content, $url, $from);
        $length = utf8_strlen($url);
        $i++;
        // check img tags
        if (isset($imgtags[$k]) && strpos($imgtags[$k], $url) !== false && $pos > strpos($content, $imgtags[$k], $from)) {
            // current url is inside the img tag, we need to skip this url.
            $result .= substr($content, $from, $pos + $length - $from);
            $from = $pos + $length;
            $k++;
            continue;
        }
        // check a tags
        if (isset($atags[$j])) {
            // there is unprocessed "a" tag
            $tag = $atags[$j];
            if (($urlpos = strpos($tag, $url)) !== false && $pos > strpos($content, $tag, $from)) {
                // the url is inside the current tag, we have to add ban icon after the tag
                $pos = strpos($content, $tag, $from);
                $length = strlen($tag);
                while (isset($urls[$i]) && ($urlpos = strpos($tag, $urls[$i], $urlpos + 1)) !== false) {
                    // skip all other urls from this tag
                    $i++;
                }
                $j++;
            }
        }
        // add processed part and ban icon to result and set current position
        $result .= substr($content, $from, $pos + $length - $from);
        $from = $pos + $length;
        $result .= add_jsban($url);
    }
    // add the end of the content to the result
    $result .= substr($content, $from, strlen($content) - $from);
    return $result;
}