function save_link($type, $size, $url, $nick, $saved_file) { global $fetch_log; $title = $url; if (stristr($type, 'text/html') !== false && $size < FIVE_MEGS) { if (preg_match('!<title>(?<title>.*?)</title>!sim', file_get_contents($saved_file), $match)) { $title = html_entity_decode($match['title']); } } unlink($saved_file); if (ORM::all('link', array('url' => $url))->count() === 0) { $link = new Link(array('nick' => $nick, 'title' => $title, 'url' => $url, 'ctime' => date('Y-m-d H:i:s', $_SERVER['REQUEST_TIME']))); $link->save(); } else { file_put_contents($fetch_log, "[" . date('Y-m-d H:i:s') . "]\t{$nick}\tduplicate link\t{$url}\n", FILE_APPEND); } }
function measurize() { $pics = ORM::all('Pic'); print "<pre>"; foreach ($pics as $i => $pic) { list($w, $h) = getimagesize($pic->thumb); $pic->width = $w; $pic->height = $h; $pic->save(); print "."; if ($i % 100 == 0 && $i != 0) { print "\n{$i}\n"; } flush(); } }