Skip to content

Commit

Permalink
daudz jaunumu...
Browse files Browse the repository at this point in the history
  • Loading branch information
M4t1ss committed Nov 5, 2011
1 parent 0c13d79 commit 9f4bec2
Show file tree
Hide file tree
Showing 476 changed files with 72,684 additions and 26 deletions.
111 changes: 111 additions & 0 deletions dienas.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
<h1 style='margin:auto auto; text-align:center;'>Ēšanas kalendārs</h1>
<br/>
<h3>Cikos tvīto visbiežāk</h3>
<div style='margin:auto auto;width:500px;'>
<?php

//jādabū visas dienas Mon-Sun...
//šitā ir pirmdiena...sāksim ar to
$theDate = '2011-10-31';
$timeStamp = StrToTime($theDate);
for($zb=0;$zb<7;$zb++) {
$ddd = date('D', $timeStamp);
$timeStamp = StrToTime('+1 days', $timeStamp);
$dienas[$ddd][skaits]=0;
}

//dabū šodienas datumu
$menesiss = $menesis = date("m");
$dienasz = $diena = date("d");
$gadss = $gads = date("Y");
//izrēķina datumu pirms mēneša
$menesis--;
if($menesis==0){
$menesis=12;
$gads--;
}
$max=0;
$maxd=0;
for($zb=0;$zb<24;$zb++) $stundas[$zb][skaits]=0;

$q = mysql_query("SELECT created_at FROM `tweets` WHERE created_at between '$gads-$menesis-$diena' AND '$gadss-$menesiss-$dienasz'");
while($r=mysql_fetch_array($q)){
$laiks=$r["created_at"];
$laiks=strtotime($laiks);
$diena=date("D", $laiks);
$laiks=date("G", $laiks);
$dienas[$diena][skaits]++;
$stundas[$laiks][skaits]++;
if($stundas[$laiks][skaits]>$max) $max=$stundas[$laiks][skaits];
if($dienas[$diena][skaits]>$maxd) $maxd=$dienas[$diena][skaits];
}

//izdrukā populārākās stundas
for($zb=0;$zb<24;$zb++) {
$percent = round($stundas[$zb][skaits]/$max*100);
?>
<script type="text/javascript">
$(function(){
$("#progressbar<?php echo $zb;?>").progressbar({
value: <?php echo $percent;?>
});
});
</script>
<div style=" font: 50% 'Trebuchet MS', sans-serif;" id="progressbar<?php echo $zb;?>"></div>
<div class="sk"><?php echo $zb.":00 - ".($zb+1).":00";?></div>
</br>
<?php
}
?>
</div>
<br/>
<h3>Kurās dienās tvīto visbiežāk</h3>
<div style='margin:auto auto;width:500px;'>
<?php
$theDate = '2011-10-31';
$timeStamp = StrToTime($theDate);
//izdrukā populārākās dienas
for($zb=0;$zb<7;$zb++) {
$ddd = date('D', $timeStamp);
$timeStamp = StrToTime('+1 days', $timeStamp);
$percent = round($dienas[$ddd][skaits]/$maxd*100);
?>
<script type="text/javascript">
$(function(){
$("#progressbar<?php echo $ddd;?>").progressbar({
value: <?php echo $percent;?>
});
});
</script>
<div style=" font: 50% 'Trebuchet MS', sans-serif;" id="progressbar<?php echo $ddd;?>"></div>
<div class="sk"><?php
switch ($ddd) {
case 'Mon':
echo "Pirmdien";
break;
case 'Tue':
echo "Otrdien";
break;
case 'Wed':
echo "Trešdien";
break;
case 'Thu':
echo "Ceturtdien";
break;
case 'Fri':
echo "Piektdien";
break;
case 'Sat':
echo "Sestdien";
break;
case 'Sun':
echo "Svētdien";
break;
}
?></div>
</br>
<?php
}
?>

</div>
56 changes: 42 additions & 14 deletions draugi.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
require_once('auth/twitteroauth/twitteroauth.php');
require_once('auth/config.php');

