php class PublicPage extends InteractivePage { function save_data($req) { if(!$this->validate()) { // alert, error } $fields_to_insert=$this->bewerbertable_data($req); //xxx($fields_to_insert);exit; $req1=array(); foreach($fields_to_insert as $field) { $tmp=$req[$field]; if($tmp=='ja') { $tmp='1'; } elseif ($tmp=='nein') { $tmp='0'; } if($field=='text_content') { $tmp=nl2br($tmp); } if($field=='abschlussland' && $req['schulabschluss']!='auslaendischer_bildungsabschluss') { $tmp=''; } $req1[$field]="'".$tmp."'"; } //handle other fields $req1['created']="'".date('Y-m-d H:i:s')."'"; $req1['birthdate']="'".$req['birthdate_year'].'-'.$req['birthdate_month'].'-'.$req['birthdate_day']. "'"; $req1['begindate']="'".$req['begin_year'].'-'.$req['begin_month'].'-'.$req['begin_day']. "'"; $user_id=$this->save_into_db($req1); //other tables if(isset($req['in_plz'])) { foreach($req['in_plz'] as $i=>$v) { $plz=$req['in_plz'][$i]; if(strlen($plz)<3) continue; $umkreis=0; if(isset($req['in_umkreis'][$i])) { $umkreis=$req['in_umkreis'][$i]; } $q="insert into bewerber_plz (bewerber_id, plz, umkreis) values('$user_id','$plz','$umkreis')"; $this->db->executeQuery($q); } }; if(isset($req['sportart'])) { foreach($req['sportart'] as $i=>$v) { $sportart=$req['sportart'][$i]; if(strlen($sportart)<3) continue; $von_jahr=$req['sport_von_jahr'][$i]; $bemerkung=$req['sport_bemerkung'][$i]; $bemerkung=str_replace(PHP_EOL, ' ', $bemerkung); $q="insert into bewerber_sport (bewerber_id, sportart, von_jahr,bemerkung) values('$user_id','$sportart','$von_jahr','$bemerkung')"; $this->db->executeQuery($q); } }; // at this place, insert into static /* if(isset($req['ausbildung_title'])) { foreach($req['ausbildung_title'] as $i=>$v) { $title=$req['ausbildung_title'][$i]; if(strlen($title)<3) continue; $ort=$req['ausbildung_ort'][$i]; $von_monat=$req['ausbildung_von_monat'][$i]; $von_jahr=$req['ausbildung_von_jahr'][$i]; $bis_monat=$req['ausbildung_bis_monat'][$i]; $bis_jahr=$req['ausbildung_bis_jahr'][$i]; $abschluss=$req['ausbildung_abschluss'][$i]; $note=(float)str_replace(',','.',$req['ausbildung_note'][$i]); $q="insert into bewerber_ausbildung (bewerber_id, title, ort, von_monat, von_jahr, bis_monat, bis_jahr, abschluss, note) values('$user_id','$title','$ort','$von_monat','$von_jahr','$bis_monat','$bis_jahr','$abschluss','$note')"; $this->db->executeQuery($q); } }; if(isset($req['praktikum_branche'])) { foreach($req['praktikum_branche'] as $i=>$v) { $branche=$req['praktikum_branche'][$i];//xxx($req); if(strlen($branche)<3) continue; $von_monat=$req['praktikum_von_monat'][$i]; $von_jahr=$req['praktikum_von_jahr'][$i]; $bis_monat=$req['praktikum_bis_monat'][$i]; $bis_jahr=$req['praktikum_bis_jahr'][$i]; $title=$req['praktikum_title'][$i]; $q="insert into bewerber_praktikum (bewerber_id, branche, von_monat, von_jahr, bis_monat, bis_jahr, title) values('$user_id','$branche','$von_monat','$von_jahr','$bis_monat','$bis_jahr','$title')"; $this->db->executeQuery($q); } }; */ return $user_id; } function bewerbertable_data($req) { //intersect $_POST and fields of table bewerber $fields=array_keys($this->db->getTableFields('bewerber'));//xxx($req);xxx($fields); $fields_to_insert=array_intersect(array_keys($req), $fields); return $fields_to_insert; } function save_into_db($req1) { $q="insert into bewerber (".implode(',',array_keys($req1)).") values (".implode(', ',$req1).")"; //exit($q); return $this->db->executeQuery($q); } function upload_files($user_id) { //test if dir exists and create it $dir=$this->config->upload_path.'/'.$user_id;//echo $dir; exit; if(!is_dir($dir)) { mkdir($dir); } $dir.='/'; $fup=new FileUploader($dir); return $fup->upload(); } function send_confirm_mail($user_id) { //find bewerber mail $q="select email, gender, vorname, nachname from bewerber where id=".$user_id; $row=$this->db->getRow($q); $to=$row->email; $gender=$row->gender; $vorname=$row->vorname; $nachname=$row->nachname; $from=$this->config->supportmail; $fromname=$this->config->supportmail_name; $subj=$this->Txt->subjects['confirm_registration']; $message=$this->config->email_css."\n".file_get_contents($this->config->app_path.'/view/static/bewerbung_answer.html'); $signature=Util::template('signature'); $message.=$signature; $attachements=array(); //no anrede, no attachments /* $anrede=($gender=='w' ? ' Frau ' : 'r Herr '). $nachname; $message=sprintf($message, $anrede); //get attachements $dir=$this->config->app_path.$this->config->bewerber_attachements_path; $files=Util::get_files_in_dir($dir); if($files) { $finfo = finfo_open(FILEINFO_MIME_TYPE); foreach($files as $file) { //make full path $file=$dir.'/'.$file; //get extension and filetype $filetypes=explode(',',$this->config->bewerber_data_filetypes); $ext = pathinfo($file, PATHINFO_EXTENSION); if(!in_array($ext, $filetypes)) { continue; } $contenttype =finfo_file($finfo, $file); $attachements[]=array('filepath'=>$file,'contenttype'=>$contenttype); } finfo_close($finfo); } */ Util::send_phpmailer_mail($from, $fromname, $to, $subj, $message, true, $attachements); $to='almarna@gmx.de'; // Util::send_phpmailer_mail($from, $fromname, $to, $subj, $message, true, $attachements); } function countries() { $q="select common_token as _key, title_ger as title from country order by title_ger"; return $this->db->getRowset($q); } /** * check form data; we doesnt check becaue send via javascript and already tested * @return boolean */ function validate() { return true; } /* used on annonce pages which are common for logged and not logged user*/ function logged() { if(isset($this->user) && isset($this->user->user_id) && $this->user->user_id>0) return true; if(isset($_SESSION['user_id']) && $_SESSION['user_id']>0){ $U=User::getInstance(); $U->init($this->db); $this->user=$U; return true; } return false; } function fill_lon_lat() { //1.search from geoinfo $q="UPDATE bewerber_plz B LEFT JOIN geoinfo G ON B.plz = G.plz SET B.lon =G.lon, B.lat=G.lat WHERE ISNULL(B.lon) OR ISNULL(B.lat) "; //$this->db->executeQuery($q); //2. if some not found, search in google $q="SELECT DISTINCT plz FROM bewerber_plz WHERE (ISNULL(lon) OR ISNULL(lat)) and plz<>'00000'"; $plzs=$this->db->getSingleColumn($q); foreach($plzs as $plz) { $coord=self::get_lon_lat($plz); if(is_object($coord) && $coord) { $q="update bewerber_plz set lon='$coord->lon', lat='$coord->lat' where plz='$plz'"; $this->db->executeQuery($q); } else { //no message here; the missing lon/lat are visible in the bewerber_plz table //$e=new LoggedException('plz: '.$plz,'no_coord');; } } } static function get_lon_lat($plz, $with_ortsname=false) { $addr=$plz.' Deutschland'; $addr=urlencode($addr); $url="http://maps.googleapis.com/maps/api/geocode/xml?sensor=false&address="; $url2=$url.$addr; //echo $url2; $str=file_get_contents($url2); if(!$str) { return false; } $s=simplexml_load_string($str); try { $status=$s->status; } catch(Exception $e) { $ex=new LoggedException('no status for url: '.$url,'ebayCall'); return false; } if($status!='OK') { if($status!='ZERO_RESULTS') { return -1;/* OVER_QUERY_LIMIT, REQUEST_DENIED, INVALID_REQUEST, UNKNOWN_ERROR*/ } else { return false; /* can try again , with plz or so */ } } if($s->result) { $is_erkannt_as_plz=$s->result->type; if($is_erkannt_as_plz!='postal_code') return false; //if this plz not exists, i can be recognized as route etc, also the result is false for as $lon=$s->result->geometry->location->lng; $lat=$s->result->geometry->location->lat;//echo $s->geometry; if(!$lon || !$lat) { return false; } $coord=new stdClass(); $coord->lon=$lon; $coord->lat=$lat; if($with_ortsname) { $node=$s->xpath('//result/address_component/type[.="locality"]/parent::*/long_name'); $str=(string)$node[0]; $coord->ortsname=$str; } } else { return false; } return $coord; } /* update table statis_v_matching, insert a new fields; use this table instead of the view v_matching, table */ function update_static_v_matching($item_id, $item='bewerber') { if(!in_array($item, array('bewerber','gesuch'))) { $e=new LoggedException('item is: '.$item,'static_view'); return; } set_time_limit(0); //replace this short sql with an longer because it is too slow /* $q="INSERT INTO static_v_matching SELECT * FROM v_matching WHERE ".$item."_id=".$item_id;*/ //get the view content $view=file_get_contents(snippet('sql/v_matching')); if($item=='gesuch') { $item_name='g.id'; } else { $item_name='b.id'; } $view=str_replace('__condition__', $item_name."=".$item_id, $view); //xxx($view); exit; $rows=$this->db->getRowset($view); foreach($rows as $row) { $gesuch_id=$row->gesuch_id; $gesuch_title=$row->gesuch_title; $bewerber_id=$row->bewerber_id; $bstatus=$row->bstatus; $plz_id=$row->plz_id; $plz=$row->plz; $vorname=$row->vorname; $nachname=$row->nachname; $age=$row->age; $age_until=$row->age_until; $age_from=$row->age_from; $begindate=$row->begindate; $bewerber_created=$row->bewerber_created; $q="INSERT INTO static_v_matching (gesuch_id, gesuch_title, bewerber_id, bstatus,plz_id, plz, vorname, nachname, age, age_until, age_from, begindate, bewerber_created) values ('$gesuch_id', '$gesuch_title', '$bewerber_id', '$bstatus', '$plz_id', '$plz', '$vorname','$nachname','$age', '$age_until', '$age_from', '$begindate', '$bewerber_created')"; $this->db->executeQuery($q); } } function change_static_v_matching($field, $value, $id, $idfield='bewerber_id') { $q="update static_v_matching set $field='$value' where $idfield='$id'"; $this->db->executeQuery($q); } /* re-create the table static_v_matching, if some bewerber were dropped etc */ /* function fill_static_v_matching() { $q="truncate table static_v_matching"; $this->db->executeQuery($q); set_time_limit(0); $q="INSERT INTO static_v_matching SELECT * FROM v_matching "; $this->db->executeQuery($q); } // re-create the table static_v_matching, if some bewerber were dropped etc function fill_static_v_bewerber_plz() { $q="truncate table static_bewerber_plz"; $this->db->executeQuery($q); set_time_limit(0); $q="INSERT INTO static_bewerber_plz SELECT * FROM v_bewerber_all_plzs "; $this->db->executeQuery($q); } */ }
Fatal error: Class 'PublicPage' not found in /home/controls/index.php on line 2