mf_init(); } function mf_init() { $this->basepath = realpath(dirname(__FILE__)."/../pix").'/'; $this->template_dir = realpath(dirname(__FILE__)."/../../vcars_templates"); $this->compile_dir = "/var/smarty/vcars_templates_c"; $this->cnfg = array(); if(empty($this->DB)) $this->DB = new DB; $cnfgx = $this->DB->simpleQuery('cnfg','ky,dat','',''); foreach($cnfgx as $datx){ $this->cnfg[$datx['ky']] = $datx['dat']; } $this->no_auth = explode(',',@$this->cnfg['no_auth']); } function mklog($ltyp,$ldt){ if(empty($this->DB)) $this->DB = new DB; $lg['usr']=$this->user->call; $lg['typ']=$ltyp; $lg['stmp']=time(); $lg['txt']=$ldt; $lg['script']=$_SERVER["SCRIPT_NAME"]; if($_SERVER['REMOTE_ADDR']){ $lg['ip']=$_SERVER['REMOTE_ADDR']; }else{ $lg['ip']=$_SESSION['REMOTE_ADDR']; } $this->DB->dbWrite("ilog",$lg,""); } // takes a mysql-formatted timestamp and creates an array function parseDate($date) { $dateVar['month'] = substr($date, 4, 2); $dateVar['day'] = substr($date, 6, 2); $dateVar['year'] = substr($date, 0, 4); $dateVar['hour'] = substr($date, 8, 2); $dateVar['min'] = substr($date, 10, 2); $dateVar['sec'] = substr($date, 12, 2); return $dateVar; } // this is a groovy lil function. Automatically creates a date dropdown for ya!! // 'type' will be reserved for full time/date drop (5 fields) or just the date drop // 'name' is the primary name of the date fields (eg. "created" or "modified") // 'selected' is a date/time entry. if entered, it will return the proper fields as "SELECTED" function makeDateDrop($type,$name,$selected) { // let's extract all of our date info from the selected if($selected) $selDate = $this->parseDate($selected); if($type == "date-time" || $type == "date") { // ok, so first, let's create the month dropdown $myMonths = explode(",",",Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec"); $month = ""; // day dropdown $day = ""; // year dropdown $year = ""; // now let's create the table data we need $date = "$month\n$day\n$year\n"; } if($type == "date-time" || $type == "time") { // hour dropdown $hour = ""; // min dropdown $min = ""; // now let's create the table data we need $time = "$hour\n$min\n"; } $thisDrop = "\n\n$date$time\n
\n"; return $thisDrop; } // this just puts together a date from the info submitted in the form, returns mysql timestamp format function compileDateSubmitted($type,$name,$data) { // this could maybe be a lil cleaner, but i wanna get this moving, so i did it quickly if($type == "date-time" || $type == "date") { if($data["$name".'_year'] != "" && $data["$name".'_month'] != "" && $data["$name".'_day'] != "") $retThis = $data["$name".'_year'].$data["$name".'_month'].$data["$name".'_day']; else return false; } if($type == "date-time" || $type == "time") { if($data["$name".'_hour'] != "" && $data["$name".'_min'] != "") $retThis .= $data["$name".'_hour'].$data["$name".'_min']; else return false; } return $retThis; } // this function creates a dropdown menu function makeDrop($name,$data,$selection,$onChange) { if($onChange) $onchg = " onChange=\"$onChange\""; $thisDrop = ""; return $thisDrop; } function makeRadio($name,$data,$selection,$onChange) { if($onChange) $onchg = " onChange=\"$onChange\""; $thisRadio = ""; // let's loop through our input data foreach($data as $dataRow) { $x = explode(":",$dataRow); ($selection == $x[1]) ? $sel = " CHECKED" : $sel = ''; if($thisRadio){$thisRadio.="
\n";} $thisRadio .= "$x[0]"; } return $thisRadio; } // automatically makes a state dropdown function makeStateDrop($name,$selected,$onChange) { if($onChange) $onchg = " onChange=\"$onChange\""; $myStates = explode(",","AL,AK,AR,AZ,CA,CO,CT,DC,DE,FL,GA,HI,IA,ID,IL,IN,IS,KY,AL,MA,MD,ME,MI,MN,MO,MS,MT,NC,ND,NE,NH,NJ,NM,NV,NY,OH,OK,OR,PA,RI,SC,SD,TN,TX,UT,VA,VT,WA,WI,WV,WY"); $statesDrop = ""; return $statesDrop; } // this takes a mysql formatted timestamp and formats it into something a lil more legible function giveMyTime($stamp,$type) { if(substr($stamp, 8, 2) <= "12"){ $hour = substr($stamp, 8, 2); $AMPM = "AM"; } else { $hour = (substr($stamp, 8, 2)-12); $AMPM = "PM"; } if($type == "small"){ $MyTime = substr($stamp, 4, 2)."-".substr($stamp, 6, 2)."-".substr($stamp, 0, 4); } else { $MyTime = substr($stamp, 4, 2)."-".substr($stamp, 6, 2)."-".substr($stamp, 0, 4)." ".$hour.":".substr($stamp, 10, 2)." ".$AMPM; } return $MyTime; } // sends an email... whoopie!! function sendEmail($recipName, $recipEmail, $fromName, $fromEmail, $subject, $message) { $contactheader = "\"$recipName\" <$recipEmail>"; $fromheader = "\"$fromName\" <$fromEmail>"; // $headers .= "MIME-Version: 1.0\r\n"; $headers .= "To: $contactheader\r\n"; $headers .= "From: $fromheader\r\n"; $headers .= "Reply-To: $fromheader\r\n"; $omsg=$headers."Subject: ".$subject."\r\n\r\n".$message; // $this->assign('msgo',$omsg); //echo "contactheader:\n".$contactheader."\n\nheaders:\n".$headers; //mail($contactheader, $subject, $message, $headers); // return mail($recipEmail, $subject, $message, $headers); $tfn="tmp_".$recipEmail.'_'.time().rand(0,99999).".eml"; if($mh=fopen("c:\\inetpub\\mailroot\\tmpx\\".$tfn,'w')){ fwrite($mh,$omsg,strlen($omsg)); fclose($mh); rename("c:\\inetpub\\mailroot\\tmpx\\".$tfn,"c:\\inetpub\\mailroot\\pickup\\".$tfn); }else{ return False; } return True; } // we'll create this function to display the template, instead of calling the Smarty display function directly. // this is so we can control the subnav and some console stuff (body tag). function displayTmpl($tplfilex = "vcars_site.tpl", $dispmenux = true) { echo $this->mkPage($tplfilex, $dispmenux); } function mkPage($tplfile = "vcars_site.tpl", $dispmenu = true) { $this->assign('astg',@$this->astg); // here we're creating our JS console commands ( tag) if(@$this->onLoad){ foreach ($this->onLoad as $dat) { $data .= $dat; } $myConsole .= " onLoad=\"$data\""; } if(@$this->onBeforeUnload){ unset($data); foreach ($this->onBeforeUnload as $dat) { $data .= $dat; } $myConsole .= " onBeforeUnload=\"$data\""; } if(count(@$this->onUnLoad) > 0) { unset($data); foreach ($this->onUnLoad as $dat) { $data .= $dat; } $myConsole .= " onUnLoad=\"$data\""; } if(count(@$this->onClick) > 0) { unset($data); foreach ($this->onClick as $dat) { $data .= $dat; } $myConsole .= " onClick=\"$data\""; } $this->assign('console',@$myConsole); $this->assign('mainBody',$this->mainBody); $this->assign('title',$this->title); $this->assign('errormsg',@$this->errormsg); // $this->getMenuX(); if($dispmenu){$this->getMenu();} // let's only send these headers if DB debugging is off if($this->DB->DBdebug != true) { // DB debugging is off. so let's disable caching header("Expires: Tue, 01 Jan 1970 00:00:00 GMT"); header("Cache-Control: no-store, no-cache, must-revalidate"); header("Cache-Control: post-check=0, pre-check=0", false); header("Pragma: no-cache"); } $this->assign('cryear',date('Y')); // $lvlx=intval($this->user->lvl); $this->assign('cpg',@$this->page); // $this->assign('lvl',$lvlx); // if($lvlx > 0){ // $this->assign('username',$this->user->username); // } /* $mnu = $this->DB->simpleQuery('MenuItems','id,vlu,txt,subm,smdef','mnu=0 and lvl <= '.$lvlx,'order by dord'); $this->assign('menu',$mnu); $sbm=0; foreach($mnu as $mnl){ if($mnl['vlu'] == $this->page){ $sbm=$mnl['subm']; $smd=$mnl['smdef']; $this->assign('mnid',$mnl['id']); } } $this->assign('sbm',$sbm); if($sbm){ $smnu = $this->DB->simpleQuery('MenuItems','id,vlu,txt','mnu='.$sbm.' and lvl <= '.$lvlx,'order by dord'); $this->assign('smenu',$smnu); if(!$this->spage){ foreach($smnu as $sml){ if($sml['id']==$smd){ $this->spage=$sml['vlu']; } } } $this->assign('cspg',$this->spage); }*/ // we should have everything we need now, so let's display the template return $this->fetch($tplfile); } function getMenuX(){ if(empty($this->DB)) $this->DB = new DB; $menuline = $this->DB->simpleQuery('pages','ky,lnktxt,linkonly,txt','line=0 AND showmenu=1','order by lkord'); $this->assign('menuline',$menuline); } function getMenu(){ if(empty($this->DB)) $this->DB = new DB; $menudat = $this->DB->simpleQuery('html','ky,lnktxt,line,htmlfile','showmenu = 1 and disabled = 0','ORDER BY line,lkord'); $lml = -1; $lrc = -1; foreach($menudat as $mnx => $mdat){ $mln = $mdat['line']; if($mln != $lml){ $menudat[$mnx]['rowbegin'] = 1; if($lrc > -1){ $menudat[$lrc]['rowend'] = 1; } } $lml = $mln; $lrc = $mnx; } $menudat[$lrc]['rowend'] = 1; $this->assign('mnu',$menudat); // echo "\n"; } function getAds($Restrict) { if(empty($this->DB)) $this->DB = new DB; $cnfgx = $this->DB->simpleQuery('cnfg','ky,dat','',''); foreach($cnfgx as $ky => $datx){ $this->cnfg[$datx['ky']] = $datx['dat']; } $tt=time(); srand($tt); // $cfg = $this->DB->simpleQuery('spdb.cnfg','dat',"ky LIKE 'adn'",''); $adn=$this->cnfg['adn']; if($adn < 1){ $adn=1; } $lFlg = True; while($lFlg){ $t2=rand(1,$adn); $adx = $this->DB->simpleQuery('spdb.ads','adtx,outside','idx = '.$t2,''); $lFlg=$Restrict; if(!($adx[0]['outside'] == 'Y')){ $lFlg = False; } } $tadx = $this->DB->simpleQuery('spdb.tads','adtx','idx = '.$t2,''); $this->ads=$adx[0]['adtx']; $this->tads=$tadx[0]['adtx']; $this->assign('adcd',$this->ads); $this->assign('tads',$this->tads); return false; } function GetQuery($iptx) { $optx = $_GET[$iptx]; if(!$optx){ $optx = $_POST[$iptx]; } return $optx; } function myFormatDate($mfdidt) { return strftime("%b %d, %Y %H:%M",$mfdidt); // return date('M d, Y H:i (T)',$mfdidt); // return date('M d, Y H:i',$mfdidt)." (".getenv('TZ').")"; } function validAddr($ieml){ return ereg('^[0-9a-z][-0-9a-z_.]*\@[0-9a-z][-0-9a-z_.]*\.[0-9a-z]*$',$ieml); } function getFAQ(){ if(empty($this->DB)) $this->DB = new DB; $faqa = $this->DB->simpleQuery('faq','id,short,full','enabled = 1','order by rdr'); if($faqa){ $this->assign('fqa',$faqa); $ftx=$this->fetch('fam_faq.tpl'); $this->assign('faqtx',$ftx); } return; } function updX($tbl,$rid,$typ,$dat){ if(empty($this->DB)) $this->DB = new DB; $fid = $this->DB->simpleQuery($tbl,'id','rid = '.$rid.' AND typ = '.$typ,''); if($fid){ $pr['dat']=$dat; $this->DB->dbUpdate($tbl,$pr,'rid = '.$rid.' AND typ = '.$typ,''); }else{ $prs['rid']=$rid; $prs['typ']=$typ; $prs['dat']=$dat; $this->DB->dbWrite($tbl,$prs,""); } } function mkProfArray($anm,$cid){ if(empty($this->DB)) $this->DB = new DB; $xtrf=$this->DB->simpleQuery('xfld,xftyp','xfld.id,xfld.typ,xfld.name,sname,tblmnam,tblnam,formord,quotes,xdat',"formshow > 0 AND tblnam='$anm' AND xfld.typ=xftyp.id",'ORDER BY formord'); $ixx=0; foreach($xtrf as $xtrfl){ $flnums[$xtrfl['typ']][$xtrfl['formord']]=$xtrfl['id']; $fldtbls[$xtrfl['formord']]=$xtrfl['tblmnam']; $flds[$ixx]['xname']=$xtrfl['name']; $flds[$ixx]['name']=$xtrfl['sname']; $flds[$ixx]['typ']=$xtrfl['typ']; $flds[$ixx]['quotes']=$xtrfl['quotes']; $flds[$ixx]['id']=$xtrfl['id']; $flds[$ixx]['val']=''; $fldx[$xtrfl['id']]=$ixx; if($xtrfl['typ']==6){ $flds[$ixx]['ch']=$this->DB->simpleQuery('xchoices','idx,txt','fid='.$xtrfl['xdat'],'ORDER BY idx'); } $ixx++; } // echo "\n"; foreach($flnums as $fld => $fldqx){ $xtqd=$this->DB->simpleQuery($fldtbls[$fld],'typ,dat','typ IN ('.implode(',',$fldqx).') AND rid='.$cid,''); if($xtqd){ foreach($xtqd as $xtql){ $flds[$fldx[$xtql['typ']]]['val']=$xtql['dat']; } } // echo "\n"; } $this->ftbls=$fldtbls; return $flds; } function sendPassword() { $err = true; $usnm = $_POST['username']; $usr = $this->DB->simpleQuery("members","`uid`,`call`,`pw`,`eml`,`FirstName`,`LastName`","`call` LIKE '".$_POST['username']."'",""); if($usr){ $msg=" Your user ID for \"My Mountain Pictures\" is ".$usr[0]['username']." Your password is ".$usr[0]['pw']." You may login at http://www.mymountainpix.com/ If you would prefer a password that is easier to remember, you may change it in the 'User Profile' page after logging in. Please do NOT reply to this message as this address is not monitored. Direct any correspondence to admin@mymountainpix.com\n"; if($this->sendEmail($usr[0]['FirstName'].' '.$usr[0]['LastName'],$usr[0]['eml'],'MyMountainPix','passwords@mymountainpix.com','My Mountain Pictures password for '.$usr[0]['call'],$msg)){ $rsn = 'The password for '.$usr[0]['call'].' has been sent to this eMail address.'; $error = false; // $rsn .= "(".$usr[0]['eml'].")"; }else{ $rsn = 'There was a problem sending the password for '.$usr[0]['eml'].' to this eMail address.'; } }else{ $rsn = 'Record not found.'; } $this->authError = $rsn; echo "\n\n"; // $this->displayLogin(); $this->logit(0,"Password ".(($err)?"send failed":"sent")); return false; } function MonthName($mn) { return date('F',($mn * 2592000)-864000); } function logit($typ,$tx) { if(empty($this->DB)) $this->DB = new DB; $lga = array( 'Stamp' => date('Y-m-d'), 'User' => $this->user->call, 'Type' => $typ, 'Entry' => $tx ); $this->DB->dbWrite('log',$lga,''); } } /*## END OF PAGE CLASS ##*/ // just some user & acct vars... class user { /* this is just an internal placeholder for the user's login info obj */ } class group { /* this is just an internal placeholder for the user's group info obj */ } ?>