//kārtošana
$ord=$_GET['ord'];
$sort=$_GET['sort'];
if($sort=='')$sort='sk';
if($ord=='')$ord='desc';
if($ord=='desc'){$ord0='asc';}else if($ord=='asc'){$ord0='desc';}else{$ord0='asc';}

//Ja nav pieslēdzies, pārsūta uz pieslēgšanās lapu
if (empty($_SESSION['access_token']) || empty($_SESSION['access_token']['oauth_token']) || empty($_SESSION['access_token']['oauth_token_secret'])) {
?>
Expand All @@ -12,6 +19,7 @@
<a href="./auth/redirect.php"><img src="./auth/images/lighter.png" alt="Sign in with Twitter"/></a>
</div>
<?php
//Ja ir pieslēdzies
}else{
$access_token = $_SESSION['access_token'];
$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $access_token['oauth_token'], $access_token['oauth_token_secret']);
Expand All @@ -20,11 +28,10 @@
<div style='float:right;margin-top:-22px'>Sveiki, <?php echo $usr->{'name'}?> [<a style='text-decoration:none; color:grey;' href="auth/clearsessions.php">Iziet</a>]</div><br/>
<?php
$krasa=TRUE;
echo "<table class='sortable' style='margin:auto auto;'>";
echo "<table id='results' style='margin:auto auto;'>";
echo "<tr>
<th>Lietotājs</th>
<th>Tvīts</th>
<th style='width:135px;'>Laiks</th>
<th><a href='?id=draugi&sort=liet&ord=".$ord0."'>Lietotājs</a></th>
<th><a href='?id=draugi&sort=sk&ord=".$ord0."'>Tvītu skaits</a></th>
</tr>";
//dabū draugu Twitter screen name
$nextCursor = -1;
Expand All @@ -34,18 +41,39 @@
for ($i = 0; $i < sizeof($content->{'users'}); $i++) {
$niks = $content->{'users'}[$i]->{'screen_name'};
//Paskatās, vai datubāzē ir tvīti no konkrētā drauga
$q = mysql_query("SELECT text, created_at FROM tweets where screen_name='$niks' order by created_at desc");
while($r=mysql_fetch_array($q)){
if ($krasa==TRUE) {$kr=" style='background-color:#E0E0E0'";}else{$kr="";}
$teksts=$r["text"];
$laiks=$r["created_at"];
$laiks=strtotime($laiks);
$laiks=date("m.d.Y H:i", $laiks);
echo "<tr".$kr."><td><b><a style='text-decoration:none;color:#658304;' href='https://twitter.com/#!/".$niks."'>".$niks."</a></b></td><td>".$teksts."</td><td>".$laiks."</td></tr>";
$krasa=!$krasa;
$q = mysql_query("SELECT created_at FROM tweets where screen_name='$niks' order by created_at desc");
//Ja kāds tomēr ir
$skaits = mysql_num_rows($q);
if($skaits>0){
//sametam masīvā un sakārtojam masīvu
if($sort=='sk'){
$draugi[] = array('skaits' => $skaits, 'niks' => $niks);
}else if($sort=='liet'){
$draugi[] = array('niks' => $niks, 'skaits' => $skaits);
}
}
}
}
//pārkārtojam masīvu
if ($ord=='desc'){
array_multisort($draugi, SORT_DESC);
}else if ($ord=='asc'){
array_multisort($draugi, SORT_ASC);
}
for($i=0;$i<sizeof($draugi);$i++){
$niks = $draugi[$i]['niks'];
$skaits = $draugi[$i]['skaits'];
if ($krasa==TRUE) {$kr=" style='background-color:#E0E0E0'";}else{$kr="";}
echo '<tr'.$kr.'><td><b><a style="text-decoration:none;color:#658304;" href="?id=draugs&dra='.$niks.'">'.$niks.'</a></b></td><td>'.$skaits.'</td></tr>';
$krasa=!$krasa;
}
echo "</table>";
}
?>
?>
<div style="margin:auto auto; text-align:center;" id="pageNavPosition"></div>
<script type="text/javascript"><!--
var pager = new Pager('results', 15);
pager.init();
pager.showPageNav('pager', 'pageNavPosition');
pager.showPage(1);
//--></script>
39 changes: 39 additions & 0 deletions draugs.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php
//ja nav norādīts draugs, ej prom...
if (!isset($_GET['dra'])) echo "<script type=\"text/javascript\">setTimeout(\"window.location = 'index.php'\",5);</script>";
$draugs = $_GET['dra'];
?>
<h1 style='margin:auto auto; text-align:center;'>Tavi Twitter draugi, kas tvītos pieminējuši ēšanu</h1>
<h2 style='margin:auto auto; text-align:center;'><?php echo $draugs;?></h2>
<?php

