function &ScanGallery(&$gallery, &$category, &$whitelisted, $all_images = FALSE) { require_once "{$GLOBALS['BASE_DIR']}/includes/http.class.php"; require_once "{$GLOBALS['BASE_DIR']}/includes/htmlparser.class.php"; // Setup default values $results = array('thumbnails' => 0, 'links' => 0, 'format' => FMT_PICTURES, 'has_recip' => FALSE, 'has_2257' => FALSE, 'thumbs' => array(), 'server_match' => TRUE); // Download the gallery page $http = new Http(); $http_result = $http->Get($gallery['gallery_url'], $whitelisted['allow_redirect']); // Record the request results $results = array_merge($results, $http->request_info); $results['page_hash'] = md5($http->body); $results['gallery_ip'] = GetIpFromUrl($http->end_url); $results['bytes'] = intval($results['size_download']); $results['html'] = $http->body; $results['headers'] = trim($http->raw_response_headers); $results['status'] = $http->response_headers['status']; $results['success'] = $http_result; $results['errstr'] = $http->errstr; $results['end_url'] = $http->end_url; if (!$http_result) { $http_result = null; return $results; } // Check if reciprocal link and 2257 code are present $results['has_recip'] = CheckReciprocal($http->body); $results['has_2257'] = Check2257($http->body); // Extract information from the gallery HTML $parser = new PageParser($http->end_url, $category['pics_extensions'], $category['movies_extensions']); $parser->parse($http->body); $results['links'] = $parser->num_links; if ($parser->num_content_links > 0) { if ($parser->num_picture_links > $parser->num_movie_links) { $results['format'] = FMT_PICTURES; $results['thumbnails'] = $parser->num_picture_links; $results['preview'] = $parser->thumbs['pictures'][array_rand($parser->thumbs['pictures'])]['full']; $results['thumbs'] = array_values($parser->thumbs['pictures']); } else { $results['format'] = FMT_MOVIES; $results['thumbnails'] = $parser->num_movie_links; $results['preview'] = $parser->thumbs['movies'][array_rand($parser->thumbs['movies'])]['full']; $results['thumbs'] = array_values($parser->thumbs['movies']); } } else { if ($all_images) { $results['thumbnails'] = count($parser->images); $results['preview'] = $parser->images[array_rand($parser->images)]['full']; $results['thumbs'] = array_values($parser->images); } } // Check that gallery content is hosted on same server as the gallery itself $parsed_gallery_url = parse_url($results['end_url']); $parsed_gallery_url['host'] = preg_quote(preg_replace('~^www\\.~', '', $parsed_gallery_url['host'])); foreach ($results['thumbs'] as $thumb) { $parsed_content_url = parse_url($thumb['content']); if (!preg_match("~{$parsed_gallery_url['host']}~", $parsed_content_url['host'])) { $results['server_match'] = FALSE; break; } } $parser->Cleanup(); unset($parser); $http->Cleanup(); unset($http); return $results; }
<td width="235" align="right"> <b>HTTP Status</b> </td> <td> <?php echo htmlspecialchars($http->response_headers['status']); ?> </td> </tr> <tr> <td width="235" align="right"> <b>IP Address</b> </td> <td> <?php echo GetIpFromUrl($http->end_url); ?> </td> </tr> <tr> <td width="235" align="right"> <img src="images/<?php echo $blacklisted !== FALSE ? 'x' : 'check'; ?> .png"> </td> <td> No blacklisted data found </td> </tr> </table>
function CheckBlacklistAccount(&$account, $full_check = FALSE) { $checks = array('email' => array($account['email']), 'url' => array($account['site_url']), 'domain_ip' => array(GetIpFromUrl($account['gallery_url'])), 'submit_ip' => array($_SERVER['REMOTE_ADDR']), 'word' => array($account['title'], $account['description'], $account['keywords']), 'html' => array($account['html']), 'headers' => array($account['headers']), 'dns' => GetNameServers($account['site_url'])); return CheckBlacklistGeneric($checks, $full_check); }
function ImportFromRss($feed) { global $DB, $C; $settings = unserialize($feed['settings']); $category = $DB->Row('SELECT * FROM `tx_categories` WHERE `category_id`=?', array($settings['category'])); $columns = $DB->GetColumns('tx_gallery_fields'); $imported = 0; $defaults = array('gallery_url' => null, 'description' => null, 'keywords' => null, 'thumbnails' => 0, 'email' => $C['from_email'], 'nickname' => null, 'weight' => $C['gallery_weight'], 'clicks' => 0, 'submit_ip' => GetIpFromUrl($feed['feed_url']), 'gallery_ip' => '', 'sponsor_id' => !empty($feed['sponsor_id']) ? $feed['sponsor_id'] : null, 'type' => $settings['type'], 'format' => $settings['format'], 'status' => $settings['status'], 'previous_status' => null, 'date_scanned' => null, 'date_added' => MYSQL_NOW, 'date_approved' => null, 'date_scheduled' => null, 'date_displayed' => null, 'date_deletion' => null, 'partner' => null, 'administrator' => $_SERVER['REMOTE_USER'], 'admin_comments' => null, 'page_hash' => null, 'has_recip' => 0, 'has_preview' => 0, 'allow_scan' => 1, 'allow_preview' => 1, 'times_selected' => 0, 'used_counter' => 0, 'build_counter' => 0, 'tags' => null, 'categories' => MIXED_CATEGORY . " " . $category['tag'], 'preview_url' => null, 'dimensions' => null); require_once "{$GLOBALS['BASE_DIR']}/includes/rssparser.class.php"; $http = new Http(); if ($http->Get($feed['feed_url'], TRUE, $C['install_url'])) { $parser = new RSSParser(); if (($rss = $parser->Parse($http->body)) !== FALSE) { foreach ($rss['items'] as $item) { $gallery = array(); $gallery['gallery_url'] = html_entity_decode($item[$settings['gallery_url_from']]); $gallery['description'] = html_entity_decode($item[$settings['description_from']]); if (!empty($settings['date_added_from'])) { if (($timestamp = strtotime($item[$settings['date_added_from']])) !== FALSE) { $gallery['date_added'] = date(DF_DATETIME, $timestamp); } } if (!empty($settings['preview_from'])) { if (!is_array($item[$settings['preview_from']])) { $item[$settings['preview_from']] = array($item[$settings['preview_from']]); } foreach ($item[$settings['preview_from']] as $item_value) { if (preg_match('~(http://[^>< ]+\\.(jpg|png))~i', $item_value, $matches)) { $gallery['preview_url'] = $matches[1]; break; } } } // Remove HTML tags and trim the description $gallery['description'] = trim(strip_tags($gallery['description'])); // Merge with the defaults $gallery = array_merge($defaults, $gallery); // Skip over duplicate or empty URLs if ($DB->Count('SELECT COUNT(*) FROM `tx_galleries` WHERE `gallery_url`=?', array($gallery['gallery_url'])) || IsEmptyString($gallery['gallery_url'])) { continue; } $imported++; // Has a preview thumbnail if (!empty($gallery['preview_url'])) { $gallery['has_preview'] = 1; } // Add regular fields $DB->Update('INSERT INTO `tx_galleries` VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)', array(null, $gallery['gallery_url'], $gallery['description'], $gallery['keywords'], $gallery['thumbnails'], $gallery['email'], $gallery['nickname'], $gallery['weight'], $gallery['clicks'], $gallery['submit_ip'], $gallery['gallery_ip'], $gallery['sponsor_id'], $gallery['type'], $gallery['format'], $gallery['status'], $gallery['previous_status'], $gallery['date_scanned'], $gallery['date_added'], $gallery['date_approved'], $gallery['date_scheduled'], $gallery['date_displayed'], $gallery['date_deletion'], $gallery['partner'], $gallery['administrator'], $gallery['admin_comments'], $gallery['page_hash'], $gallery['has_recip'], $gallery['has_preview'], $gallery['allow_scan'], $gallery['allow_preview'], $gallery['times_selected'], $gallery['used_counter'], $gallery['build_counter'], $gallery['tags'], $gallery['categories'])); $gallery['gallery_id'] = $DB->InsertID(); // Add user defined fields $query_data = CreateUserInsert('tx_gallery_fields', $gallery, $columns); $DB->Update('INSERT INTO `tx_gallery_fields` VALUES (' . $query_data['bind_list'] . ')', $query_data['binds']); // Has a preview thumbnail if (!empty($gallery['preview_url'])) { $DB->Update('INSERT INTO `tx_gallery_previews` VALUES (?,?,?,?)', array(null, $gallery['gallery_id'], $gallery['preview_url'], $gallery['dimensions'])); } } } $DB->Update('UPDATE `tx_rss_feeds` SET `date_last_import`=? WHERE `feed_id`=?', array(MYSQL_NOW, $feed['feed_id'])); } else { return "Could not access the RSS feed: " . $http->errstr; } return $imported; }