Forum FAQForum FAQSearchSearch MemberlistMemberlist Forum ignore listForum ignore list RegisterRegister ProfileProfile Log in to check your private messagesLog in to check your private messages Log inLog in
muči me kontakt forma

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    mi3dot.org Forum Index -> Server-side
View previous topic :: View next topic  
Author Message
jurka



Joined: 26 Aug 2004
Posts: 1088
Location: Zagreb

PostPosted: 14.03.2006 00:15    Post subject: muči me kontakt forma Add user to your forum ignore list Reply with quote

problem je sljedeći. imam textpattern cms, i instaliran plug-in za kontakt formu sljedećeg koda
Code:
function zem_contact($atts, $thing='') {
   global $zem_contact_error, $sitename, $zem_contact_from, $zem_contact_nonce, $zem_contact_form;

   $form = (empty($atts['form']) ? '' : $atts['form']);
   $thanksform = (empty($atts['thanksform']) ? '' : $atts['thanksform']);
   $thanks = (empty($atts['thanks']) ? '<ul><li>Thank you for your enquiry. We will contact you as soon as possible! </li></ul>' : $atts['thanks']);
   $mailto = (empty($atts['mailto']) ? '' : $atts['mailto']);
   $mailfrom = (empty($atts['mailfrom']) ? '' : $atts['mailfrom']);
   $showinput = isset($atts['showinput']) ? $atts['showinput'] : 1;
   $showerror = isset($atts['showerror']) ? $atts['showerror'] : 1;

   if (!$mailto)
      return '<ul><li>No mailto address specified</li></ul>';

   if ($form)
      $Form = fetch("Form","txp_form","name",$form);
   else
      $form = $thing;

   if (empty($form)) {
      $form =<<<EOF
<txp:zem_contact_text label="Enter your name" /><br />
<txp:zem_contact_email /><br />
<txp:zem_contact_textarea /><br />
<txp:zem_contact_submit />
EOF;
   }

   if ($thanksform)
      $thanks = fetch("Form","txp_form","name",$thanksform);

   $zem_contact_nonce = md5(uniqid(rand(), true));
   safe_insert("txp_discuss_nonce", "issue_time=now(), nonce='$zem_contact_nonce'");

   $f = parse($form);

   $out = '';
   if (is_array($zem_contact_error) and count($zem_contact_error)) {
      if ($showerror) {
         $out .= "<ul>\n";
         foreach($zem_contact_error as $err) {
            $out .= "<li>$err</li>\n";
         }
         $out .= "</ul>\n";
      }
   }
   elseif ($showinput and is_array($zem_contact_form) and ps('zem_contact_submit')) {

      $from = ($mailfrom ? $mailfrom : $zem_contact_from);
      $headers = (empty($from) ? '' : "From: $from\r\n");
      if ($mailfrom)
         $headers .= "Reply-To: $zem_contact_from\r\n";
       $headers .= "Content-Transfer-Encoding: 8bit\r\n";
       $headers .= "Content-Type: text/plain; charset=\"UTF-8\"\r\n";

      $msg = '';
      foreach ($zem_contact_form as $k=>$v)
         $msg .= "$k: ".htmlspecialchars($v)."\n";
      $r = mail($mailto, "Email enquiry for $sitename", $msg, $headers);

      if ($r) {
         $_POST = array();
         $out .= $thanks;
         $f = parse($form);
      }
      else {
         $out .= "<p>Unable to send email</p>";
      }
   }

   if ($showinput)
      $out .= '<form action="'.$_SERVER['REQUEST_URI'].'" method="post">'
         . $f
         . '</form>';

   return $out;
}

function zem_contact_text($atts) {
   global $zem_contact_error, $zem_contact_form;
   $label = (empty($atts['label']) ? 'Text' : $atts['label']);
   $name = (empty($atts['name']) ? preg_replace('/\W/', '', $label) : $atts['name']);
   $break = (!isset($atts['break']) ? '<br />' : $atts['break']);
   $size = (empty($atts['size']) ? '' : $atts['size']);
   $min = (empty($atts['min']) ? 0 : $atts['min']);
   $max = (!isset($atts['max']) ? 100 : $atts['max']);
   $default = (empty($atts['default']) ? '' : $atts['default']);
   $required = (empty($atts['required']) ? false : true);

   $size = ($size ? 'size="'.(int)$size.'"' : '');
   $maxlength = ($max ? 'maxlength="'.(int)$max.'"' : '');

   $default = ($default ? 'value="'.$default.'"' : '');
   $v = (ps($name) ? ps($name) : $default);

   if ($v and $max)
      $v = substr($v, 0, $max);

   if (ps('zem_contact_submit') and $required and empty($v))
      $zem_contact_error[] = "Required field $label is missing";
   elseif (ps($name) and $min and strlen($v) < $min)
      $zem_contact_error[] = "$label must be at least $min characters";
   elseif (ps($name))
      $zem_contact_form[$label] = $v;

   $l = ($required ? "$label" : $label);

   return '<label for="'.$name.'">'.$l.':</label>'.
      $break.
      '<input type="text" name="'.$name.'" id="'.$name.'" value="'.htmlentities($v).'" '.$size.' '.$maxlength.' />';
}

