dr4g 25 Junior Poster

Hi there.
All mail sent through the SMTP server, i need to modify the message being sent through.
I already have a PHP script to send MIME emails with embedded images for HTML meails. However this can be re-created in C,bash,perl.
What i need is a script to modify the message being sent to SMTP and return it to SMTP, or stop the SMTP process, and do all the sending from my script.

Purpose of this is to have a pre-defined HTML template, and when users send plain text through, to wrap the HTML template around that.

Maybe i'm going about it all wrong, so i thought i'd get some feedback from someone.

Thanks.

dr4g 25 Junior Poster

Hi there.
All mail sent through the SMTP server, i need to modify the message being sent through.
I already have a PHP script to send MIME emails with embedded images for HTML meails. What i need is a script to modify the message being sent to SMTP and return it to SMTP, or stop the SMTP process, and do all the sending from my script.

Purpose of this is to have a pre-defined HTML template, and when users send plain text through, to wrap the HTML template around that.

Maybe i'm going about it all wrong, so i thought i'd get some feedback from someone.

Thanks.

dr4g 25 Junior Poster

Hi there.
All mail sent through the SMTP server, i need to modify the message being sent through.
I thought of making either a C,bash,perl script to take in the message, modify it and return it to SMTP, or stop the SMTP process, and re-call it from the script.

Purpose of this is to have a pre-defined HTML template, and when users send plain text through, to wrap the HTML template around that.

It would be preferred to have my own file set up the HTML headers and for HTML, and do the sending through that. However killing the initial SMTP process that called the script in the first place.

Maybe i'm going about it all wrong, so i thought i'd get some feedback from someone.

Thanks.

dr4g 25 Junior Poster

Your Database information is incorrect
In order to connect you will need to have the valid information for;

DB Name
DB Username
DB Userpass
DB Host

One of these is incorrect.

dr4g 25 Junior Poster

What you want to do, is create a global space for your site,
and depending on which action your performing, include the appropriate class and content pages.

What i do is make a module (eg: for handling all User operations).
which then includes the content.

I have attached an image to help explain how to do things in OOP.
It's merley an example there are 101 ways to skin a cat. just your preference really.

Cheers.

dr4g 25 Junior Poster

You are running PHP on an operating system, which one is it ?

dr4g 25 Junior Poster

Do you want to create the class using DB information?

Or get DB information when creating the class ?

Just clarifying before i answer your question

dr4g 25 Junior Poster

Are you running PHP on windows or linux?

dr4g 25 Junior Poster

You wouldnt really create the object of Animal in its own class unless you really need to.

After creating the class and all its methods.

You just need to do.

include_once("dir/clsAnimal.php");

$dog = new Animal("dog", "Woof!");
$noise = $dog->noise();
echo $noise;

NOTE: Within your class your instance variables '$noise' and '$name' you should declare them specifying the type of variable it is.

Being 'public' 'protected' or 'private'.
eg:
public $noise; 
public $name;

code is fine, but you generally include the class then create an object out of it.

Cheers.

dr4g 25 Junior Poster

Again, you need to validate your mail() command. By using @ or IF.

dr4g 25 Junior Poster

Golffor1, without going into your code too much, ihave noticed your using row[0] and row[1].

However in your SQL query you're only selecting 1 field, therefore you will only have row[0]

Cheers

dr4g 25 Junior Poster

>$sql = "SELECT `policy` AS 'policy' FROM `Premiums` where ID < 10";

This statement just doesn't make any sense in terms of SQL. And you got some strange (non standard ) apostrophe's there as well.

Iamthwee, what are you talking about ? the back ticks `` denote a field name or table name within mySQL proper syntax.

PHP fills these in for you if you don't use them.

iamthwee commented: yes +13
dr4g 25 Junior Poster

aasgar. Your problem is when you do an explode() on the $even_time your seperator is "." but there are no dots in 13:00 it should be
exlode(":", $event_time);

Fix that, and it should work for you.

Cheers.

dr4g 25 Junior Poster

I'm not aware of any scripts to do this.

You're looking to create your text file.
Create a socket to your FTP server.
Send the appropriate FTP commands to Login + change DIR + upload file.

Then you will want to use actionscript to
grab the file contents from FTP server, and display them.

Thats one solution to your problem.

Cheers.

dr4g 25 Junior Poster

A better solution for yourself would be just to mask the bad words (unless you really don't want to send the email).

Just do a preg_replace of *@!>&^ (or however many characters are in the badword).

Nothing much wrong with your code though, just a few logic changes might benefit yourself.

You are not validating your mail() function either. I suggest wrapping it in an IF statement or use the @ character eg: @mail(..);

Cheers

dr4g 25 Junior Poster

Taking the 'if' statement away from the mail functions worked :-)

The mail() function returns TRUE or FALSE upon sendin the email.
In order for you to write a decent script, you will have to verify that this mail was sent corrently.

Therefore you will need to wrap your mail() in an IF statement.
Otherwise your just firing an email out there and not getting any response back that it was successfull.

You can also do this to catch error messages instead of doing an if()

@mail(..);

The @ symbol would be an alternative to using the IF statement

dr4g 25 Junior Poster

Every page in the system is grabbed into index.php.
For each page i'd like the title to change according to the page it's on, this can be set manually within each page we want to send.

My question is what would be the most effective method of updating the title each time a new page is viewed.

eg: $common->setTitle($title);

Is what i have in mind, but how would index.php know what the current title is so it can do '<title><?php echo getTitle(); ?>' or something along those lines.

Thanks in Advance.
Drag

dr4g 25 Junior Poster

The following is the necessary code to store, check that no info was empty and email the user.
You will need to change the $to variable to suit your needs.
You will also need to make <input name="form_from"> for the Text Box that stores the users email address
And the same need applied to the subject and message input boxes.

<?php
if(isset($_POST['your_submit_button_name_here'])) {


    $from = $_POST['form_from'];
    $subject = $_POST['form_message'];
    $message = $_POST['form_subject'];

    if(strlen($from) > 0 AND strlen($subject) > 0 AND strlen($message) > 0) {
        if(emailUser($from, $subject, $message))
            echo "Email Sent";
        else
            echo "Email Not Sent";
    }


    function emailUser ($from, $subject, $message) {
    
        $to = 'you@youremail.com';            
        $headers = "From: " . $from . "\r\n" . 'X-Mailer: PHP/' . phpversion();
        return mail ($to, $subject, $message, $headers);
    }

} else {
?>


<!-- Do your HTML Here -->



<?php
}
?>

Cheers.
Enjoy.

dr4g 25 Junior Poster

You can execute PHP in any part of your HTML page, for example witin the <head>

dr4g 25 Junior Poster

You could use JavaScript Encode, to encode the HTML/page source, so that it isn't readable at all.

dr4g 25 Junior Poster

Well there is always gaming conventions (G3).
Or even just hire out a place, and we all just meet there. Could be cheaper.

I suggested something like that, somewhere where we could all game ,chat, code or whatever we want.

Could you talk more about G3 ??

Thanks.

dr4g 25 Junior Poster

I repeat.. " It's not good resourcefully if you use this method"..

dr4g 25 Junior Poster

I think he was suggesting if it mattered, he's wanting someone's opinion on it, therefore its a question..
That's my theory anyway

Back to the topic.
Can someone do some research for IT meetings in England? so we'll have something to do, then whoever wants to go for a drink afterwards, can (depending on their age ofcourse).

dr4g 25 Junior Poster

OP = Original Poster. I thought OP was a pretty common term, but maybe I was wrong. That's what I get for using an anronym.

He asked for variable arguments -- the code you posted did nothing to answer that question. I don't know his experience and neither does anyone else. He must have at least some programming knowledge in order to even ask the question.

Haha, i thought he ment passing variable arguments.. as you can pass an array as a parameter (using pointers of course), so i thought he ment how do you pass a variable to a function.

Oh well :)

dr4g 25 Junior Poster

1) What's the OP?

2) didn't want to over complicate things for the guy, as he seems to be just starting out in C, giving him a basic understanding of parameter passing would be more beneficial without talking to him about 'VA'.

That's my opinion anyway.

dr4g 25 Junior Poster

The above links will help you learn about sockets.

What you're looking to do is..

Create a socket (using socket() ).
Setup destination for this socket, and the port you want to make this socket connect to (check the links).

Try connecting to another socket at the destination end (using connect() ).

Send information to this socket (using send() )


The above is based on TCP/IP, so you can create a TCP/IP 3-way handshake, and verify that data has been transferred correctly.
Using UDP would just send the data and we wouldnt know if it has been received or not.


Any questions or elaboration needed.
Just reply.
Cheers.

dr4g 25 Junior Poster

how can we pass variable arguments in any function of C?

Simply to answer your question.

#include <stdio.h>

int sum;

int main() {

sum = myfunction(5, 10);

}

int myfunction(int argument1, int argument2) {

      return argument1 + argument2;

}

Code not tested, but see no reason why it shouldn't work. :)


Cheers.

dr4g 25 Junior Poster

You can also use system("PAUSE"), DevC++ puts this in for you automatically, i'm not sure about linux at all since i don't need to use it on Linux :)

It just outputs "Press Any Key To Continue..." and waits for input.

It's not good resourcefully if you use this method, something like getchar() would be a little more light-weight.

If you're using C, getchar() is good.
If you're using C++ cin.get() is good.

Cheers.

dr4g 25 Junior Poster

Well done Johny, i never tought of that :D

dr4g 25 Junior Poster

Try echoing your query, and see if it makes sense.

Try pasting it directly into mySQL (not via PHP) and see what happens also.

dr4g 25 Junior Poster

Some valid points we defo need a tech event.
I don't know of many, i'm not from england.
I guess there should be a vote or happygeek should just suggest somewhere; but yes we defo need a technical event to go to.

Drinking is an option, but not everyone is 18 possibly? i'm not sure i don't know everyone here only been here half a year or something,.

dr4g 25 Junior Poster

Anywhere is reachable by train these days.
Middle england sounds fair i think.
I'm not getting on london tubes anyway. :p
Damn iraqis.!

dr4g 25 Junior Poster

What is the money for?
Are you paying that? or paying someone else that? Let me know, and i'll help you further.

Or is that what you want your paypal integration to do.

dr4g 25 Junior Poster

Can you also have a MySQL database to work on your PC with PHP???

As i mentioned before. You can run Apache. mySQL, PHP servers all configured to work with each other.

Using WAMP (www.wampserver.com)

Google it.

Enjoy.

dr4g 25 Junior Poster

fixed your problem at IRC, but just for the people who are sitting are the code thinking about it, when it's already been fixed :)

Your doing
a[j + 1] := tmp;
on th third last line.

Meaning when j reaches 5, your doing
a[5+1] which is a[6]

Which does NOT exist, as you only created 5 elements for your array at the very start..

Error coded 201 came out of this as you mentioned, which is an outofbounds error.

Confirmation: http://community.freepascal.org:10000/bboards/message?message_id=144869&forum_id=24092


Enjoy.

dr4g 25 Junior Poster

Thanks for your input digital-ether.
CAPTCHA is already going to be implemented to minimalise the risk of automated attacks.

The database idea, i'll go with. However you mentioned;

A simple pattern is 5 failed login attempts on a username. This is without regards to who made the attempts or from where or what IP

You didn't talk about what to do if theres 5 failed login attempts, were you agreeing with that fact that disabling user login for 15 minutes?

Cheers.

dr4g 25 Junior Poster

>Some comments might help the beginners Aia
Read the code with a C reference manual, step through it, and if you still have questions, ask them.

I understand the code, it was for the C beginners trying to understand the code (as there were 0 comments in his code)

dr4g 25 Junior Poster

I like the way your thinking Invisal.

I will wait for more replies from other coders, before i decide which is the more suitable method to use.

Thanks for your input ;)

