示例#1
0
 /**
  * Checks if a user is a club member
  * (currently only works for recently added members, does not deal with old members or admins)
  *
  * @return bool
  */
 function isClubMember()
 {
     $RecentlyJoined = HTTP::legitimateRequest('http://mlp-vectorclub.deviantart.com/modals/memberlist/');
     return !empty($RecentlyJoined['response']) && preg_match(new RegExp('<a class="[a-z ]*username" href="http://' . strtolower($this->name) . '.deviantart.com/">' . USERNAME_PATTERN . '</a>'), $RecentlyJoined['response']);
 }
示例#2
0
 /**
  * Retrieve the full size URL for a submission
  *
  * @param string $id
  * @param string $prov
  *
  * @return null|string
  */
 static function getFullsizeURL($id, $prov)
 {
     $stash_url = $prov === 'sta.sh' ? "http://sta.sh/{$id}" : "http://fav.me/{$id}";
     try {
         $stashpage = HTTP::legitimateRequest($stash_url, null, null);
     } catch (CURLRequestException $e) {
         if ($e->getCode() === 404) {
             return 404;
         }
         return 1;
     } catch (\Exception $e) {
         return 2;
     }
     if (empty($stashpage)) {
         return 3;
     }
     $STASH_DL_LINK_REGEX = '(https?://(sta\\.sh|www\\.deviantart\\.com)/download/\\d+/[a-z\\d_]+-d[a-z\\d]{6,}\\.(?:png|jpe?g|bmp)\\?[^"]+)';
     $urlmatch = preg_match(new RegExp('<a\\s+class="[^"]*?dev-page-download[^"]*?"\\s+href="' . $STASH_DL_LINK_REGEX . '"'), $stashpage['response'], $_match);
     if (!$urlmatch) {
         return 4;
     }
     $fullsize_url = HTTP::findRedirectTarget(htmlspecialchars_decode($_match[1]), $stash_url);
     if (empty($fullsize_url)) {
         return 5;
     }
     global $Database;
     if ($Database->where('id', $id)->where('provider', $prov)->has('deviation_cache')) {
         $Database->where('id', $id)->where('provider', $prov)->update('deviation_cache', array('fullsize' => $fullsize_url));
     }
     return URL::makeHttps($fullsize_url);
 }