include("../include/init_front.php");
//----------define layout variables in case is HOME PAGE or not -------------------------------------
if ($HOME_PAGE) //$HOME_PAGE = 1 in index.php and =0 elsewhere
{
$RIGHT_PADDING = "padding-right:8px;";
}
else
{
$RIGHT_CORNER_CSS = "background: url(../images/right_corner.gif) no-repeat top right;";
$RIGHT_PADDING = "padding-right:10px;";
}
//--------------------------------------------------------------------------------------------
?>
=$SITE_TITLE?>
$small_calendar->load_files(); ?>
if (!$auth->member_id)
{
?>
}
?>
if ($auth->member_id)
{
?>
}
?>
if ($auth->member_id)
{
?>
}
?>
Copyright �2006 Shuffle Your Dance Cards. All rights reserved. �Psi Pi
function isBlocked($user_id, $bl_user_id)
{
global $conn;
$sql = "select * from m_block_list where user_id = " . $user_id . " and bl_user_id = " . $bl_user_id;
$rs = $conn->query($sql);
if($conn->num_rows($rs)>0)
{
return true;
}
return false;
}
function isContact($user_id, $cl_user_id)
{
global $conn;
$sql = "select * from m_contact_list where user_id = " . $user_id . " and cl_user_id = " . $cl_user_id;
$rs = $conn->query($sql);
if($conn->num_rows($rs)>0)
{
return true;
}
return false;
}
// Formateaza o data din modelul mysql in formatul romanesc
function format_mysql_data($value,$time=1)
{
$arr = explode(" ",$value);
$data = $arr[0];
$timp = $arr[1];
$data_arr = explode("-",$arr[0]);
//data e nula (si neavenita)
if ($data_arr[2]=='00')
return 'N/A';
$data_str = $data_arr[2]."/".$data_arr[1]."/".$data_arr[0];
if ($timp=='' || $time==0)
return $data_str;
else
{
$timp_arr = explode(":",$arr[1]);
//nu are nevoie nimeni de ora la secunda
$data_str .=" ".$timp_arr[0].":".$timp_arr[1];
return $data_str;
}
}
function myDateFormat($timestamp)
{
return date('d/m/y h:i',$timestamp);
}
function unhtmlentities($string)
{
$trans_tbl = get_html_translation_table (HTML_ENTITIES);
$trans_tbl = array_flip ($trans_tbl);
return strtr ($string, $trans_tbl);
}
function get_date($string_date)
{
$yr = substr($string_date,0,4);
$mon = substr($string_date,5,2);
$day = substr($string_date,8,2);
$time = substr($string_date,11,8);
return $mon."/".$day."/".$yr." ".$time;
}
?>
// Note that these functions where meant to work if the php.ini setting
// magic_quotes_gpc is ON !!! (and it is by default)
function getFormFieldMail($fieldName)
{
$fieldVal = "";
if (isset($_POST[$fieldName]))
$fieldVal = stripslashes($_POST[$fieldName]);
return $fieldVal;
}
//////////////////////////////////////////////////////////////////////////////////////
function getFormField($fieldName)
{
$fieldVal = "";
if (isset($_POST[$fieldName]))
$fieldVal = $_POST[$fieldName];
return $fieldVal;
}
//////////////////////////////////////////////////////////////////////////////////////
function saveFormField($fieldValue, $fieldName, $prefix)
{
$_SESSION[$prefix."_".$fieldName] = $fieldValue;
}
//////////////////////////////////////////////////////////////////////////////////////
function loadAndClearSavedField($fieldName, $prefix)
{
$fieldVal = "";
if (isset($_SESSION[$prefix."_".$fieldName])){
$fieldVal = $_SESSION[$prefix."_".$fieldName];
$_SESSION[$prefix."_".$fieldName] = "";}
return stripslashes($fieldVal);
}
//////////////////////////////////////////////////////////////////////////////////////
function loadSavedField($fieldName, $prefix)
{
$fieldVal = "";
$fieldVal = $_SESSION[$prefix."_".$fieldName];
return stripslashes($fieldVal);
}
//////////////////////////////////////////////////////////////////////////////////////
function display_date_format()
{
return "'%m/%d/%Y %H:%i:%s'";
}
//////////////////////////////////////////////////////////////////////////////////////
function check_field_empty($field)
{
if ($field=="") return "N/A";
return $field;
}
//////////////////////////////////////////////////////////////////////////////////////
function format_mysql_date($date)
{
$date = explode(" ",$date);
$date_arr = explode("-",$date[0]);
return $date_arr[2]."/".$date_arr[1]."/".$date_arr[0];
}
//////////////////////////////////////////////////////////////////////////////////////
function format_mysql_time($date)
{
$date = explode(" ",$date);
$date_arr = explode(":",$date[1]);
return $date_arr[0].":".$date_arr[1];
}
?>
function get_events_query($cond,$order_clause='ORDER BY archive DESC',$limit_clause='LIMIT 200')
{
$query = "SELECT *,
archive_datediscipline_caption= $DISCIPLINE_LABEL;
$event_filter->proc_file="event_proc.php";
$event_filter->show_filter($info);
return $event_filter->filter_cond;
}
//return the days that have event for use in the calendar for example
//all days inside periods are also returned
function get_dates_with_events($event_cond='1',$date_format='Y-n-j')
{
global $conn;
$dates=array();
$events_query=get_events_query($event_cond);
$events_res=$conn->query($events_query);
while ($info=$conn->fetch_array($events_res))
{
$current_date=format_date($info["event_date"],$date_format);
$dates[]=$current_date;
if ( $info["period"] && strlen($info["event_end_date"]) )
{
$end_date=format_date($info["event_end_date"],$date_format);
$current_time=strtotime($current_date);
$end_time=strtotime($end_date);
while($current_time < $end_time && $i<100)//100 just for safety
{
$i++;
$current_time=strtotime("+1 day", $current_time);
$dates[]=date($date_format,$current_time);
}
}
}
return $dates;
}
//shows the menu for events: few buttons
function show_front_menu()
{
global $auth;
?>
if ($auth->member_id)
{
?>
}
?>
}
// shows the button with Archive/Current Events
function show_archive_button($archive)
{
if ($archive)
{
?>
}
else
{
?>
}
}
?>
/**
* implements a restriction for members to send a maximum of x messages in the first y days from subscription
*/
class CMsgRestriction
{
var $max_allowed_msg_no=5; // maximum allowed number of messages
var $days_from_subscr=7; // number of days from subscription, the restriction applies on
// stores the display message
var $forbid_msg="For security reasons you are allowed to send only %%max_allowed_msg_no%% messages in the first %%days_from_subscr%% days from subscription date";
var $notice_msg="You may still send %%remained_msg_no%% messages until %%disable_date%% when the anti-spam filter will be lifted.";
var $sent_msg_no; // number of sent messages in the first days from subscription
var $disable_date; // the date when the restriction will be lifted
var $conn; /* @var CConn */
function CMsgRestriction()
{
global $conn;
$this->conn=&$conn;
$this->get_settings();
}
/* load settings from database */
function get_settings()
{
$query="SELECT * FROM settings";
$info=$this->conn->fetch($query);
$this->max_allowed_msg_no=$info["antispam_max_allowed_msg_no"];
$this->days_from_subscr=$info["antispam_days_from_subscr"];
$this->forbid_msg=$info["antispam_forbid_msg"];
$this->notice_msg=$info["antispam_notice_msg"];
}
/* Implements the restriction and returns false if forbidden*/
function check($member_id, $subscribe_date)
{
$query=" SELECT COUNT(*) AS sent_msg_no
,('$subscribe_date' + INTERVAL $this->days_from_subscr DAY) AS disable_date
,NOW()<('$subscribe_date' + INTERVAL $this->days_from_subscr DAY) AS recently_subscribed
FROM m_messages
WHERE from_id=$member_id
AND message_date<('$subscribe_date' + INTERVAL $this->days_from_subscr DAY)";
$info=$this->conn->fetch($query);
if($info["recently_subscribed"])
{
$this->sent_msg_no=$info["sent_msg_no"];
$this->disable_date=$info["disable_date"];
}
if ($this->sent_msg_no>=$this->max_allowed_msg_no)
{
$this->forbid_msg=str_replace("%%max_allowed_msg_no%%",$this->max_allowed_msg_no,$this->forbid_msg);
$this->forbid_msg=str_replace("%%days_from_subscr%%",$this->days_from_subscr,$this->forbid_msg);
return false;
}
return true;
}
/* returns the notice message to inform the user about the number of messages he may send */
function get_notice_msg($member_id, $subscribe_date)
{
$this->check($member_id, $subscribe_date);
if ($this->sent_msg_no && $this->sent_msg_no<$this->max_allowed_msg_no)
{
$remained_msg_no=$this->max_allowed_msg_no-$this->sent_msg_no;
$disable_date=format_date($this->disable_date);
$this->notice_msg=str_replace("%%remained_msg_no%%",$remained_msg_no,$this->notice_msg);
$this->notice_msg=str_replace("%%disable_date%%",$disable_date,$this->notice_msg);
return $this->notice_msg;
}
}
}
?>
class CFilter
{
var $main_table;
var $categories_table;
var $states;
var $discipline_caption="Discipline/Style";
var $main_caption="events";
var $filter_button="Filter";
var $filter_cond;
var $info;
var $proc_file="event_proc.php";
var $conn;
var $is_admin=0;
var $show_category_field=1;
var $show_discipline_field=1;
function CFilter($main_table,$categories_table)
{
global $states,$conn;
$this->main_table=$main_table;
$this->categories_table=$categories_table;
$this->states=$states;
unset($this->states[-1]);
$this->conn=$conn;
}
function set_filter($info)
{
global $auth;
if (!is_array($info) && !$auth->is_admin)
$info=$this->get_filter_preferences($this->main_caption,$auth->member_id);
$this->info=$info;
}
function get_filter_cond($info)
{
$this->set_filter($info);
$filter_cond="";
$info=$this->info;
if ($info["country"])
{
$filter_cond.=" AND (country='".$info["country"]."' OR country=0) ";
}
if ($info["category"])
{
$filter_cond.=" AND (category='".$info["category"]."' OR category=0) ";
}
if (strlen($info["town"]))
{
$filter_cond.=" AND (town='".$info["town"]."' OR town='') ";
}
if ($info["discipline"])
{
$filter_cond.=" AND (discipline=".$info["discipline"]." OR discipline=0) ";
}
$this->filter_cond=$filter_cond;
return $filter_cond;
}
function show_filter($info)
{
global $conn, $BG_COLOR1, $BG_COLOR2, $auth;
$this->set_filter($info);
$info=$this->info;
$states=$this->states;
$this->filter_button="Filter ".ucfirst($this->main_caption);
$state_sel=new CSelect($info["country"],$conn);
$category_sel=new CSelect($info["category"],$conn);
$town_sel=new CSelect($info["town"],$conn);
$discipline_sel=new CSelect($info["discipline"],$conn);
//highlight active filters
if ($info["country"])
$country_bg=$BG_COLOR2;
if ($info["category"])
$category_bg=$BG_COLOR2;
if (strlen($info["town"]))
$town_bg=$BG_COLOR2;
if ($info["discipline"])
$discipline_bg=$BG_COLOR2;
?>
return $this->get_filter_cond($info);
}
function get_populated_countries()
{
global $states, $conn;
$arr=array();
$query=" SELECT country,
COUNT(*) AS no
FROM $this->main_table
GROUP BY country
ORDER BY country";
$res=$conn->query($query);
if (!$conn->num_rows($res))
return $arr;
while ($info=$conn->fetch_array($res))
$countries[$info["country"]]=$info["no"];
$for_all=(int)$countries[0];
foreach ($countries as $key=>$value)
$arr[$key]=$states[$key];
//$arr[$key]=$states[$key]." (".($for_all+$value).")";
unset($arr[0]);
return $arr;
}
function get_populated_towns()
{
$query=" CREATE TEMPORARY TABLE temporary_towns
SELECT DISTINCT town FROM $this->main_table WHERE LENGTH(town)>0";
$this->conn->query($query);
$query="
SELECT c.town,
CONCAT(c.town,' (',SUM(e.town IS NOT NULL),')') AS show_name_numbers,
c.town AS show_name
FROM temporary_towns AS c
LEFT JOIN $this->main_table AS e ON (c.town=e.town OR e.town='')
GROUP BY LOWER(c.town)
";
$res=$this->conn->query($query);
$this->conn->query("DROP TABLE IF EXISTS temporary_towns");
return $res;
}
function get_populated_categories()
{
$query="
SELECT c.category_id,
CONCAT(c.name,' (',SUM(e.category IS NOT NULL),')') AS show_name_numbers,
c.name AS show_name
FROM $this->categories_table AS c
INNER JOIN $this->main_table AS e ON (e.category=c.category_id OR e.category=0)
GROUP BY c.category_id
HAVING MAX(e.category)!=0
ORDER BY c.position
";
return $this->conn->query($query);
}
function get_populated_disciplines()
{
$query="
SELECT d.discipline_id,
CONCAT(d.discipline,' (',SUM(e.discipline IS NOT NULL),')') AS show_name_numbers,
d.discipline AS show_name
FROM disciplines AS d
LEFT JOIN $this->main_table AS e ON (e.discipline=d.discipline_id OR e.discipline=0)
GROUP BY d.discipline_id
HAVING MAX(e.discipline)!=0
ORDER BY d.position
";
return $this->conn->query($query);
}
function get_filter_preferences($prefix,$member_id)
{
if (!$member_id)
return array(); //empty array since member is not logged in
$country_field=$prefix."_country";
$town_field=$prefix."_town";
$category_field=$prefix."_category";
$discipline_field=$prefix."_discipline";
$query=" SELECT $country_field AS country,
$town_field AS town,
$category_field AS category,
$discipline_field AS discipline
FROM preferences
WHERE member_id=$member_id";
$info=$this->conn->fetch($query);
return $info;
}
}
?>