Last active
August 29, 2015 14:26
-
-
Save phpdude/23897d2be673fbe721c9 to your computer and use it in GitHub Desktop.
gavnocode.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$query = $db->query("SELECT * FROM refer GROUP BY keyword ORDER BY date DESC LIMIT 0,10"); | |
while($row = $db->get_row($query)){ | |
preg_match_all('/([0-9]{4})\/([0-9]{2})\/([0-9]{2})\/(.+?).html/', $row['url'], $request_out); | |
$first = mb_substr($row['keyword'],0,1); // первая буква | |
$last = mb_substr($row['keyword'],1); // все кроме первой буквы | |
$first = mb_strtoupper($first); | |
$last = mb_strtolower($last); | |
$keyword = $first.$last; | |
$db->query( "SELECT p.id, p.date, p.short_story, p.xfields, p.title, p.category, p.alt_name FROM " . PREFIX . "_post p LEFT JOIN " . PREFIX . "_post_extras e ON (p.id=e.news_id) WHERE p.approve=1 AND p.alt_name = '" . $request_out[4][0] . "' AND date >= '" . $request_out[1][0] . "-" . $request_out[2][0] . "-" . $request_out[3][0] . "' AND date < '" . $request_out[1][0] . "-" . $request_out[2][0] . "-" . $request_out[3][0] . "' + INTERVAL 24 HOUR LIMIT 1" ); | |
while ( $row_post = $db->get_row() ) { | |
$row_post['date'] = strtotime( $row_post['date'] ); | |
preg_match_all('/(img|src)=("|\')[^"\'>]+/i', $row_post['short_story'], $media); | |
$data=preg_replace('/(img|src)("|\'|="|=\')(.*)/i',"$3",$media[0]); | |
$info = parse_url($data[0]); | |
if($info['host'] == 'site.ru') { | |
$referer_block .= '<li><a href="'.$row['url'].'"><div><img src="' . $data[0] . '" border="0" alt="'.$row_post['title'].'" title="'.$row_post['title'].'" /></div>'.$keyword.'</a></li>'; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment