コード例 #1
0
$following_dao = new Following_dao();
$data = $following_dao->getAll();
$clos_id = array();
$clos_val = array();
foreach ($data as $datum) {
    $x = $datum->similarity_followers + $datum->similarity_friends;
    //nilai total similarity
    $y = $datum->id;
    //id following
    $clos_id[] = $y;
    $clos_val[] = $x;
}
$clos = array_combine($clos_id, $clos_val);
//combine id dan nilai similarity
//var_dump($clos);
$id = max_key($clos);
//medapatkan id dgn niliai similarity terbesar
//echo $id;
$following = $following_dao->getById($id);
//dapatkan data user
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>MyTwit</title>
<style type="text/css">
<!--
body {
	background-image: url(images/bg.gif);
}
コード例 #2
0
ファイル: po4locale.php プロジェクト: jcisio/po4locale
<?php

/**
 * Replace button/menu/window... text with its translation in software
 * so that there is consistence between the manual and the software itself.
 *
 * Written by jcisio, 2010, licensed under GPLv2
 */
$T = array();
$LOCALE = isset($argv[1]) ? $argv[1] : 'vi';
foreach (glob('../rosetta-lucid/' . $LOCALE . '/LC_MESSAGES/*.po') as $filename) {
    parse_file($filename);
}
$T2 = array();
foreach ($T as $key => $values) {
    $T2[$key] = max_key($values);
}
$c = count($T);
$before = memory_get_usage();
unset($T);
$after = memory_get_usage();
$data = file_get_contents('po/' . $LOCALE . '.po');
$data = preg_replace_callback('#^msgstr .+?(?=\\n\\n)#ms', 'po4locale_match', $data);
file_put_contents('po/' . $LOCALE . '-new.po', $data);
printf("%d strings, %d KB used, %d title replaced.\n\n", $c, ($before - $after) / 1024, po4locale_item_replace());
function parse_file($filename)
{
    global $T;
    $data = file($filename);
    $k = 0;
    for ($k = 0, $l = count($data); $k < $l; $k++) {
コード例 #3
0
		public function buildChart($oAnalytics) {
		
			require_once 'lib/google_chart.php'; // By Andrey Savchenko (Rarst), http://www.rarst.net/script/google-chart/
			
			
			// Generating visit arrays for the date range.
			 $visit_report = $oAnalytics->getData(
			 	array('dimensions'=>urlencode('ga:date'),
			 	'metrics'=>urlencode('ga:visits'),
			 ));
			 
			 
			 $visits = array();
			 foreach($visit_report as $dimensions => $metric) {
			 	array_push($visits, $metric);
			 }
			 
			 // Generating visit arrays for the date range.
			  $views_report = $oAnalytics->getData(
			  	array('dimensions'=>urlencode('ga:date'),
			  	'metrics'=>urlencode('ga:pageviews'),
			  ));
			  
			  
			  $page_views = array();
			  foreach($views_report as $dimensions => $metric) {
			  	array_push($page_views, $metric);
			  }
			
			// Extract various dates from the report array keys in order to use them as variables for x-axis labels
			$days = array_keys($views_report);
			list($d0, $d1, $d2, $d3, $d4, $d5, $d6, $d7, $d8, $d9, $d10, $d11, $d12, $d13,
			$d14, $d15, $d16, $d17, $d18, $d19, $d20, $d21,$d22,$d23,$d24,$d25,$d26,$d27,$d28, $d29, $d30) = $days;
			
			
			// Get the keys for max. values of page views and visits
			if( !function_exists('max_key') ){
			 function max_key($array) {
			  foreach ($array as $key => $val) {
			   if ($val == max($array)) return $key;
			  }
			 }
			}
			$array = $page_views;
			$precord = max_key($array);
			$array = $visits;
			$vrecord = max_key($array);
			
			// Always use max. value recorded in array for y-axis
			$ymax = 1*(ceil(max($page_views)));
			// Devide it by six and round up to nearest whole number to set appropriate y-axis ticks
			$ytick = ceil((max($page_views))/6);
			
			// Chart settings
			$traffic = new GoogleChart;
			$traffic->type='lc';
			$traffic->SetImageSize(700,200);
			$traffic->SetChartMargins(20,20,20,20);
			$traffic->SetEncode('simple');
			$traffic->AddData($visits);
			$traffic->AddData($page_views);
			
			$traffic->AddChartColor('FF9900');
			$traffic->AddChartColor('0077CC');
			
			$traffic->AddLineStyle(3);
			$traffic->AddLineStyle(3);

			
			$traffic->AddFillArea('B','FF99007F',0);
			$traffic->AddFillArea('b','E6F2FA7F',0,1);
			
			$traffic->AddShapeMarker('o','FFFFFF',0,-1,9);
			$traffic->AddShapeMarker('o','FF9900',0,-1,7);
			$traffic->AddShapeMarker('o','FFFFFF',1,-1,9);
			$traffic->AddShapeMarker('o','0077CC',1,-1,7);

			
			$traffic->AddAxis('y,x');
			$traffic->AddAxisRange(0,round($ymax,-3),round($ytick, -3));
			$traffic->AddAxisLabel(extension_dashboard_analytics::formatDates(array($d0,$d10,$d20,$d30)),1);

			$traffic->SetGrid(round(100/30,2),round(100/6,2),1,3);
			
			
			$traffic->SetTitle('Visits and Page Views of last 30 days');
			$traffic->AddLegend('visits');
			$traffic->AddLegend('page views');
			$traffic->SetLegendPosition('b');
			
			

			// Generate chart URL
	
			
			$graph = new XMLElement('div', $traffic->GetImg());
			$graph->setAttribute('class', 'graph');
			return $graph;
		
		}
コード例 #4
0
ファイル: iCacher.php プロジェクト: Rpsl/iCacher
/**
 * Обрезание картинки от центра
 *
 * @param   Object    $T (phpThumb)
 * @param   string    $file
 * @param   mixed     $size
 * @param   string    $folder
 *
 * @return  string    $file_path
 */
function CropFromCenter($t, $file, $size, $folder = 'cc')
{
    if (empty($size[0]) or empty($size[1])) {
        $size[min_key($size)] = $size[max_key($size)];
    }
    $t->CropFromCenter($size[0], $size[1]);
    $save_size = SaveSize($size);
    $file = CACHE_FOLDER . '/' . $folder . '/' . $save_size . '/' . $file;
    return $file;
}
コード例 #5
0
/**
* Assigns points to one of the centroids 
* @param array $data the data points to cluster
* @param array $centroids The array of centroids
* @param int $k The number of clusters
*/
function assign_points($data, $centroids, $k)
{
    foreach ($data as $datum_index => $datum) {
        foreach ($centroids as $centroid) {
            $distances[$datum_index][] = dist($datum, $centroid);
        }
    }
    foreach ($distances as $distance_index => $distance) {
        $which_cluster = min_key($distance);
        $tentative_clusters[$which_cluster][] = $distance_index;
        $distances_from_clusters = array("{$distance_index}" => $distance);
    }
    //in case there's not enough clusters, take the farthest element from any of the cluster's centres
    //and make it a cluster.
    if (count($tentative_clusters) < $k) {
        $point_as_cluster = max_key($distances_from_clusters);
        foreach ($tentative_clusters as $tentative_index => $tentative_cluster) {
            foreach ($tentative_cluster as $tentative_element) {
                if ($tentative_element == $point_as_cluster) {
                    $clusters[$k + 1][] = $tentative_element;
                } else {
                    $clusters[$tentative_index][] = $tentative_element;
                }
            }
        }
    } else {
        $clusters = $tentative_clusters;
    }
    return $clusters;
}