在这篇文章中,我们将带领您了解GooglePageRank的计算源代码的全貌,包括googlepagerank算法的相关情况。同时,我们还将为您介绍有关Chrome中快速查询页面GooglePageR
在这篇文章中,我们将带领您了解Google PageRank的计算源代码的全貌,包括google pagerank算法的相关情况。同时,我们还将为您介绍有关Chrome中快速查询页面 Google PageRank & Alexa 排名、com.google.android.gms.maps.GoogleMap.OnCameraChangeListener的实例源码、com.google.android.gms.maps.GoogleMap.OnMarkerDragListener的实例源码、google chrome浏览器下载 PHP通用分页类pagephp[仿google分页]的知识,以帮助您更好地理解这个主题。
本文目录一览:- Google PageRank的计算源代码(google pagerank算法)
- Chrome中快速查询页面 Google PageRank & Alexa 排名
- com.google.android.gms.maps.GoogleMap.OnCameraChangeListener的实例源码
- com.google.android.gms.maps.GoogleMap.OnMarkerDragListener的实例源码
- google chrome浏览器下载 PHP通用分页类pagephp[仿google分页]
Google PageRank的计算源代码(google pagerank算法)
最近对google的PageRank(网页等级)比较感兴趣,一直想知道如何不用google toolbar来获取pr值。苦苦搜索之后,找到如下代码:
<?php
/**
This code is released unto the public domain
*/
//header("Content-Type: text/plain; charset=utf-8");
define('GOOGLE_MAGIC', 0xE6359A60);
//unsigned shift right
function zeroFill($a, $b)
{
$z = hexdec(80000000);
if ($z & $a)
{
$a = ($a>>1);
$a &= (~$z);
$a |= 0x40000000;
$a = ($a>>($b-1));
}
else
{
$a = ($a>>$b);
}
return $a;
}
function mix($a,$b,$c) {
$a -= $b; $a -= $c; $a ^= (zeroFill($c,13));
$b -= $c; $b -= $a; $b ^= ($a<<8);
$c -= $a; $c -= $b; $c ^= (zeroFill($b,13));
$a -= $b; $a -= $c; $a ^= (zeroFill($c,12));
$b -= $c; $b -= $a; $b ^= ($a<<16);
$c -= $a; $c -= $b; $c ^= (zeroFill($b,5));
$a -= $b; $a -= $c; $a ^= (zeroFill($c,3));
$b -= $c; $b -= $a; $b ^= ($a<<10);
$c -= $a; $c -= $b; $c ^= (zeroFill($b,15));
return array($a,$b,$c);
}
function GoogleCH($url, $length=null, $init=GOOGLE_MAGIC) {
if(is_null($length)) {
$length = sizeof($url);
}
$a = $b = 0x9E3779B9;
$c = $init;
$k = 0;
$len = $length;
while($len >= 12) {
$a += ($url[$k+0] +($url[$k+1]<<8) +($url[$k+2]<<16) +($url[$k+3]<<24));
$b += ($url[$k+4] +($url[$k+5]<<8) +($url[$k+6]<<16) +($url[$k+7]<<24));
$c += ($url[$k+8] +($url[$k+9]<<8) +($url[$k+10]<<16)+($url[$k+11]<<24));
$mix = mix($a,$b,$c);
$a = $mix[0]; $b = $mix[1]; $c = $mix[2];
$k += 12;
$len -= 12;
}
$c += $length;
switch($len) /* all the case statements fall through */
{
case 11: $c+=($url[$k+10]<<24);
case 10: $c+=($url[$k+9]<<16);
case 9 : $c+=($url[$k+8]<<8);
/* the first byte of c is reserved for the length */
case 8 : $b+=($url[$k+7]<<24);
case 7 : $b+=($url[$k+6]<<16);
case 6 : $b+=($url[$k+5]<<8);
case 5 : $b+=($url[$k+4]);
case 4 : $a+=($url[$k+3]<<24);
case 3 : $a+=($url[$k+2]<<16);
case 2 : $a+=($url[$k+1]<<8);
case 1 : $a+=($url[$k+0]);
/* case 0: nothing left to add */
}
$mix = mix($a,$b,$c);
/*-------------------------------------------- report the result */
return $mix[2];
}
//converts a string into an array of integers containing the numeric value of the char
function strord($string) {
for($i=0;$i<strlen($string);$i++) {
$result[$i] = ord($string{$i});
}
return $result;
}
// http://www.example.com/ - Checksum: 6540747202
$url = 'info:'.$_GET['url'];
$ch = GoogleCH(strord($url));
$url='info:'.urlencode($_GET['url']);
echo file_get_contents("http://www.google.com/search?client=navclient-auto&ch=6$ch&ie=UTF-8&oe=UTF-8&features=Rank&q=$url");
/* use curl send the user angent
$curl = curl_init("http://www.google.com/search?client=navclient-auto&ch=6$ch&ie=UTF-8&oe=UTF-8&features=Rank&q=$url");
curl_setopt ($curl, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; GoogleToolbar 2.0.110-big; Windows 2000 5.0)");
curl_exec($curl);
*/
?>
</></>
Chrome中快速查询页面 Google PageRank & Alexa 排名
ChromeFans.org制作的一个JS插件,可以用来快速查询页面的Google PageRank & Alexa 排名,非常之方便。将如下按钮PageRank Status直接拖放到标签栏(或者手动以添加网页的方式将代码添加到标签栏,图2),今后遇到想到查询的页面,就直接点击该标签栏按钮,稍等片刻之后,就能看到如图所示的查询结果窗口,很直观的显示的相关数据(图1)。
图1
具体代码:
javascript:void(window.open(”http://www.chromefans.org/pr/?u=”+escape(location.href), “PageRank%20Status%20-%20ChromeFans”,”width=405,height=120,top=0,left=0,location=0″))
图2
com.google.android.gms.maps.GoogleMap.OnCameraChangeListener的实例源码
/** * Sets up the map if it is possible to do so (i.e.,the Google Play services APK is correctly * installed) and the map has not already been instantiated.. This will ensure that we only ever * call {@link #setUpMap()} once when {@link #mMap} is not null. * <p> * If it isn't installed {@link SupportMapFragment} (and * {@link com.google.android.gms.maps.MapView MapView}) will show a prompt for the user to * install/update the Google Play services APK on their device. * <p> * A user can return to this FragmentActivity after following the prompt and correctly * installing/updating/enabling the Google Play services. Since the FragmentActivity may not * have been completely destroyed during this process (it is likely that it would only be * stopped or paused),{@link #onCreate(Bundle)} may not be called again so we should call this * method in {@link #onResume()} to guarantee that it will be called. */ private void setUpMapIfNeeded() { // Do a null check to confirm that we have not already instantiated the map. if (mMap == null) { // Try to obtain the map from the SupportMapFragment. mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)) .getMap(); // Check if we were successful in obtaining the map. if (mMap != null) { // turn MyLocation on and move to a place with indoor (SFO airport) mMap.setMyLocationEnabled(true); mMap.setPadding(currentLeft,currentTop,currentRight,currentBottom); mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(SFO,18)); // Add a marker to the Opera House mMap.addMarker(new MarkerOptions().position(SOH).title("Sydney Opera House")); // Add a camera change listener. mMap.setonCamerachangelistener(new OnCamerachangelistener() { public void onCameraChange(CameraPosition pos) { mMessageView.setText("Camerachangelistener: " + pos); } }); } } }
/** * Sets up the map if it is possible to do so (i.e.,18)); // Add a marker to the Opera House mMap.addMarker(new MarkerOptions().position(SOH).title("Sydney Opera House")); // Add a camera change listener. mMap.setonCamerachangelistener(new OnCamerachangelistener() { public void onCameraChange(CameraPosition pos) { mMessageView.setText("Camerachangelistener: " + pos); } }); } } }
private void initMap() { if (map == null) { SupportMapFragment mapFragment = (SupportMapFragment)getSupportFragmentManager().findFragmentById(R.id.map); if (mapFragment != null) { map = mapFragment.getMap(); if (map != null) { UiSettings uiSettings = map.getUiSettings(); uiSettings.setAllGesturesEnabled(false); uiSettings.setScrollGesturesEnabled(true); uiSettings.setZoomGesturesEnabled(true); map.setonCamerachangelistener(new OnCamerachangelistener() { @Override public void onCameraChange(CameraPosition arg0) { moveMapCameraToBoundsAndInitClusterkraf(); } }); } } } else { moveMapCameraToBoundsAndInitClusterkraf(); } }
private void zoomAndDrawLines(ArrayList<LatLng> healthiestPath,ArrayList<LatLng> shortestPath) { final LatLngBounds.Builder builder = new LatLngBounds.Builder(); Set<LatLng> duplicates = getDuplicates(healthiestPath,shortestPath); List<polylineoptions> healthiestList = getpolylineoptions( healthiestPath,duplicates,builder,true); List<polylineoptions> shortestList = getpolylineoptions(shortestPath,false); List<polylineoptions> mergedShortest = mergepolylineoptions(shortestList); List<polylineoptions> mergedHealthiest = mergepolylineoptions(healthiestList); // Zoom to path once the map has a layout. map.setonCamerachangelistener(new OnCamerachangelistener() { @Override public void onCameraChange(CameraPosition arg0) { // Move camera. getMap().moveCamera( CameraUpdateFactory.newLatLngBounds(builder.build(),100)); // Remove listener to prevent position reset on camera move. getMap().setonCamerachangelistener(null); } }); addpolylinesToMap(mergedShortest); addpolylinesToMap(mergedHealthiest); }
private void setonCamerachangelistener() { mGoogleMap.setonCamerachangelistener(new OnCamerachangelistener() { @Override public void onCameraChange(CameraPosition pos) { mCurrentZoom = pos.zoom; } }); }
@Override public void onViewCreated(View view,Bundle savedInstanceState) { super.onViewCreated(view,savedInstanceState); getLoaderManager().initLoader(URL_LOADER,null,this); /*getMap().setonMarkerClickListener(new GoogleMap.OnMarkerClickListener() { @Override public boolean onMarkerClick(Marker marker) { getMap().setInfoWindowAdapter(new PhotoInfoWindowAdapter(getActivity())); marker.showInfoWindow(); return true; } });*/ getMap().setonCamerachangelistener(new OnCamerachangelistener() { @Override public void onCameraChange(CameraPosition position) { LatLngBounds bounds = getMap().getProjection().getVisibleRegion().latLngBounds; double swlong = bounds.southwest.longitude; double swlat = bounds.southwest.latitude; double nelong = bounds.northeast.longitude; double nelat = bounds.northeast.latitude; RestAdapter restAdapter = new AuthKlusterRestAdapter() .build(); KlusterService service = restAdapter.create(KlusterService.class); service.getEvents(null,String.format("%f,%f|%f,%f",swlong,swlat,nelong,nelat),new EventsCallback(getActivity())); } }); }
@Override public final void setonCamerachangelistener(OnCamerachangelistener listener) { map.setonCamerachangelistener(listener); }
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); if (savedInstanceState != null) { keepCurrentLocationVisible = savedInstanceState.getBoolean( KEEP_CURRENT_LOCATION_VISIBLE_KEY,false); if (keepCurrentLocationVisible) { Location location = (Location) savedInstanceState.getParcelable(CURRENT_LOCATION_KEY); if (location != null) { setCurrentLocation(location); } } } /* * At this point,after onCreateView,getMap will not return null and we can * initialize googleMap. However,onActivityCreated can be called multiple * times,e.g.,when the user switches tabs. With * GoogleMapOptions.useViewLifecycleInFragment == false,googleMap lifecycle * is tied to the fragment lifecycle and the same googleMap object is * returned in getMap. Thus we only need to initialize googleMap once,when * it is null. */ if (googleMap == null) { googleMap = getMap(); googleMap.setMyLocationEnabled(true); /* * My Tracks needs to handle the onClick event when the my location button * is clicked. Currently,the API doesn't allow handling onClick event,* thus hiding the default my location button and providing our own. */ googleMap.getUiSettings().setMyLocationButtonEnabled(false); googleMap.setIndoorEnabled(true); googleMap.setonMarkerClickListener(new OnMarkerClickListener() { @Override public boolean onMarkerClick(Marker marker) { if (isResumed()) { String title = marker.getTitle(); if (title != null && title.length() > 0) { long id = Long.valueOf(title); Context context = getActivity(); Intent intent = IntentUtils.newIntent(context,MarkerDetailActivity.class) .putExtra(MarkerDetailActivity.EXTRA_MARKER_ID,id); context.startActivity(intent); } } return true; } }); googleMap.setLocationSource(new LocationSource() { @Override public void activate(OnLocationChangedListener listener) { onLocationChangedListener = listener; } @Override public void deactivate() { onLocationChangedListener = null; } }); googleMap.setonCamerachangelistener(new OnCamerachangelistener() { @Override public void onCameraChange(CameraPosition cameraPosition) { if (isResumed() && keepCurrentLocationVisible && currentLocation != null && !isLocationVisible(currentLocation)) { keepCurrentLocationVisible = false; } } }); } }
private void setUpMap() { this.mMap.addCircle(new CircleOptions().center(this.center) .radius(this.radius).strokeColor(Color.argb(128,255)) .strokeWidth(3).fillColor(Color.argb(64,255))); this.mMap.setonCamerachangelistener(new OnCamerachangelistener() { @Override public void onCameraChange(CameraPosition arg0) { LatLngBounds.Builder builder = LatLngBounds.builder(); LatLngBounds bounds = builder .include( SphericalUtil .computeOffset( AffectedAreaMapActivityOnline.this.center,AffectedAreaMapActivityOnline.this.radius,0)) .include( SphericalUtil .computeOffset( AffectedAreaMapActivityOnline.this.center,90)) .include( SphericalUtil .computeOffset( AffectedAreaMapActivityOnline.this.center,180)) .include( SphericalUtil .computeOffset( AffectedAreaMapActivityOnline.this.center,270)).build(); // Move camera. AffectedAreaMapActivityOnline.this.mMap .moveCamera(CameraUpdateFactory.newLatLngBounds(bounds,0)); // Remove listener to prevent position reset on camera move. AffectedAreaMapActivityOnline.this.mMap .setonCamerachangelistener(null); } }); }
@Override public final void setonCamerachangelistener(OnCamerachangelistener listener) { map.setonCamerachangelistener(listener); }
@Override public final void setonCamerachangelistener(OnCamerachangelistener listener) { map.setonCamerachangelistener(listener); }
private void initializeUI() { Switch onOffAlarm = (Switch) findViewById(R.id.switchOnOffAlarm); if (geoAlarm.isFirstTimeRun) { showWelcomeDialog(); // Actual zoom will be performed when location service // is connected zoomOnCurrentPosition = true; geoAlarm.isFirstTimeRun = false; } else { if (geoAlarm.zone == null) { // Actual zoom will be performed when location service // is connected zoomOnCurrentPosition = true; } else { // Zoom on zone (last position) gMap.setonCamerachangelistener(new OnCamerachangelistener() { @Override public void onCameraChange(CameraPosition pos) { showMapLocation(geoAlarm.zone); Log.d(GeoAlarmUtils.APPTAG,"Showing zone saved in SharedPrefs"); gMap.setonCamerachangelistener(null); } }); } // set vibrate mode CheckBox checkBoxUseVibrate = (CheckBox) findViewById(R.id.checkBoxUseVibrate); checkBoxUseVibrate.setChecked(geoAlarm.isUseVibrate); // set toggle button state onOffAlarm.setChecked(geoAlarm.isAlarmOn); } if (geoAlarm.isAlarmOn) { disableuI(); } // Events onOffAlarm .setonCheckedchangelistener(new CompoundButton.OnCheckedchangelistener() { @Override public void onCheckedChanged(CompoundButton buttonView,boolean isChecked) { MainActivity.this.switchOnOffAlarm_onChange(buttonView,isChecked); } }); }
void setonCamerachangelistener(OnCamerachangelistener listener);
void setonCamerachangelistener(OnCamerachangelistener listener);
void setonCamerachangelistener(OnCamerachangelistener listener);
com.google.android.gms.maps.GoogleMap.OnMarkerDragListener的实例源码
@Override public final void setonMarkerDragListener(OnMarkerDragListener listener) { map.setonMarkerDragListener(listener); }
@Override public final void setonMarkerDragListener(OnMarkerDragListener listener) { map.setonMarkerDragListener(listener); }
@Override public final void setonMarkerDragListener(OnMarkerDragListener listener) { map.setonMarkerDragListener(listener); }
void setonMarkerDragListener(OnMarkerDragListener listener);
void setonMarkerDragListener(OnMarkerDragListener listener);
void setonMarkerDragListener(OnMarkerDragListener listener);
google chrome浏览器下载 PHP通用分页类pagephp[仿google分页]
page.php
复制代码 代码如下:
/**
** 通用php分页类。(仿Google样式)
** 只需提供记录总数与每页显示数两个参数。(已附详细使用说明..)
** 无需指定URL,链接由程序生成。方便用于检索结果分页。
** 表单采用GET方法提交,可保证在诸如查询之,删除之类的操作时,不丢失URL参数
**/
class Pager{
//IE地址栏地址
var $url;
//记录总条数
var $countall;
//总页数
var $page;
//分页数字链接
var $thestr;
//首页、上一页链接
var $backstr;
//尾页、下一页链接
var $nextstr;
//当前页码
var $pg;
//每页显示记录数量
var $countlist;
//翻页样式
var $style;
//构造函数,实例化该类的时候自动执行该函数
function Pager($countall,$countlist,$){
//记录数与每页显示数不能整队时,页数取余后加1
$this->countall = $countall;
$this->countlist = $countlist;
$this->style=$style;
if ($this->countall%$this->countlist!=0){
$this->page=sprintf("%d",$this->countall/$this->countlist)+1;
}else{
$this->page=$this->countall/$this->countlist;
}
$this->pg=$_GET["pg"];
//保证pg在未指定的情况下为从第1页开始
if (!ereg("^[1-9][0-9]*$",$this->pg) || empty($this->pg)){
$this->pg=1;
}
//页码超出最大范围,取最大值
if ($this->pg>$this->page){
$this->pg=$this->page;
}
//得到当前的URL。具体实现请看最底部的函数实体
$this->url = Pager::getUrl();
//替换错误格式的页码为正确页码
if(isset($_GET["pg"]) && $_GET["pg"]!=$this->pg){
$this->url=str_replace("?pg=".$_GET["pg"],"?pg=$this->pg",$this->url);
$this->url=str_replace("&pg=".$_GET["pg"],"&pg=$this->pg",$this->url);
}
//生成12345等数字形式的分页。
if ($this->pagefor ($i=1;$ipage+1;$i++){
$this->thestr=$this->thestr.Pager::makepg($i,$this->pg);
}
}else{
if ($this->pgfor ($i=1;$i$this->thestr=$this->thestr.Pager::makepg($i,$this->pg);
}
}else{
if (6+$this->pgpage){
for ($i=$this->pg-4;$ipg+6;$i++){
$this->thestr=$this->thestr.Pager::makepg($i,$this->pg);
}
}else{
for ($i=$this->pg-4;$ipage+1;$i++){
$this->thestr=$this->thestr.Pager::makepg($i,$this->pg);
}
}
}
}
//生成上页下页等文字链接
$this->backstr = Pager::gotoback($this->pg);
$this->nextstr = Pager::gotonext($this->pg,$this->page);
//echo (" 共".$this->countall." 条,每页".$this->countlist."条,共".$this->page."页".$this->backstr.$this->thestr.$this->nextstr);
}
//生成数字分页的辅助函数
function makepg($i,$pg){
if ($i==$pg){
return "
}else{
return " url,5,%24i)." .="">style."''>".$i."";
}
}
//生成上一页等信息的函数
function gotoback($pg){
if ($pg-1>0){
return $this->gotoback=" url,3,0)." .="">style."''>首页 url,2,0)." .="">style."''>上一页";
}else{
return $this->gotoback="
}
}
//生成下一页等信息的函数
function gotonext($pg,$page){
if ($pg return " url,1,0)." .="">style."''>下一页 url,4,0)." .="">style."''>尾页";
}else{
return "
}
}
//处理url中$pg的方法,用于自动生成pg=x
function replacepg($url,$flag,$i){
if ($flag == 1){
$temp_pg = $this->pg;
return str_replace("pg=".$temp_pg,"pg=".($this->pg+1),$url);
}else if($flag == 2) {
$temp_pg = $this->pg;
return str_replace("pg=".$temp_pg,"pg=".($this->pg-1),$url);
}else if($flag == 3) {
$temp_pg = $this->pg;
return str_replace("pg=".$temp_pg,"pg=1",$url);
}else if($flag == 4){
$temp_pg = $this->pg;
return str_replace("pg=".$temp_pg,"pg=".$this->page,$url);
}else if($flag == 5){
$temp_pg = $this->pg;
return str_replace("pg=".$temp_pg,"pg=".$i,$url);
}else{
return $url;
}
}
//获得当前URL的方法
function getUrl(){
$url="http://".$_SERVER["HTTP_HOST"];
if(isset($_SERVER["REQUEST_URI"])){
$url.=$_SERVER["REQUEST_URI"];
}else{
$url.=$_SERVER["PHP_SELF"];
if(!empty($_SERVER["QUERY_STRING"])){
$url.="?".$_SERVER["QUERY_STRING"];
}
}
//在当前的URL里加入pg=x字样
if (!ereg("(pg=|PG=|pG=|Pg=)", $url)){
if (!strpos($url,"?")){
$url = $url."?pg=1";
}else{
$url = $url."&pg=1";
}
}
return $url;
}
}
?>
以上就介绍了google chrome浏览器下载 PHP通用分页类pagephp[仿google分页],包括了google chrome浏览器下载方面的内容,希望对PHP教程有兴趣的朋友有所帮助。
今天关于Google PageRank的计算源代码和google pagerank算法的分享就到这里,希望大家有所收获,若想了解更多关于Chrome中快速查询页面 Google PageRank & Alexa 排名、com.google.android.gms.maps.GoogleMap.OnCameraChangeListener的实例源码、com.google.android.gms.maps.GoogleMap.OnMarkerDragListener的实例源码、google chrome浏览器下载 PHP通用分页类pagephp[仿google分页]等相关知识,可以在本站进行查询。
本文标签: