Stefano Mtangoo 455 Senior Poster

A quick explanation of the code above.

the class board extends JPanel thefore it is a JPanel. In the constructor for board, it creates a JFrame (Window) sets the size of the frame, title, background and close operation (what happens when the window is exited). It then creates the "snake" which is a JComponent (Panel, Button, Label ...) and adds that to the frame. The frame is then made visible.

Thanks. I didn't knew you cann add JFrame to JPanel. I only knew the opposite

Stefano Mtangoo 455 Senior Poster

If you love RAD then there is wxGlade and XRCed
wxGlade is ugly but it works wonderfully!

Coding from scratch is best. I can now code faster and clean GUIs
I'm working on TodoList application and wxPython works!

Stefano Mtangoo 455 Senior Poster

Use Linux OS to remove it
Boot from linux. I have external USB with Linux in it

Stefano Mtangoo 455 Senior Poster

looks interesting! I have downloaded and will check it
Thanks ardav

Stefano Mtangoo 455 Senior Poster

I need to sit down and think how to implement keith's ideas

Stefano Mtangoo 455 Senior Poster

So far this is all I have in my class. Mind you I have also a Form file that utilizes JS/JQuery. Here is the full code. Feel free to pint weakness or change them (no one have pocked around yet. I will be happy if one just did it. May be it is still immature heheh!)

<?php
//class for db connections and manipulations
/*
 * so far the post values submitted are fname, lname, email, username and passwd
 * db field includes those plus isadmin, active -- for checking if logged user is admin and if accoun is activated
*/

class Connectdb {
    //private values
    private $dbuser="user";
    private $dbpass="pass";
    private $dbhost="localhost";
    private $dbname="testdb";

    public function __construct() {
        $conn = mysql_connect($this->dbuser, $this->dbpass , $this->dbhost) or die("Cannot connect to database: Error - ".mysql_error());
        mysql_select_db($this->dbname);
        return $conn;
    }

}//end connectdb

class Cleaning extends Connectdb {
    public function __construct() {
        parent::__construct();

    }

    private  function  cleanValue($arrayValue) {
        $value = array_map("mysql_real_escape_string", $arrayValue);
        return $value ;
    }

    //to sanitize Names/string like username
    private  function cleanNames($badVariable) {
        if(empty($badVariable)) {
            return false;
        }
        else {
            $cleaned =  filter_var($badVariable, FILTER_SANITIZE_STRING);
            if(!$cleaned) {
                return false;
            }
            else {
                $cleaned = $this->cleanValue($cleaned);
                if(!$cleaned) {
                    return false;
                }
                else {
                    return $cleaned;
                }//inner else
            }//end else

        }//main else ends here

    }

    //sanitize and validate email
    private  function cleanEmail($badVariable) {
        if(empty($badVariable)) {
            return false;
        }
        else {

            $cleaned =  filter_var($badVariable, FILTER_SANITIZE_EMAIL);
            if (!$cleaned) {
                return false;
            }
            else {
                $cleaned =  filter_var($badVariable, FILTER_VALIDATE_EMAIL);
                if (!$cleaned) {
                    return false;
                }
                else {
                    $cleaned = $this->cleanValue($cleaned); …
Stefano Mtangoo 455 Senior Poster

For this to have any merit, it has to be very flexible.

Sure! modularity is in my plann but I'm not very good at planning yet!

The way you are sanitizing the inputs is going to cause a lot of problems for someone trying to add/modify/remove something.

Mhh! I don't understand. can you point it directly what I'm doing wrong? Thanks for pointing that!

The way I would set something like this up would be:

Database Class - Handles db connection and queries

I have that although for now it only connects to the database. I plan to put more queries there. I hope it will be ok

Form Class - Handles forms. Could build forms dynamically from configuration array. Will sanitize all input data.

I have no idea how to do that! Do you mean I should mix HTML in my PHP Class, that is require array to be passed to a constructor that in turn will build up the form? I currently use separate form with JS/JQuery pre-validation plus PHP validation. I need major help here

Template Class - Handles template files. Would be very basic.

Login Class - Handles login form and displaying the login template.

Also I would be happy to hear your suggestion on how login class should handle the login (with return only boolean values or return error code? or build error array?). I will be happy to hear more from you on this

Register Class - Handles registration obviously. …

Stefano Mtangoo 455 Senior Poster

welcome to Daniweb my Sister!
Definitely PHP beats ASP hands down :)
And it is for web application including but not limited to website!

Steve

Stefano Mtangoo 455 Senior Poster

how do you install other stuffs like VLC media ?

Stefano Mtangoo 455 Senior Poster

Hi All,
I use at work Rflection X to access Server Running on Solaris 10. There are applications running there so what we do is just connect to that using IP address. Then comes login windows and starts GUI

I can login to commandline via putty but cannot start the CDE session to start GUI. Is this possible? Yes, How?

Stefano Mtangoo 455 Senior Poster

Just curious, why do you use #include <stdafx.h> in C++?

Stefano Mtangoo 455 Senior Poster

I'm have not well understood but I thinks functions are good ways to go.
Here I have little time (at work) so I will try to do little thing to show example of function. One can improve it ;)

// InfoMenu.cpp : main project file.

#include <stdafx.h>
#include <iostream>
#include <string>

using namespace std;

//define function prototypes
void MyMenu();

int main()
{
int test=1;//test conditio that user want to continue{1=Yes, 0=no}
if(test==1){
	MyMenu();
}
else{
	return 0;
}
  
}

void MyMenu(){
	
	  int loop=1;
	  int choice;
	  string getinput;

	  while(loop==1)
	{
		cout << "Type 'exit' to leave at any time\n"
			 << "Type 'login' to begin\n";
		cin >> getinput;
		if(getinput=="exit") // Exit Code
		{
			exit(0);
		}
		if(getinput=="login") // Login Code
		cout << "Username:"; // Username Code
		cin >> getinput;
		if (getinput=="Test")
		{
			cout << "Passsword:"; // Password Code
			cin >> getinput;
			if(getinput=="Pass")
			cout << "Welcome...";
			
		}
	}
  }
	
}
Stefano Mtangoo 455 Senior Poster
Stefano Mtangoo 455 Senior Poster

what exactly do you mean by 'a variable' speeds?

I think he means speed is varying while it was supposed to be constant


Also as Java learner I'm lost with this code
Does it imply JFrame is contained in JPanel? Is that Possible with Java?

package snake;
import javax.swing.*;
import java.awt.*;

public class board extends JPanel {

       public board()
       {

            JFrame frame = new JFrame();
            frame.setSize(300,400);
            frame.setTitle("Snake");
            frame.setBackground(Color.black);
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            snake component = new snake();
            frame.add(component);
            frame.setVisible(true);
            

       }
}
Stefano Mtangoo 455 Senior Poster

Just wondering... Is there a reason you only clean the ones you need. You could clean all values in the post array, or use an array with the values you need to clean, so it could be extended if needed.

Indeed, being modula is one of my aims. That is because you make something bigger out of plugins. I'm not good at plugin architecture thing but I will be learning as I go ;)

You would then just need to add an entry to an array to add and clean a new field. I prefer the array option.

Adding it should not be difficult and here is how to do that:
1. Create a method in same class responsible for cleaning new item from post let say birthdate

function cleanBirthDate($argument_is_birth_date){
//.....your code
}

2. Then add a line to above method

$this->cleanBirthDate($postArray["birthdate"]);

NOTE: The variable birthdate should be somewhere in your register form

Any suggestions are welcomed

Stefano Mtangoo 455 Senior Poster

Just serialize them with Python's pickle or cpickle module

Stefano Mtangoo 455 Senior Poster

The only blemish I can see with wxPython is that it will not work with Python3 at the moment.

True, that turns me down, haven't even tried to mess with Py3k

PyQT works with Python3, but may have licensing problems down the road.

There is Nokia Project that is interesting. I heard from wxPy mailing list

Tkinter is pretty much cross platform and comes with Python2 and Python3. Its widgets are rather basic and look a little homely on a Windows machine, but look great on Apple's OS.

Haven't tried it. Don't know why it dosn't fit my brain. Have anythig changed from 2.x?

Ironpython 2.6 is a close equivalent of Python 2.6 with the added advantage of having access to CLR and the MS .NET Framework. It can use the Framework's library as a GUI toolkit.

Uh! I forgot that there are alot of classes in .Net farmework :)

Stefano Mtangoo 455 Senior Poster

Where is the current effort? Has this been posted anywhere? Please advise as to the current status? Thank you.

Currently, I will be writing Register class. It is not yet published (I will start actually writing today). So the above was the function I wanted to be sure of because it will be used in cleaning variables

Anyway I will proceed

Stefano Mtangoo 455 Senior Poster

Can you Clarify? I'm yet to be a *nix geek :)

Stefano Mtangoo 455 Senior Poster

Also I have noticed there is thread safe and non thread safe. Which one should I go?

Stefano Mtangoo 455 Senior Poster

Hello All,
Please help me with the question I posed on thread title
Thanks you!

Stefano Mtangoo 455 Senior Poster

Cool,
Get XAMPP zipped version and unzip it. Add your project to htdocs and zip it. Now make a script (Bash/CMD-.bat/Python) in any language (I recommend Python) which will do simple stuffs --> Unzip to C:\ or whatever and make XAMPP shortcut and add bookmark on Web browser. or it might be a script to start XAMPP and open web browser at localhost soon when server is up.

It is not difficult-almost-impossible task ;)

