Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problem to edit a page
#8
Strange. I just went back to the unmodified plugin, then modded one part at a time and now it works.

Thanks for your help.

I wonder if there is anything different in the code now:

Code:
<?php
/*
Name: Simple Cumbe contact form
Description: Pues eso es un formulario de contacto simple
Version: 4.0
Author: Cumbe
Author URI: http://
*/

// Relative
$relative = '../';
$path = $relative. 'data/other/';

# get correct id for plugin
$thisfile=basename(__FILE__, ".php");

# register plugin
register_plugin(
    $thisfile,
    'Cumbe_contact',
    '3.0',
    'Cumbe',
    'http://',
    'Description:  Getsimple contactform',
    'plugins', //page type
    'vermensajes'
);

//set internationalization
                //$VIEWMESSAGE = 'Ver mensajes recibidos';
                $VIEWMESSAGE = 'View contactform.log';

//añadimos a sidebar de pestaña plugins
add_action('plugins-sidebar','createSideMenu',array('contact_form',$VIEWMESSAGE));

////////////////////////////////////////////////
////////////////////////////////////////////////
////////////////////////////////////////////////

function vermensajes(){
global $i18n;

$log_name = 'contactform.log';
$log_path = GSDATAOTHERPATH.'logs/';
$log_file = $log_path . $log_name;

if(file_exists($log_file)) {
    $log_data = getXML($log_file);
    if (@$_GET['action'] == 'delete' && strlen($log_name)>0) {
        unlink($log_file);
        exec_action('logfile_delete');
?>
        <label>Log <?php echo $log_name;?> <?php echo $i18n['MSG_HAS_BEEN_CLR']; ?>            
                </div>
        </div>
        <div id="sidebar" >
            <?php include('template/sidebar-plugins.php'); ?>
        </div>    
        <div class="clear"></div>
        </div>
        <?php get_template('footer'); ?>
<?php
                exit;
    }
?>

            <label><?php echo $i18n['VIEWING'];?>&nbsp;<?php echo $i18n['LOG_FILE'];?>: &lsquo;<em><?php echo @$log_name; ?></em>&rsquo;</label>
            <div class="edit-nav" >
                <a href="load.php?id=contact_form&action=delete" accesskey="c" title="<?php echo $i18n['CLEAR_ALL_DATA'];?> <?php echo $log_name; ?>?" /><?php echo $i18n['CLEAR_THIS_LOG'];?></a>
                <div class="clear"></div>
            </div>
            <ol class="more" >
                <?php
                $count = 1;

                foreach ($log_data as $log) {
                    echo '<li><p style="font-size:11px;line-height:15px;" ><b style="line-height:20px;" >'.$i18n['LOG_FILE_ENTRY'].'</b><br />';
                    foreach($log->children() as $child) {
                      $name = $child->getName();
                      echo '<b>'. stripslashes(ucwords($name)) .'</b>: ';
                      
                      $d = $log->$name;
                      $n = strtolower($child->getName());
                      $ip_regex = '/^(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:[.](?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}$/';
                      $url_regex = @"((https?|ftp|gopher|telnet|file|notes|ms-help):((//)|(\\\\))+[\w\d:#@%/;$()~_?\+-=\\\.&]*)";
                      
                      
                      //check if its an url address
                      if (do_reg($d, $url_regex)) {
                          $d = '<a href="'. $d .'" target="_blank" >'.$d.'</a>';
                      }
                      
                      //check if its an ip address
                      if (do_reg($d, $ip_regex)) {
                          if ($d == $_SERVER['REMOTE_ADDR']) {
                              $d = $i18n['THIS_COMPUTER'].' (<a href="http://www.geobytes.com/IpLocator.htm?GetLocation&IpAddress='. $d.'" target="_blank" >'.$d.'</a>)';
                          } else {
                              $d = '<a href="http://www.geobytes.com/IpLocator.htm?GetLocation&IpAddress='. $d.'" target="_blank" >'.$d.'</a>';
                          }
                      }
                      
                      //check if its an email address
                      if (check_email_address($d)) {
                          $d = '<a href="mailto:'.$d.'">'.$d.'</a>';
                      }
                      
                      //check if its a date
                      if ($n === 'date') {
                          $d = lngDate($d);
                      }
                          
                      echo stripslashes($d);
                      echo ' <br />';
                    }
                    echo "</p></li>";
                    $count++;
                }                
                
                ?>
            </ol>
        
<?php
}
else{   //If file does not exist
?>
            <label><?php echo $i18n['MISSING_FILE']; ?>: &lsquo;<em><?php echo @$log_name; ?></em>&rsquo;</label>
<?php
}

}

////////////////////////////////////////////////
////////////////////////////////////////////////
////////////////////////////////////////////////