$krasa=TRUE;
echo "<table id='results' class='sortable' style='margin:auto auto;'>";
echo "<tr>
<th>Tvīts</th>
<th style='width:135px;'>Ēdieni / dzērieni</th>
<th style='width:135px;'>Laiks</th>
</tr>";
$q = mysql_query("SELECT id, text, created_at FROM tweets where screen_name='$draugs' order by created_at desc");
while($r=mysql_fetch_array($q)){
$tvid = $r["id"];
$q2 = mysql_query("SELECT distinct nominativs FROM words where tvits='$tvid' and nominativs!='0'");
if ($krasa==TRUE) {$kr=" style='background-color:#E0E0E0'";}else{$kr="";}
$teksts=$r["text"];
$laiks=$r["created_at"];
$laiks=strtotime($laiks);
$laiks=date("m.d.Y H:i", $laiks);
echo "<tr".$kr."><td>".$teksts."</td><td>";
while($r2=mysql_fetch_array($q2)){echo $r2["nominativs"].", ";};
echo "</td><td>".$laiks."</td></tr>";
$krasa=!$krasa;
}
echo "</table>";
?>
<div style="margin:auto auto; text-align:center;" id="pageNavPosition"></div>
<script type="text/javascript"><!--
var pager = new Pager('results', 10);
pager.init();
pager.showPageNav('pager', 'pageNavPosition');
pager.showPage(1);
//--></script>
34 changes: 28 additions & 6 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,46 @@
?>
<!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" xml:lang="lv" lang="lv">
<script type="text/javascript" src="paging.js"></script>
<head>
<title>TwitEdiens</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<style type="text/css">
img {border-width: 0}
* {font-family:'Lucida Grande', sans-serif;}
#nav a {text-decoration:none;font-weight:bold;color:grey;}
#nav a:hover {border-bottom:1px dotted red;}
td{padding:2px;}
a{text-decoration:none;color:#000;}
#progressbar{ font: 30% "Trebuchet MS", sans-serif; margin-left:30px;}
.sk{ margin-top:-20px;margin-left:-100px;}
img {border-width: 0}
* {font-family:'Lucida Grande', sans-serif;}
#nav a {text-decoration:none;font-weight:bold;color:grey;}
#nav a:hover {border-bottom:1px dotted red;}
td{padding:2px;}
.pg-normal {
color: black;
font-weight: normal;
text-decoration: none;
cursor: pointer;
}
.pg-selected {
color: black;
font-weight: bold;
text-decoration: underline;
cursor: pointer;
}
</style>
<script src="sorttable.js"></script>
<link type="text/css" href="jq/css/trontastic/jquery-ui-1.8.16.custom.css" rel="stylesheet" />
<script type="text/javascript" src="jq/js/jquery-1.6.2.min.js"></script>
<script type="text/javascript" src="jq/js/jquery-ui-1.8.16.custom.min.js"></script>
</head>
<body>
<div id="nav">
<a href="?id=draugi">Draugi</a> |
<a href="?id=karte">Karte</a> |
<a href="?id=koest">Ko ēst?</a> |
<a href="?id=tops">TOPs</a> |
<a href="?id=stat">Statitika</a>
<a href="?id=dienas">Kalendārs</a> |
<a href="?id=vardi">Vārdi</a> |
<a href="?id=stat">Statistika</a>
</div>
<?php $id = $_GET['id']; if ( !$id || $id == "" ) { include "draugi.php"; } else { include($id.".php"); } ?>
</body>
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 9f4bec2

Please sign in to comment.