Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

file 524 lines (482 sloc) 19.871 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524
<?php
/**
* @version 1.5.1 $Id: install.mspseniors.php
* @package Joomla 1.5.x
* @subpackage MSP-seniors
* @copyright (C) 2009 Miami Solution Providers Inc (http://www.causewaycomputer.com)
* @license GNU/GPL
*/

// no direct access
defined('_JEXEC') or die('Restricted access');

error_reporting(E_ALL ^ E_NOTICE);
ini_set('display_errors', 1);

require_once(JPATH_BASE.DS.'components'.DS.'com_mspseniors'.DS.'includes'.DS.'mspsettings.php');
require_once(JPATH_BASE.DS.'components'.DS.'com_mspseniors'.DS.'includes'.DS.'mspfunctions.php');

$task = $_REQUEST['task'];

switch($task) {
case 'submit':
submit();
break;
case 'add':
addsenior();
break;
case 'searchsenior':
searchsenior();
break;
default:
display();
break;
}
//-------------------------------------- Header()
//---------------------------------------------------------------------------------------

function headerT() {
global $mainframe;
$params = $mainframe->getParams();


?>
<?php if ( $params->def( 'show_page_title', 1 ) ) { ?>
<div class="componentheading<?php echo $params->get( 'pageclass_sfx' ); ?>">
<?php echo stripslashes($params->get('page_title')); ?>
</div>
<?php } else { ?>
<div class="componentheading">Senior Pictures Preview</div>
<?php } ?>
<?php
if($_REQUEST['saved'] == 'true') {
if(fetchParam('auto_approval') == 'true') {
echo "<p>&nbsp;</p><p class='MSP_success'>Thank you for posting yourself as a Senior.</p><p>&nbsp;</p>";
}
else {
echo "<p>&nbsp;</p><p class='MSP_success'>Thank you for posting yourself as a Senior. We will review your information and publish your senior pictures very soon.</p><p>&nbsp;</p>";
}
}
?>
<?php if(fetchParam('show_form') != 'false') { ?><p class="MSP_submit_link"><a href="#submitform">Submit yourself as a Senior for Pictures.</a></p><?php } ?>
<p style="text-align:right;"><?php echo '<a href="'.base64_decode('aHR0cDovL3d3dy5yc3dlYnNvbHMuY29t').'"></a>'; ?></p>
<?php
}

//-------------------------------------- addsenior()
//---------------------------------------------------------------------------------------

function addsenior() {
global $mainframe;
$params = $mainframe->getParams();

// get list of schools
$database =& JFactory::getDBO();
$database->setQuery("select * from `#__".MSP_TABLE_PREFIX_SCHOOL."` where `status`='1' order by `schoolname` desc");
$items = $database->loadObjectList();
 
?>
<script type="text/javascript">
function seniorSubmit() {
var f = document.rsmonialsForm;
var err = 0;
if(trim(f.fname.value) == '') {
document.getElementById('fname_d').style.color='#ff0000';
document.getElementById('fname').style.borderColor='#ff0000';
err++;
}
else {
document.getElementById('fname_d').style.color='';
document.getElementById('fname').style.borderColor='';
}
if(trim(f.lname.value) == '') {
document.getElementById('lname_d').style.color='#ff0000';
document.getElementById('lname').style.borderColor='#ff0000';
err++;
}
else {
document.getElementById('lname_d').style.color='';
document.getElementById('lname').style.borderColor='';
}
if(trim(f.email.value) == '') {
document.getElementById('email_d').style.color='#ff0000';
document.getElementById('email').style.borderColor='#ff0000';
err++;
}
else if((/^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z.]{2,5}$/).exec(f.email.value)==null) {
document.getElementById('email_d').style.color='#ff0000';
document.getElementById('email').style.borderColor='#ff0000';
err++;
}
else {
document.getElementById('email_d').style.color='';
document.getElementById('email').style.borderColor='';
}
<?php if(fetchParam('show_captcha') != 'false') { ?>
if(trim(f.security_code.value) == '') {
document.getElementById('security_code_d').style.color='#ff0000';
document.getElementById('security_code').style.borderColor='#ff0000';
err++;
}
else {
document.getElementById('security_code_d').style.color='';
document.getElementById('security_code').style.borderColor='';
}
<?php } ?>
if(err > 0) {
return false;
}
else {
f.submit();
}
}

function trim(str, chars) {
return ltrim(rtrim(str, chars), chars);
}

function ltrim(str, chars) {
chars = chars || "\\s";
return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}

function rtrim(str, chars) {
chars = chars || "\\s";
return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}
</script>
<?php
if(fetchParam('show_form') != 'false') {
$postA = $_SESSION['MSP_post'];
?>
<a name="submitform"></a>
<?php echo '<a href="'.base64_decode('aHR0cDovL3d3dy5yc3dlYnNvbHMuY29t').'"></a>'; ?>
<fieldset>
<legend class="MSP_form_heading">Add me as a Senior</legend>
<form name="rsmonialsForm" action="index.php" method="post" class="rsmonialsForm">
<input type="hidden" name="option" id="option" value="com_mspseniors" />
<input type="hidden" name="task" id="task" value="submit" />
<input type="hidden" name="Itemid" id="Itemid" value="<?php echo $_REQUEST['Itemid']; ?>" />
<table class="MSP_form_main" cellpadding="5" cellspacing="5" border="0">
<?php if($_REQUEST['err'] == 'true') { ?>
<tr>
<td colspan="2" class="MSP_form_error">
<p>Please correct the following errors:</p>
<div>
<ul>
<?php
$errA = $_SESSION['MSP_error'];
foreach($errA as $val) {
echo '<li>'.$val.'</li>';
}
?>
</ul>
</div>
</td>
</tr>
<?php } ?>
<tr><td colspan="2" class="MSP_form_mandatory"><span class="MSP_form_star_color">*</span> fields are mandatory.</td></tr>
<tr><td class="MSP_form_first_col"><span id="fname_d" class="MSP_form_text">Your First Name:</span><span class="MSP_form_star_color">*</span></td><td style="width:75%;"><input name="fname" id="fname" type="text" maxlength="50" class="MSP_form_input" value="<?php echo $postA['fname']; ?>" /></td></tr>
<tr><td><span id="lname_d" class="MSP_form_text">Your Last Name:</span><span class="MSP_form_star_color">*</span></td><td><input name="lname" id="lname" type="text" maxlength="50" class="MSP_form_input" value="<?php echo $postA['lname']; ?>" /><BR>
<span id="fname_d" class="MSP_form_text">Your School:</span><span class="MSP_form_star_color">*</span>
<select name="school_id" id="school_id" class="MSP_form_input" >
<?php
if(count($items) > 0) {
foreach($items as $item) {
echo '<option value="'.$item->id.'">'.$item->schoolname.'</option>';
}
}else{
echo '<option >Schools Not Available</option>';
}
?>
</select>
</td></tr>
<tr><td><span id="email_d" class="MSP_form_text">Email Address:</span><span class="MSP_form_star_color">*</span></td><td><input name="email" id="email" type="text" maxlength="100" class="MSP_form_input" value="<?php echo $postA['email']; ?>" /></td></tr>
<?php if(fetchParam('show_about') != 'false') { ?>
<tr><td><span class="MSP_form_text">About You:</span></td><td><input name="about" id="about" type="text" class="MSP_form_input" value="<?php echo $postA['about']; ?>" /></td></tr>
<?php } ?>
<?php if(fetchParam('show_location') != 'false') { ?>
<tr><td><span class="MSP_form_text">Your Location:</span></td><td><input name="location" id="location" type="text" maxlength="255" class="MSP_form_input" value="<?php echo $postA['location']; ?>" /></td></tr>
<?php } ?>
<?php if(fetchParam('show_website') != 'false') { ?>
<tr><td><span class="MSP_form_text">Your Website:</span></td><td><input name="website" id="website" type="text" maxlength="255" class="MSP_form_input" value="<?php echo $postA['website']; ?>" /></td></tr>
<?php } ?>
<?php
if(fetchParam('show_captcha') != 'false') {
$rand = rand(1111,9999);
?>
<tr><td><span class="MSP_form_text">Security Code:</span></td><td>
<img id="imgCaptcha" src="components/com_mspseniors/includes/rscaptcha.php" alt="" />
</td></tr>
<tr><td><span id="security_code_d" class="MSP_form_text">Enter Code Here:</span><span class="MSP_form_star_color">*</span></td><td><input name="security_code" id="security_code" type="text" maxlength="255" class="MSP_form_input" /></td></tr>
<?php
}
?>
<tr><td colspan="2"><span id="comments_d" class="MSP_form_text">Send us your comments below:</span><span class="MSP_form_star_color">*</span></td></tr>
<tr><td colspan="2"><textarea name="comments" id="comments" class="MSP_form_textarea" rows="" cols=""><?php echo $postA['comments']; ?></textarea></td></tr>
<tr><td colspan="2" style="text-align:center;"><input type="button" value="Submit Senior" class="MSP_form_button" onclick="return seniorSubmit();" /></td></tr>
</table>
</form>
</fieldset>
<?php } ?>
<p>&nbsp;</p>
<?php
}

//-------------------------------------- searchsenior()
//---------------------------------------------------------------------------------------

function searchsenior() {
unset($_SESSION['MSP_error']);
unset($_SESSION['MSP_post']);

global $mainframe;
$params = $mainframe->getParams();

$isfalse = false;
$MSP_error = array();
if(trim($_POST['fname']) == '') {
$isfalse = true;
$MSP_error[] = 'Please enter first name.';
}
if(trim($_POST['lname']) == '') {
$isfalse = true;
$MSP_error[] = 'Please enter last name.';
}
if(trim($_POST['email']) == '') {
$isfalse = true;
$MSP_error[] = 'Please enter email address.';
}
if(trim($_POST['password']) == '') {
$isfalse = true;
$MSP_error[] = 'Please enter password.';
}


// get list of schools
$database =& JFactory::getDBO();
$sql = "select * from `#__".MSP_TABLE_PREFIX."` where `fname` = '".strtoupper($_POST['fname'])."' and `lname` = '".strtoupper($_POST['lname'])."' and `flower` = '".strtoupper($_POST['password'])."' ";
$database->setQuery($sql);
$rows = $database->loadObjectList();
//$pic_count = $database->getNumRows($rows);

//echo $sql;
   
?>
<a name="submitform"></a>
<fieldset>
<legend class="MSP_form_heading">Senior Pictures Results</legend>
<?php

if(count($rows)>0){
foreach ($rows as $item) {
?>
<fieldset>
<legend class="MSP_form_heading"><?php echo $item->fname." ".$item->lname;?></legend>
<div><?php echo $item->address1?> in <?php echo $item->city?></div>
<hr>
<?php
$sql_pic = "select * from `#__".MSP_TABLE_PREFIX_PICTURES."` where `seniorid` = ".$item->id;
//$sql_pic = "select * from `jos_mspseniorspictures` where `seniorid` = ".$item->id;
//echo $sql_pic."\n" ;
$database->setQuery($sql_pic);
$picrows = $database->loadObjectList();
echo $picrows."\n";
if( count($picrows) > 0 ){
foreach($picrows as $pic){
echo "<img src=images/seniors/".$pic->filename." border=0 title='Image ".$pic->filename."' >";
//echo $pic->id;

}
}else{
echo "Your senior pictures are not yet ready for online display and review. <BR>Please allow a 2 business days for your pictures to be available online.<BR><BR>Sincerely,<BR> Nick's Quality Photo Studio<BR>";
//echo $item->id."\n";
//echo count($picrows)." pictures\n";
}
?>
</fieldset>
<?php
}
}else{
echo "We apologize, we either do not have an account for you or you entered the wrong information.<BR>";
echo "Please contact our Studio directly to verify your account<BR><BR>Contact Nicks Photo Studio <BR>";
echo "<BR>11500 NW 7th Avenue<BR>North Miami, FL. 33168<BR><BR>BOOK AN APPOINTMENT NOW! <BR>";
echo "<BR>Phone: 305-688-2670 Fax: 305-688-0161 <BR>Open: Monday-Saturday 9AM to 7PM<BR>and Sundays 10AM to 6PM";
echo "<BR><p>&nbsp;</p>";
}
?>
</fieldset>
<p>&nbsp;</p>
<?php
}
 
//-------------------------------------- Display()
//---------------------------------------------------------------------------------------
function display() {
headerT();

//echo '<div><br /><hr align="center" width="100%" size="1" noshade="noshade" class="MSP_hr_color" /><br /></div>';
$database =& JFactory::getDBO();
  // pagination was removed for clearity
$database->setQuery("select * from `#__".MSP_TABLE_PREFIX_SCHOOL."` where `status`='1' order by `date` desc, `id` desc");
 

$items = $database->loadObjectList();
?>
<script type="text/javascript">
function seniorSearch() {
var f = document.mspseniorsForm;
var err = 0;
if(trim(f.fname.value) == '') {
document.getElementById('fname_d').style.color='#ff0000';
document.getElementById('fname').style.borderColor='#ff0000';
err++;
}
else {
document.getElementById('fname_d').style.color='';
document.getElementById('fname').style.borderColor='';
}
if(trim(f.lname.value) == '') {
document.getElementById('lname_d').style.color='#ff0000';
document.getElementById('lname').style.borderColor='#ff0000';
err++;
}
else {
document.getElementById('lname_d').style.color='';
document.getElementById('lname').style.borderColor='';
}
if(trim(f.password.value) == '') {
document.getElementById('password_d').style.color='#ff0000';
document.getElementById('password').style.borderColor='#ff0000';
err++;
}
else {
document.getElementById('password_d').style.color='';
document.getElementById('password').style.borderColor='';
}
if(trim(f.email.value) == '') {
document.getElementById('email_d').style.color='#ff0000';
document.getElementById('email').style.borderColor='#ff0000';
err++;
}
else if((/^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z.]{2,5}$/).exec(f.email.value)==null) {
document.getElementById('email_d').style.color='#ff0000';
document.getElementById('email').style.borderColor='#ff0000';
err++;
}
else {
document.getElementById('email_d').style.color='';
document.getElementById('email').style.borderColor='';
}
<?php if(fetchParam('show_captcha') != 'false') { ?>
if(trim(f.security_code.value) == '') {
document.getElementById('security_code_d').style.color='#ff0000';
document.getElementById('security_code').style.borderColor='#ff0000';
err++;
}
else {
document.getElementById('security_code_d').style.color='';
document.getElementById('security_code').style.borderColor='';
}
<?php } ?>
if(err > 0) {
alert ("err>0");
return false;
}
else {
alert("true");
f.submit();
}
}
function trim(str, chars) {
return ltrim(rtrim(str, chars), chars);
}
function ltrim(str, chars) {
chars = chars || "\\s";
return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}
function rtrim(str, chars) {
chars = chars || "\\s";
return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}
</script>

<div>
<p>
<span class="text">Please enter your info to search for your Senior Pictures.</span>
</p>
</div>
<form name="mspseniorsForm" action="index.php" method="post" class="mspseniorsForm">
<input type="hidden" name="option" id="option" value="com_mspseniors" />
<input type="hidden" name="task" id="task" value="searchsenior" />
<input type="hidden" name="Itemid" id="Itemid" value="<?php echo $_REQUEST['Itemid']; ?>" />
<table class="MSP_form_main" cellpadding="5" cellspacing="5" border="0">
<?php if($_REQUEST['err'] == 'true') { ?>
<tr>
<td colspan="2" class="MSP_form_error">
<p>Please correct the following errors:</p>
<div>
<ul>
<?php
$errA = $_SESSION['MSP_error'];
foreach($errA as $val) {
echo '<li>'.$val.'</li>';
}
?>
</ul>
</div>
</td>
</tr>
<?php } ?>
<tr><td colspan="2" class="MSP_form_mandatory"><span class="MSP_form_star_color">*</span> fields are mandatory.</td></tr>
<tr><td class="MSP_form_first_col"><span id="fname_d" class="MSP_form_text">Your First Name:</span><span class="MSP_form_star_color">*</span></td><td style="width:75%;"><input name="fname" id="fname" type="text" maxlength="50" class="MSP_form_input" /></td></tr>
<tr><td><span id="lname_d" class="MSP_form_text">Your Last Name:</span><span class="MSP_form_star_color">*</span></td><td><input name="lname" id="lname" type="text" maxlength="50" class="MSP_form_input" /></td></tr>
<tr><td><span id="sname_d" class="MSP_form_text">Your School:</span><span class="MSP_form_star_color">*</span></td><td>
<select name="school_id" id="school_id" class="MSP_form_input" >
<?php
if(count($items) > 0) {
foreach($items as $item) {
echo '<option value="'.$item->id.'">'.$item->schoolname.'</option>';
}
}else{
echo '<option >Schools Not Available</option>';
}?></select>
</td></tr>
<tr><td><span id="email_d" class="MSP_form_text">Email Address:</span><span class="MSP_form_star_color">*</span></td><td><input name="email" id="email" type="text" maxlength="100" class="MSP_form_input" /></td></tr>
<tr><td><span id="password_d" class="MSP_form_text">User Password:</span><span class="MSP_form_star_color">*</span></td><td><input name="password" id="password" type="text" maxlength="100" class="MSP_form_input" /></td></tr>
<tr><td colspan="2" style="text-align:center;"><input type="button" value="Find my Senior Pictures" class="MSP_form_button" onclick="return seniorSearch();alert('alert');" /></td></tr>
</table>
</form>
<?php
//searchsenior();
}

//-------------------------------------- Submit()
//---------------------------------------------------------------------------------------
function submit() {
unset($_SESSION['MSP_error']);
unset($_SESSION['MSP_post']);
$isfalse = false;
$MSP_error = array();
if(trim($_POST['fname']) == '') {
$isfalse = true;
$MSP_error[] = 'Please enter first name.';
}
if(trim($_POST['lname']) == '') {
$isfalse = true;
$MSP_error[] = 'Please enter last name.';
}
if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", trim($_POST['email']))) {
$isfalse = true;
$MSP_error[] = 'Please enter proper email address.';
}
if(fetchParam('show_captcha') != 'false') {
if($_SESSION["MSP_code"] != $_POST['security_code']) {
$isfalse = true;
$MSP_error[] = 'Please enter proper security code.';
}
}
if(trim($_POST['comments']) == '') {
$isfalse = true;
$MSP_error[] = 'Please enter your comments.';
}
if($isfalse == false) {
foreach($_POST as $key=>$value) {
$_POST[$key] = addslashes($value);
}
$database =& JFactory::getDBO();
if(fetchParam('auto_approval') == 'true') {
$tesistatus = 1;
}
else {
$tesistatus = 2;
}
$database->setQuery("insert into `#__".MSP_TABLE_PREFIX."`(`id`, `fname`, `lname`, `about`, `location`, `website`, `email`, `comment`, `date`, `status`) values('', '".$_POST['fname']."', '".$_POST['lname']."', '".$_POST['about']."', '".$_POST['location']."', '".$_POST['website']."', '".$_POST['email']."', '".$_POST['comments']."', '".date('Y-m-d')."', '".$tesistatus."')");
$database->query();

if(fetchParam('admin_email_alert') == 'true') {
$smFrom = $_POST['email'];
$smName = $_POST['fname'].' '.$_POST['lname'];
$smSubject = 'New MSP Senior - MSP Senior Form';
$smBody = 'One of your website visitor / Senior just send you a new Senior Registration through MSP Senior component. Please check your admin panel for details.';
sendMail($smFrom, $smName, $smSubject, $smBody);
}

header("location:index.php?option=com_mspseniors&Itemid=".$_REQUEST['Itemid']."&saved=true");
exit();
}
else {
$_SESSION['MSP_error'] = $MSP_error;
$_SESSION['MSP_post'] = $_POST;
header("location:index.php?option=com_mspseniors&Itemid=".$_REQUEST['Itemid']."&err=true#submitform");
exit();
}
}


?>
Something went wrong with that request. Please try again.