/** * method ini untuk generate short url dan melakukan pengecekan di database. * jika short url sudah ada di database, maka script ini akan melakukan generate ulang. */ function generateUrl() { while (1) { $id = rand(100000, 999999); $shortUrl = base_convert($id, 20, 36); if (checkUrl($shortUrl)) { return $shortUrl; exit; } else { continue; } } }
<?php $errorMessage = ''; if (filter_var($serverUrl, FILTER_VALIDATE_URL) && checkUrl($serverUrl)) { $presearchFlag = 0; if (isset($_GET['presearch_by_addr'])) { $presearchFlag = 1; } else { if (isset($_GET['presearch_by_pn'])) { $presearchFlag = 2; } } if (isset($_GET['search'])) { redirect(url('search')); } else { if ($presearchFlag) { $params = array(); $params['presearch_flag'] = $presearchFlag; redirect(url('presearch', $params)); } } } else { $errorMessage = 'Адреса сервера не існує!'; } $smarty->assign('error_msg', $errorMessage);
function DownloadNewBlock() { global $context, $smcFunc, $txt; checkSession('get'); $context['page_title'] = $txt['adkmod_block_download']; $context['sub_template'] = 'download_new_block'; //Get xml information $context['smf_personal_blocks'] = checkUrl('http://www.smfpersonal.net/xml/get_blocks.php') ? simplexml_load_file("http://www.smfpersonal.net/xml/get_blocks.php") : ''; }
function changeUrl($url, $new_url, $pdo) { if (checkUrl($new_url)) { try { $stmt = $pdo->prepare("UPDATE note SET id = :new_url WHERE id = :url"); $stmt->bindValue(':new_url', $new_url, PDO::PARAM_STR); $stmt->bindValue(':url', $url, PDO::PARAM_STR); $stmt->execute(); return true; } catch (PDOException $e) { throw $e; } } else { return false; } }
function isHttpUrl($url) { $isHttpUrl = checkUrl($url); return @$isHttpUrl; }
/** * This action actualizes entries from one or several feeds. * * Parameters are: * - id (default: false): Feed ID * - url (default: false): Feed URL * - force (default: false) * If id and url are not specified, all the feeds are actualized. But if force is * false, process stops at 10 feeds to avoid time execution problem. */ public function actualizeAction($simplePiePush = null) { @set_time_limit(300); $feedDAO = FreshRSS_Factory::createFeedDao(); $entryDAO = FreshRSS_Factory::createEntryDao(); Minz_Session::_param('actualize_feeds', false); $id = Minz_Request::param('id'); $url = Minz_Request::param('url'); $force = Minz_Request::param('force'); // Create a list of feeds to actualize. // If id is set and valid, corresponding feed is added to the list but // alone in order to automatize further process. $feeds = array(); if ($id || $url) { $feed = $id ? $feedDAO->searchById($id) : $feedDAO->searchByUrl($url); if ($feed) { $feeds[] = $feed; } } else { $feeds = $feedDAO->listFeedsOrderUpdate(FreshRSS_Context::$user_conf->ttl_default); } // Calculate date of oldest entries we accept in DB. $nb_month_old = max(FreshRSS_Context::$user_conf->old_entries, 1); $date_min = time() - 3600 * 24 * 30 * $nb_month_old; // PubSubHubbub support $pubsubhubbubEnabledGeneral = FreshRSS_Context::$system_conf->pubsubhubbub_enabled; $pshbMinAge = time() - 3600 * 24; //TODO: Make a configuration. $updated_feeds = 0; $is_read = FreshRSS_Context::$user_conf->mark_when['reception'] ? 1 : 0; foreach ($feeds as $feed) { $url = $feed->url(); //For detection of HTTP 301 $pubSubHubbubEnabled = $pubsubhubbubEnabledGeneral && $feed->pubSubHubbubEnabled(); if (!$simplePiePush && !$id && $pubSubHubbubEnabled && $feed->lastUpdate() > $pshbMinAge) { //$text = 'Skip pull of feed using PubSubHubbub: ' . $url; //Minz_Log::debug($text); //file_put_contents(USERS_PATH . '/_/log_pshb.txt', date('c') . "\t" . $text . "\n", FILE_APPEND); continue; //When PubSubHubbub is used, do not pull refresh so often } if (!$feed->lock()) { Minz_Log::notice('Feed already being actualized: ' . $feed->url()); continue; } try { if ($simplePiePush) { $feed->loadEntries($simplePiePush); //Used by PubSubHubbub } else { $feed->load(false); } } catch (FreshRSS_Feed_Exception $e) { Minz_Log::warning($e->getMessage()); $feedDAO->updateLastUpdate($feed->id(), true); $feed->unlock(); continue; } $feed_history = $feed->keepHistory(); if ($feed_history == -2) { // TODO: -2 must be a constant! // -2 means we take the default value from configuration $feed_history = FreshRSS_Context::$user_conf->keep_history_default; } // We want chronological order and SimplePie uses reverse order. $entries = array_reverse($feed->entries()); if (count($entries) > 0) { $newGuids = array(); foreach ($entries as $entry) { $newGuids[] = $entry->guid(); } // For this feed, check existing GUIDs already in database. $existingHashForGuids = $entryDAO->listHashForFeedGuids($feed->id(), $newGuids); unset($newGuids); $oldGuids = array(); // Add entries in database if possible. foreach ($entries as $entry) { $entry_date = $entry->date(true); if (isset($existingHashForGuids[$entry->guid()])) { $existingHash = $existingHashForGuids[$entry->guid()]; if (strcasecmp($existingHash, $entry->hash()) === 0 || $existingHash === '00000000000000000000000000000000') { //This entry already exists and is unchanged. TODO: Remove the test with the zero'ed hash in FreshRSS v1.3 $oldGuids[] = $entry->guid(); } else { //This entry already exists but has been updated Minz_Log::debug('Entry with GUID `' . $entry->guid() . '` updated in feed ' . $feed->id() . ', old hash ' . $existingHash . ', new hash ' . $entry->hash()); //TODO: Make an updated/is_read policy by feed, in addition to the global one. $entry->_isRead(FreshRSS_Context::$user_conf->mark_updated_article_unread ? false : null); //Change is_read according to policy. if (!$entryDAO->hasTransaction()) { $entryDAO->beginTransaction(); } $entryDAO->updateEntry($entry->toArray()); } } elseif ($feed_history == 0 && $entry_date < $date_min) { // This entry should not be added considering configuration and date. $oldGuids[] = $entry->guid(); } else { if ($entry_date < $date_min) { $id = min(time(), $entry_date) . uSecString(); $entry->_isRead(true); //Old article that was not in database. Probably an error, so mark as read } else { $id = uTimeString(); $entry->_isRead($is_read); } $entry->_id($id); $entry = Minz_ExtensionManager::callHook('entry_before_insert', $entry); if ($entry === null) { // An extension has returned a null value, there is nothing to insert. continue; } if ($pubSubHubbubEnabled && !$simplePiePush) { //We use push, but have discovered an article by pull! $text = 'An article was discovered by pull although we use PubSubHubbub!: Feed ' . $url . ' GUID ' . $entry->guid(); file_put_contents(USERS_PATH . '/_/log_pshb.txt', date('c') . "\t" . $text . "\n", FILE_APPEND); Minz_Log::warning($text); $pubSubHubbubEnabled = false; $feed->pubSubHubbubError(true); } if (!$entryDAO->hasTransaction()) { $entryDAO->beginTransaction(); } $entryDAO->addEntry($entry->toArray()); } } $entryDAO->updateLastSeen($feed->id(), $oldGuids); } if ($feed_history >= 0 && rand(0, 30) === 1) { // TODO: move this function in web cron when available (see entry::purge) // Remove old entries once in 30. if (!$entryDAO->hasTransaction()) { $entryDAO->beginTransaction(); } $nb = $feedDAO->cleanOldEntries($feed->id(), $date_min, max($feed_history, count($entries) + 10)); if ($nb > 0) { Minz_Log::debug($nb . ' old entries cleaned in feed [' . $feed->url() . ']'); } } $feedDAO->updateLastUpdate($feed->id(), 0, $entryDAO->hasTransaction()); if ($entryDAO->hasTransaction()) { $entryDAO->commit(); } if ($feed->hubUrl() && $feed->selfUrl()) { //selfUrl has priority for PubSubHubbub if ($feed->selfUrl() !== $url) { //https://code.google.com/p/pubsubhubbub/wiki/MovingFeedsOrChangingHubs $selfUrl = checkUrl($feed->selfUrl()); if ($selfUrl) { Minz_Log::debug('PubSubHubbub unsubscribe ' . $feed->url()); if (!$feed->pubSubHubbubSubscribe(false)) { //Unsubscribe Minz_Log::warning('Error while PubSubHubbub unsubscribing from ' . $feed->url()); } $feed->_url($selfUrl, false); Minz_Log::notice('Feed ' . $url . ' canonical address moved to ' . $feed->url()); $feedDAO->updateFeed($feed->id(), array('url' => $feed->url())); } } } elseif ($feed->url() !== $url) { // HTTP 301 Moved Permanently Minz_Log::notice('Feed ' . $url . ' moved permanently to ' . $feed->url()); $feedDAO->updateFeed($feed->id(), array('url' => $feed->url())); } $feed->faviconPrepare(); if ($pubsubhubbubEnabledGeneral && $feed->pubSubHubbubPrepare()) { Minz_Log::notice('PubSubHubbub subscribe ' . $feed->url()); if (!$feed->pubSubHubbubSubscribe(true)) { //Subscribe Minz_Log::warning('Error while PubSubHubbub subscribing to ' . $feed->url()); } } $feed->unlock(); $updated_feeds++; unset($feed); // No more than 10 feeds unless $force is true to avoid overloading // the server. if ($updated_feeds >= 10 && !$force) { break; } } if (Minz_Request::param('ajax')) { // Most of the time, ajax request is for only one feed. But since // there are several parallel requests, we should return that there // are several updated feeds. $notif = array('type' => 'good', 'content' => _t('feedback.sub.feed.actualizeds')); Minz_Session::_param('notification', $notif); // No layout in ajax request. $this->view->_useLayout(false); } else { // Redirect to the main page with correct notification. if ($updated_feeds === 1) { $feed = reset($feeds); Minz_Request::good(_t('feedback.sub.feed.actualized', $feed->name()), array('params' => array('get' => 'f_' . $feed->id()))); } elseif ($updated_feeds > 1) { Minz_Request::good(_t('feedback.sub.feed.n_actualized', $updated_feeds), array()); } else { Minz_Request::good(_t('feedback.sub.feed.no_refresh'), array()); } } return $updated_feeds; }
if (isset($_REQUEST['tag']) && trim($_REQUEST['tag']) != '') { $tag = trim($_REQUEST['tag']); } else { $tag = NULL; } // Get the posts relevant to the passed-in variables. $bookmarks =& $bookmarkservice->getBookmarks(0, NULL, NULL, $tag, NULL, getSortOrder()); // Set up the plain file and output all the posts. header('Content-Type: text/plain; charset=utf-8'); if (!$xml) { header('Content-Type: text/plain'); foreach ($bookmarks['bookmarks'] as $row) { if (checkUrl($row['bAddress'], false)) { echo $row['bAddress'] . "\n"; } } } else { header('Content-Type: text/xml'); echo '<GoogleCustomizations>' . "\n"; echo ' <Annotations>' . "\n"; foreach ($bookmarks['bookmarks'] as $row) { //if(substr($row['bAddress'], 0, 7) == "http://") { if (checkUrl($row['bAddress'], false)) { echo ' <Annotation about="' . filter($row['bAddress']) . '">' . "\n"; echo ' <Label name="include"/>' . "\n"; echo ' </Annotation>' . "\n"; } } echo ' </Annotations>' . "\n"; echo '</GoogleCustomizations>' . "\n"; }
function getFile($adkfile = '') { global $sourcedir, $context, $getFile, $txt; require_once $sourcedir . '/Subs-Package.php'; if (empty($adkfile)) { $getFile = ''; } else { $checkUrl = checkUrl($adkfile); if (!$checkUrl) { $getFile = ''; } else { $getFile = fetch_web_data($adkfile); } } return $getFile; }
$tagcacheservice->deleteByUser($uId); $tag2tagservice->removeLinkedTagsForUser($uId); $userservice->deleteUser($uId); $bookmark2tagservice->deleteTagsForUser($uId); $commondescriptionservice->deleteDescriptionsForUser($uId); $searchhistoryservice->deleteSearchHistoryForUser($uId); $tagstatservice->deleteTagStatForUser($uId); // XXX: don't delete bookmarks before tags, else tags can't be deleted !!! $bookmarkservice->deleteBookmarksForUser($uId); $tplVars['msg'] = sprintf(T_('%s and all his bookmarks and tags were deleted.'), $user); } break; case 'checkUrl': $bookmarks =& $bookmarkservice->getBookmarks(0, NULL, NULL, NULL, NULL, getSortOrder()); foreach ($bookmarks['bookmarks'] as $bookmark) { if (!checkUrl($bookmark['bAddress'])) { $tplVars['error'] .= T_('Problem with ') . $bookmark['bAddress'] . ' (' . $bookmark['username'] . ')<br/>'; } } break; default: // DO NOTHING } } $templatename = 'admin.tpl'; $users =& $userservice->getObjectUsers(); if (!is_array($users)) { $users = array(); } $tplVars['users'] =& $users; $templateservice->loadTemplate($templatename, $tplVars);
if (!strlen($queLink)) { continue; } // Link Extract $queInfo = parse_url($queLink); $queInfo['host'] = strtolower($queInfo['host']); if (preg_match('/^[\\w\\-\\d]+\\.[\\w\\-\\d]+$/', $queInfo['host'])) { $queInfo['host'] = 'www.' . $queInfo['host']; } // Check External if ($intMode && $urlHost != $queInfo['host']) { $extQueue[] = $queLink; continue; } // Check / Process $check = checkUrl($queLink); $code = $check['code']; if ($check['contentType']) { $contentType = ereg_replace(";.*\$", "", $check['contentType']); } else { $contentType = 'Unknown'; } // Determine Type if ($urlHost == $queInfo['host']) { $urlPrint = '<a href="' . $queLink . '" target="_blank">' . rawurldecode($queInfo['path'] . (isset($queInfo['query']) ? '?' . $queInfo['query'] : '')) . '</a>'; } else { $urlPrint = '<a href="' . $queLink . '" target="_blank">' . rawurldecode($queLink) . '</a>'; } // Push to Sitemap if Internal Content if ($siteMapActive && $urlHost == $queInfo['host'] && eregi("^text/html", $contentType) && $code == 200) { $urlNode = $siteMapXML->addChild('url');
function pubSubHubbubSubscribe($state) { if (FreshRSS_Context::$system_conf->base_url && $this->hubUrl && $this->selfUrl) { $hubFilename = PSHB_PATH . '/feeds/' . base64url_encode($this->selfUrl) . '/!hub.json'; $hubFile = @file_get_contents($hubFilename); if ($hubFile === false) { Minz_Log::warning('JSON not found for PubSubHubbub: ' . $this->url); return false; } $hubJson = json_decode($hubFile, true); if (!$hubJson || empty($hubJson['key']) || !ctype_xdigit($hubJson['key'])) { Minz_Log::warning('Invalid JSON for PubSubHubbub: ' . $this->url); return false; } $callbackUrl = checkUrl(FreshRSS_Context::$system_conf->base_url . 'api/pshb.php?k=' . $hubJson['key']); if ($callbackUrl == '') { Minz_Log::warning('Invalid callback for PubSubHubbub: ' . $this->url); return false; } $ch = curl_init(); curl_setopt_array($ch, array(CURLOPT_URL => $this->hubUrl, CURLOPT_FOLLOWLOCATION => true, CURLOPT_RETURNTRANSFER => true, CURLOPT_USERAGENT => _t('gen.freshrss') . '/' . FRESHRSS_VERSION . ' (' . PHP_OS . '; ' . FRESHRSS_WEBSITE . ')', CURLOPT_POSTFIELDS => 'hub.verify=sync' . '&hub.mode=' . ($state ? 'subscribe' : 'unsubscribe') . '&hub.topic=' . urlencode($this->selfUrl) . '&hub.callback=' . urlencode($callbackUrl))); $response = curl_exec($ch); $info = curl_getinfo($ch); file_put_contents(USERS_PATH . '/_/log_pshb.txt', date('c') . "\t" . 'PubSubHubbub ' . ($state ? 'subscribe' : 'unsubscribe') . ' to ' . $this->selfUrl . ' with callback ' . $callbackUrl . ': ' . $info['http_code'] . ' ' . $response . "\n", FILE_APPEND); if (!$state) { //unsubscribe $hubJson['lease_end'] = time() - 60; file_put_contents($hubFilename, json_encode($hubJson)); } if (substr($info['http_code'], 0, 1) == '2') { return true; } else { $hubJson['lease_start'] = time(); //Prevent trying again too soon $hubJson['error'] = true; file_put_contents($hubFilename, json_encode($hubJson)); return false; } } return false; }
<?php // arrivée standard $pdo = $app['pdo']; $app->get('/', function () use($app) { $pdo = $app['pdo']; require './src/model_index.php'; $url = generateUrl($pdo); return $app->redirect($url . '/edit'); }); //arrivée avec url deja connue $app->get('/{url}', function ($url) use($app) { $pdo = $app['pdo']; require './src/model_index.php'; if (checkUrl($url, $pdo)) { return $app->redirect($url . '/view'); } else { $app->abort(404, "l'url \" {$url} \" is not a valid one. Must be alphanumeric and less than 10 characters."); } }); $app->get('/{url}/', function ($url) use($app) { return $app->redirect($url); }); // la view pour chaque note $app->get('/{url}/view', function ($url) use($app) { $pdo = $app['pdo']; require './src/model_note_view.php'; if (!isViewProtected($url, $pdo)) { $content = getContent($url, $pdo); return $app['twig']->render('view_note_view.html.twig', array('content' => $content, 'url' => $url)); } else {
public function _website($value, $validate = true) { if ($validate) { $value = checkUrl($value); } if (empty($value)) { $value = ''; } $this->website = $value; }
$choice = $_GET['raw']; } if ($choice < 'a' || $choice > 'd') { $choice = 'a'; unset($_GET['raw']); } # generate the filename to be used as input //$fileName = $path.$controlArr[$choice]['file']; $path = $SITE['clientrawDir']; #-------------------------------------------------------------------------------------------------- # or use the filename the user entered if (isset($_POST['path'])) { // pogram is entered by post (a button was pressed) #-------------------------------------------------------------------------------------------------- # first clean all userinput fields, save the fields and error info so we can show it to the user $savedUserInput = checkUrl($_POST['path']); echo "<!-- post = " . $_POST['path'] . " / savedUserInput = " . $savedUserInput . ' -->' . PHP_EOL; # check which button was pressed and save it as the users choice // if (isset($_POST['submit'])) {} # pick the user supplied filename to be used as input # only when it's length suggests it is a filename # this happens when user enters a filename on one line but hits button on another line if (strlen($savedUserInput) > 15 && substr($savedUserInput, 0, 5) != "ERROR") { $path = $savedUserInput; } else { # otherwise take the own website file for this choice $path = $SITE['clientrawDir']; } } // eo if POST #--------------------------------------------------------------------------------------------------