function zem_contact_textarea($atts) {
   global $zem_contact_error, $zem_contact_form;
   $label = (empty($atts['label']) ? 'Message' : $atts['label']);
   $name = (empty($atts['name']) ? preg_replace('/\W/', '', $label) : $atts['name']);
   $break = (!isset($atts['break']) ? '<br />' : $atts['break']);
   $cols = (empty($atts['cols']) ? '34' : $atts['cols']);
   $rows = (empty($atts['rows']) ? '6' : $atts['rows']);
   $min = (empty($atts['min']) ? 0 : $atts['min']);
   $max = (!isset($atts['max']) ? 10000 : $atts['max']);
   $default = (empty($atts['default']) ? '' : $atts['default']);
   $required = (empty($atts['required']) ? false : true);

   $v = (ps($name) ? ps($name) : $default);
   if (ps($name) and $max)
      $v = substr($v, 0, $max);

   if (ps('zem_contact_submit') and $required and empty($v))
      $zem_contact_error[] = "Required field $label is missing";
   elseif (ps($name) and $min and strlen($v) < $min)
      $zem_contact_error[] = "$label must be at least $min characters";
   elseif (ps($name))
      $zem_contact_form[$label] = $v;

   $l = ($required ? "$label" : $label);
   return '<label for="'.$name.'">'.$l.':</label>'.
      $break.
      '<'.'textarea name="'.$name.'" id="'.$name.'" rows="'.$rows.'" cols="'.$cols.'">'.htmlentities($v).'<'.'/textarea>';
}

function zem_contact_email($atts) {
   global $zem_contact_error, $zem_contact_form, $zem_contact_from;
   $atts = array_merge(array('label'=>'Email', 'required'=>'1'), $atts);
   $label = (empty($atts['label']) ? 'Email' : $atts['label']);
   $name = (empty($atts['name']) ? preg_replace('/\W/', '', $label) : $atts['name']);

   if (ps('zem_contact_submit')) {
      $email = ps($name);
      if (!preg_match('/^[\w._-]+@([\w-]+\.)+[\w-]+$/', $email))
         $zem_contact_error[] = "'$email' is not a valid email address";
      elseif (preg_match("/@(.+)$/", $email, $match)) {
         $domain = $match[1];
         $mx = 0;
         if (is_callable('getmxrr')) {
            $dummy = array();
            $mx = @getmxrr($domain, $mx);
         }

         if (!$mx and (@gethostbyname($domain) == $domain))
            $zem_contact_error[] = "Domain '$domain' is not a valid email host";
         else
            $zem_contact_from = $email;
      }
      else
         $zem_contact_from = $email;
   }

   return zem_contact_text($atts);
}

function zem_contact_select($atts) {
   global $zem_contact_error, $zem_contact_form;
   $delim = empty($atts['delim']) ? ',' : $atts['delim'];
   $list = empty($atts['list']) ? 'General enquiry' : $atts['list'];
   $selected = empty($atts['selected']) ? '' : $atts['selected'];
   $label = (empty($atts['label']) ? 'Option' : $atts['label']);
   $name = (empty($atts['name']) ? preg_replace('/\W/', '', $label) : $atts['name']);
   $break = (!isset($atts['break']) ? '<br />' : $atts['break']);
   $required = (empty($atts['required']) ? false : true);

   $list = split($delim, $list);
   $list = array_map('trim', $list);

   $v = (ps($name) ? ps(name) : $selected);
   if (ps('zem_contact_submit') and $required and empty($v))
      $zem_contact_error[] = "Required field $label is missing";
   elseif (ps($name) and !in_array($v, $list))
      $zem_contact_error[] = "Unknown $label $v";
   elseif (ps($name))
      $zem_contact_form[$label] = $v;

   $out = '';
   for ($i=0; $i < count($list); $i++) {
      if ($list[$i] == $selected)
         $out .= '<option selected=1>'.$list[$i]."</option>\n";
      else
         $out .= '<option>'.$list[$i]."</option>\n";
   }

   $l = ($required ? "<b>$label</b>" : $label);
   return '<label for="'.$name.'">'.$l.':</label>'.
      $break.
      '<select name="'.$name.'">'.$out.'</select>';
}