Stefano Mtangoo 455 Senior Poster

putty fails to connect. I use local IP
And one more thing, SSH is not graphical right? Is there a graphical solution?

Stefano Mtangoo 455 Senior Poster

Thank you for giving me that info. I'll try to look into that. It's not that I want to create my own language, just an application that will do whatever you type. I don't like the setup of the current python interpreter, so I want to create my own, the way I did with Windows' Command Prompt.

Cool! I think those above mentioned class will do the job though personally haven't test it. Sorry for misunderstanding your questio, I though you are like one guy who planned to code his own OS

Stefano Mtangoo 455 Senior Poster

Jython/IronPython aren't toolkits for GUI rather implementations of Python in Java/DotNet

I use wxPython anyway!

Stefano Mtangoo 455 Senior Poster

Thanks I'm visiting their site. But installing, No floppy disk !

Stefano Mtangoo 455 Senior Poster

what distor do you have?
in Mandriva use urpmi, Suse there is Yast or zypper ...et al

urpmi mysql

Stefano Mtangoo 455 Senior Poster

what distor do you have?
in Mandriva use urpmi, Suse there is Yast or zypper ...et al

urpmi mysql

Stefano Mtangoo 455 Senior Poster

Really this is kinda foolish error :embarrased:
The class is wxNotebook not wxNoteBook
I will check if it will give me more of this error but I guess problem should be over :)

Stefano Mtangoo 455 Senior Poster

Sorry for late reply.
Actually I got tired after working 8 hours and do some hours of coding, I had to rest. May be I was too tired; but I wanted to Make class AdditionalWindow inheriting from wxnotbook, one of wxWidgets' classes.

I will try to recheck my code

Stefano Mtangoo 455 Senior Poster

Your project should be able to bundle WAMP or MAPP with your project at www folder (hope you know that). You should make utility to launch the url to localhost (using Python it is few lines) or if users can understand just do it themselves. Alternative to this trick you can just create toolbar bookmark to default webbrowser (perhaps all browsers) directly from installer.

I hope that is what you need ;)

Stefano Mtangoo 455 Senior Poster

