ОБСУЖДЕНИЕ

подправить граб

30 сообщений1 просмотровОткрыта
#1
код
PHP
<?php
define('_IN_JOHNCMS', 1);
require '../incfiles/core.php';
require 'functions.php';
header("Content-type:text/html; charset=utf-8");
$type = isset($_REQUEST['type']) ? trim($_REQUEST['type']) : false;
switch ($act)
{

default:
$textl   = 'Новости футбола';
$headmod = 'fnews';
require '../incfiles/head.php';
echo '<div class="orange_bg"><b>Новости футбола</b></div>';
require_once 'phpQuery.php';
$content       = file_get_contents('http://sport.ua/news/archive?sport=1');
$document      = phpQuery::newDocument($content);
$list_elements = $document->find('.hentry');
foreach ($list_elements as $element)
{
$pq         = pq($element);
$title_news = $pq->find('.hentry__title')->text();
$data_news  = $pq->find('.hentry__published')->text();
if (strpos($title_news, 'Смотреть Видео') > -1) {}else{
$link       = $pq->find('a')->attr('href');
$link       = str_replace('//sport.ua/news/', '', $link);
echo '<div class="c">';
$img_news = $pq->find('img ')->attr('src');
$img_news = str_replace('//', 'http://', $img_news);
if (!$img_news)
$img_news = 'nophoto.png';
echo '<table><tr><td><a href="index.php?act=news&amp;id=' . $link . '"><img style="float:left;margin-right:10px;max-width:150px;" src="' . $img_news . '" /></a></td>';
echo '<td><a href="index.php?act=news&amp;id=' . $link . '">' . $title_news . '</a><br/><small>' . $data_news . '</small></td></tr></table>';
echo '<div style="clear:both;"></div></div>';
}
}
break;
case 'news':
$textl   = 'Новости футбола';
$headmod = 'fnews';
require '../incfiles/head.php';
require_once 'phpQuery.php';
$content       = file_get_contents('http://sport.ua/news/' . $id . '');
$document      = phpQuery::newDocument($content);
$list_elements = $document->find('#news-page');
$pq            = pq($list_elements);
$title_news    = $pq->find('.news-title>h1')->text();
$title_news_sub    = $pq->find('.news-title>h2')->text();
echo '<div class="orange_bg"><b>' . $title_news . '</b></div>';
if ($title_news_sub) echo '<div class="info">' . $title_news_sub . '</div>';

echo '<div class="list1">';
$img_news = $pq->find('img ')->attr('src');
$img_news = str_replace('//', 'http://', $img_news);
echo '<center><img style="width:100%;max-width:450px;" src="' . $img_news . '" /></center>';

echo '<div class="info">';

$pq->find('script, figure')->remove();
$text_news = $pq->find('.content')->text();
$text_news = preg_replace('#<script>(.*)</script>#isU', '', $text_news);
$text_news = preg_replace('#<figure>(.*)</figure>#isU', '', $text_news);
$text_news = preg_replace('#Источни(.*)Если#isU', '', $text_news);
$text_news = str_replace('
 ', '<br/>', $text_news);
$text_news = str_replace('вы нашли ошибку, пожалуйста, выделите фрагмент текста и нажмите Ctrl+Enter.', '', $text_news);
$text_news = str_replace('Подписывайся на наш канал в Telegram и узнавай все самые свежие новости первым!', '', $text_news);
$text_news= preg_replace("/s{2,}/"," ",$text_news);
//$text_news = preg_replace('/\n{2,}/',"",$text_news);
//$text_news = preg_replace('<br/>',"",$text_news);
print_r(rtrim(ltrim($text_news)));
//echo '' . trim(nl2br($text_news)) . '';
echo '<div style="clear:both;"></div></div>';
echo '<div class="menu"><a href="index.php"><input type="submit" name="submit" value="Новости футбола" /></a></div>';
break;
}
require '../incfiles/end.php';



не виводит картинки и текст
#2
Какой сайт?
#3
Savik, sport.ua футбольние новости
#4
Ещё актуально? Есть знакомый можеть исправить, владелец adsnet.site
#5
Savik, да актуально
#6
Цена ?
#7
Mr.Max, безвоздмездно)))
#8
сколько платишь?
#9
Уф ностальгия)
#10
Давай в zip этот код, попробую помочь.
#11
MazaXakep, вот
#12
напиши адрес своего сайта
#13
KpuTuK, http://footmen.tk/fnews/index.php
#14
Предупреждение : file_get_contents (http://sport.ua/news/archive?sport=1): не удалось открыть поток: не удалось найти транспортный сокет "ssl" - вы забыли включить его при настройке PHP? в /home/usr/data/footmen/footmen.tk/fnews/index.php в строке 16
#15
Попробуй заменить на https://sport.ua/news/football
#16
Dblog, не помогло
#17
TUWAP, В течении вечера у ПК буду гляну
#18
TUWAP, ты http на https попробуй поменять
#19
попробуй отключить проверку сертификата. стр 16
PHP


$context = stream_context_create(
              array(
                'ssl' => array(
                           'verify_peer' => false,  //default
                           'allow_self_signed' => true, //needs verify peer, tried that
                           'ciphers'=>"SHA1", // quite random.
                   ),
                'https' => array(
                           'curl_verify_ssl_peer'  => false,
                           'curl_verify_ssl_host'  => false
                          )
      )
            );

file_get_contents('http://sport.ua/news/archive?sport=1' false, $context);



если не поможет, можно попробовать на curl заменить
#20
Не помогло?
Страница 1 из 2 · Всего записей: 30