function zem_contact_checkbox($atts) {
   global $zem_contact_error, $zem_contact_form;

   $label = (empty($atts['label']) ? 'Checkbox' : $atts['label']);
   $name = (empty($atts['name']) ? preg_replace('/\W/', '', $label) : $atts['name']);
   $break = (!isset($atts['break']) ? '<br />' : $atts['break']);
   $checked = empty($atts['checked']) ? 0 : 1;
   $required = (empty($atts['required']) ? false : true);

   $v = (ps('zem_contact_submit') ? (bool)ps($name) : '');

   if (ps('zem_contact_submit') and $required and empty($v))
      $zem_contact_error[] = "Required field $label is missing";
   elseif (ps('zem_contact_submit'))
      $zem_contact_form[$label] = ($v ? 'Yes' : 'No');

   $l = ($required ? "<b>$label</b>" : $label);
   return '<input type="checkbox" name="'.$name.'"'.
      ($checked ? ' checked="true"' : '').
      '>'.
      '<label for="'.$name.'">'.$l.'</label>'.
      $break;
}

function zem_contact_serverinfo($atts) {
   global $zem_contact_error, $zem_contact_form;

   $name = (empty($atts['name']) ? '' : $atts['name']);
   $label = (empty($atts['label']) ? $name : $atts['label']);

   if ($name and ps('zem_contact_submit'))
      $zem_contact_form[$label] = serverSet($name);
}

function zem_contact_submit($atts) {
   global $zem_contact_nonce, $zem_contact_error;

   $label = (empty($atts['label']) ? 'Send' : $atts['label']);

   if (ps('zem_contact_submit')) {
      $nonce = ps('zem_contact_nonce');
      if (empty($nonce)) {
         $zem_contact_error[] = "Required field nonce is missing";
      }
      else {
         safe_delete("txp_discuss_nonce", "issue_time < date_sub(now(),interval 10 minute)");
         $rs = safe_row("*", "txp_discuss_nonce", "nonce='$nonce' and used='0'");
         if ($rs)
            safe_update("txp_discuss_nonce", "used='1'", "nonce='$nonce'");
         else
            $zem_contact_error[] = "Form expired, please try again.";
      }
   }

   return '<input type="hidden" name="zem_contact_nonce" value="'.$zem_contact_nonce.'" />'.
      '<input type="submit" name="zem_contact_submit" value="'.$label.'" />';
}


čestitam onom kome se ovo dalo čitati Wink
pošto nemam neko znanje programiranja obraćam se mi3 zajednici da mi pomogne. želio bi da kada netko upiše sve šta se treba upisati, klikom na submit skoči na anchor npr #contact. znači htio bi da mi gumb send osim što pošalje sve potrebne podatke ode na
Code:
<a name="contact"></a>
. znam da bi negdje u kodu trebao dodati
Code:
<a href="#contact">nešto</a>
ali problem je u tome što ne znam točno gdje. help?

_________________
Jedan šest | Behance | Vimeo
Back to top
View user's profile Send private message Visit poster's website
ToDD



Joined: 05 May 2005
Posts: 83
Location: Zagreb

PostPosted: 14.03.2006 11:07    Post subject: Add user to your forum ignore list Reply with quote

Code:

if ($showinput)
      $out .= '<form action="'.$_SERVER['REQUEST_URI'].'" method="post">'
         . $f
         . '</form>';

   return $out;



zamijeni sa
Code:

if ($showinput)
      $out .= '<form action="'.$_SERVER['REQUEST_URI'].'#contact" method="post">'
         . $f
         . '</form>';

   return $out;
Back to top
View user's profile Send private message MSN Messenger
jurka



Joined: 26 Aug 2004
Posts: 1088
Location: Zagreb

PostPosted: 14.03.2006 14:54    Post subject: Add user to your forum ignore list Reply with quote

LEGENDO!! puno ti hvala, radi iz prve bez problema!!
imaš pivu, rakiju i ćevape ak se vidimo! Wink

_________________
Jedan šest | Behance | Vimeo
Back to top
View user's profile Send private message Visit poster's website
ToDD



Joined: 05 May 2005
Posts: 83
Location: Zagreb

PostPosted: 14.03.2006 20:32    Post subject: Add user to your forum ignore list Reply with quote

dođi u rudeš/zg Very Happy
gladan sam a i piva bi mi dobro dosla Very Happy
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    mi3dot.org Forum Index -> Server-side All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group