''); var $current_rec; var $current_section; var $db; function xmail($email_address,$email_from,$subject,$msg,$attach_filepath) { $b = 0; $mail_attached = ""; $boundary = md5(uniqid(time(),1))."_xmail"; if (count($attach_filepath)>0) { for ($a=0;$adb->query($sql); if(($row = $result->fetchRow())) { $form_id = $row['id']; $xml_string .= "
\n"; while(list($key, $value) = each($_POST)) { if(!in_array($key, array("MAX_FILE_SIZE", '__auto_gen_form_submit'))) { if(is_array($value)) { $value = implode(', ',$value); } $string .= "$key : $value \n"; $xml_string .= "<$key>$value\n"; } } $files = array(); foreach($_FILES as $v => $k) { if(move_uploaded_file($k['tmp_name'], BLUECMS_CACHE . '/'. $k['name'])) { $files[] = BLUECMS_CACHE . '/' . $k['name']; } } $xml_string .= "
"; $form_id = $row['id']; $message = $row['message']; $xml_string = addslashes($xml_string); $string = addslashes($string); $sql = "select name, required, description from form_description where form_id=?"; $form_stuff = $this->db->query($sql,array($form_id)); $allreq = true; $missing_fields = array(); while($oneodem = $form_stuff->fetchRow()) { //pre_dump($oneodem); if($oneodem['required']) { //echo "checking[".$_POST[$oneodem['name']]."]"; if($_POST[$oneodem['name']] == '') { //echo "hmm error"; $allreq = false; $missing_fields[] = $oneodem['description']; } } } if($allreq) { $sql = "insert into form_results(form_id, result_text, result_xml) values($form_id,'$string','$xml_string')"; $this->db->query($sql); if($row['email_to'] != '') { $headers = "From: webmaster@" . BLUECMS_SITENAME . "\r\nReply-To: webmaster@" . BLUECMS_SITENAME . "\r\n"; $string = "Generated by page $base \r\n" . $string; if(count($files) >0) $this->xmail($row['email_to'],"webmaster@" . BLUECMS_SITENAME , "Form generated mail from " . BLUECMS_SITENAME . "...", $string, $files); else mail($row['email_to'], "Form generated mail from " . BLUECMS_SITENAME . "...", $string, $headers); } } } if($allreq) { $this->content['body'] = '

' . $message . '

'; } else { $body = "Required fields missing: "; foreach($missing_fields as $field) { $body .= "
     ".$field.""; } $body .= '
Return to previous page '; $this->content['body'] = $body; } return($this->content['body']); } else { return( stripslashes($this->content['body'])); } } /** load should retrieve from the db and stuff in the content array. */ function load($template_var) { $this->template_var = $template_var; $this->content['body'] = $this->get_content_from_db($template_var); } function get_content_from_db($template_var) { if(isset($this->current_rec)) { $f = new HTML_QuickForm('form', 'POST'); $r = & new HTML_QuickForm_Renderer_Default(); $el="\n\t\n\t\t*{label}
{error}
\t{element}\n\t"; $r->setElementTemplate($el); $groupT=" {content}
"; $elT = '{label}
{element}'; $r->setGroupTemplate($groupT, 'grpLabel'); $r->setGroupElementTemplate($elT, 'grpLabel'); $sql = "select form.id as form_id, form_url, form.description as form_description, title, form_description.* from form inner join form_description on form.id=form_id where form.id=" . $this->current_rec . ' order by id'; $result = $this->db->query($sql); $first = true; $els = array(); $grp = array(); while($row = $result->fetchRow()) { $el = null; if($first == true) { $top = '

' . $row['title'] . '

' . "\n" . '
' . $row['form_description'] . '
'; $first = false; } if($row['grp'] != 0) if(count($grp) ==0) #first item in group { $labels = $row['labels']; $grplabel = $row['description']; $grpnum = $row['grp']; $grpname = $row['name']; //first in group.. } switch($row['form_type']) { case 'text': $el = &HTML_QuickForm::createElement('text', $row['name'], $row['description'], array('size'=>$row['data_size'])); break; case 'textarea': list($rows, $cols) = explode(',', $row['data_size']); $el = &HTML_QuickForm::createElement('textarea', $row['name'],$row['description'], array('rows'=>$rows, 'cols'=>$cols)); break; case 'checkbox': case 'advcheckbox': $ar = split(',', $row['select_values']); if(!empty($ar[0])) { $grp = array(); $grplabel = $row['description']; $grpnum = 0; foreach($ar as $v) { $grp[] = &HTML_QuickForm::createElement('checkbox', $row['name'] . '[]', '',$v); $grp[count($grp)-1]->updateAttributes(array('value'=>$v)); } } else $el = &HTML_QuickForm::createElement('checkbox', $row['name'], $row['description']); break; case 'radio': #either added as a group (so use first name in group), else is group by itself $ar = split(',', $row['select_values']); if(!empty($ar[0])) { $grp = array(); $grplabel = $row['description']; $grpnum = 0; foreach($ar as $v) { $grp[] = &HTML_QuickForm::createElement('radio', $row['name'], $row['description'],$v,$v); } } else $el = &HTML_QuickForm::createElement('radio', $grpname,$row['description'],$row['select_values'], $row['select_values']); break; case 'file': $el = &HTML_QuickForm::createElement('file', $row['name'], $row['description']); break; case 'select': $list = explode(',', $row['select_values']); if(is_array($list)) { foreach($list as $key => $value) $list[$key] = trim($value); } else { $list = array(); } $el = &HTML_QuickForm::createElement('select', $row['name'],$row['description']); $el->loadArray($list); break; default: $el = &HTML_QuickForm::createElement(array('text', $row['name'], $row['description'], 'size'=>$row['data_size'])); break; } if($row['grp'] != 0) { if($grpnum == $row['grp']) { $grp[] = $el; } else #else if starting a new group { if(count($grp) > 0) { $this->addGroup($f, $labels, $grplabel, $grp); $grp = array(); $grp[] = $el; } } } else { if(count($grp) > 0) { $this->addGroup($f, $labels, $grplabel, $grp); $grp = array(); } if(!empty($el)) $f->addElement($el); } } #oh yeah, and if last el was part of group, then wasn't added yet if(count($grp) > 0) $this->addGroup($f, $labels, $grplabel, $grp); if($first == false) { $el = &HTML_QuickForm::createElement('submit', '__auto_gen_form_submit','Submit'); $f->addElement($el); $f->accept($r); return($top . $r->toHtml()); } else { return(''); } } else { return(''); } } function addGroup(&$f, $labels, $grplabel, &$grp) { if($labels==1) { $f->addGroup($grp, 'grpLabel', '',' ',False); } else { $f->addGroup($grp, 'grpNoLabels', $grplabel,' ',False); } } function handle_nav() { $base = current_path(); $sql = "select form.id as form_id from form where form_url='$base'"; $result = $this->db->query($sql); if($row = $result->fetchRow()) { $this->set_current($row['form_id']); } } function get_admin() { if(!isset($this->current_rec)) $this->current_rec = 'NEW'; return('
Edit this form.
'); } } ?>
Module form does not exist. Error in page_generator...

© Copyright 2009-2017 AntiqueWarehouseAuctions.com All Rights Reserved