function set_contact_page() {
global $EMAIL;
global $SITEURL;

if (file_exists('gsconfig.php')) {
    include_once('gsconfig.php');
}

// Debugging
if (defined('GSDEBUG')){
    error_reporting(E_ALL | E_STRICT);
    ini_set('display_errors', 1);
} else {
    error_reporting(0);
    @ini_set('display_errors', 0);
}
    
    $err = '';
    
if (file_exists(GSDATAOTHERPATH.'website.xml')) {
        $dataw = getXML(GSDATAOTHERPATH.'website.xml');
        $TIMEZONE = $dataw->TIMEZONE;
}

        //Set Internationalization  
        //Traducción al español. Descomentar las siguientes líneas y comentar la traducción al inglés
        /*        
        $MSG_CONTACTERR = 'Hubo un error enviando su correo electrónico';
                $MSG_CAPTCHA_FAILED = 'Fallo en el Captcha, creemos que usted puede ser un robot de spam';
        $CONTACT_FORM_SUB = 'Envío de Formulario de Contacto';
        $WHO = 'de';
        $MSG_CONTACTSUC = 'Su mensaje ha sido enviado, gracias.';
        */
        
        //Translate to english                
        $MSG_CAPTCHA_FAILED = 'Captcha failed, we think you are a spam bot';
        $CONTACT_FORM_SUB = 'Contact Form Submission';
        $WHO = 'from';
               $MSG_CONTACTSUC = 'Your email has successfully been sent, thank you.';
        $MSG_CONTACTERR = 'There was an error sending your message. Please check your details';
                

        //translate words show in page
        $Nb = 'Name:&nbsp;';    //Name
        $Em = 'Email:&nbsp;';
        $Tm = 'Subject:&nbsp;';      //Subject, Tema
        $Ms = 'Message:';   //Message
        $Ev = 'Send message'; //Send message    


    if( function_exists('date_default_timezone_set') ) {
        date_default_timezone_set(@$TIMEZONE);
    }
    
    if (file_exists(GSDATAOTHERPATH.'user.xml')) {
        $data = getXML(GSDATAOTHERPATH.'user.xml');
        $EMAIL = $data->EMAIL;
    }
    
    if (isset($_POST['contact-submit'])) {


              $pot = file_get_contents(GSDATAUPLOADPATH.'string.txt');
             if ( $pot == strtolower($_POST['contact']['pot']) ) {
                  $captcha = $_POST['contact']['pot'];
             }
             else {
              $err .= "\n". $MSG_CAPTCHA_FAILED;
         }

         if ( $_POST['contact']['email'] != '' ) {
            $from = $_POST['contact']['email'];
        } else {
            $from = 'no-reply@get-simple.info';
         }          

         if ( $_POST['contact']['tema'] != '' ) {
            $subject = $_POST['contact']['tema'];
        } else {
            $subject = $CONTACT_FORM_SUB;
         }

        if ($err == '' && trim($_POST['contact']['email']) !='' && trim($_POST['contact']['Mensaje']) !='') {

            $server_name = getenv ("SERVER_NAME");       // Server Name
            $request_uri = getenv ("REQUEST_URI");       // Requested URI

            $headers = "From: ".$from."\r\n";
            $headers .= "Return-Path: ".$from."\r\n";
            $headers .= "Content-type: text/html\r\n";

            $temp = $_POST['contact'];
            $captcha = $_POST['contact']['pot'];

            unset($temp['pot']);
            unset($temp['contact-submit']);
            unset($temp['submit']);

            $body = $CONTACT_FORM_SUB.' '.$WHO.' http://'.$server_name.$request_uri.' <br />';
            $body .= "-----------------------------------<br /><br />";

            $xmlfile = "data/other/logs/contactform.log";
            if ( ! file_exists($xmlfile) ) {
                            $xml = new SimpleXMLExtended('<channel></channel>');
            } else
            {
                $xmldata = file_get_contents($xmlfile);
                        $xml = new SimpleXMLExtended($xmldata);
            }

            $thislog = $xml->addChild('entry');
            $thislog->addChild('date', date('r'));
            $cdata = $thislog->addChild('from');
            $cdata->addCData($from);
            $cdata = $thislog->addChild('subject');
            $cdata->addCData(htmlentities($subject, ENT_QUOTES, 'UTF-8'));
            $cdata = $thislog->addChild('captcha');
            $cdata->addCData($captcha);
            $cdata = $thislog->addChild('ip_address');
            $ip = getenv("REMOTE_ADDR");
            $cdata->addCData(htmlentities($ip, ENT_QUOTES, 'UTF-8'));
            $body .= "Ip: ". $ip ."<br />";
            foreach ( $temp as $key => $value ) {
                $body .= ucfirst($key) .": ". $value ."<br />";
                $cdata = $thislog->addChild(clean_url($key));
                $cdata->addCData(htmlentities($value, ENT_QUOTES, 'UTF-8'));
            }
            $result = mail($EMAIL,$subject,$body,$headers);

            XMLsave($xml, $xmlfile);

//results
            if ($result=='1') {
                echo '<p class="contactmsg success">'.$MSG_CONTACTSUC.'<br /><br /></p>';
            } else {
                echo '<p class="contactmsg error">'.$MSG_CONTACTERR.'</p>';
            }
        } else {
             if (trim($err) !=''){
            echo '<p class="contactmsg error">'.$err.'.<br />Captcha code: '.$pot.'<br / >Code wrote: '.$_POST['contact']['pot'].'</p>';
             }
                 else {
                    echo '<font color="red">*** Required fields empty ***</font>';
             }
        }

    }


//Show in page  
?>    
        <form action="index.php?id=<?php get_page_slug(); ?>" method="post">
            <p style="margin-bottom: 6px;"><label><?php echo $Nb; ?></label>
              <br />
        <input style="margin-left:2px; width: 400px;" type="text" class="text" name="contact[nombre]" /></p>
            <p style="margin-bottom: 6px;">
          <label><?php echo $Em; ?><br />
</label><input style="margin-left:2px; width: 400px;" type="text" class="text" name="contact[email]" /></p>
                        <p style="margin-bottom: 6px;"><label><?php echo $Tm; ?><br />
        </label><input style="margin-left:2px; width: 400px;" type="text" class="text" name="contact[tema]" cols="60" /></p>
            <p style="margin-bottom: 6px;">
          <label><?php echo $Ms; ?><br />
        </label><br /><textarea class="text" name="contact[Mensaje]" rows="7" cols="70"></textarea></p>
            <p><label>CAPTCHA Code</label>
            :
                        <br />
                        <?php imgCtf_cp(); ?>
                        <img src= "<?php echo $SITEURL; ?>data/uploads/string.png" /><br />
<input class="text" type="text" style="width: 130px;" value="" name="contact[pot]" />
            </p>
            <p><input type="submit" class="submit" value="<?php echo $Ev; ?>" id="contact-submit" name="contact-submit" /></p>  
               </form>
<?php
}
function imgCtf_cp(){
    function randomText($length) {
        $key = '';
        $cadena = "123456789ABCDEFGHIJKLMNPQRSTUVWXYZ";
        for($i=0;$i<$length;$i++) {
          $key .= $cadena{rand(0,33)}.' ';
        }
        return $key;
         }

    $pot = randomText(4);
        $im = imagecreate(100, 30);
        // Colors
        $rojo = imagecolorallocate($im, 131, 131, 131);
    $blanco = imagecolorallocate($im, 255, 255, 255);
        $gris = imagecolorallocate($im, 128, 128, 128);
        $negro = imagecolorallocate($im, 0, 0, 0);
        // Dibujar la imagen
    imagefilledrectangle($im, 0, 0, 164, 29, $rojo);
        imagestring($im,  6, 20, 11, $pot, $negro);
    imagestring($im,  6, 16, 5, $pot, $blanco);
    //if you want to difficult more the captcha discomment the next line.
        //imageline($im, 10, 25, 155, 25, $blanco);
        // Guardar la imagen
        imagepng($im, GSDATAUPLOADPATH.'string.png');
        imagedestroy($im);
        //guardar el texto
        $str_txt = fopen(GSDATAUPLOADPATH.'string.txt', 'w');
        fwrite($str_txt, str_replace(' ','',trim(strtolower($pot))));
        fclose ($str_txt);
    }


?>
Reply


Messages In This Thread
Problem to edit a page - by ronsandova - 2010-06-01, 16:14:20
Problem to edit a page - by Zegnåt - 2010-06-01, 21:46:59
Problem to edit a page - by James - 2010-09-30, 00:42:01
Problem to edit a page - by ccagle8 - 2010-09-30, 01:11:40
Problem to edit a page - by James - 2010-09-30, 01:43:03
Problem to edit a page - by cumbe - 2010-09-30, 02:11:49
Problem to edit a page - by cumbe - 2010-09-30, 02:25:21
Problem to edit a page - by James - 2010-09-30, 02:43:00
Problem to edit a page - by cumbe - 2010-09-30, 03:01:02
Problem to edit a page - by pharqall - 2010-10-04, 08:56:18
Problem to edit a page - by cumbe - 2010-10-05, 20:06:10
Problem to edit a page - by fulnestio - 2010-10-09, 21:22:00
Problem to edit a page - by Zegnåt - 2010-10-11, 21:40:26
Problem to edit a page - by wakh - 2011-03-07, 23:38:13



Users browsing this thread: 1 Guest(s)