public static function mark(GWF_User $user, GWF_Links $link, $bool) { $userid = $user->getID(); $linkid = $link->getID(); $is_fav = self::table(__CLASS__)->getRow($userid, $linkid) !== false; if ($is_fav === $bool) { return true; } $row = new self(array('lf_uid' => $userid, 'lf_lid' => $linkid)); if ($bool) { if (!$row->replace()) { return false; } } else { if (!$row->delete()) { return false; } } if (false === $link->increase('link_favcount', $bool ? 1 : -1)) { return false; } if (false === $link->onCalcPopularity()) { return false; } return true; }
private static function checkLinkDown(Module_Links $module, GWF_Links $link) { # Get HREF $href = $link->getVar('link_href'); if (strpos($href, '/') === 0) { $href = 'http://' . GWF_DOMAIN . GWF_WEB_ROOT . substr($href, 1); } if (GWF_HTTP::pageExists($href)) { self::notice("Checking {$href} ... UP"); $link->saveVar('link_downcount', 0); $link->saveOption(GWF_Links::DOWN | GWF_Links::DEAD, false); } else { self::notice("Checking {$href} ... DOWN"); $link->increase('link_downcount', 1); $bits = GWF_Links::DOWN; $count = $link->getVar('link_downcount'); if ($count > GWF_Links::DOWNCOUNT_DEAD) { $bits |= GWF_Links::DEAD; } $link->saveOption($bits, true); } $link->saveVar('link_lastcheck', time()); }