function update_site_content($site_id = 0) { $result = array(); if (!empty($site_id)) { $CI =& get_instance(); $CI->load->model('model_site_content'); $CI->load->model('model_client_attributes'); $CI->load->model('model_site_attribute_values'); $site = $this->get_records(array('site_id' => $site_id)); if (!empty($site)) { $site_html = ''; $site_content_data = array(); $site_content_data['site_id'] = $site_id; $site_content_data['client_id'] = $site[0]['client_id']; $site_content_data['redirect_url'] = ''; $site_content_data['redirect_count'] = 0; $site_content_data['redirects'] = ''; $site_content_data['http_status_code'] = 999; $site_content_data['site_web_property_id'] = 'n/a'; $site_content_data['stat_date'] = mktime(); $site_content = $CI->model_site_content->get_records(array('site_id' => $site_id)); if (!empty($site_content)) { $site_content_data['site_content_id'] = $site_content[0]['site_content_id']; } // Assume http only for now $site_url = 'http://' . $site[0]['site_title']; $url = $site_url; $cookie_file = '/tmp/cookie.txt'; $response_start = microtime(true); // Work out all redirects and only allow 10 deep (silly, if more than that!) while (!empty($url) && $site_content_data['redirect_count'] < 5) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HEADER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_COOKIESESSION, true); curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file); curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); curl_setopt($ch, CURLOPT_TIMEOUT, 10); if (preg_match('/^https:/', $url)) { curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); } $output = curl_exec($ch); $site_content_data['http_status_code'] = curl_getinfo($ch, CURLINFO_HTTP_CODE); if ($site_content_data['http_status_code'] == 301 || $site_content_data['http_status_code'] == 302 || $site_content_data['http_status_code'] == 307) { // See if there's a Location specified in the output if (preg_match('#Location: #', $output)) { // If there is, pick it out $success = preg_match('#Location: (.*)#', $output, $redirect); $url = get_redirect_url(trim($redirect[1]), $site_url); if (!empty($site_content_data['redirects'])) { $site_content_data['redirects'] .= ' » '; } $site_content_data['redirects'] .= $url . ' (' . $site_content_data['http_status_code'] . ')'; $site_content_data['redirect_count']++; } else { // If there is no location, then we've reached the end, so assigned the values we need $site_html = $output; if ($url != $site_url) { $site_content_data['redirect_url'] = $url; } $url = ''; } } else { $error = curl_errno($ch); if ($error == 6) { $site_content_data['http_status_code'] = 999; // Couldn't resolve host } elseif ($error == 28) { $site_content_data['http_status_code'] = 998; // Timeout } elseif ($error == 7) { $site_content_data['http_status_code'] = 997; // Couldn't connect host } elseif ($error == 52) { $site_content_data['http_status_code'] = 996; // Got nothing } $site_html = $output; if ($url != $site_url) { $site_content_data['redirect_url'] = $url; } $url = ''; } curl_close($ch); if (file_exists($cookie_file)) { unlink($cookie_file); } } $site_content_data['response_seconds'] = microtime(true) - $response_start; // Now let's find out about the tracking code if (!empty($site_html)) { $tracking = array(); if (preg_match('#\'_setAccount\',.*\'(UA-[0-9]*-[0-9]*)\'.*;#', $site_html, $tracking)) { $site_content_data['site_web_property_id'] = $tracking[1]; $site_content_data['analytics_type'] = 'Google Analytics'; if (preg_match('#ga\\.async = true#', $site_html)) { $site_content_data['analytics_type'] = 'Google Analytics Async'; } } elseif (preg_match('#"_setAccount",.*"(UA-[0-9]*-[0-9]*)".*;#', $site_html, $tracking)) { $site_content_data['site_web_property_id'] = $tracking[1]; $site_content_data['analytics_type'] = 'Google Analytics'; if (preg_match('#ga\\.async = true#', $site_html)) { $site_content_data['analytics_type'] = 'Google Analytics Async'; } } elseif (preg_match('#_getTracker\\("(UA-[0-9]*-[0-9]*)"\\)#', $site_html, $tracking)) { $site_content_data['site_web_property_id'] = $tracking[1]; $site_content_data['analytics_type'] = 'Google Analytics Sync'; } elseif (preg_match('#_uacct = "(UA-[0-9]*-[0-9]*)"#', $site_html, $tracking)) { $site_content_data['site_web_property_id'] = $tracking[1]; $site_content_data['analytics_type'] = 'Google Analytics Deprecated'; } elseif (preg_match('#START OF SDC Advanced Tracking Code#', $site_html)) { $site_content_data['analytics_type'] = 'Webtrends'; } } $CI->model_site_content->save($site_content_data); // Now we can do the smart field searches, as long as there's some content to look for if (!empty($site_html)) { $smart_fields = $CI->model_client_attributes->get_records(array('client_id' => $site[0]['client_id'], 'attribute_value_type' => 'SF')); if (!empty($smart_fields)) { foreach ($smart_fields as $smart_field) { $CI->model_site_attribute_values->delete(array('client_id' => $site[0]['client_id'], 'site_id' => $site_id, 'attribute_index' => $smart_field['attribute_array_index'])); if (!empty($smart_field['attribute_values'])) { $command = 'if ('; foreach ($smart_field['attribute_values'] as $i => $attribute_value) { if ($i > 0) { if ($attribute_value['client_attribute_value_operator'] == 'or') { $command .= ' || '; } elseif ($attribute_value['client_attribute_value_operator'] == 'and not') { $command .= ' && !'; } else { $command .= ' && '; } } $command .= 'stripos($site_html,\'' . addslashes($attribute_value['client_attribute_value']) . '\')'; } $command .= ') { return 1; } else { return 0; }'; $search_result = eval($command); $site_attribute_value_data = array(); $site_attribute_value_data['client_id'] = $site[0]['client_id']; $site_attribute_value_data['site_id'] = $site_id; $site_attribute_value_data['client_attribute_id'] = $smart_field['client_attribute_id']; $site_attribute_value_data['attribute_index'] = $smart_field['attribute_array_index']; if ($search_result) { $site_attribute_value_data['site_attribute_value'] = $smart_field['client_attribute_found_value']; } else { $site_attribute_value_data['site_attribute_value'] = $smart_field['client_attribute_not_found_value']; } $CI->model_site_attribute_values->save($site_attribute_value_data); } } } } } } }
$cookies .= $k . '=' . $v . ';'; } curl_setopt($ch, CURLOPT_COOKIE, '"' . $cookies . '"'); $data = curl_exec($ch); $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); $header_len = curl_getinfo($ch, CURLINFO_HEADER_SIZE); $header = substr($data, 0, $header_len); $body = substr($data, $header_len); curl_close($ch); /* get cookies from curl'd data */ preg_match('/^Set-Cookie:\\s*([^;]*)/mi', $data, $m); if (isset($m[1])) { parse_str($m[1], $cookies); foreach ($cookies as $key => $value) { $expire = time() + 3600 * 24 * 30; setcookie($key, $value, $expire, '/', $_SERVER['HTTP_HOST']); // set cookies again } } if ($http_code == 301 || $http_code == 302) { header('Location: ' . get_redirect_url($data)); } else { echo $body; } function get_redirect_url($header) { if (preg_match('/^Location:\\s+(.*)$/mi', $header, $m)) { return trim($m[1]); } return ""; }
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="X-UA-Compatible" content="IE=7.0000"/> <link href="/images/favicon-captive-portal.png" type="image/png" rel="icon"></link> <script type="text/javascript"> var redirectUrl = "<?php echo get_redirect_url(); ?> "; var displayLogoutButton = <?php echo $cpd_settings["logout_button"] == "t" ? "true" : "false"; ?> ; </script> <?php // Reference parent Javascript using the current working directory ?> <script src="json2-min.js" type="text/javascript"></script> <?php // Reference custom Javascript using the custom directory. ?> <script src="custom/my_portal.js" type="text/javascript"></script> <title> <?php // To use values from the branding settings, use this format ?> <?php echo trim($branding_settings["company_name"]); ?>
/** * get_all_redirects() * Follows and collects all redirects, in order, for the given URL. * * @param string $url * @return array */ function get_all_redirects($url) { $redirects = array(); while ($newurl = get_redirect_url($url)) { if (in_array($newurl, $redirects)) { break; } $redirects[] = $newurl; $url = $newurl; } return $redirects; }
public/scripts/belron.js"></script> <script type="text/javascript" src="<?php echo base_url(); ?> public/scripts/jquery.tablesorter.js"></script> <script src="<?php echo base_url(); ?> public/scripts/jquery-tools-min.js"></script> <link href="<?php echo base_url(); ?> public/styles/style.css" rel="stylesheet" type="text/css" /> </head> <?$redirect_url = get_redirect_url();?> <?change_language($lang);?> <body> <div id="header_full"> <div id="header_960"> <div id="logo"><img src="<?php echo base_url(); ?> public/styles/images/logo.gif" alt="" border="0" /></div> <div id="header_menu"> <div id="welcom_name"><?php echo gettext("Welcome"); ?> <span><?php echo $this->session->userdata['name'];
public function login($mobile = '', $password = '', $verify = '') { if (is_login()) { $this->redirect('User/index'); } if (IS_POST) { //登录验证 /* 检测验证码 */ // if(!check_verify($verify)){ // $this->error('验证码输入错误!'); // } /* 调用UC登录接口登录 */ $user = new UserApi(); $uid = $user->login($mobile, $password, 3); if (0 < $uid) { //UC登录成功 /* 登录用户 */ $Member = D('Member'); if ($Member->login($uid)) { //登录用户 //TODO:跳转到登录前页面 $this->success('登录成功!', get_redirect_url()); } else { $this->error($Member->getError()); } } else { //登录失败 switch ($uid) { case -1: $error = '用户不存在或被禁用!'; break; //系统级别禁用 //系统级别禁用 case -2: $error = '密码错误!'; break; default: $error = '未知错误!'; break; // 0-接口参数错误(调试阶段使用) } $this->error($error); } } else { //显示登录表单 set_redirect_url(I('referer')); $this->display(); } }
function process_bbs_appgame_url($req_url) { preg_match('#^http://bbs\\.appgame\\.com/thread-[\\d]+-[\\d]+-[\\d]+\\.html$#us', $req_url, $matches); if ($matches == null) { return false; } $user_agent = 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.57 Safari/537.36'; $html = curl_get_content($req_url, $user_agent); if (empty($html)) { return false; } $regex_match = "#<div id=\"post_(\\d+)\">#s"; if (!preg_match($regex_match, $html, $match)) { return false; } $pid = $match[1]; preg_match('#发表于[^<]*?<span title="([^"]*?)">.*?</span>#s', $html, $match); $time_str = $match[1]; preg_match("#<title>([^<]*?)</title>#s", $html, $match); $title = $match[1]; $title = preg_replace("#_[^_]+_任玩堂.*\$#u", '', $title); $html = mb_convert_encoding($html, 'HTML-ENTITIES', mb_detect_encoding($html)); $saw = new nokogiri($html); $target = $saw->get('td#postmessage_' . $pid); $dom = $target->getDom(); $node = $dom->firstChild->childNodes->item(0); $content = strip_tags(dom_to_html($node)); $content = preg_replace("#[\\s]+#us", '', $content); preg_match('#showauthor\\(this, \'userinfo' . $pid . '\'.*?<img .*?src="([^"]+?)"#s', $html, $match); $user_pic = $match[1]; $user_img = get_redirect_url($user_pic); $res = array(); $res['onebox'] = 'appgame-bbs'; $res['provider_name'] = '任玩堂论坛'; $res['provider_url'] = 'http://bbs.appgame.com/'; $res['favicon_url'] = 'http://www.appgame.com/favicon.ico'; $res['ori_url'] = $req_url; $res['title'] = $title; $res['image'] = $user_img; $res['ID'] = intval($pid); $res['description'] = trim($content); $res['update_time'] = format_time($time_str); $res['create_time'] = $res['update_time']; return $res; }
static function parse_message($text, $redirect = false) { if (empty($text)) { return; } $twitter = array(); //extract links if (preg_match_all('/https?:[^\\s<>"\',]+/', $text, $matches)) { foreach ($matches as $match) { $temp = $match[0]; $twitter["url_raw"][] = $temp; if ($redirect) { if (strlen($temp) < 30) { $temp1 = get_redirect_url($temp); if ($temp1) { $twitter["url"][] = $temp1; } else { $twitter["url"][] = $temp; } } } if ($follow_redirect) { $twitter["final_url"][] = get_final_url($temp); } } // print_r($matches); } //expand links //extract hashtags if (preg_match_all('/#[A-Za-z0-9-_]+/', $text, $matches)) { foreach ($matches[0] as $match) { $temp = substr($match, 1); $twitter["dc:subject"][] = $temp; // $twitter["dc:subject"][] = URL_TWITTER_HASHTAG. $temp; $twitter["rdfs:seeAlso"][] = URL_TWITTER4RDF_HASHTAG . $temp; $twitter["dc:relation"][] = URL_TWITTERLOGIC_HASHTAG . strtolower($temp); } // print_r($matches); } return $twitter; }
curl_setopt($ch, CURLOPT_COOKIEJAR, $ckfile); curl_setopt($ch, CURLOPT_COOKIEFILE, $ckfile); curl_setopt($ch, CURLOPT_HEADER, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); //curl_setopt($ch, CURLOPT_VERBOSE, true); curl_setopt($ch, CURLOPT_USERAGENT, 'UWDataSpider/1.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.1.7)'); $output = curl_exec($ch); if (preg_match('/Set-Cookie: ([a-z0-9_\\.]+)=([a-z0-9]+)/i', $output, $match)) { $cookie = $match[1] . '=' . $match[2]; } else { echo "No cookie found.\n"; $no_cookie = true; } $is_old_calendar = false; $redirect_calendar_url = get_redirect_url($calendar_url); if (0 === strpos($redirect_calendar_url, 'http://www.ucalendar')) { // This is an old calendar that links straight to the ucalendar data. $is_old_calendar = true; $calendar_url = $redirect_calendar_url; echo "This is an old calendar\n"; } else { if ($no_cookie) { echo "No cookie found and using a new calendar\n"; exit; } } /////////////////////////////////////////////////////////////////////////////////////////////////// // First, let's hit the UW course calendar web page and see which year we're currently looking at. /////////////////////////////////////////////////////////////////////////////////////////////////// if ($is_old_calendar) {
function print_stop_message2($phrase, $file = NULL, $extra = array(), $backurl = NULL, $continue = false, $redirect_route = 'admincp') { //handle phrase as a string if (!is_array($phrase)) { $phrase = array($phrase); } $phraseAux = vB_Api::instanceInternal('phrase')->fetch(array($phrase[0])); if (isset($phraseAux[$phrase[0]])) { $message = $phraseAux[$phrase[0]]; } else { $message = $phrase[0]; // phrase doesn't exist or wasn't found, display the varname } if (sizeof($phrase) > 1) { $phrase[0] = $message; $message = call_user_func_array('construct_phrase', $phrase); } //todo -- figure out where this is needed and remove. global $vbulletin; if ($vbulletin->GPC['ajax']) { require_once DIR . '/includes/class_xml.php'; $xml = new vB_XML_Builder_Ajax('text/xml'); $xml->add_tag('error', $message); $xml->print_xml(); } //todo -- figure out where this is needed and remove. if (VB_AREA == 'Upgrade') { echo $message; exit; } $hash = ''; if ($file) { if (!empty($extra['#'])) { $hash = '#' . $extra['#']; unset($extra['#']); } $redirect = get_redirect_url($file, $extra, $redirect_route); } print_cp_message($message, $redirect . $hash, 1, $backurl, $continue); }
function login() { $data = filter_forwarded_data($this); # The user wants to proceed to login if (!empty($_POST)) { if (!empty($_POST['verified'])) { $response = $this->_account->login($_POST['loginusername'], $_POST['loginpassword'], array('uri' => uri_string(), 'ip_address' => get_ip_address(), 'device' => get_user_device(), 'browser' => $this->agent->browser())); # Proceed based on the login response from the API if (!empty($response['result']) && $response['result'] == 'SUCCESS' && !empty($response['default_view'])) { add_to_user_session($this, $response['user_details']); $this->native_session->set('__default_view', $response['default_view']); if (!empty($response['permissions'])) { $this->native_session->set('__permissions', $response['permissions']); } if (!empty($response['default_view']) && !empty($response['permissions'])) { if (!empty($_POST['redirect'])) { redirect(base_url() . get_redirect_url($_POST['redirect'])); } else { redirect(base_url() . $response['default_view']); } } else { $data['msg'] = "ERROR: No permissions could be resolved for your account."; } } else { $data['msg'] = "ERROR: The user name and password do not match a registered user. Please check and try again."; } } else { $data['msg'] = "ERROR: Your login could not be verified."; } } $this->load->view('accounts/login', $data); }
public function testPropertiesOfRequestObjectAreRequestObjects() { $auth = new Auth(new TraktProvider(get_client_id(), get_client_secret(), get_redirect_url())); $trakt = new Trakt($auth); $this->assertInstanceOf(Followers::class, $trakt->users->followers); }
public function pay() { require_once "WeixinpayV3/WxPayPubHelper.class.php"; //使用jsapi接口 $jsApi = new JsApi_pub($this->payConfig['wxappid'], $this->payConfig['wxmchid'], $this->payConfig['wxv3key'], $this->payConfig['wxv3appsecret']); //获取订单信息 $orderid = $_GET['orderid']; if ($orderid == "") { $orderid = $_GET['single_orderid']; } $price = $_GET['price']; $body = $orderid; if (isset($_GET["sbody"])) { $body = $_GET["sbody"]; } //=========步骤1:网页授权获取用户openid============ //通过code获得openid if (!isset($_GET['code'])) { //$config_M = getAddonConfig('Payment'); // 获取后台插件的配置参数 //触发微信返回code码 $geturl = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] . '?' . $_SERVER['QUERY_STRING']; $url = $jsApi->createOauthUrlForCode(urlencode($geturl)); Header("Location: {$url}"); } else { //获取code码,以获取openid $code = $_GET['code']; $jsApi->setCode($code); $openid = $jsApi->getOpenId(); } //=========步骤1:使用统一支付接口,获取prepay_id============ //使用统一支付接口 $unifiedOrder = new UnifiedOrder_pub($this->payConfig['wxappid'], $this->payConfig['wxmchid'], $this->payConfig['wxv3key'], $this->payConfig['wxv3appsecret']); $unifiedOrder->setParameter("openid", $openid); //商品描述 $unifiedOrder->setParameter("body", $orderid); //商品描述 //自定义订单号,此处仅作举例 $unifiedOrder->setParameter("out_trade_no", $orderid); //商户订单号 $unifiedOrder->setParameter("total_fee", $price * 100); //总金额,单位为分 //可能需要授权 //$return_url = addons_url('Payment://WeixinV3/return_url'); $return_url = "http://www.onesword.cn/addon/Payment/WeixinV3/return_url.html"; $unifiedOrder->setParameter("notify_url", $return_url); //通知地址 $unifiedOrder->setParameter("trade_type", "JSAPI"); //交易类型 $attach = json_decode($_GET['attach'], true); $unifiedOrder->setParameter('goods_tag', $attach['goods_tag']); //商品标记 $unifiedOrder->setParameter("attach", json_encode($attach)); //附加数据 $prepay_id = $unifiedOrder->getPrepayId(); //=========步骤2:使用jsapi调起支付============ $jsApi->setPrepayId($prepay_id); $jsApiParameters = $jsApi->getParameters(); $this->assign('jsApiParameters', $jsApiParameters); $this->assign('price', $_GET['price']); $this->assign('redirect_url', get_redirect_url()); $this->display(); }
function fetch_lh($link) { $tmp = file_get_contents($link); $tmp = explode("\n", $tmp); $data = null; foreach ($tmp as $tmp2) { if (preg_match("/atom\\+xml/", $tmp2)) { $data = $tmp2; } } $data = substr($data, 0, strlen($data) - 1); $data = str_replace("'", "\"", $data); $obj = json_decode($data); $return = array(); if ($obj) { foreach ($obj->preload->feed->media->content as $media) { if (preg_match("/video\\//", $media->type)) { $return[] = array('file' => get_redirect_url(html_entity_decode($media->url)) . "&sponsor=hayphimtv/hayphimtv.mp4", 'quality' => $media->height . "p " . quality2str($media->height)); } } } $return[0]['default'] = 'true'; return $return; }