Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Modules
Author Message
adaykin
Regular
Regular



Joined: Sep 26, 2007
Posts: 60

PostPosted: Fri May 23, 2008 8:45 pm Reply with quote

Hey, I have a submit button on the index page of my contact module, so the user can submit information by sending an email. I want the page to be self processing and call itself from the index file of the module, so I have code saying if the server request method is a post, then send the email.
Code:
if($_SERVER['REQUEST_METHOD'] == 'POST')

However when I try to call the page itself, I get a message saying "You can't access this file directly...". I saw this in the top of the module, but when I commented it out I got an error linking back to mainfile.php. Where should I define the MODULE_FILE, and what should I define it as?



Also I am adding AJAX to the module and for the page to look nice I need to make the body start look like
Code:
<body class="tundra";

how would I do this?
 
View user's profile Send private message Visit poster's website
evaders99
Former Moderator in Good Standing



Joined: Apr 30, 2004
Posts: 3221

PostPosted: Fri May 23, 2008 9:02 pm Reply with quote

You will need the form to post in the URL format that Nuke uses

Code:


<form action="modules.php?name=MODULENAME&file=filename" method="post">




For your second one, the BODY tag is usually defined in your theme's theme.php

_________________
- Star Wars Rebellion Network -

Need help? Nuke Patched Core, Coding Services, Webmaster Services 
View user's profile Send private message Visit poster's website
adaykin







PostPosted: Thu May 29, 2008 3:00 pm Reply with quote

I tried calling it that way but I got an error saying:

Sorry, that module file was not found.


Also if I want to import a css style using @import, can I put it in the theme file style.css like:
@import "http://o.aolcdn.com/dojo/1.0/dijit/themes/tundra/tundra.css";
 
fkelly
Former Moderator in Good Standing



Joined: Aug 30, 2005
Posts: 3312
Location: near Albany NY

PostPosted: Thu May 29, 2008 5:57 pm Reply with quote

Check the spelling, including spaces and capitalization of MODULENAME carefully. The statement that Evaders gave you is used throughout RN so it should work but you need to make sure that you have it exactly.

Also I think you want to use the format:

form method="post" name="member" action="modules.php?name=Purchase&amp;file=new_member_info"

for example. My modulename is "Purchase" in that example and I put in &amp; instead of just &.

As to the import, try it and see what happens. However, if you use multiple themes on your site you may need to modify the style.css for all of them.
 
View user's profile Send private message Visit poster's website
adaykin







PostPosted: Thu May 29, 2008 8:29 pm Reply with quote

Ok, so now I have:

Code:


<form action="modules.php?name='.$module_name.'&file=filename" name="member" method="post">


I added the name="member" part

Once I get unbanned from my localhost, or fix my FTP on my website I can test this some more...
 
Guardian2003
Site Admin



Joined: Aug 28, 2003
Posts: 6799
Location: Ha Noi, Viet Nam

PostPosted: Fri May 30, 2008 2:56 am Reply with quote

I have found (for me any way) in utilising additional CSS styles is to either have the styles in the theme style.css, provided they do not conflict with a previously declared style or use an IF test in the custom header file to determine if your module is active $module_name then us the IF test to include a 'relative' style sheet which will then only be active when you are in that module.
If you need code for that I can post some.
 
View user's profile Send private message Send e-mail
adaykin







PostPosted: Tue Jun 03, 2008 5:52 pm Reply with quote

Hmm..I tried changing the file, but didn't get much success. I still get the "Sorry, that module file was not found." message. Here is my code for the index page, hope this helps:

Code:


<script type="text/javascript"> djConfig = { isDebug: true, parseOnLoad: true }; </script>
<script type="text/javascript" src="../../../lib/dojo/dojo.js"></script>
<script type="text/javascript" src="../../../lib/dijit/form/Button.js"></script>   
<script type="text/javascript">
   dojo.require("dijit.form.Button");
   dojo.require("dijit.form.CheckBox");
   dojo.require("dijit.form.ComboBox");
   dojo.require("dijit.form.TextBox");
   dojo.require("dijit.form.Textarea");
   dojo.require("dijit.form._FormWidget");
   dojo.require("dijit.TitlePane");
</script>

<?php
/*********************************************************
 * Contact Module
 * Andy Daykin 2008
 * Module for users to contact the admin
 ********************************************************/

/************************************************************************/
/* PHP-NUKE: Web Portal System                                          */
/* ===========================                                          */
/*                                                                      */
/* Copyright (c) 2002 by Francisco Burzi                                */
/* http://phpnuke.org                                                   */
/*                                                                      */
/* Based on Journey Links Hack                                          */
/* Copyright (c) 2000 by James Knickelbein                              */
/* Journey Milwaukee (http://www.journeymilwaukee.com)                  */
/*                                                                      */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License.       */
/*                                                                      */
/************************************************************************/
/*         Additional security & Abstraction layer conversion           */
/*                           2003 chatserv                              */
/*      http://www.nukefixes.com -- http://www.nukeresources.com        */
/************************************************************************/

if (!defined('MODULE_FILE')) die('You can\'t access this file directly...');
if (isset($min)) $min = intval($min);
if (isset($show)) $show = intval($show);
require_once('mainfile.php');
$module_name = basename(dirname(__FILE__));
get_lang($module_name);
$pagetitle = '- '._CONTACT;
define('INDEX_FILE', true);

if (!(isset($d_op))) $d_op = '';
if (!(isset($min)))  $min = 0;
if (!(isset($orderby))) $orderby = '';
if (!(isset($show))) $show = '';

switch($d_op) {
    default:
    index();
    break;

    case 'AddDownload':
    AddDownload();
    break;
}
die();

function index() {
    global $prefix, $db, $show_links_num, $module_name;
    include_once('header.php');
   OpenTable();
    /*****************************************************
    * Start the content section to be displayed specifc
    * for this module
    * **************************************************/
   echo'
   <br />
   <p style="text-align: center;">
   Please fill out the form below to receive a free quote. Fill out the form with as much detail as possible
   so I can provide you with an accurate estimate. I will contact you by phone or email within 1-2 business days.
   BTW Module name is '.$module_name .'
   </p>
   <br />
   <br />
   <form action="modules.php?name='.$module_name.' name="member" method="post">
   <table align="center" summary = "Contact Info1" width= "70%" cellspacing = "2" cellpadding="5">
    <tr>
     <td bgcolor = "#A7DFC4" width="20%">
     *Services
     </td>
     <td bgcolor = "#008000" width = "15%" align = "center">
     <select name="services"
        dojoType="dijit.form.ComboBox"
       autocomplete="false"
       <option value="Web Design" selected="selected">Web Design</option>
       <option value="Web Programming">Web Programming</option>
       <option value="Web Graphics">Web Graphics</option>
       <option value="Page Layout">Page Layout</option>
      <option value="Other">Other</option>
      </select>
     </td>
    </tr>
    <tr>
     <td bgcolor = "#A7DFC4" width = "20%">
     How many pages do you need?
     </td>
     <td Style = "color: white;" bgcolor = "#008000" width = "15%" align = "center">
     <p>
     <label for="pages1">1 - 8</label>
     <input dojoType="dijit.form.RadioButton" type="radio" name="pages" id="pages1" value="1-8" checked="checked"/>
     <label for="pages2">8 - 20</label>
     <input dojoType="dijit.form.RadioButton" type="radio" name="pages" id="pages2" value="8-20" />
     </p>
     <p>
     <label for="pages3">20 - 40</label>
     <input dojoType="dijit.form.RadioButton" type="radio" name="pages" id="pages3" value="20-40" />
     <label for="pages4">40+</label>
     <input dojoType="dijit.form.RadioButton" type="radio" name="pages" id="pages4" value="40+" />
     </p>
     </td>
    </tr>
    <tr>
     <td bgcolor = "#A7DFC4" width = "20%">
     Do you plan to update the content yourself?
     </td>
     <td Style="color: white;" bgcolor="#008000" width="15%" align="center">
     <label for="updates1">Yes</label>
     <input dojoType="dijit.form.RadioButton" type="radio" name="updates" id="updates1" value="Yes" checked="checked" />
     <label for="updates2">No</label>
     <input dojoType="dijit.form.RadioButton" type="radio" name="updates" id="updates2" value="No" />
     <label for="updates3">Not Sure</label>
     <input dojoType="dijit.form.RadioButton" type="radio" name="updates" id="updates3" value="Not Sure" />
     </td>
    </tr>
    <tr>
     <td bgcolor="#A7DFC4" width="25%">
     *Your Name
     </td>
     <td bgcolor="#008000" width="15%" align="center">
     <input dojoType="dijit.form.TextBox" name="name" maxlength="35"/>
     </td>
    </tr>
    <tr>
     <td bgcolor="#A7DFC4" width="25%">
     Location
     </td>
     <td bgcolor="#008000" width="15%" align="center">
     <input dojoType="dijit.form.TextBox" name="location" maxlength="35"/>
     </td>
    </tr>
    <tr>
     <td bgcolor = "#A7DFC4" width = "25%">
     Phone
     </td>
     <td bgcolor = "#008000" width = "15%" align = "center">
     <input dojoType="dijit.form.TextBox" name = "phone" />
     </td>
    </tr> 
    <tr>
     <td bgcolor = "#A7DFC4" width = "25%">
     *Email
     </td>
     <td bgcolor="#008000" width="15%" align="center">
     <input dojoType="dijit.form.TextBox" name="email" />
     </td>
    </tr>
    <tr>
     <td bgcolor = "#A7DFC4" width="25%">
     Additional Comments
     </td>
     <td bgcolor = "#008000" width="15%" align="center">
     <textarea dojoType="dijit.form.Textarea" name="comments" style="width:300px" style="height:300px">
     </textarea>
     </td>
    </tr>
    <tr>
     <td>&nbsp;</td>
    </tr>
    <tr>
     <td><button type="submit" dojoType="dijit.form.Button">Submit</button></td>
    </tr>
    <tr>
     <td>&nbsp;</td>
    </tr>
    <tr>
     <td>* Denotes required field</td>
    </tr>
   </table>
   </form>
   ';
    CloseTable();
    include_once('footer.php');
}




// Determine whether the services selections were valid or not
// Generating the menu, then validate it
if($_SERVER['REQUEST_METHOD'] == 'POST')
{
    global $prefix, $db, $show_links_num, $module_name;
    include_once('header.php');
   OpenTable();   
   $choices = array('Web Design', 'Web Programming', 'Web Graphics', 'Page Layouts', 'Other');
   if(! in_array($_POST['services'], $choices))
   {
         print "You must select a valid choice. \n";
   }
   
   // Determine whether the name was entered or not
   // Set the name equal to the name form, then validate the name
   $name = $_POST['name'];
   if(! $name)
   {
      print "You must enter a name. \n";
   }
   
   // Run tests on email address
   $email = $_POST['email'];
   function isValidEmailAddress($email)
   {
      $qtext = '[^\\x0d\\x22\\x5c\\x80-\\xff]';
       $dtext = '[^\\x0d\\x5b-\\x5d\\x80-\\xff]';
       $atom = '[^\\x00-\\x20\\x22\\x28\\x29\\x2c\\x2e\\x3a-\\x3c'.
               '\\x3e\\x40\\x5b-\\x5d\\x7f-\\xff]+';
       $quoted_pair = '\\x5c[\\x00-\\x7f]';
       $domain_literal = "\\x5b($dtext|$quoted_pair)*\\x5d";
       $quoted_string = "\\x22($qtext|$quoted_pair)*\\x22";
       $domain_ref = $atom;
       $sub_domain = "($domain_ref|$domain_literal)";
       $word = "($atom|$quoted_string)";
       $domain = "$sub_domain(\\x2e$sub_domain)*";
       $local_part = "$word(\\x2e$word)*";
       $addr_spec = "$local_part\\x40$domain";
       return preg_match("!^$addr_spec$!", $email) ? 1 : 0;
   }
   
   // Check and see if email address is valid or not
   if(! isValidEmailAddress($email))
   {
       print "Sorry, that email address is invalid. Please try again. \n";
   }
   
   // If everything is valid, send the email
   if(isValidEmailAddress($email) && $name && in_array($_POST['services'], $choices))
   {
      // Send Email
      print "We reached the email section";
      $to = "daykinandy@gmail.com";
      $subject = "Customer Inquiry";
      $body = "Hello my name is $name \n" .
            "My email is $email \n" .
            "The services selected are " . $_POST['services']. "\n" .
            "I need " . $_POST['pages'] . "\n" .
            $_POST['update'] . " for updating the page" . "\n" .
            "I am from " . $_POST['location'] . "\n" .
            "My phone number is " . $_POST['phone'] . "\n" .
            $_POST['comments'];
      mail($to, $subject, $body);
   }
    CloseTable();
    include_once('footer.php');   
}
?>

 
evaders99







PostPosted: Tue Jun 03, 2008 8:47 pm Reply with quote

Two things

First, your syntax seems to be missing here

Quote:

<form action="modules.php?name='.$module_name.'" name="member" method="post">


Second, your code will never reach the second half to process anything in and below
Code:


if($_SERVER['REQUEST_METHOD'] == 'POST')


It will always stop at the switch and run index() since d_op is never declared
Code:


switch($d_op) {
    default:
    index();
    break;
 
adaykin







PostPosted: Tue Jun 03, 2008 10:05 pm Reply with quote

Hey, thanks for the response. What I don't get is how do I define the different cases, i.e. how do I define it so that each case can get called? I changed my code so that the if($_SERVER['REQUEST_METHOD'] == 'POST') is now a function name, and tried defining it in the switch statement, however when I tried running the module I got the same message as before.

Code:



if (!defined('MODULE_FILE')) die('You can\'t access this file directly...');
if (isset($min)) $min = intval($min);
if (isset($show)) $show = intval($show);
require_once('mainfile.php');
$module_name = basename(dirname(__FILE__));
get_lang($module_name);
$pagetitle = '- '._CONTACT;
define('INDEX_FILE', true);

if (!(isset($d_op))) $d_op = '';
if (!(isset($min)))  $min = 0;
if (!(isset($orderby))) $orderby = '';
if (!(isset($show))) $show = '';

switch($d_op) {
    default:
    index();
    break;

    case 'checkMail':
    checkMail();
    break;
}
die();

function index() {
    global $prefix, $db, $show_links_num, $module_name;
    include_once('header.php');
   OpenTable();
    /*****************************************************
    * Start the content section to be displayed specifc
    * for this module
    * **************************************************/
   echo'
   <br />
   <p style="text-align: center;">
   Please fill out the form below to receive a free quote. Fill out the form with as much detail as possible
   so I can provide you with an accurate estimate. I will contact you by phone or email within 1-2 business days.
   </p>
   <br />
   <br />
   <form action="modules.php?name='.$module_name.'&amp;d_op=checkMail" name="member" method="post">
   <table align="center" summary = "Contact Info1" width= "70%" cellspacing = "2" cellpadding="5">
    <tr>
     <td bgcolor = "#A7DFC4" width="20%">
     *Services
     </td>
     <td bgcolor = "#008000" width = "15%" align = "center">
     <select name="services"
        dojoType="dijit.form.ComboBox"
       autocomplete="false"
       <option value="Web Design" selected="selected">Web Design</option>
       <option value="Web Programming">Web Programming</option>
       <option value="Web Graphics">Web Graphics</option>
       <option value="Page Layout">Page Layout</option>
      <option value="Other">Other</option>
      </select>
     </td>
    </tr>
    <tr>
     <td bgcolor = "#A7DFC4" width = "20%">
     How many pages do you need?
     </td>
     <td Style = "color: white;" bgcolor = "#008000" width = "15%" align = "center">
     <p>
     <label for="pages1">1 - 8</label>
     <input dojoType="dijit.form.RadioButton" type="radio" name="pages" id="pages1" value="1-8" checked="checked"/>
     <label for="pages2">8 - 20</label>
     <input dojoType="dijit.form.RadioButton" type="radio" name="pages" id="pages2" value="8-20" />
     </p>
     <p>
     <label for="pages3">20 - 40</label>
     <input dojoType="dijit.form.RadioButton" type="radio" name="pages" id="pages3" value="20-40" />
     <label for="pages4">40+</label>
     <input dojoType="dijit.form.RadioButton" type="radio" name="pages" id="pages4" value="40+" />
     </p>
     </td>
    </tr>
    <tr>
     <td bgcolor = "#A7DFC4" width = "20%">
     Do you plan to update the content yourself?
     </td>
     <td Style="color: white;" bgcolor="#008000" width="15%" align="center">
     <label for="updates1">Yes</label>
     <input dojoType="dijit.form.RadioButton" type="radio" name="updates" id="updates1" value="Yes" checked="checked" />
     <label for="updates2">No</label>
     <input dojoType="dijit.form.RadioButton" type="radio" name="updates" id="updates2" value="No" />
     <label for="updates3">Not Sure</label>
     <input dojoType="dijit.form.RadioButton" type="radio" name="updates" id="updates3" value="Not Sure" />
     </td>
    </tr>
    <tr>
     <td bgcolor="#A7DFC4" width="25%">
     *Your Name
     </td>
     <td bgcolor="#008000" width="15%" align="center">
     <input dojoType="dijit.form.TextBox" name="name" maxlength="35"/>
     </td>
    </tr>
    <tr>
     <td bgcolor="#A7DFC4" width="25%">
     Location
     </td>
     <td bgcolor="#008000" width="15%" align="center">
     <input dojoType="dijit.form.TextBox" name="location" maxlength="35"/>
     </td>
    </tr>
    <tr>
     <td bgcolor = "#A7DFC4" width = "25%">
     Phone
     </td>
     <td bgcolor = "#008000" width = "15%" align = "center">
     <input dojoType="dijit.form.TextBox" name = "phone" />
     </td>
    </tr> 
    <tr>
     <td bgcolor = "#A7DFC4" width = "25%">
     *Email
     </td>
     <td bgcolor="#008000" width="15%" align="center">
     <input dojoType="dijit.form.TextBox" name="email" />
     </td>
    </tr>
    <tr>
     <td bgcolor = "#A7DFC4" width="25%">
     Additional Comments
     </td>
     <td bgcolor = "#008000" width="15%" align="center">
     <textarea dojoType="dijit.form.Textarea" name="comments" style="width:300px" style="height:300px">
     </textarea>
     </td>
    </tr>
    <tr>
     <td>&nbsp;</td>
    </tr>
    <tr>
     <td><button type="submit" dojoType="dijit.form.Button">Submit</button></td>
    </tr>
    <tr>
     <td>&nbsp;</td>
    </tr>
    <tr>
     <td>* Denotes required field</td>
    </tr>
   </table>
   </form>
   ';
    CloseTable();
    include_once('footer.php');
}




// Determine whether the services selections were valid or not
// Generating the menu, then validate it
function checkMail()
{
    global $prefix, $db, $show_links_num, $module_name;
    include_once('header.php');
   OpenTable();   
   $choices = array('Web Design', 'Web Programming', 'Web Graphics', 'Page Layouts', 'Other');
   if(! in_array($_POST['services'], $choices))
   {
         print "You must select a valid choice. \n";
   }
   
   // Determine whether the name was entered or not
   // Set the name equal to the name form, then validate the name
   $name = $_POST['name'];
   if(! $name)
   {
      print "You must enter a name. \n";
   }
   
   // Run tests on email address
   $email = $_POST['email'];
   function isValidEmailAddress($email)
   {
      $qtext = '[^\\x0d\\x22\\x5c\\x80-\\xff]';
       $dtext = '[^\\x0d\\x5b-\\x5d\\x80-\\xff]';
       $atom = '[^\\x00-\\x20\\x22\\x28\\x29\\x2c\\x2e\\x3a-\\x3c'.
               '\\x3e\\x40\\x5b-\\x5d\\x7f-\\xff]+';
       $quoted_pair = '\\x5c[\\x00-\\x7f]';
       $domain_literal = "\\x5b($dtext|$quoted_pair)*\\x5d";
       $quoted_string = "\\x22($qtext|$quoted_pair)*\\x22";
       $domain_ref = $atom;
       $sub_domain = "($domain_ref|$domain_literal)";
       $word = "($atom|$quoted_string)";
       $domain = "$sub_domain(\\x2e$sub_domain)*";
       $local_part = "$word(\\x2e$word)*";
       $addr_spec = "$local_part\\x40$domain";
       return preg_match("!^$addr_spec$!", $email) ? 1 : 0;
   }
   
   // Check and see if email address is valid or not
   if(! isValidEmailAddress($email))
   {
       print "Sorry, that email address is invalid. Please try again. \n";
   }
   
   // If everything is valid, send the email
   if(isValidEmailAddress($email) && $name && in_array($_POST['services'], $choices))
   {
      // Send Email
      print "We reached the email section";
      $to = "daykinandy@gmail.com";
      $subject = "Customer Inquiry";
      $body = "Hello my name is $name \n" .
            "My email is $email \n" .
            "The services selected are " . $_POST['services']. "\n" .
            "I need " . $_POST['pages'] . "\n" .
            $_POST['update'] . " for updating the page" . "\n" .
            "I am from " . $_POST['location'] . "\n" .
            "My phone number is " . $_POST['phone'] . "\n" .
            $_POST['comments'];
      mail($to, $subject, $body);
   }
    CloseTable();
    include_once('footer.php');   
}
?>
 
evaders99







PostPosted: Tue Jun 03, 2008 11:44 pm Reply with quote

Here's a question:
Is MODULE_NAME defined in modules.php?

What version of phpNuke are you using? Is it Patched or RavenNuke?
 
adaykin







PostPosted: Wed Jun 04, 2008 7:37 pm Reply with quote

I'm using RavenNuke 2.20.01. I don't see MODULE_NAME in modules.php anywhere, I didn't modify the file either. Should it be in there?
 
evaders99







PostPosted: Thu Jun 05, 2008 12:03 am Reply with quote

You should definitely have this line in the beginning of modules.php
Code:


define('MODULE_FILE', true);


If not, you may have replaced this file with an older one.
 
adaykin







PostPosted: Thu Jun 05, 2008 10:18 am Reply with quote

Ok I added that line, I'm still getting the same error as before. Do I need to have it defined somewhere besides the lang-english files in my Contact directory?
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Modules

View next topic
View previous topic
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
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©