mirror of
https://github.com/FranP-code/Allnews.com.git
synced 2025-10-13 00:32:45 +00:00
a
This commit is contained in:
0
img/credits.txt
Normal file → Executable file
0
img/credits.txt
Normal file → Executable file
0
img/logo.svg
Normal file → Executable file
0
img/logo.svg
Normal file → Executable file
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB |
0
img/test.jpg
Normal file → Executable file
0
img/test.jpg
Normal file → Executable file
|
Before Width: | Height: | Size: 81 KiB After Width: | Height: | Size: 81 KiB |
0
mySQLconnect.php
Normal file → Executable file
0
mySQLconnect.php
Normal file → Executable file
3
news/00_news_done.txt
Normal file → Executable file
3
news/00_news_done.txt
Normal file → Executable file
@@ -1,3 +0,0 @@
|
||||
./news/aaa.html
|
||||
./news/bbb.html
|
||||
./news/ccc.html
|
||||
1593
news/xataka.html
Executable file
1593
news/xataka.html
Executable file
File diff suppressed because one or more lines are too long
62
news_logic.php
Normal file → Executable file
62
news_logic.php
Normal file → Executable file
@@ -1,5 +1,8 @@
|
||||
<?php
|
||||
|
||||
error_reporting(~0);
|
||||
ini_set('display_errors', 1);
|
||||
|
||||
function check_news() {
|
||||
$news = glob('./news/*');
|
||||
|
||||
@@ -21,9 +24,12 @@ function check_news() {
|
||||
echo '<br>';
|
||||
|
||||
if (!strstr($news_done, $new)) {
|
||||
$author = know_autor($new); //! HACER FUNCION
|
||||
$create_entry($new, $author); //! HACER FUNCION
|
||||
file_put_contents($news_done, $new . '/n', FILE_APPEND);
|
||||
$page = know_page($new); //! HACER FUNCION
|
||||
echo $page;
|
||||
$author = know_author($page, $new);
|
||||
echo $author;
|
||||
//$create_entry_in_DB($new, $author); //! HACER FUNCION
|
||||
//file_put_contents($news_done, $new . '/n', FILE_APPEND);
|
||||
}
|
||||
|
||||
/*if ($new is in $done) {
|
||||
@@ -33,4 +39,54 @@ function check_news() {
|
||||
}
|
||||
}
|
||||
|
||||
function know_page($new) {
|
||||
switch ($new) {
|
||||
case './news/xataka.html'|| './news/Xataka.html':
|
||||
return 'Xataka';
|
||||
break;
|
||||
|
||||
default:
|
||||
return 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function know_author($page, $new) {
|
||||
$content = file_get_contents($new);
|
||||
|
||||
switch ($page) {
|
||||
case 'Xataka':
|
||||
$frist_cut = get_string_between($content, '<a class="article-author-link" ', '</a>');
|
||||
$second_cut = strrchr($frist_cut, '>');
|
||||
return str_replace('>', '', $second_cut);
|
||||
break;
|
||||
|
||||
default:
|
||||
return 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function get_string_between($string, $start, $end){
|
||||
$string = ' ' . $string;
|
||||
$ini = strpos($string, $start);
|
||||
if ($ini == 0) return '';
|
||||
$ini += strlen($start);
|
||||
$len = strpos($string, $end, $ini) - $ini;
|
||||
return substr($string, $ini, $len);
|
||||
//! CREDITS: https://stackoverflow.com/questions/5696412/how-to-get-a-substring-between-two-strings-in-phphttps://stackoverflow.com/questions/5696412/how-to-get-a-substring-between-two-strings-in-php
|
||||
}
|
||||
|
||||
/*
|
||||
switch ($variable) {
|
||||
case 'value':
|
||||
# code...
|
||||
break;
|
||||
|
||||
default:
|
||||
# code...
|
||||
break;
|
||||
}
|
||||
*/
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user