Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ivan-beesquare authored and ivan-beesquare committed Jan 5, 2013
1 parent 148bac1 commit 38b6b15
Show file tree
Hide file tree
Showing 59 changed files with 7,082 additions and 1 deletion.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
ridestats
Ride Stats is an open source tracking system that allows you to keep track of your progress in your community of bikers.
The only language supported currently is spanish.

THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
=========
674 changes: 674 additions & 0 deletions gpl-3.0.txt

Large diffs are not rendered by default.

86 changes: 86 additions & 0 deletions graph_route.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<?php
/**
Ride Stats - Statistics system for non-competitive associations.
Copyright (C) 2008 - Iván Sánchez Luque
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// Own code starts here
include ('source/connect.php');

global $DB_PREFIX;

$con = connect();

$res = mysql_query(" SELECT value
FROM " . $DB_PREFIX . "_settings
WHERE name = 'current_track'
");

$row= mysql_fetch_array($res);
$track_table = $row['value'];

$res = mysql_query(" SELECT pointID, alt
FROM " . $track_table);
mysql_close($con);

$cn2 = 0;
$points = 50; //points in graph

$max = 0;
$p = mysql_num_rows($res)/$points;
while ($row = mysql_fetch_array($res))
{
if (($cn2 % $p) == 0)
{
$data[] = $row['alt'];
}
if ($max < $row['alt'])
$max = $row['alt'];
$cn2++;
}
$data[] = 'null';
for ($n=0; $n < $max; $n+=200);
$max = $n;
// use the chart class to build the chart:
include_once( 'ofc-library/open-flash-chart.php' );
$g = new graph();
$g->line( 2, '#2222BB');

// Title
$g->title( 'Perfil Ruta ', '{font-size: 18px; color: #FFFFFF}' );

//Set style
$g->bg_colour = '#44607e';
//$g->set_x_label_style( 14, '#FFFFFF', 2 );
$g->set_y_label_style( 14, '#FFFFFF');
$g->set_y_legend( 'Metros', 12, '#FFFFFF' );
$g->x_axis_colour( '#D0D0D0', '#808080' );
$g->y_axis_colour( '#D0D0D0', '#808080' );
$g->set_inner_background( '#999999', '#888888', 90 );

$g->set_data( $data );

$g->set_x_axis_steps( 10 );
// label each point with its value
//$g->set_x_labels( array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec' ) );

// set the Y max
$g->set_y_max( $max );
// label every 20 (0,20,40,60)
$g->y_label_steps( 5 );

// display the data
echo $g->render();
?>
90 changes: 90 additions & 0 deletions graph_user_km.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
<?php
/**
Ride Stats - Statistics system for non-competitive associations.
Copyright (C) 2008 - Iván Sánchez Luque
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// Own code starts here

include ('source/connect.php');
include ('source/stats.php');

global $DB_PREFIX;

$con = connect();

mysql_query("DELETE FROM " . $DB_PREFIX . "_temp_users");

$res = mysql_query(" SELECT userID, name
FROM ".$DB_PREFIX."_users");
while ($row= mysql_fetch_array($res))
{
$name = str_replace("á", "a", $row['name']);
$name = str_replace("é", "e", $name);
$name = str_replace("í", "i", $name);
$name = str_replace("ó", "o", $name);
$name = str_replace("ú", "u", $name);
$name = str_replace("à", "a", $name);
$users[] = $name;
/*$res2 = mysql_query("SELECT tourID FROM ".$DB_PREFIX."_user_tours WHERE userID = '" . $row['userID'] . "'");*/
$res2 = getTours($row['userID']);
$km[] = getKilometers($res2);
$id[] = $row['userID'];
}

for ($n = 0; $n < sizeof($users); $n++)
{
mysql_query("INSERT INTO ". $DB_PREFIX ."_temp_users (userID, name, km)
VALUES ('" . $id[$n] . "', '" . $users[$n] . "', '" . $km[$n] . "')");
}
unset($users);
unset($km);
unset($links);

$res = mysql_query("SELECT userID, name, km FROM ". $DB_PREFIX ."_temp_users ORDER BY km DESC");

while ($row = mysql_fetch_array($res))
{
if ($row['km'] > 0)
{
$users[] = $row['name'];
$km[] = sprintf("%d", $row['km']);
$links[] = ""; //@todo: "index.php?action=user&amp;userid=" . $row['userID'];
}
}

include_once( 'ofc-library/open-flash-chart.php' );
$g = new graph();
$g->bg_colour = '#FFFFFF';
//
// PIE chart, 60% alpha
//
$g->pie(60,'#111111','{font-size: 9px; color: #000000;');
//
// pass in two arrays, one of data, the other data labels
//
$g->pie_values( $km, $users, $links );
//
// Colours for each slice, in this case some of the colours
// will be re-used (3 colurs for 5 slices means the last two
// slices will have colours colour[0] and colour[1]):
//
$g->pie_slice_colours( array('#033387','#00306f') );

//$g->set_tool_tip( '#val#%' );

//$g->title( 'Kms totales', '{font-size:18px; color: #000000}' );
echo $g->render();
?>
80 changes: 80 additions & 0 deletions index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<?php
/**
Ride Stats - Statistics system for non-competitive associations.
Copyright (C) 2008 - Iván Sánchez Luque
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

require_once('source/template.php');
require_once('settings.php');

global $RS_URL;

$actionArray = array(
'admin' => array('admin.php'),
'admin_login' => array('admin_login.php'),
'contact' => array('contact.php'),
'delete_route' => array('delete_route.php'),
'delete_tour' => array('delete_tour.php'),
'delete_user' => array('delete_user.php'),
'edit_route' => array('edit_route.php'),
'edit_tour' => array('edit_tour.php'),
'edit_user' => array('edit_user.php'),
'faq' => array('faq.php'),
'index' => array('start.php'),
'login' => array('login.php'),
'login_error' => array('login_error.php'),
'new_route' => array('new_route.php'),
'new_tour' => array('new_tour.php'),
'new_user' => array('new_user.php'),
'route' => array('route.php'),
'routes' => array('routes.php'),
'save_route' => array('save_route.php'),
'save_tour' => array('save_tour.php'),
'save_user' => array('save_user.php'),
'tour' => array('tour.php'),
'tours' => array('tours.php'),
'upload_track' => array('upload_track.php'),
'upload_user_photo' => array('upload_user_photo.php'),
'user' => array('user.php'),
'users' => array('users.php')
);

// Creates the template
$theme = $_COOKIE['stylesheet'];
if (!$theme) $theme = 'blue';
//$tpl = & new Template($RS_URL.'/themes/'.$theme.'/index.template.php');
$tpl = & new Template($RS_URL.'/source/index.template.php');
$tpl->set('title', 'Ride Stats');
$tpl->set('style', $RS_URL.'/themes/'.$theme.'/style.css');
$tpl->set('admin_rights', isset($_COOKIE["user"]));

// Sets action page
if (isset($_REQUEST['action']))
$action = $actionArray[$_REQUEST['action']][0];

// If no action or unrecognized action, use start page
if (!$action)
$action = $actionArray['index'][0];

// Creates body and adds it to the template
$body = & new Template('source/'.$action);
$body->set('something', 0);
$tpl->set('body', $body->fetch('source/'.$action));

// Fetch template
//echo $tpl->fetch('themes/'.$theme.'/index.template.php');
echo $tpl->fetch('source/index.template.php');
?>
Loading

0 comments on commit 38b6b15

Please sign in to comment.