function item_image_upload() { // if ((User::have_permit(ADMIN_ITEM) || User::is_mod()) && (int) Url::get('user_id', 0) && (int) Url::get('user_id', 0) != User::id()) { $user_id = (int) Url::get('user_id', 0); $user_name = ''; $user = User::getUser($user_id); if ($user) { $user_name = $user['user_name']; } } else { $user_id = User::id(); $user_name = User::user_name(); } $json['error'] = 'not_uploaded'; $json['id'] = 0; $json['image_url'] = ''; if (User::is_login()) { if (User::is_az_team() || User::level() > 0) { $upload_path = AZLib::folderUpload($user_id); if (AZLib::ftp_check_dir($upload_path, true, IMAGE_SERVER_NO)) { //Check dir for upload if (isset($_FILES['img_upload']) && !$_FILES['img_upload']['error'] && $_FILES['img_upload']['name']) { list($imagewidth, $imageheight, $imageType) = getimagesize($_FILES['img_upload']['tmp_name']); if ($imagewidth && $_FILES['img_upload']['size'] <= Item::MAX_UPLOAD_SIZE) { /* if(($imagewidth > 479)||($imageheight > 359)) { if($imagewidth > 479)//&& ($imagewidth < 1281) && ($imageheight < 1025)) { if($imageheight > 359) { */ $file_name = $_FILES['img_upload']['name']; $sourceName = $_FILES['img_upload']['tmp_name']; $file_ext = AZLib::getExtension($file_name); if (in_array($file_ext, array('.jpg', '.jpeg', '.gif', '.png'))) { $img_url = $upload_path . date("YmdHis", TIME_NOW) . '_' . substr(AZLib::make_safe_name(basename(strtolower($file_name), $file_ext)), 0, 36) . $file_ext; /* $json['error'] = AZLib::ftp_image_put_file($img_url, $sourceName, IMAGE_SERVER_NO); echo json_encode($json); exit; */ if (AZLib::ftp_image_put_file($img_url, $sourceName, IMAGE_SERVER_NO)) { $image_id = DB::insert('item_image', array('des' => '', 'item_id' => 0, 'title' => '', 'position' => 0, 'img_server' => IMAGE_SERVER_NO, 'img_url' => $img_url, 'root_id' => 0, 'time' => TIME_NOW, 'user_id' => $user_id, 'user_name' => $user_name)); if ($image_id) { $json['id'] = $image_id; $json['img_server'] = IMAGE_SERVER_NO; $json['image_url'] = $img_url; $json['error'] = 'success'; } } } else { $json['error'] = 'ext_invalid'; //Sai định dạng file } /* } else { $json['error'] = 'height_not_allow'; } } else { $json['error'] = 'width_not_allow'; } } else { $json['error'] = 'width_n_height_not_allow'; } */ } else { $json['error'] = 'over_max_size'; //Sai định dạng file hoặc upload dung lượng quá lớn } } elseif ($_POST['url'] && $_POST['url'] != 'Hoặc Url') { $url = $_POST['url']; $tem_cache_dir = DIR_CACHE . 'user_images/'; AZLib::CheckDir($tem_cache_dir); $tem_cache_file = User::user_name() . md5($url) . '.gif'; $image_content = disguise_curl($url); if ($image_content) { if (@file_put_contents($tem_cache_dir . $tem_cache_file, $image_content)) { if (getimagesize($tem_cache_dir . $tem_cache_file) && filesize($tem_cache_dir . $tem_cache_file) <= Item::MAX_UPLOAD_SIZE) { $sourceName = $tem_cache_dir . $tem_cache_file; $img_url = $upload_path . TIME_NOW . '_' . $tem_cache_file; //$json['error'] = AZLib::ftp_image_put_file($img_url, $sourceName, IMAGE_SERVER_NO); //echo json_encode($json); //exit; if (AZLib::ftp_image_put_file($img_url, $sourceName, IMAGE_SERVER_NO)) { $image_id = DB::insert('item_image', array('des' => '', 'item_id' => 0, 'title' => '', 'position' => 0, 'img_server' => IMAGE_SERVER_NO, 'img_url' => $img_url, 'root_id' => 0, 'time' => TIME_NOW, 'user_id' => $user_id, 'user_name' => $user_name)); if ($image_id) { $json['id'] = $image_id; $json['img_server'] = IMAGE_SERVER_NO; $json['image_url'] = $img_url; $json['url_error'] = 'success'; } else { $json['url_error'] = 'over_max_size'; } } else { $json['url_error'] = 'not_uploaded'; } } else { $json['url_error'] = 'over_max_size'; } @unlink($tem_cache_dir . $tem_cache_file); } else { $json['url_error'] = 'not_cache_file'; } } else { $json['url_error'] = 'not_get_img'; } } elseif ($_FILES['img_upload']['error'] == 1) { $json['error'] = 'over_max_size'; } } } } else { $json['error'] = 'not_login'; } echo json_encode($json); exit; }
function UpdateJSONFeedBots() { global $smcFunc, $txt, $context, $sourcedir, $tag_attrs, $feedcount, $smcFunc, $maxitemcount, $insideitem, $tag, $modSettings; // Load the language files if (loadlanguage('FeedPoster') == false) { loadLanguage('FeedPoster', 'english'); } // First get all the enabled bots $context['feeds'] = array(); $request = $smcFunc['db_query']('', "\n\t\t\tSELECT\n\t\t\t\tID_FEED, ID_BOARD, feedurl, title, postername, updatetime, enabled, html,\n\t\t\t\tID_MEMBER, locked, articlelink, topicprefix, numbertoimport, importevery,\n\t\t\t\tmsgicon, footer, id_topic \n\t\t\tFROM {db_prefix}feedbot\n\t\t\tWHERE enabled = 1 AND json = 1"); while ($row = $smcFunc['db_fetch_assoc']($request)) { $request2 = $smcFunc['db_query']('', "\n\t\t\tSELECT\n\t\t\t\tcount_posts\n\t\t\tFROM {db_prefix}boards \n\t\t\tWHERE ID_BOARD = " . $row['ID_BOARD']); $row2 = $smcFunc['db_fetch_assoc']($request2); $row['count_posts'] = $row2['count_posts']; $context['feeds'][] = $row; } $smcFunc['db_free_result']($request); // For the createPost function require_once $sourcedir . '/Subs-Post.php'; require_once $sourcedir . '/Subs-Editor.php'; // Check if a field expired foreach ($context['feeds'] as $key => $feed) { $current_time = time(); // If the feedbot time to next import has expired if ($current_time > $feed['updatetime']) { $feeddata = disguise_curl($feed['feedurl']); $json_feed_object = json_decode($feeddata); $feedcount = 0; $context['feeditems'] = array(); if (!empty($json_feed_object->entries)) { foreach ($json_feed_object->entries as $entry) { // echo "<h2>{$entry->title}</h2>"; // $published = date("g:i A F j, Y", strtotime($entry->published)); // echo "<small>{$published}</small>"; //echo "<p>{$entry->content}</p>"; $context['feeditems'][$feedcount]['title'] = (string) $entry->title; $context['feeditems'][$feedcount]['description'] = (string) $entry->content; $context['feeditems'][$feedcount]['description'] = html_to_bbc($context['feeditems'][$feedcount]['description']); $context['feeditems'][$feedcount]['link'] = (string) $entry->alternate; $feedcount++; } } if (!empty($feeddata)) { // Process the XML $maxitemcount = $feed['numbertoimport']; $context['feeditems'] = array_reverse($context['feeditems']); // Loop though all the items $myfeedcount = 0; for ($i = 0; $i < $feedcount; $i++) { if ($myfeedcount >= $maxitemcount) { continue; } // Check feed Log // Generate the hash for the log if (!isset($context['feeditems'][$i]['title']) || !isset($context['feeditems'][$i]['description'])) { continue; } if (empty($context['feeditems'][$i]['title']) && empty($context['feeditems'][$i]['description'])) { continue; } $itemhash = md5($context['feeditems'][$i]['title'] . $context['feeditems'][$i]['description']); $request = $smcFunc['db_query']('', "\n\t\t\t\t\t\t\tSELECT\n\t\t\t\t\t\t\t\tfeedtime\n\t\t\t\t\t\t\tFROM {db_prefix}feedbot_log\n\t\t\t\t\t\t\tWHERE feedhash = '{$itemhash}'"); $smcFunc['db_free_result']($request); // If no has has found that means no duplicate entry if ($smcFunc['db_affected_rows']() == 0) { // Create the Post $msg_title = $smcFunc['htmlspecialchars']($feed['html'] ? $context['feeditems'][$i]['title'] : strip_tags($context['feeditems'][$i]['title']), ENT_QUOTES); $msg_title = trim($msg_title); $msg_body = ''; if ($feed['html']) { $msg_body = $smcFunc['htmlspecialchars']($context['feeditems'][$i]['description'], ENT_QUOTES); $msg_body = trim($msg_body); preparsecode($msg_body); $msg_body = '[html]' . $msg_body . '[/html]'; $msg_body .= $smcFunc['htmlspecialchars']("\n\n" . $txt['feedposter_source'] . "[url=" . $context['feeditems'][$i]['link'] . "]" . $msg_title . "[/url]", ENT_QUOTES); if (!empty($feed['footer'])) { $msg_body .= $smcFunc['htmlspecialchars']("\n\n" . $feed['footer'], ENT_QUOTES); } } else { $msg_body = $smcFunc['htmlspecialchars'](strip_tags($context['feeditems'][$i]['description']), ENT_QUOTES); $msg_body = trim($msg_body); $msg_body .= $smcFunc['htmlspecialchars']("\n\n" . $txt['feedposter_source'] . "[url=" . $context['feeditems'][$i]['link'] . "]" . $msg_title . "[/url]", ENT_QUOTES); if (!empty($feed['footer'])) { $msg_body .= $smcFunc['htmlspecialchars']("\n\n" . $feed['footer'], ENT_QUOTES); } } $msg_title = htmlspecialchars_decode($msg_title); $msg_body = htmlspecialchars_decode($msg_body); $updatePostCount = $feed['ID_MEMBER'] == 0 ? 0 : 1; if ($feed['count_posts'] == 0) { $updatePostCount = 0; } $msgOptions = array('id' => 0, 'subject' => $feed['topicprefix'] . $msg_title, 'body' => '[b]' . $msg_title . "[/b]\n\n" . $msg_body, 'icon' => $feed['msgicon'], 'smileys_enabled' => 1, 'attachments' => array()); $topicOptions = array('id' => $row['id_topic'], 'board' => $feed['ID_BOARD'], 'poll' => null, 'lock_mode' => $feed['locked'], 'sticky_mode' => null, 'mark_as_read' => false); $posterOptions = array('id' => $feed['ID_MEMBER'], 'name' => $feed['postername'], 'email' => '', 'ip' => '127.0.0.1', 'update_post_count' => $updatePostCount); createPost($msgOptions, $topicOptions, $posterOptions); $topicID = 0; if (isset($topicOptions['id'])) { $topicID = $topicOptions['id']; } $msgID = 0; if (isset($msgOptions['id'])) { $msgID = $msgOptions['id']; } // Add Feed Log $fid = $feed['ID_FEED']; $ftime = time(); $smcFunc['db_query']('', "\n\t\t\t\t\t\t\t\tINSERT INTO {db_prefix}feedbot_log\n\t\t\t\t\t\t\t\t\t(ID_FEED, feedhash, feedtime, ID_TOPIC,ID_MSG)\n\t\t\t\t\t\t\t\tVALUES\n\t\t\t\t\t\t\t\t\t({$fid},'{$itemhash}',{$ftime},{$topicID},{$msgID})"); $smcFunc['db_query']('', "\n\t\t\t\t\t\t\t\tUPDATE {db_prefix}feedbot\n\t\t\t\t\t\t\t\tSET total_posts = total_posts + 1 \n\t\t\t\t\t\t\t\tWHERE ID_FEED = {$fid}\n\t\t\t\t\t\t\t\t"); $myfeedcount++; } } } // End get feed data // Set the RSS Feed Update time $updatetime = time() + 60 * $feed['importevery']; $smcFunc['db_query']('', "\n\t\t\tUPDATE {db_prefix}feedbot \n\t\t\tSET \n\t\t\t\tupdatetime = '{$updatetime}'\n\t\t\n\t\t\tWHERE ID_FEED = " . $feed['ID_FEED']); } // End expire check } // End for each feed }
function EditFeed2() { global $txt, $db_prefix, $sourcedir, $func; // Get the Feed ID $id = (int) $_REQUEST['id']; if (empty($id)) { fatal_error($txt['feedposter_nofeedselected'], false); } // Get the Fields $feedposter_feedtitle = $func['htmlspecialchars']($_REQUEST['feedposter_feedtitle'], ENT_QUOTES); $feedposter_feedurl = $_REQUEST['feedposter_feedurl']; $boardselect = (int) $_REQUEST['boardselect']; $feedposter_postername = str_replace('"', '', $_REQUEST['feedposter_postername']); $feedposter_postername = str_replace("'", '', $feedposter_postername); $feedposter_postername = str_replace('\\', '', $feedposter_postername); $feedposter_postername = $func['htmlspecialchars']($feedposter_postername, ENT_QUOTES); $feedposter_topicprefix = $func['htmlspecialchars']($_REQUEST['feedposter_topicprefix'], ENT_QUOTES); $feedposter_importevery = (int) $_REQUEST['feedposter_importevery']; $feedposter_numbertoimport = (int) $_REQUEST['feedposter_numbertoimport']; $msgicon = $func['htmlspecialchars']($_REQUEST['msgicon'], ENT_QUOTES); $footer = $func['htmlspecialchars']($_REQUEST['footer'], ENT_QUOTES); $topicid = (int) $_REQUEST['topicid']; if ($feedposter_feedtitle == '') { fatal_error($txt['feedposter_err_feedtitle'], false); } if ($feedposter_feedurl == '') { fatal_error($txt['feedposter_err_feedurl'], false); } if ($feedposter_postername == '') { fatal_error($txt['feedposter_err_postername'], false); } if ($boardselect == 0) { fatal_error($txt['feedposter_err_forum'], false); } if ($feedposter_importevery < 5) { $feedposter_importevery = 5; } if ($feedposter_numbertoimport < 1) { $feedposter_numbertoimport = 1; } if ($feedposter_numbertoimport > 50) { $feedposter_numbertoimport = 25; } $feedposter_feedenabled = isset($_REQUEST['feedposter_feedenabled']) ? 1 : 0; $feedposter_htmlenabled = isset($_REQUEST['feedposter_htmlenabled']) ? 1 : 0; $feedposter_topiclocked = isset($_REQUEST['feedposter_topiclocked']) ? 1 : 0; $feedposter_markread = isset($_REQUEST['feedposter_markread']) ? 1 : 0; // Verify the field url require_once $sourcedir . '/Subs-RSS.php'; $json = 0; if (substr_count($feedposter_feedurl, 'format=json') > 0) { $jsondata = disguise_curl($feedposter_feedurl); $jsondata2 = json_decode($jsondata); if (empty($jsondata2)) { fatal_error($txt['feedposter_err_nodownload'], false); } $json = 1; } else { verify_rss_url($feedposter_feedurl); } // Lookup the Memeber ID of the postername $memid = 0; $dbresult = db_query("\n\tSELECT \n\t\trealName, ID_MEMBER \n\tFROM {$db_prefix}members \n\tWHERE realName = '{$feedposter_postername}' OR memberName = '{$feedposter_postername}' LIMIT 1", __FILE__, __LINE__); $row = mysql_fetch_assoc($dbresult); mysql_free_result($dbresult); if (db_affected_rows() != 0) { $memid = $row['ID_MEMBER']; } // Update the feedbot db_query("\n\t\tUPDATE {$db_prefix}feedbot\n\t\tSET \n\t\t\tID_BOARD = {$boardselect}, feedurl = '{$feedposter_feedurl}', title = '{$feedposter_feedtitle}', enabled = {$feedposter_feedenabled},\n\t\t \thtml = {$feedposter_htmlenabled}, postername = '{$feedposter_postername}', ID_MEMBER = {$memid},\n\t\t \tlocked = {$feedposter_topiclocked},articlelink = 1, topicprefix = '{$feedposter_topicprefix}',\n\t\t \tnumbertoimport = {$feedposter_numbertoimport}, importevery = {$feedposter_importevery}, markasread = {$feedposter_markread},\n\t\t \tmsgicon = '{$msgicon}', footer = '{$footer}', json = '{$json}', id_topic = '{$topicid}' \n\t WHERE ID_FEED = {$id} LIMIT 1", __FILE__, __LINE__); // Redirect to the Feed Admin redirectexit('action=feedsadmin;sa=admin'); }
function patron_contentlink($url) { $headers = $this->headers; $data = json_decode(disguise_curl($url, null, null, $headers), true); return $data; }
$ipaddr = $iparr[0] . "." . $iparr[1] . "." . $iparr[2]; } // now ipaddr should be just the first 3, lookup in our table $sql = "SELECT latitude,longitude FROM qcn_geo_ipaddr WHERE ipaddr='" . $db->base_escape_string($ipaddr) . "'"; $result = $db->do_query($sql); if ($result && mysql_num_rows($result) > 0) { // we found some records // seed the startlat & startlng if ($row = mysql_fetch_array($result)) { $startlat = $row[0]; $startlng = $row[1]; } } else { // I suppose we should do a geoip lookup and insert into geoip table? $url = MAXMIND_URL . "&i=" . $ipaddr . ".1"; $html = disguise_curl($url); if ($html) { // see if we got a good html response from maxmind for this ipaddr $iparr = explode(",", $html); if (count($iparr) == 5) { // example line: // US,CA,Stanford,37.417801,-122.171997 $country = $db->base_escape_string($iparr[0]); $region = $db->base_escape_string($iparr[1]); $city = $db->base_escape_string($iparr[2]); $startlat = $db->base_escape_string($iparr[3]); $startlng = $db->base_escape_string($iparr[4]); $sql = "(ipaddr, time_lookup, country, region, city, latitude, longitude) " . " values ('" . $ipaddr . "',unix_timestamp()," . "'" . $country . "', " . "'" . $region . "', " . "'" . $city . "', " . $startlat . ", " . $startlng . ")"; $retval = $db->insert("qcn_geo_ipaddr", $sql); } }
/* foreach ($info as $key => $value) { echo $key . " = " . $value . "<br />\n"; } */ // echo '<br />Total time ' . $info['total_time'] . ' seconds during the request to ' . $info['url']; // echo "<br />Size downloaded is " . $info["size_download"] . PHP_EOL . " Connect time equal " . $info["connect_time"]. '<br />'; } curl_close($curl); // close the connection return $html; // and finally, return $html } $url = 'http://cloudgrammar.com/'; echo "Time start: " . date('h:i:s') . "<br/>"; for ($a = 0; $a < 180; $a++) { $url_n = $url . '?a=' . $a; //echo "{$url_n} <br/>"; try { $page = disguise_curl($url_n); } catch (Exception $e) { header("http/1.0 500 Internal server error"); echo 'Caught exception: ' . $e->getMessage(); } echo date('h:i:s') . "<br/>"; // sleep for x seconds sleep(3); } echo "Time end: " . date('h:i:s') . "<br/>"; echo $page;
$mediaContentName = trim_src($actualHref); preg_match_all('/url([^)]+)/', $mediaContent, $urlArray, PREG_PATTERN_ORDER); // Catch sub url params within css, massage and save foreach ($urlArray[1] as $value) { $urlInCss = explode('(', $value); $urlInCss = $urlInCss[1]; $urlInCss = str_replace('"', '', $urlInCss); $urlInCss = str_replace("'", "", $urlInCss); $urlInCss = str_replace(' ', '', $urlInCss); $urlInCssUntouched = $urlInCss; if (substr($urlInCss, 0, 7) != 'http://') { $leadingUri = explode(".css", $actualHref); $leadingUri = substr($leadingUri[0], 0, strrpos($leadingUri[0], "/")); $urlInCss = $leadingUri . "/" . $urlInCss; } $urlContent = disguise_curl($urlInCss); $urlContentName = trim_src($urlInCss); if (!empty($urlContent)) { if (!file_put_contents($pathToFiles . "/media/" . $urlContentName, $urlContent)) { echo "Could not save " . $pathToFiles . "/media/" . $urlContentName; } } $mediaContent = str_replace($urlInCssUntouched, $urlContentName, $mediaContent); } if (!empty($mediaContent)) { // Save actual css if (!file_put_contents($pathToFiles . "/media/" . $mediaContentName, $mediaContent)) { echo "Could not save " . $pathToFiles . "/media/" . $mediaContentName; } } }
// browsers keep this blank. curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_USERAGENT, 'Googlebot/2.1 (+http://www.google.com/bot.html)'); curl_setopt($curl, CURLOPT_HTTPHEADER, $header); curl_setopt($curl, CURLOPT_REFERER, 'http://www.google.com'); curl_setopt($curl, CURLOPT_ENCODING, 'gzip,deflate'); curl_setopt($curl, CURLOPT_AUTOREFERER, true); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_TIMEOUT, 10); $html = curl_exec($curl); curl_close($curl); return $html; } $allowed_tags = implode(array('<a>', '<p>', '<h1>', '<h2>', '<h3>', '<h4>', '<h5>', '<h6>', '<h7>', '<div>', '<span>', '<ul>', '<ol>', '<li>', '<table>', '<tbody>', '<thead>', '<tr>', '<td>', '<th>')); foreach ($urls as $name => $opt) { $content = disguise_curl($opt['url']); $filename = $name . '/tos.html'; if (isset($opt['content'])) { preg_match($opt['content'], $content, $matches); $content = $matches[0]; } $content = strip_tags($content, $allowed_tags); // Make dir if (!is_dir($name)) { mkdir($name, 0777, TRUE); } // Make folder writable if (!is_writable($filename)) { chmod($name, 0777); } // Output file