Your project should be able to bundle WAMP or MAPP with your project at www folder (hope you know that). You should make utility to launch the url to localhost (using Python it is few lines) or if users can understand just do it themselves. Alternative to this trick you can just create toolbar bookmark to default webbrowser (perhaps all browsers) directly from installer.

I hope that is what you need ;)

Stefano Mtangoo 455 Senior Poster

Check this

Stefano Mtangoo 455 Senior Poster

/home/stefa/Projects/C++/evstevemd/Additions.h|7|error: expected class-name before ‘{’ token|
/home/stefa/Projects/C++/evstevemd/Additions.h|9|error: expected ‘)’ before ‘parent’|
||=== Build finished: 2 errors, 0 warnings ===|

Here is the file. Cpp file is empty. There is something wrong with My class and inheritance knowledge. What is wrong?
thanks

#ifndef ADDITIONS_H
#define ADDITIONS_H

#include <wx/panel.h>
#include <wx/notebook.h>

class AdditionalWindows: public wxNoteBook{
    public:
        AdditionalWindows(*wxWindow parent);

    private:
        //make panels and return newly made panel
        //wxPanel OnMakePanel();

        DECLARE_EVENT_TABLE()

};

#endif //ADDITIONS_H
Stefano Mtangoo 455 Senior Poster

I would suggest you contact Author at DL forums. Eran is very cooperative!
I will suggest you stick with AD's suggestion

Stefano Mtangoo 455 Senior Poster

>Don't use system("PAUSE"). It is causing unncessary
>overhead to your program by making system calls.
system("PAUSE") is typically used to keep a command prompt window open after the program is finished. Overhead is irrelevant when the very nature of the system call is I/O bound. More important is the fact that a malicious party can easily replace the pause program with malware, and the program will innocently run it with it's own privileges. It also hurts portability because the pause program isn't standard across platforms.

Bum! I was having wrong concept ;)

Stefano Mtangoo 455 Senior Poster

A trick I can suggest is check the version that WAMP is running (i.e versions of MySQL/PHP/APACHE) and download those for exactly version then play with them. Sometimes different versions doesn't play well.
Somehow vague but I hope you get my point

Stefano Mtangoo 455 Senior Poster

I have to do reinstallation due to virii destruction in this laptop. I need to slipstream Drivers to this installation. Where to get SATA drivers so that the HDD will be recognized? Currently XP CD SP3 Doen't recognize the drive. Is there another trick?

Stefano Mtangoo 455 Senior Poster

Thank you. I am trying that out now.
I can use system ("PAUSE") in a gnu compiler, right? Also, would it be better to use system ("PAUSE") on cin.get()?
Does system("PAUSE") also wait for an key to be pressed?

Don't use system("PAUSE"). It is causing unncessary overhead to your program by making system calls. Just stick with the latter

Stefano Mtangoo 455 Senior Poster

What is free solution available. I need to do two things:
1. Connect at machine in same office. I cannot use RDP as it is KDE Mandriva machine.
2. Connect fro home to that machine without VPN i.e over internet

Thanks

Stefano Mtangoo 455 Senior Poster

I managed to find a Ubuntu c++ compiler which supports every variation of c++ and its name is Codelite.

I guess you mean Codelite IDE

Stefano Mtangoo 455 Senior Poster

The Class Register will depend on this for cleaning. So what do you say guys? Is this ok to proceed?

Stefano Mtangoo 455 Senior Poster

what do you mean by "distro"?
The link you provided do not have one for SuSe 10.3~~

Distro is...

Stefano Mtangoo 455 Senior Poster

And your absolutely right! I should have just grabbed a Creative Common License, but I didn't (I'm not sure why...). I am planning to do this though. When I complete the update to my site, I will begin to include scripts (like the pagination one) for the use of others. Until then, I don't really have a plan, but hopefully I'll finish my updated site soon!

