git-svn-id: https://192.168.0.254/svn/Proyectos.MatritumCantat_Web/trunk@2 8e3496fd-7892-4c45-be36-0ff06e9dacc6
986 lines
30 KiB
PHP
986 lines
30 KiB
PHP
<?php
|
|
/*************************************************************
|
|
* Mambo Community Builder
|
|
* Author MamboJoe
|
|
* @ Released under GNU/GPL License : http://www.gnu.org/copyleft/gpl.html
|
|
*************************************************************/
|
|
|
|
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
|
|
|
|
class moscomprofilerHTML extends mosHTML {
|
|
|
|
function radioList( &$arr, $tag_name, $tag_attribs, $key, $text, $selected ) {
|
|
reset( $arr );
|
|
$html = "";
|
|
for ($i=0, $n=count( $arr ); $i < $n; $i++ ) {
|
|
$k = stripslashes($arr[$i]->$key);
|
|
$t = stripslashes($arr[$i]->$text);
|
|
$id = @$arr[$i]->id;
|
|
|
|
$extra = '';
|
|
$extra .= $id ? " id=\"" . $arr[$i]->id . "\"" : '';
|
|
if (is_array( $selected )) {
|
|
foreach ($selected as $obj) {
|
|
$k2 = stripslashes($obj->$key);
|
|
if ($k == $k2) {
|
|
$extra .= " CHECKED";
|
|
break;
|
|
}
|
|
}
|
|
} else {
|
|
$extra .= ($k == stripslashes($selected) ? " CHECKED" : '');
|
|
}
|
|
$html .= "\n\t <input type=radio name=\"$tag_name\" $tag_attribs value=\"".$k."\"$extra> " . getLangDefinition($t);
|
|
}
|
|
$html .= "\n</select>\n";
|
|
return $html;
|
|
}
|
|
function selectList( &$arr, $tag_name, $tag_attribs, $key, $text, $selected, $required=0 ) {
|
|
reset( $arr );
|
|
$html = "\n<select name=\"$tag_name\" $tag_attribs>";
|
|
if(!$required) $html .= "\n\t<option value=\"\"> </option>";
|
|
|
|
for ($i=0, $n=count( $arr ); $i < $n; $i++ ) {
|
|
$k = stripslashes($arr[$i]->$key);
|
|
$t = stripslashes($arr[$i]->$text);
|
|
$id = @$arr[$i]->id;
|
|
|
|
$extra = '';
|
|
$extra .= $id ? " id=\"" . $arr[$i]->id . "\"" : '';
|
|
if (is_array( $selected )) {
|
|
foreach ($selected as $obj) {
|
|
$k2 = stripslashes($obj->$key);
|
|
if ($k == $k2) {
|
|
$extra .= " selected=\"selected\"";
|
|
break;
|
|
}
|
|
}
|
|
} else {
|
|
$extra .= ($k == stripslashes($selected) ? " selected=\"selected\"" : '');
|
|
}
|
|
$html .= "\n\t<option value=\"".$k."\"$extra>";
|
|
$html .= getLangDefinition($t);
|
|
$html .= "</option>";
|
|
}
|
|
$html .= "\n</select>\n";
|
|
return $html;
|
|
}
|
|
|
|
function selectlistcuerdas($tag_name, $Valor) {
|
|
|
|
$html = "\n<select name=\"". $tag_name. "\"". 'class="inputbox" size="1" onchange="document.ueform.submit();"'.">";
|
|
|
|
$html .= "\n<option value=\"\" ";
|
|
if ($Valor == '') $html .= "selected>Todos los miembros del coro</option>";
|
|
else $html .= ">Todos los miembros del coro</option>";
|
|
|
|
$html .= "\n<option value=\"soprano\" ";
|
|
if ($Valor == 'soprano') $html .= "selected>Cuerda de sopranos</option>";
|
|
else $html .= ">Cuerda de sopranos</option>";
|
|
|
|
$html .= "\n<option value=\"contralto\" ";
|
|
if ($Valor == 'contralto') $html .= "selected>Cuerda de contraltos</option>";
|
|
else $html .= ">Cuerda de contraltos</option>";
|
|
|
|
$html .= "\n<option value=\"tenor\" ";
|
|
if ($Valor == 'tenor') $html .= "selected>Cuerda de tenores</option>";
|
|
else $html .= ">Cuerda de tenores</option>";
|
|
|
|
$html .= "\n<option value=\"bajo\" ";
|
|
if ($Valor == 'bajo') $html .= "selected>Cuerda de bajos</option>";
|
|
else $html .= ">Cuerda de bajos</option>";
|
|
|
|
$html .= "\n</select>\n";
|
|
return $html;
|
|
}
|
|
|
|
}
|
|
class moscomprofilerLists extends mosDBTable {
|
|
|
|
var $listid=null;
|
|
var $title=null;
|
|
var $description=null;
|
|
var $published=null;
|
|
var $default=null;
|
|
var $usergroupids=null;
|
|
var $sortfields=null;
|
|
var $ordering=null;
|
|
var $col1title=null;
|
|
var $col1enabled=null;
|
|
var $col1fields=null;
|
|
var $col1captions=null;
|
|
var $col2title=null;
|
|
var $col2enabled=null;
|
|
var $col2fields=null;
|
|
var $col2captions=null;
|
|
var $col3title=null;
|
|
var $col3enabled=null;
|
|
var $col3fields=null;
|
|
var $col3captions=null;
|
|
var $col4title=null;
|
|
var $col4enabled=null;
|
|
var $col4fields=null;
|
|
var $col4captions=null;
|
|
|
|
|
|
|
|
/**
|
|
* @param database A database connector object
|
|
*/
|
|
|
|
function moscomprofilerLists( &$db ) {
|
|
|
|
$this->mosDBTable( '#__comprofiler_lists', 'listid', $db );
|
|
|
|
} //end func
|
|
|
|
function store( $listid=0, $updateNulls=false) {
|
|
global $acl, $migrate, $database, $_POST;
|
|
|
|
if($_POST['listid']==null || $_POST['listid']=='' || !isset($_POST['listid'])) $this->listid =0;
|
|
else $this->listid=$_POST['listid'];
|
|
$sql="Select count(*) from #__comprofiler_lists where listid = '". $this->listid."'";
|
|
$database->SetQuery($sql);
|
|
$total = $database->LoadResult();
|
|
if($this->default==1) {
|
|
$sql="UPDATE #__comprofiler_lists SET `default` = 0";
|
|
$database->SetQuery($sql);
|
|
$database->LoadResult();
|
|
}
|
|
if( $total > 0 ) {
|
|
// existing record
|
|
$ret = $this->_db->updateObject( $this->_tbl, $this, $this->_tbl_key, $updateNulls );
|
|
|
|
} else {
|
|
// new record
|
|
$sql="Select max(ordering) from #__comprofiler_lists";
|
|
$database->SetQuery($sql);
|
|
$max = $database->LoadResult();
|
|
$this->ordering=$max+1;
|
|
$this->listid = null;
|
|
$ret = $this->_db->insertObject( $this->_tbl, $this, $this->_tbl_key );
|
|
}
|
|
if( !$ret ) {
|
|
$this->_error = get_class( $this )."::store failed <br />" . $this->_db->getErrorMsg();
|
|
return false;
|
|
} else {
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
} //end class
|
|
|
|
class moscomprofilerFields extends mosDBTable {
|
|
|
|
var $fieldid=null;
|
|
var $name=null;
|
|
var $title=null;
|
|
var $type=null;
|
|
var $maxlength=null;
|
|
var $size=null;
|
|
var $required=null;
|
|
var $tabid=null;
|
|
var $ordering=null;
|
|
var $cols=null;
|
|
var $rows=null;
|
|
var $value=null;
|
|
var $default=null;
|
|
var $sys=null;
|
|
var $profile=null;
|
|
var $published=null;
|
|
var $readonly=null;
|
|
var $registration=null;
|
|
var $table=null;
|
|
|
|
|
|
/**
|
|
* @param database A database connector object
|
|
*/
|
|
|
|
function moscomprofilerFields( &$db ) {
|
|
|
|
$this->mosDBTable( '#__comprofiler_fields', 'fieldid', $db );
|
|
|
|
} //end func
|
|
|
|
function store( $fieldid=0, $updateNulls=false) {
|
|
global $acl, $migrate, $database, $_POST;
|
|
|
|
if($_POST['fieldid']==null || $_POST['fieldid']=='' || !isset($_POST['fieldid'])) $this->fieldid =0;
|
|
else $this->fieldid=$_POST['fieldid'];
|
|
$sql="Select count(*) from #__comprofiler_fields where fieldid = '". $this->fieldid."'";
|
|
$database->SetQuery($sql);
|
|
$total = $database->LoadResult();
|
|
if( $total > 0 ) {
|
|
// existing record
|
|
|
|
$ret = $this->_db->updateObject( $this->_tbl, $this, $this->_tbl_key, $updateNulls );
|
|
|
|
} else {
|
|
// new record
|
|
$sql="SELECT COUNT(*) FROM #__comprofiler_fields WHERE name='".$this->name."'";
|
|
$database->SetQuery($sql);
|
|
if($database->LoadResult() > 0) {
|
|
$this->_error = "The field name ".$this->name." is already in use!";
|
|
return false;
|
|
}
|
|
$sql="Select max(ordering) from #__comprofiler_fields WHERE tabid=".$this->tabid;
|
|
$database->SetQuery($sql);
|
|
$max = $database->LoadResult();
|
|
$this->ordering=$max+1;
|
|
$this->fieldid = null;
|
|
$ret = $this->_db->insertObject( $this->_tbl, $this, $this->_tbl_key );
|
|
SWITCH($this->type) {
|
|
CASE 'date':
|
|
$cType='DATE';
|
|
break;
|
|
CASE 'textarea':
|
|
$cType='MEDIUMTEXT';
|
|
break;
|
|
CASE 'checkbox':
|
|
$cType='TINYINT';
|
|
break;
|
|
default:
|
|
$cType='VARCHAR(255)';
|
|
break;
|
|
|
|
}
|
|
$ret2 = $this->createColumn('#__comprofiler',$this->name,$cType);
|
|
}
|
|
if( !$ret ) {
|
|
$this->_error = get_class( $this )."::store failed <br />" . $this->_db->getErrorMsg();
|
|
return false;
|
|
} else {
|
|
return true;
|
|
}
|
|
}
|
|
|
|
function createColumn( $table, $column, $type) {
|
|
global $acl, $migrate, $database;
|
|
$sql="ALTER TABLE `$table` ADD `$column` $type";
|
|
$database->SetQuery($sql);
|
|
$ret = $database->LoadResult();
|
|
if( !$ret ) {
|
|
$this->_error .= get_class( $this )."::createColumn failed <br />" . $this->_db->getErrorMsg();
|
|
return false;
|
|
} else {
|
|
return true;
|
|
}
|
|
}
|
|
function deleteColumn( $table, $column) {
|
|
global $acl, $migrate, $database;
|
|
$sql="ALTER TABLE `$table` DROP `$column`";
|
|
$database->SetQuery($sql);
|
|
$ret = $database->LoadResult();
|
|
if( !$ret ) {
|
|
$this->_error .= get_class( $this )."::deleteColumn failed <br />" . $this->_db->getErrorMsg();
|
|
return false;
|
|
} else {
|
|
return true;
|
|
}
|
|
}
|
|
} //end class
|
|
|
|
class moscomprofilerTabs extends mosDBTable {
|
|
|
|
var $tabid=null;
|
|
var $title=null;
|
|
var $description=null;
|
|
var $ordering=null;
|
|
var $plugin=null;
|
|
var $width=null;
|
|
var $enabled=null;
|
|
var $sys=null;
|
|
|
|
|
|
/**
|
|
* @param database A database connector object
|
|
*/
|
|
|
|
function moscomprofilerTabs( &$db ) {
|
|
|
|
$this->mosDBTable( '#__comprofiler_tabs', 'tabid', $db );
|
|
|
|
} //end func
|
|
|
|
function store( $tabid, $updateNulls=false) {
|
|
global $acl, $migrate, $database, $_POST;
|
|
|
|
if($_POST['tabid']==null || $_POST['tabid']=='' || !isset($_POST['tabid'])) $this->tabid =0;
|
|
else $this->tabid=$_POST['tabid'];
|
|
$sql="Select count(*) from #__comprofiler_tabs where tabid = '". $this->tabid."'";
|
|
$database->SetQuery($sql);
|
|
$total = $database->LoadResult();
|
|
if( $total > 0 ) {
|
|
// existing record
|
|
$ret = $this->_db->updateObject( $this->_tbl, $this, $this->_tbl_key, $updateNulls );
|
|
|
|
} else {
|
|
$sql="Select max(ordering) from #__comprofiler_tabs";
|
|
$database->SetQuery($sql);
|
|
$max = $database->LoadResult();
|
|
$this->ordering=$max+1;
|
|
// new record
|
|
$this->tabid = null;
|
|
$ret = $this->_db->insertObject( $this->_tbl, $this, $this->_tbl_key );
|
|
|
|
}
|
|
if( !$ret ) {
|
|
$this->_error = get_class( $this )."::store failed <br />" . $this->_db->getErrorMsg();
|
|
return false;
|
|
} else {
|
|
return true;
|
|
}
|
|
}
|
|
} //end class
|
|
|
|
class moscomprofilerFieldValues extends mosDBTable {
|
|
var $fieldvalueid=null;
|
|
var $fieldid=null;
|
|
var $fieldtitle=null;
|
|
var $sys=null;
|
|
|
|
|
|
/**
|
|
* @param database A database connector object
|
|
*/
|
|
|
|
function moscomprofilerFieldValues( &$db ) {
|
|
|
|
$this->mosDBTable( '#__comprofiler_field_values', 'fieldvalueid', $db );
|
|
|
|
} //end func
|
|
|
|
function store( $fieldvalueid, $updateNulls=false) {
|
|
global $acl, $migrate, $database, $_POST;
|
|
|
|
if($_POST['fieldvalueid']==null || $_POST['fieldvalueid']=='' || !isset($_POST['fieldvalueid'])) $this->fieldvalueid =0;
|
|
else $this->tabid=$_POST['fieldvalueid'];
|
|
$sql="Select count(*) from #__comprofiler_field_values where fieldvalueid = '". $this->fieldvalueid."'";
|
|
$database->SetQuery($sql);
|
|
$total = $database->LoadResult();
|
|
if( $total > 0 ) {
|
|
// existing record
|
|
$ret = $this->_db->updateObject( $this->_tbl, $this, $this->_tbl_key, $updateNulls );
|
|
|
|
} else {
|
|
// new record
|
|
$this->fieldvalueid = null;
|
|
$ret = $this->_db->insertObject( $this->_tbl, $this, $this->_tbl_key );
|
|
}
|
|
if( !$ret) {
|
|
$this->_error = get_class( $this )."::store failed <br />" . $this->_db->getErrorMsg();
|
|
return false;
|
|
} else {
|
|
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
} //end class
|
|
|
|
|
|
class moscomprofiler extends mosDBTable {
|
|
|
|
var $id=null;
|
|
var $user_id=null;
|
|
var $avatar=null;
|
|
var $avatarapproved=null;
|
|
var $approved=null;
|
|
var $confirmed=null;
|
|
var $hits=null;
|
|
|
|
|
|
/**
|
|
* @param database A database connector object
|
|
*/
|
|
|
|
function moscomprofiler( &$db ) {
|
|
|
|
$this->mosDBTable( '#__comprofiler', 'id', $db );
|
|
|
|
} //end func
|
|
|
|
function storeExtras( $id, $updateNulls=false) {
|
|
global $acl, $migrate, $database, $_POST;
|
|
|
|
if($_POST['id']==null || $_POST['id']=='' || !isset($_POST['id'])) $this->id =0;
|
|
else $this->id=$_POST['id'];
|
|
$sql="Select count(*) from #__comprofiler where id = '". $this->id."'";
|
|
$database->SetQuery($sql);
|
|
$total = $database->LoadResult();
|
|
if( $total > 0 ) {
|
|
// existing record
|
|
$ret = $this->_db->updateObject( $this->_tbl, $this, $this->_tbl_key, $updateNulls );
|
|
|
|
} else {
|
|
// new record
|
|
$sql="Select max(id) from #__users";
|
|
$database->SetQuery($sql);
|
|
$last_id = $database->LoadResult();
|
|
$this->id = $last_id;
|
|
$this->user_id = $last_id;
|
|
$ret = $this->_db->insertObject( $this->_tbl, $this, $this->_tbl_key );
|
|
|
|
}
|
|
if( !$ret ) {
|
|
$this->_error = get_class( $this )."::store failed <br />" . $this->_db->getErrorMsg();
|
|
return false;
|
|
} else {
|
|
return true;
|
|
}
|
|
}
|
|
|
|
} //end class
|
|
|
|
class moscomprofilerUserReport extends mosDBTable {
|
|
|
|
var $reportid=null;
|
|
var $reporteduser=null;
|
|
var $reportedbyuser=null;
|
|
var $reportedondate=null;
|
|
var $reportexplaination=null;
|
|
|
|
|
|
/**
|
|
* @param database A database connector object
|
|
*/
|
|
|
|
function moscomprofilerUserReport( &$db ) {
|
|
|
|
$this->mosDBTable( '#__comprofiler_userreports', 'reportid', $db );
|
|
|
|
} //end func
|
|
|
|
|
|
} //end class
|
|
|
|
|
|
class mosInstantMessenger {
|
|
|
|
var $id=null; //Users ID
|
|
var $IMType=null; //Instant Messenger Type (MSNM,AIM,YIM,etc)
|
|
var $IMHandle=null; //User Name, Number or Handle used by IM System
|
|
|
|
|
|
/**
|
|
* @param database A database connector object
|
|
*/
|
|
|
|
function moscomprofiler( &$db ) {
|
|
|
|
$this->mosDBTable( '#__comprofiler', 'id', $db );
|
|
|
|
} //end func
|
|
|
|
function storeExtras( $id, $updateNulls=false) {
|
|
global $acl, $migrate, $database;
|
|
|
|
$sql="Select count(*) from #__comprofiler where id = '". $_POST['id']."'";
|
|
$database->SetQuery($sql);
|
|
$total = $database->LoadResult();
|
|
if( $total > 0 ) {
|
|
// existing record
|
|
$ret = $this->_db->updateObject( $this->_tbl, $this, $this->_tbl_key, $updateNulls );
|
|
|
|
} else {
|
|
// new record
|
|
$sql="Select max(id) from #__users";
|
|
$database->SetQuery($sql);
|
|
$last_id = $database->LoadResult();
|
|
$this->id = $last_id;
|
|
$this->user_id = $last_id;
|
|
$ret = $this->_db->insertObject( $this->_tbl, $this, $this->_tbl_key );
|
|
|
|
}
|
|
if( !$ret ) {
|
|
$this->_error = get_class( $this )."::store failed <br />" . $this->_db->getErrorMsg();
|
|
return false;
|
|
} else {
|
|
return true;
|
|
}
|
|
}
|
|
} //end class
|
|
|
|
//FUNCTIONS
|
|
/**
|
|
* Page navigation support functions
|
|
*
|
|
* Input:
|
|
* $limitstart (int The record number to start dislpaying from)
|
|
* $limit (int Number of rows to display per page)
|
|
* $total (int Total number of rows)
|
|
*/
|
|
|
|
/**
|
|
* Writes the html links for pages, eg, previous 1 2 3 ... x next
|
|
*/
|
|
|
|
function writePagesLinks($limitstart, $limit, $total,$ue_base_url,$search=null) {
|
|
GLOBAL $search_query;
|
|
GLOBAL $pages_in_list;
|
|
$pages_in_list = 10; // set how many pages you want displayed in the menu
|
|
$displayed_pages = $pages_in_list;
|
|
$total_pages = ceil( $total / $limit );
|
|
$this_page = ceil( ($limitstart+1) / $limit );
|
|
$start_loop = (floor(($this_page-1)/$displayed_pages))*$displayed_pages+1;
|
|
if ($start_loop + $displayed_pages - 1 < $total_pages) {
|
|
$stop_loop = $start_loop + $displayed_pages - 1;
|
|
} else {
|
|
$stop_loop = $total_pages;
|
|
}
|
|
|
|
if ($this_page > 1) {
|
|
$page = ($this_page - 2) * $limit;
|
|
echo "\n<a href=\"$ue_base_url&limitstart=0$search_query&search=$search\" title=\"" . _USRL_FIRST_PAGE . "\"><<</a>";
|
|
echo "\n<a href=\"$ue_base_url&limitstart=$page$search_query&search=$search\" title=\"" . _UE_PREV_PAGE . "\"><</a>";
|
|
}
|
|
|
|
for ($i=$start_loop; $i <= $stop_loop; $i++) {
|
|
$page = ($i - 1) * $limit;
|
|
if ($i == $this_page) {
|
|
echo "\n <b>$i</b> ";
|
|
} else {
|
|
echo "\n<a href=\"$ue_base_url&limitstart=$page$search_query&search=$search\">$i</a>";
|
|
}
|
|
}
|
|
|
|
if ($this_page < $total_pages) {
|
|
$page = $this_page * $limit;
|
|
$end_page = ($total_pages-1) * $limit;
|
|
echo "\n<a href=\"$ue_base_url&limitstart=$page$search_query&search=$search\" title=\"" . _UE_NEXT_PAGE . "\">></a>";
|
|
echo "\n<a href=\"$ue_base_url&limitstart=$end_page$search_query&search=$search\" title=\"" . _UE_END_PAGE . "\">>></a>";
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Writes the html for the pages counter, eg, Results 1-10 of x
|
|
*/
|
|
function writePagesCounter($limitstart, $limit, $total) {
|
|
GLOBAL $usrl_base_url;
|
|
$from_result = $limitstart+1;
|
|
if ($limitstart + $limit < $total) {
|
|
$to_result = $limitstart + $limit;
|
|
} else {
|
|
$to_result = $total;
|
|
}
|
|
if ($total > 0) {
|
|
echo _UE_RESULTS . " <b>" . $from_result . " - " . $to_result . "</b> " . _UE_OF_TOTAL . " <b>" . $total . "</b>";
|
|
} else {
|
|
echo _UE_NO_RESULTS . ".";
|
|
}
|
|
}
|
|
function isOdd($x){
|
|
if($x & 1) return TRUE;
|
|
else return FALSE;
|
|
}
|
|
function check_filesize($file,$maxSize) {
|
|
|
|
$size = filesize($file);
|
|
|
|
if($size <= $maxSize) {
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
function check_image_type(&$type)
|
|
{
|
|
switch( $type )
|
|
{
|
|
case 'jpeg':
|
|
case 'pjpeg':
|
|
case 'jpg':
|
|
return '.jpg';
|
|
break;
|
|
case 'png':
|
|
return '.png';
|
|
break;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
function display_avatar_gallery($avatar_gallery_path)
|
|
{
|
|
$dir = @opendir($avatar_gallery_path);
|
|
$avatar_images = array();
|
|
$avatar_col_count = 0;
|
|
while( $file = @readdir($dir) )
|
|
{
|
|
|
|
if( $file != '.' && $file != '..' && is_file($avatar_gallery_path . '/' . $file) && !is_link($avatar_gallery_path. '/' . $file) )
|
|
{
|
|
if( preg_match('/(\.gif$|\.png$|\.jpg|\.jpeg)$/is', $file) )
|
|
{
|
|
$avatar_images[$avatar_col_count] = $file;
|
|
$avatar_name[$avatar_col_count] = ucfirst(str_replace("_", " ", preg_replace('/^(.*)\..*$/', '\1', $file)));
|
|
$avatar_col_count++;
|
|
}
|
|
}
|
|
}
|
|
|
|
@closedir($dir);
|
|
|
|
@ksort($avatar_images);
|
|
@reset($avatar_images);
|
|
|
|
return $avatar_images;
|
|
}
|
|
|
|
function fmodReplace($x,$y)
|
|
{ //function provided for older PHP versions which do not have an fmod function yet
|
|
$i = floor($x/$y);
|
|
return $x - $i*$y;}
|
|
|
|
function replaceVariables($emailMSG, $row, $includePWD, $ueConfig){
|
|
global $mosConfig_live_site, $mosConfig_absolute_path,$uDetails;
|
|
if($ueConfig['reg_confirmation']==1) $confirmLink = $mosConfig_live_site."/index.php?option=com_comprofiler&task=confirm&confirmCode=".md5($row->id);
|
|
else $confirmLink = ' ';
|
|
|
|
$emailMSG = str_replace("[USERNAME]", $row->username, $emailMSG);
|
|
$emailMSG = str_replace("[NAME]", $row->name, $emailMSG);
|
|
$emailMSG = str_replace("[EMAILADDRESS]", $row->email, $emailMSG);
|
|
$emailMSG = str_replace("[SITEURL]", $mosConfig_live_site, $emailMSG);
|
|
$emailMSG = str_replace("[DETAILS]", getUserDetails($row,$includePWD), $emailMSG);
|
|
$emailMSG = str_replace("[CONFIRM]", $confirmLink, $emailMSG );
|
|
|
|
|
|
return $emailMSG;
|
|
}
|
|
function createEmail($row,$type,$ueConfig,$rowAdmin=null,$includePWD=0) {
|
|
global $mosConfig_sitename,$mosConfig_live_site;
|
|
SWITCH($type) {
|
|
CASE 'reject':
|
|
$subject = $mosConfig_sitename.'-'.$ueConfig['reg_reject_sub'];
|
|
$msg = $ueConfig['reg_reject_msg'];
|
|
$to = $row->email;
|
|
break;
|
|
CASE 'pending':
|
|
$subject = $mosConfig_sitename.'-'.$ueConfig['reg_pend_appr_sub'];
|
|
$msg = $ueConfig['reg_pend_appr_msg'];
|
|
$to = $row->email;
|
|
break;
|
|
CASE 'welcome':
|
|
$subject = $mosConfig_sitename.'-'.$ueConfig['reg_welcome_sub'];
|
|
$msg = $ueConfig['reg_welcome_msg'];
|
|
$to = $row->email;
|
|
break;
|
|
CASE 'rejectUser':
|
|
$subject = $mosConfig_sitename.'-'._UE_REG_REJECT_SUB;
|
|
$msg = sprintf(_UE_USERREJECT_MSG,$mosConfig_sitename,$rowAdmin);
|
|
$to = $row->email;
|
|
break;
|
|
CASE 'imageApproved':
|
|
$subject = $mosConfig_sitename.'-'._UE_IMAGEAPPROVED_SUB;
|
|
$msg = _UE_IMAGEAPPROVED_MSG;
|
|
$to = $row->email;
|
|
break;
|
|
CASE 'imageRejected':
|
|
$subject = $mosConfig_sitename.'-'._UE_IMAGEREJECTED_SUB;
|
|
$msg = _UE_IMAGEREJECTED_MSG;
|
|
$to = $row->email;
|
|
break;
|
|
CASE 'unbanUser':
|
|
$subject = $mosConfig_sitename.'-'._UE_UNBANUSER_SUB;
|
|
$msg = _UE_UNBANUSER_MSG;
|
|
$to = $row->email;
|
|
break;
|
|
CASE 'banUser':
|
|
$subject = $mosConfig_sitename.'-'._UE_BANUSER_SUB;
|
|
$msg = _UE_BANUSER_MSG;
|
|
$to = $row->email;
|
|
break;
|
|
CASE 'pendingAdmin':
|
|
$subject = $mosConfig_sitename.'-'._UE_REG_ADMIN_PA_SUB;
|
|
$msg = _UE_REG_ADMIN_PA_MSG;
|
|
$to = $rowAdmin->email;
|
|
break;
|
|
CASE 'welcomeAdmin':
|
|
$subject = $mosConfig_sitename.'-'._UE_REG_ADMIN_SUB;
|
|
$msg = _UE_REG_ADMIN_MSG;
|
|
$to = $rowAdmin->email;
|
|
break;
|
|
CASE 'imageAdmin':
|
|
$subject = $mosConfig_sitename.'-'._UE_IMAGE_ADMIN_SUB;
|
|
$msg = _UE_IMAGE_ADMIN_MSG;
|
|
$to = $rowAdmin->email;
|
|
break;
|
|
CASE 'unbanAdmin':
|
|
$subject = $mosConfig_sitename.'-'._UE_UNBANUSERREQUEST_SUB;
|
|
$msg = _UE_UNBANUSERREQUEST_MSG;
|
|
$to = $rowAdmin->email;
|
|
break;
|
|
CASE 'reportAdmin':
|
|
$subject = $mosConfig_sitename.'-'._UE_USERREPORT_SUB;
|
|
$msg = _UE_USERREPORT_MSG;
|
|
$to = $rowAdmin->email;
|
|
break;
|
|
}
|
|
$msg=replaceVariables($msg,$row,$includePWD,$ueConfig);
|
|
$msg.="\n\n".sprintf(_UE_EMAILFOOTER,$mosConfig_sitename,$mosConfig_live_site);
|
|
eval ("\$msg = \"$msg\";");
|
|
$headers = "MIME-Version: 1.0\r\n";
|
|
$headers .= "Content-type: text/plain; charset=iso-8859-1\r\n";
|
|
$headers .= "Organization: ".$mosConfig_sitename."\r\n";
|
|
$headers .= "Content-Transfer-encoding: 8bit\r\n";
|
|
$headers = "From: ".$ueConfig['reg_email_name']." <".$ueConfig['reg_email_from'].">\r\n";
|
|
$headers .= "Reply-To: ".$ueConfig['reg_email_name']." <".$ueConfig['reg_email_from'].">\r\n";
|
|
$headers .= "Message-ID: <".md5(uniqid(time()))."@{$_SERVER['SERVER_NAME']}>\r\n";
|
|
$headers .= "Return-Path: ".$ueConfig['reg_email_name']." <".$ueConfig['reg_email_from'].">\r\n";
|
|
$headers .= "X-Priority: 3\r\n";
|
|
$headers .= "X-MSmail-Priority: Low\r\n";
|
|
$headers .= "X-Mailer: PHP\r\n"; //hotmail and others dont like PHP mailer. --Microsoft Office Outlook, Build 11.0.5510
|
|
$headers .= "X-Sender: ".$ueConfig['reg_email_name']." <".$ueConfig['reg_email_from'].">\r\n";
|
|
|
|
|
|
|
|
mail($to, $subject, $msg, $headers);
|
|
}
|
|
function getUserDetails($row,$includePWD) {
|
|
$uDetails = _UE_EMAIL.' : '.$row->email;
|
|
$uDetails .= '\n'._UE_UNAME.' : '.$row->username.'\n';
|
|
if($includePWD==1) $uDetails .= _UE_PASS.' : '.$row->password;
|
|
return $uDetails;
|
|
}
|
|
|
|
function dateConverter($oDate,$oFromFormat,$oToFormat) {
|
|
if($oDate=='' || $oDate == null || !isset($oDate)) {
|
|
return;
|
|
} else {
|
|
$specChar = array(".","/");
|
|
$oDate = str_replace($specChar,"-",$oDate);
|
|
$oFromFormat = str_replace($specChar,"-",$oFromFormat);
|
|
|
|
$oDate=explode(" ",$oDate);
|
|
|
|
$dateParts=explode("-",$oDate[0]);
|
|
$fromParts=explode("-",$oFromFormat);
|
|
|
|
$dateArray = array();
|
|
$dateArray[$fromParts[0]] = $dateParts[0];
|
|
$dateArray[$fromParts[1]] = $dateParts[1];
|
|
$dateArray[$fromParts[2]] = $dateParts[2];
|
|
|
|
if(strpos($oToFormat,"/")!=false) $char = "/";
|
|
elseif(strpos($oToFormat,".")!=false) $char = ".";
|
|
else $char = "-";
|
|
|
|
$toParts=explode($char,$oToFormat);
|
|
|
|
$returnDate=$oToFormat;
|
|
foreach ($toParts as $toPart) {
|
|
if($toPart=='Y' || $toPart=='y') {
|
|
if(array_key_exists($toPart,$dateArray)) $returnDate=str_replace($toPart,$dateArray[$toPart],$returnDate);
|
|
elseif($toPart=='y')$returnDate=str_replace($toPart,substr($dateArray['Y'],2,2),$returnDate);
|
|
else $returnDate=str_replace($toPart,$dateArray['y'],$returnDate);
|
|
}else {
|
|
$returnDate=str_replace($toPart,substr($dateArray[$toPart],0,2),$returnDate);
|
|
}
|
|
}
|
|
return $returnDate." ".$oDate[1];
|
|
}
|
|
|
|
}
|
|
function getNameFormat($name,$uname,$format) {
|
|
SWITCH ($format) {
|
|
CASE 1 :
|
|
$returnName = $name;
|
|
break;
|
|
CASE 2 :
|
|
$returnName = $name." (".$uname.")";
|
|
break;
|
|
CASE 3 :
|
|
$returnName = $uname;
|
|
break;
|
|
CASE 4 :
|
|
$returnName = $uname." (".$name.")";
|
|
break;
|
|
}
|
|
return $returnName;
|
|
}
|
|
function getLangDefinition($text) {
|
|
if(defined($text)) $returnText = constant($text);
|
|
else $returnText = $text;
|
|
return $returnText;
|
|
}
|
|
function getFieldValue($oType,$oValue=null,$user=null,$prefix=null) {
|
|
global $ueConfig,$database,$mosConfig_lang,$mosConfig_absolute_path;
|
|
SWITCH ($oType){
|
|
CASE 'checkbox':
|
|
if($oValue!='' && $oValue!=null) {
|
|
if($oValue==1) { $oReturn=_UE_YES;
|
|
} elseif($oValue==0) { $oReturn=_UE_NO;
|
|
} else { $oReturn=null; }
|
|
}
|
|
break;
|
|
CASE 'select':
|
|
CASE 'radio':
|
|
$oReturn = getLangDefinition($oValue);
|
|
break;
|
|
CASE 'date':
|
|
if($oValue!='' || $oValue!=null) {
|
|
if ($oValue!='0000-00-00 00:00:00') {
|
|
$oReturn = dateConverter($oValue,'Y-m-d',$ueConfig['date_format']);
|
|
} else {
|
|
$oReturn = _UE_NA;
|
|
}
|
|
}
|
|
break;
|
|
CASE 'primaryemailaddress':
|
|
IF($oValue==null) return;
|
|
IF($ueConfig['allow_email_display']==1) $oReturn=$oValue;
|
|
ELSEIF($ueConfig['allow_email_display']==2) $oReturn="<a href=\"mailto:".$oValue."\">".$oValue."</a>";
|
|
ELSEIF($ueConfig['allow_email_display']==3) $oReturn="<a href=\"index.php?option=com_comprofiler&task=emailUser&uid=".$user->id."\">"._UE_SENDEMAIL."</a>";
|
|
ELSE $oReturn="";
|
|
break;
|
|
CASE 'emailaddress':
|
|
IF($oValue==null) return;
|
|
IF($ueConfig['allow_email']==1) $oReturn="<a href=\"mailto:".$oValue."\">".$oValue."</a>";
|
|
ELSE $oReturn=$oValue;
|
|
break;
|
|
CASE 'webaddress':
|
|
IF($oValue==null) return;
|
|
IF($ueConfig['allow_website']==1) $oReturn="<a href=\"http://".$oValue."\" target=\"_blank\">".$oValue."</a>";
|
|
ELSE $oReturn=$oValue;
|
|
break;
|
|
CASE 'image':
|
|
if(is_dir($mosConfig_absolute_path."/components/com_comprofiler/images/".$mosConfig_lang)) $fileLang=$mosConfig_lang;
|
|
else $fileLang="english";
|
|
if($user->avatarapproved==0) $oValue="components/com_comprofiler/images/".$fileLang."/tnpendphoto.jpg";
|
|
elseif(($user->avatar=='' || $user->avatar==null) && $user->avatarapproved==1) $oValue="components/com_comprofiler/images/".$fileLang."/tnnophoto.jpg";
|
|
elseif(strpos($user->avatar,"gallery/")===false) $oValue="images/comprofiler/tn".$oValue;
|
|
else $oValue="images/comprofiler/".$oValue;
|
|
if(!is_file($mosConfig_absolute_path."/".$oValue)) $oValue="components/com_comprofiler/images/".$fileLang."/tnnophoto.jpg";
|
|
if(is_file($mosConfig_absolute_path."/".$oValue)) {
|
|
if($ueConfig['allow_profilelink']==1) $onclick = "onclick=\"javascript:window.location='".sefRelToAbs("index.php?option=com_comprofiler&task=userProfile&user=".$user->id)."'\"";
|
|
$oReturn="<img src=\"".$oValue. "\" ".$onclick." />";
|
|
}
|
|
break;
|
|
CASE 'status':
|
|
$database->setQuery("SELECT COUNT(*) FROM #__session WHERE userid ='".$user->id."'");
|
|
$isonline = $database->loadResult();
|
|
if($isonline > 0) { $oReturn = _UE_ISONLINE; } else { $oReturn = _UE_ISOFFLINE; }
|
|
break;
|
|
CASE 'formatname':
|
|
$oReturn = getNameFormat($user->name,$user->username,$ueConfig['name_format']);
|
|
break;
|
|
DEFAULT:
|
|
//echo "I got here ".$oValue."<br>";
|
|
$oReturn = $oValue;
|
|
break;
|
|
}
|
|
if($prefix != null && ($oReturn != null || $oReturn != '')) $oReturn = $prefix.$oReturn;
|
|
return $oReturn;
|
|
}
|
|
function getFieldEntry($oType,$oName,$oValue,$oReq,$oLabel,$oID,$oSize, $oMaxLen, $oCols, $oRows,$oProfile, $rowFieldValues=null,$oReadOnly=0) {
|
|
global $ueConfig,$database,$mosConfig_live_site;
|
|
if($oSize > 0) $pSize=" size='".$oSize."' ";
|
|
else $pSize="";
|
|
if($oMaxLen > 0) $pMax=" MAXLENGTH='".$oMaxLen."' ";
|
|
else $pMax="";
|
|
if($oCols > 0) $pCols=" cols='".$oCols."' ";
|
|
else $pCols="";
|
|
if($oRows > 0) $pRows=" rows='".$oRows."' ";
|
|
else $pRows="";
|
|
if(($oReadOnly > 0) && ($oType != 'hidden')) {
|
|
$pReadOnly=" DISABLED ";
|
|
$oReq=0;
|
|
} else {
|
|
$pReadOnly="";
|
|
}
|
|
SWITCH ($oType){
|
|
CASE 'text':
|
|
$oReturn = "<input class=\"inputbox\" $pReadOnly mosReq=".$oReq." mosLabel=\"".getLangDefinition($oLabel)."\" $pSize $pMax type=\"text\" name=\"".$oName."\" value=\"".$oValue."\" />";
|
|
break;
|
|
CASE 'textarea':
|
|
$oReturn = "<textarea class=\"inputbox\" $pReadOnly mosReq=".$oReq." $pMax mosLabel=\"".getLangDefinition($oLabel)."\" $pCols $pRows name=\"".$oName."\">".$oValue."</textarea>";
|
|
break;
|
|
CASE 'editorta':
|
|
|
|
ob_start();
|
|
editorArea( 'editor'.$oName , $oValue , $oName , 500, 350, $pCols, $pRows ) ;
|
|
$oReturn=ob_get_contents();
|
|
ob_end_clean();
|
|
|
|
//echo $fieldJS;
|
|
$oReturn .= " <script> EditUser.".$oName.".setAttribute('mosReq',".$oReq."); EditUser.".$oName.".setAttribute('mosLabel','".getLangDefinition($oLabel)."'); </script>";
|
|
break;
|
|
CASE 'select':
|
|
$oReturn = $rowFieldValues;
|
|
break;
|
|
CASE 'radio':
|
|
$oReturn = $rowFieldValues;
|
|
break;
|
|
CASE 'checkbox':
|
|
$checked='';
|
|
if($oValue!='' && $oValue != null && $oValue==1) $checked="CHECKED";
|
|
$oReturn = "<input class=\"inputbox\" $pReadOnly mosLabel=\"".getLangDefinition($oLabel)."\" type=\"checkbox\" $checked name=\"".$oName."\" value=\"1\" />";
|
|
break;
|
|
CASE 'hidden':
|
|
$oReturn = "<input class=\"inputbox\" $pReadOnly mosLabel=\"".getLangDefinition($oLabel)."\" type=\"hidden\" name=\"".$oName."\" value=\"".$oValue."\" />";
|
|
break;
|
|
CASE 'password':
|
|
$oReturn = "<input class=\"inputbox\" $pReadOnly mosReq=".$oReq." mosLabel=\"".getLangDefinition($oLabel)."\" type=\"password\" name=\"".$oName."\" value=\"".$oValue."\" />";
|
|
break;
|
|
CASE 'date':
|
|
$dFind=array("d","m","y","Y");
|
|
$dReplace=array("dd","mm","yy","y");
|
|
$oValue;
|
|
$sqlFormat = "Y-m-d";
|
|
$oReturn = "<input class=\"inputbox\" readonly mosReq=".$oReq." mosLabel=\"".getLangDefinition($oLabel)."\" type=\"text\" id=\"".$oName."\" name=\"".$oName."\" value=\"".dateConverter($oValue,'Y-m-d',$ueConfig['date_format'])."\" />";
|
|
if($oReadOnly!=1) $oReturn .= "<input type=\"reset\" class=\"button\" value=\"...\" onClick=\"return showCalendar2('".$oName."', '".str_replace($dFind, $dReplace, $ueConfig['date_format'])."');\" />";
|
|
break;
|
|
CASE 'emailaddress':
|
|
$oReturn = "<input class=\"inputbox\" $pReadOnly $pMax mosReq=".$oReq." $pSize mosLabel=\"".getLangDefinition($oLabel)."\" type=\"text\" name=\"".$oName."\" id=\"".$oName."\" value=\"".$oValue."\" />";
|
|
break;
|
|
CASE 'webaddress':
|
|
$oReturn = "<input class=\"inputbox\" $pReadOnly $pMax $pSize mosReq=".$oReq." mosLabel=\"".getLangDefinition($oLabel)."\" type=\"text\" name=\"".$oName."\" id=\"".$oName."\" value=\"".$oValue."\" />";
|
|
break;
|
|
|
|
}
|
|
|
|
//Rodax Software
|
|
if ($oType != 'hidden') {
|
|
if($oReq==1) $oReturn .= " <img src='".$mosConfig_live_site."/components/com_comprofiler/images/required.gif' title='"._UE_FIELDREQUIRED."' />";
|
|
if($oProfile==1) $oReturn .= " <img src='".$mosConfig_live_site."/components/com_comprofiler/images/profiles.gif' title='"._UE_FIELDONPROFILE."' />";
|
|
else $oReturn .= " <img src='".$mosConfig_live_site."/components/com_comprofiler/images/noprofiles.gif' title='"._UE_FIELDNOPROFILE."' />";
|
|
}
|
|
return $oReturn;
|
|
}
|
|
|
|
function allowAccess( $accessgroupid,$recurse, $usersgroupid, &$acl)
|
|
{
|
|
// "agroup:".$accessgroupid." ugroupid:".$usersgroupid." recurse ".$recurse;
|
|
if ($accessgroupid == -2 || ($accessgroupid == -1 && $usersgroupid > 0)) {
|
|
//grant public access or access to all registered users
|
|
return 1;
|
|
}
|
|
else {
|
|
//need to do more checking based on more restrictions
|
|
if( $usersgroupid == $accessgroupid ) {
|
|
//direct match
|
|
return 1;
|
|
}
|
|
else {
|
|
if ($recurse=='RECURSE') {
|
|
//check if there are children groups
|
|
$groupchildern=array();
|
|
$groupchildren=$acl->get_group_children( $accessgroupid, 'ARO', $recurse );
|
|
|
|
if ( is_array( $groupchildren ) && count( $groupchildren ) > 0) {
|
|
if ( in_array($usersgroupid, $groupchildren) ) {
|
|
//match
|
|
return 1;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
//deny access
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
?>
|