Example #1
0
function parse_line_to_array($line)
{
    if (!is_numeric($line[0])) {
        return null;
    }
    DLOG("line1={$line}");
    $line = convert_seperator($line);
    DLOG("line2={$line}");
    $cells = explode("|", $line);
    $cells[0] = parse_time($cells[0]);
    $cells[2] = parse_amount($cells[2]);
    $cells[3] = parse_description($cells[3]);
    return $cells;
}
Example #2
0
function fetch_via_wordpress_ynf($fansub_id, $url, $last_fetched_item_date)
{
    $elements = array();
    $tidy_config = "tidy.conf";
    $error_connect = FALSE;
    $html_text = file_get_contents($url) or $error_connect = TRUE;
    if ($error_connect) {
        return array('error_connect', array());
    }
    $tidy = tidy_parse_string($html_text, $tidy_config, 'UTF8');
    tidy_clean_repair($tidy);
    $html = str_get_html(tidy_get_output($tidy));
    $go_on = TRUE;
    while ($go_on) {
        //parse through the HTML and build up the elements feed as we go along
        foreach ($html->find('article') as $article) {
            if ($article->find('h1.entry-title a', 0) !== NULL) {
                //Create an empty item
                $item = array();
                //Look up and add elements to the item
                $title = $article->find('h1.entry-title a', 0);
                $item[0] = $title->innertext;
                $item[1] = $article->find('div.entry-content', 0)->innertext;
                $description = str_replace("text-align:center;", "", $article->find('div.entry-content', 0)->innertext);
                $item[2] = parse_description($description);
                //The format is: 2013-09-02T14:43:43+00:00
                $datetext = $article->find('time', 0)->datetime;
                $date = date_create_from_format('Y-m-d\\TH:i:sP', $datetext);
                $date->setTimeZone(new DateTimeZone('Europe/Berlin'));
                $item[3] = $date->format('Y-m-d H:i:s');
                $item[4] = $title->href;
                $item[5] = fetch_and_parse_image($fansub_id, $url, $description);
                $elements[] = $item;
            }
        }
        $texts = $html->find('text');
        $go_on = FALSE;
        if (count($elements) > 0 && $elements[count($elements) - 1][3] >= $last_fetched_item_date) {
            foreach ($texts as $text) {
                if ($text->plaintext == ' Entrades més antigues') {
                    //Not sleeping, Wordpress.com does not appear to be rate-limited
                    $html_text = file_get_contents($text->parent->href) or $error_connect = TRUE;
                    if ($error_connect) {
                        return array('error_connect', array());
                    }
                    $tidy = tidy_parse_string($html_text, $tidy_config, 'UTF8');
                    tidy_clean_repair($tidy);
                    $html = str_get_html(tidy_get_output($tidy));
                    $go_on = TRUE;
                    break;
                }
            }
        }
    }
    return array('ok', $elements);
}
Example #3
0
        // Category
        $category = $cells[1];
        $row_string .= "<td>" . $category . "</td>";
        $category_id = "&nbsp;";
        foreach ($cate_list as $cate) {
            if ($cate['Name'] == $category) {
                $category_id = $cate['Id'];
                break;
            }
        }
        $row_string .= "<td>" . $category_id . "</td>";
        // Amount
        $amount = parse_amount($cells[2]);
        $row_string .= "<td>" . $amount . "</td>";
        // Description
        $description = parse_description($cells[3]);
        $row_string .= "<td>" . $description . "&nbsp;</td>";
        // Insert into database
        add_data($conn, $config, $category_id, $description, $time, $amount, "");
    }
    $row_string .= "</tr>";
    echo $row_string;
}
echo "</table>";
fclose($file);
echo "Added rows from " . ($added_row_count + 1) . " to " . $row_count . "<br/>";
$added_row_count = $row_count;
?>

<form action="xls_importer.php" method="post">
	<input type="hidden" name="added_row_count" value="<?php