dr4g 25 Junior Poster

Not a problem dude, i have nothing else to do :)
Ask away.

dr4g 25 Junior Poster

Yes, that's correct.

You've declared $msg as an instance variable of the class, so to refer to it you would do $this->variable.
Same if u have another function in the same class, you could call it by doing $this->function();

dr4g 25 Junior Poster

Any time ;)

dr4g 25 Junior Poster

None.

dr4g 25 Junior Poster

Sorry mabye i was a bit unclear - if the user login fails 5 times WITHIN 15 mins, it will block it for 15 minutes.

Intresting concept invisal . any more ?

dr4g 25 Junior Poster

What happens when you print it ?

dr4g 25 Junior Poster
/*
 * r_ascii.c
 */
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
 
#define MAX 126
#define MIN 33
 
int randy( int max, int min )
{
    int r_num;
    do
     {
        r_num = rand();
    }
    while ( r_num < min || r_num > max );
    return r_num;
}
 
int main( void )
{
    int i;
 
    srand( (unsigned) time( NULL ) );
 
 
     for( i = 0; i < 1000; i++ )
     {
        printf( "%c ", randy( MAX, MIN ) );
    }
    getchar();
    return 0;
}

Output:

b U * = ^ s y F c ; ^ x 5 v - k L 1 0 M r a n c w 4 o 5 w = : ' - 7 ? v ; L $ )
4 ? D I P r d y { D @ e p & O Y C L T % y f U h ( i F , p 8 D [ ^ < p W | V z |
2 : 1 * = 1 n q V & r F X { ] c ) > ] I O ? < < * ! U l W O ' h [ 1 g { x z % I
# R J L ) U : < ( % 9 + 6 S 8 q } , i . 8 O Z ; s D j i y W n o } P z ` i ^ i K
A 2 ] " 5 / = ( …
dr4g 25 Junior Poster

Hey, just made the title like that, to grab intrest ;)

I'm developing a system at the moment, i'm going to implement a filter to the login section, so that only 5 invalid login attempts can be made, then its temp denied access to login with that username, for 15 minutes.
Making it virtually pointless to try and brute force the login.

Just curious if anyone has any existing methods of doing this, or any coding suggestions/tips that they can throw my way, before i start implementing it.

Cheers.
Paul.

dr4g 25 Junior Poster

I think a representative of Daniweb (a high end moderator or something) should organise something,

I personally don't see why london would be most convenient, people are from all over the UK, and london is at the bottom!

Why can't we all meet in the middle of the UK, or middle of england at least.

I'm from Glasgow, i can imagine a few others are from scotland too.

I recommend somewhere in the middle of England (not so far down at the bottom).

We could have a BBQ/Lan party/meetup for everyone.

Possibly having somewhere that we can stay overnight, for example.

If someone has a nice spot of land, we can all just bring tents and camp out there.
And use the house for electricity if we decided to have a big LAN game, or have some fun anyway :)

Just throwing some ideas about to get more specific feedback from everyone.

Cheers.

dr4g 25 Junior Poster

the purpose of this, is just to check if the SQL table actually exists before you INSERT data into it. If you're sure that the table exists (that you've created it), then you won't need this, its just to stop noobies from doing insert's into a table that doesnt' exist :)

dr4g 25 Junior Poster

Security applies to all sections of IT.
You can have application security, network security and so on. each one specialising in it's own field.

Have a think, we have nothing better to do than chat about pointless stuff on forums :)

dr4g 25 Junior Poster

I do something very similar.

/* set up valid pages in array */
$array = array('contact','forum','about','cable');
 
/* if page isnt set, make default page=home.php */
if(!isset($_GET['page']))
   $page = "home.php";
 
/* if it exists within the array, assign $page to $_GET['page']
elseif(in_array($array, $_GET['page']))
   $page = $_GET['page'];
 
/* if is is none of the above, generate error message */
else
    die("error no page found");
 
/* if we get to this point, no error was found and we can go ahead and include the file from $page */
include_once ('includes/' . $page . '.php');
 
}