So you didn't say what about derived works and in your script it doesn't say. I think it should be given free without any notice (Leaving giving credit to user if he wishes) Like how we do it on Python forum (again that is just MHO). It would be good for PHP moderators to add a stick for sharing codes for those who wish. That is one of the thing that makes Daniweb Python forum the best!

again just my opinions ;)

Stefano Mtangoo 455 Senior Poster

If you are talking about using the google server to send mail without having any mail server installed well that is possible with the help of a custom mail script/class you can download. Now don't get me banned by hijacking a thread...

This last time, bear with me guys. I would like to know where to download such a script or the keywords for google et al. Then Back to the thread's owner: Did the suggestions above helped you?

Stefano Mtangoo 455 Senior Poster

Okay, all I want to do for now, is create a rather simple python interpreter. I have already created a simple command prompt for windows, utilizing the os module, the script's code is here:

You missed one point that Python interpreter already exists and is not simple but rather a complex coding by Guido and PSF team! So calling your interpreter Python will get you in trouble with PSF trademark/whatever it is called in US. Just curious, do you want to take Python out of business using Python?

import os
os.system("title Command Prompt")
while True:
    osc = raw_input(os.getcwd()+">> ")
    if osc == "exit" or osc == "quit" or osc == "exit()" or osc == "quit()":
        quit()
    try:
        os.system(osc)
    except:
        print "Not a valid shell command"
    print ""

Okay, you are calling system calls right? It does the job. The problem is, the commandline windows vanishes quickly. Try command like (in windows) ping x.x.x.x -t

I want to do the same, but have it evaluate python commands instead. Any help would be appreciated! :D
Also, I've already tried setting a variable to raw_input, then doing eval(variable). That doesn't work.

you should list your own keywords and syntax .....etc. It is not simple job. It is like creating your own language which is not english, swahili or any other. Just new one!

Stefano Mtangoo 455 Senior Poster

you are welcome.
How far did it take you. I haven't ever bothered to do that because my mandriva have drakxwizard that does all the config with you via a GUI ;)
Bravo for mandriva

Stefano Mtangoo 455 Senior Poster

I love your pagination script. But I see it should include notice that you coded it. I understand your concern for your property but I'm curious:
1. Why did you wanted it that way and not free in the meaning of free?
2. If somebody hacked it and derived from it, what should be included.

My Suggestion for you (Just my humble suggestion) is that, for experienced coder like you, should give them away as part of fun! How do you see That?

No offense meant here, just what I see :)

Stefano Mtangoo 455 Senior Poster

The old mail function bug. The smtp only works if you have a localhost mail server. The reason, there is no password provided anywhere for php to read so access is denied to the remote smtp although you could try the imap_mail() function to see if it makes a difference. Alternatively I have heard in the past there are some scripts that provide custom mail functions which will allow such a smtp request.

Soory for hijacking thread for a minute. Does this allow gmail thing+local wamp server. It would be cool playing wth e-mail related PHP without "true" server

Stefano Mtangoo 455 Senior Poster

I Have done function that combines the above functions and validate POST variables.
Scrutinize it to see any improvements needed and I'm definitely shifting to Register class.

So far thanks for your inputs all of you guys!

public  function cleanMe($postArray){
            //the post values submitted are fname, lname, email, username and passwd
            $newPostArray[];
            $newPostArray["fname"] = $this->cleanNames($postArray["fname"]);
            $newPostArray["lname"] = $this->cleanNames($postArray["lname"]);
            $newPostArray["email"] = $this->cleanEmail($postArray["email"]);
            $newPostArray["username"] = $this->cleanNames($postArray["username"]);
            $newPostArray["password"] = $this->cleanNames($postArray["password"]);

            //loop through the array looking for any false value and terminate
            foreach ($newPostArray as $key => $value) {
                if($value==false) {
                    $returnValue =  false;
                    break;
                }//endif

            }//end foreach loop

            if(!$returnValue) {
                return $returnValue;
            }
            else {
                //everything is validated and is fine
                return $newPostArray;
            }
    }