Re: datetime question

2013-11-11 Thread Νίκος Αλεξόπουλος

Στις 8/11/2013 11:11 μμ, ο/η Νίκος Αλεξόπουλος έγραψε:

Is there someway to write the following line even better with the
ability to detect daylight saving time by itself so i don't have to
alter the line manually when time changes?

lastvisit = ( datetime.utcnow() + timedelta(hours=2) ).strftime(
'%y-%m-%d %H:%M:%S' )# MySQL datetime format

Thanks.



Someone has an idea what to add to this line to automatically adjust 
itself if DST happens?

--
https://mail.python.org/mailman/listinfo/python-list


Re: To whoever hacked into my Database

2013-11-11 Thread Νίκος Αλεξόπουλος

Στις 6/11/2013 5:25 μμ, ο/η Νίκος Γκρ33κ έγραψε:

Okey let the hacker try again to mess with my database!!!

He is done it twice, lets see if he will make it again!

I'am waiting!


I can't believe your ignorance. You're actually telling a huge group of 
developers from all over the globe that your site is impenetrable. Do 
you know how ridiculous you sound? Have you stopped and thought that 
maybe people have better things to do than try to hack your stupid circa 
1990 website? My three year old could have modified your database. It 
doesn't take a pro to take down your 'security'. Have you not read up on 
anything these people have suggested? Cross Site Scripting? SQL 
Injection? Digital Piracy? Private User Information? No.. you haven't. 
That's why your code is starting to look like this:
if not '..' in page and not page == '/etc/passwd' and 
os.path.isfile(page) and os.path.exists('/cgi-bin' + page) and cookieID 
== 'some_secret' and host == 'superhost.gr' and 
hacker_is_not_being_mean_today:

   load_site()

load_private_user_phone_numbers_and_then_post_a_screenshot_for_everyone_to_see()
else:
   play_pre_millenium_music_and_load_lots_of_gifs()
wait___go_back_and_load_pirated_music_and_gifs_from_1995_anyway(extra_sauce=True)
You can't sue me for posting the code to your site, there was no copyright.
I guess my whole point is, if someone really cared I'm sure they could 
get into your site. They could get into a lot of sites that were created 
by people way smarter than you. Ever heard of apache exploits? cpanel 
exploits? for that matter..python exploits? Some of this is beyond your 
control. Actually, all of this is beyond your personal control, you lack 
the capability. What I meant to say is that you could not possibly fix 
all of this even if you were a better python programmer. Be glad 'she' 
wasn't mean.


==

Somebody this morning sent me an email as nikos.su...@gmail.com sayign 
the above.

My code is not like you provided you ignorant.

# is it a python file or an html template?
if page and page in os.listdir( cgi_path ):
pyvalid = True
elif os.path.isfile( file ):
page = file.replace( path, '' )
htmlvalid = True
else:
file = 'forbidden'


if 'forbidden' in file:
print( '''Δεν επιτρέπεται η απευθείας πρόσβαση 
στο script παρά μόνον μέσω της αρχικής σελίδας!Ανακατεύθυνση σε 
5...''' )
print( '''content="5;URL=http://superhost.gr";>''' )

sys.exit(0)


if cookieID != 'wont_say' and ( htmlvalid or pyvalid ) and re.search( 
r'(amazon|google|proxy|cloud|reverse|fetch|msn|who|spider|crawl|ping)', 
host ) is None:

# do database insertion here


Tell the mighty female hacker to polish her nails, do her hair and fix a 
good meal.


She is incompetent just like yourself.

These all is just an excuse of not being able to mess with my script 
again, because is she could she would.

--
https://mail.python.org/mailman/listinfo/python-list


Re: To whoever hacked into my Database

2013-11-10 Thread Νίκος Αλεξόπουλος

Στις 10/11/2013 9:16 μμ, ο/η Petite Abeille έγραψε:


On Nov 10, 2013, at 7:46 PM, Νίκος Αλεξόπουλος  wrote:


You are a moron


Rumor has it you are the head of ELSTAT, the Hellenic Statistical Authority. 
Any truth to that?




Perhaps i'm working for NSA too and i was assigned to keep an eye on 
what's happening on Python News Lists.

--
https://mail.python.org/mailman/listinfo/python-list


Re: To whoever hacked into my Database

2013-11-10 Thread Νίκος Αλεξόπουλος

Στις 10/11/2013 7:57 μμ, ο/η Petite Abeille έγραψε:


On Nov 10, 2013, at 4:28 PM, Antoon Pardon  wrote:


You are a perfect example of the arrogance of the ignorant.


Finally! The Dunning–Kruger effect proven beyond a doubt.





You are a moron, no doubt! Freddy Kruger Effect!
--
https://mail.python.org/mailman/listinfo/python-list


Re: To whoever hacked into my Database

2013-11-10 Thread Νίκος Αλεξόπουλος

Στις 10/11/2013 5:28 μμ, ο/η Antoon Pardon έγραψε:

Op 10-11-13 16:01, Νίκος Αλεξόπουλος schreef:

Στις 10/11/2013 3:49 μμ, ο/η Antoon Pardon έγραψε:

Op 10-11-13 11:32, Νίκος Αλεξόπουλος schreef:

Ha, ha ha!
I'm safe now!!

No breaks in this time!


You just can't help yourself, can you? I predict your database will
be broken in, within a week, after which you will plug one leak
and after an other day boast again about how secure your system is,
because you hadn't had a break in after your latest "fix".



It won't break again. 'page' variable cannot be manipulated by
arbitrary url strings no more.


So you fixed one specific leak and you think that is enough to
declare yourself safe?!


This time is fixed for good.


The fact that you said this before and were wrong didn't teach
you anything?


Your predictions are wrong.


And you wonder why people think you are arrogant. You are a perfect
example of the arrogance of the ignorant.


Really?

I have even pasted the code as i used to had it and the new correction i 
have made.


Since my code is so crappy try to mess with the script and databases 
since you re so competent and smart

--
https://mail.python.org/mailman/listinfo/python-list


Re: To whoever hacked into my Database

2013-11-10 Thread Νίκος Αλεξόπουλος

Στις 10/11/2013 4:45 μμ, ο/η Mark Lawrence έγραψε:

On 10/11/2013 10:32, Νίκος Αλεξόπουλος wrote:



Ha, ha ha!
I'm safe now!!

No breaks in this time!


She's just biding her time again.  Or was it the little fingers of my
team?



Tell your female friend to polish her nails or do her hair instead as 
she will not be successful any more to mess with any of my 3 scripts.


If it was little fingers tell him to stick those fingers you know where
--
https://mail.python.org/mailman/listinfo/python-list


Re: To whoever hacked into my Database

2013-11-10 Thread Νίκος Αλεξόπουλος

Στις 10/11/2013 3:49 μμ, ο/η Antoon Pardon έγραψε:

Op 10-11-13 11:32, Νίκος Αλεξόπουλος schreef:

Στις 10/11/2013 12:20 πμ, ο/η Chris Angelico έγραψε:



There are two major problems with
what you did here, Nikos, and they are:

1) Starting with a hopelessly insecure system and then trying to
band-aid patch it one vulnerability at a time, which is folly; and

2) Boasting that your system was now secure.

The main issue is the boasting, which is utterly unwarranted
arrogance.

,,,


Ha, ha ha!
I'm safe now!!

No breaks in this time!


You just can't help yourself, can you? I predict your database will
be broken in, within a week, after which you will plug one leak
and after an other day boast again about how secure your system is,
because you hadn't had a break in after your latest "fix".




It won't break again. 'page' variable cannot be manipulated by arbitrary 
url strings no more.


This time is fixed for good.

Your predictions are wrong.

--
https://mail.python.org/mailman/listinfo/python-list


Re: To whoever hacked into my Database

2013-11-10 Thread Νίκος Αλεξόπουλος

Στις 10/11/2013 12:20 πμ, ο/η Chris Angelico έγραψε:

On Sun, Nov 10, 2013 at 2:32 AM, Antoon Pardon
 wrote:

And i had until i made some new changes last night, which i think i have 
corrected now as we speak.


Continuing the arrogance.


Just to put that in perspective, by the way: *EVERYONE* writes
vulnerable code. Even Python itself has been found to have had
significant exploits (hash randomization had to get backported a long
way). There's nothing wrong with fixing security bugs; there's not
even a lot wrong with the iterative process of "find bug, fix bug,
find another bug, fix another bug". There are two major problems with
what you did here, Nikos, and they are:

1) Starting with a hopelessly insecure system and then trying to
band-aid patch it one vulnerability at a time, which is folly; and

2) Boasting that your system was now secure.

The main issue is the boasting, which is utterly unwarranted
arrogance. All you have to do is look at how, after boasting
previously, you were provably vulnerable - which means that you
clearly still had problems while you were boasting. A more humble
attitude of "Oops, well, that's fixed now" without saying "Ha ha, now
try to break THAT, I'm oh so perfect now" would suit you far better,
based on your history.

ChrisA




Ha, ha ha!
I'm safe now!!

No breaks in this time!
--
https://mail.python.org/mailman/listinfo/python-list


Re: To whoever hacked into my Database

2013-11-09 Thread Νίκος Αλεξόπουλος

Στις 9/11/2013 5:07 μμ, ο/η Steven D'Aprano έγραψε:

On Sat, 09 Nov 2013 09:05:51 +0200, Νίκος Αλεξόπουλος wrote:


Its probably unwise to post the following snippet of code that validates
user input so an attacker wouldn't pass arbitrary values to my script
but what the heck.


On the contrary, it is wise to publicise your security code. It is a very
strong principle of security that you should not put your trust in
obscurity. To give an analogy, your doors should be secure even if people
know where the door is, what brand of lock you use, and even the type of
key used.

Nikos, you have annoyed and alienated enough people here that the
following may not apply to you, but in general I would expect that
publishing your code in a friendly forum would lead to "many eyes make
shallow bugs" -- people who spotted a bug in your security code, a
weakness or a flaw, would speak up and tell you. Your security should
depend on the strength of the security mechanism, and not rely on others
being ignorant of what security you have in place.

On the other hand, it is possible to be *too* open. Secrets should not be
publicised. Secrets include passwords. Occasionally they may include
other things. For example, in port-knocking, the precise sequence of
ports used is a secret.

There is, sometimes, value in obfuscating parts of your security. E.g.
rather than allowing ssh on the usual port 22, some people prefer to use
some other port number for that extra bit of security. But they don't
rely on that -- if the attacker manages to discover that they use port
45081 instead of 22, they still have to defeat the normal ssh security
before gaining access.





Thank you Steven, indeed posting my code helped me realize that it 
wasn't the secure code i though it were.


The attacker compromised my counters database once again and that helped 
me push my logic further into delve into how we went successful.


Now witht he last changed i have made, for 9 hours or so, my databases 
are intact.


I feel a bit sad though because if i wasn't able to detect the flaw 
nobody would have heed me solve it.

--
https://mail.python.org/mailman/listinfo/python-list


Re: To whoever hacked into my Database

2013-11-09 Thread Νίκος Αλεξόπουλος

Στις 9/11/2013 5:07 μμ, ο/η Steven D'Aprano έγραψε:

On Sat, 09 Nov 2013 09:05:51 +0200, Νίκος Αλεξόπουλος wrote:


Its probably unwise to post the following snippet of code that validates
user input so an attacker wouldn't pass arbitrary values to my script
but what the heck.


On the contrary, it is wise to publicise your security code. It is a very
strong principle of security that you should not put your trust in
obscurity. To give an analogy, your doors should be secure even if people
know where the door is, what brand of lock you use, and even the type of
key used.

Nikos, you have annoyed and alienated enough people here that the
following may not apply to you, but in general I would expect that
publishing your code in a friendly forum would lead to "many eyes make
shallow bugs" -- people who spotted a bug in your security code, a
weakness or a flaw, would speak up and tell you. Your security should
depend on the strength of the security mechanism, and not rely on others
being ignorant of what security you have in place.

On the other hand, it is possible to be *too* open. Secrets should not be
publicised. Secrets include passwords. Occasionally they may include
other things. For example, in port-knocking, the precise sequence of
ports used is a secret.

There is, sometimes, value in obfuscating parts of your security. E.g.
rather than allowing ssh on the usual port 22, some people prefer to use
some other port number for that extra bit of security. But they don't
rely on that -- if the attacker manages to discover that they use port
45081 instead of 22, they still have to defeat the normal ssh security
before gaining access.





Thank you Steven, indeed posting my code helped me realize that it 
wasn't the secure code i though it were.


The attacker compromised my counters database once again and that helped 
me push my logic further into delve into how we went successful.


Now witht he last changed i have made, for 9 hours or so, my databases 
are intact.


I feel a bit sad though because if i wasn't able to detect the flaw nobody
--
https://mail.python.org/mailman/listinfo/python-list


Re: datetime question

2013-11-09 Thread Νίκος Αλεξόπουλος

Στις 9/11/2013 2:45 μμ, ο/η Mark Lawrence έγραψε:

On 08/11/2013 23:02, Νίκος Αλεξόπουλος wrote:

Στις 9/11/2013 12:49 πμ, ο/η Denis McMahon έγραψε:

On Sat, 09 Nov 2013 00:01:37 +0200, Νίκος Αλεξόπουλος wrote:


I saw the link and i'm wondering if it can be written in 1-liner.


Yes, but you have to rewrite all your code in perl to do this.




Please tell me and as a git i will provide you with 2 good pdfs i just
found:

You can see them at my website if you click the blue download button.

The 1st is a Linux Bile and the 2nd is WebHosting for Dummies.


Why is Web Security for Dummies missing?




It's not missing.
Its there, check again.
Just click on the Blue download button and select it from the list of 
buttons.

--
https://mail.python.org/mailman/listinfo/python-list


Re: To whoever hacked into my Database

2013-11-09 Thread Νίκος Αλεξόπουλος

Στις 9/11/2013 10:39 πμ, ο/η Chris Angelico έγραψε:

On Sat, Nov 9, 2013 at 7:31 PM, Νίκος Αλεξόπουλος  wrote:

if page and os.path.isfile( cgi_path + page ) in os.listdir( cgi_path ):

Try pass bogus values again into my database!


Well done! *slow clap* In the interests of security, you have just
locked everything out, including legitimate usage!

ChrisA




Ah yes you are right!

Correction!

if page and page in os.listdir( cgi_path ):

That should keep the site working and still leave the attacker away from 
my daatabase!

--
https://mail.python.org/mailman/listinfo/python-list


Re: To whoever hacked into my Database

2013-11-09 Thread Νίκος Αλεξόπουλος

Στις 9/11/2013 10:39 πμ, ο/η Chris Angelico έγραψε:

On Sat, Nov 9, 2013 at 7:31 PM, Νίκος Αλεξόπουλος  wrote:

if page and os.path.isfile( cgi_path + page ) in os.listdir( cgi_path ):

Try pass bogus values again into my database!


Well done! *slow clap* In the interests of security, you have just
locked everything out, including legitimate usage!

ChrisA




What ?!!?
--
https://mail.python.org/mailman/listinfo/python-list


Re: To whoever hacked into my Database

2013-11-09 Thread Νίκος Αλεξόπουλος

Στις 9/11/2013 9:54 πμ, ο/η Νίκος Αλεξόπουλος έγραψε:

Στις 9/11/2013 9:05 πμ, ο/η Νίκος Αλεξόπουλος έγραψε:

Στις 9/11/2013 8:37 πμ, ο/η Chris Angelico έγραψε:

On Sat, Nov 9, 2013 at 5:32 PM, Νίκος Αλεξόπουλος
 wrote:

I'am not saying out of arrogance but i was really under the
impression i had
secure my script.

And i had until i made some new changes last night, which i think i
have
corrected now as we speak.


In other words, you closed off whatever you could see as being a
problem, and then boasted that the script was secure... until someone
proved to you that it wasn't. Your script is insecure by default, and
you're band-aid patching everything you happen to be made aware of.
What makes you think that it's now secure?

ChrisA




Its probably unwise to post the following snippet of code that validates
user input so an attacker wouldn't pass arbitrary values to my script
but what the heck.

==
# initiate some local variables
htmlvalid = pyvalid = False
path = '/home/nikos/public_html/'
cgi_path = '/home/nikos/public_html/cgi-bin/'

# define how the .html or .python pages are called
file = form.getvalue('file')# this value should come only
from .htaccess and not as http://superhost.gr/~nikos/cgi-bin/metrites.py
page = form.getvalue('page')# this value comes from
'index.html' or from within 'metrites.py'

# is it a python file or an html template?
if page and os.path.exists( cgi_path + page ):
 pyvalid = True
elif os.path.exists( file ):
 page = file.replace( path, '' )
 htmlvalid = True
else:
 file = 'forbidden'

.
.

if 'forbidden' in file:
 print( '''Δεν επιτρέπεται η απευθείας πρόσβαση
στο script παρά μόνον μέσω της αρχικής σελίδας!Ανακατεύθυνση σε
5...''' )
 print( '''http://superhost.gr";>''' )
 sys.exit(0)
==


Now, when it comes to database insertions i use this check to prevent
bogus data:

==
if cookieID != 'some_secret_here' and ( htmlvalid or pyvalid ) and
re.search(
r'(amazon|google|proxy|cloud|reverse|fetch|msn|who|spider|crawl|ping)',
host ) is None:
==

Even if i get re-hacked i'll find a security alternative.






How on earth did the hacker managed to alter the database again:

http://superhost.gr/?show=stats

i can't ing believe it!

He is actually trying to read sensitive stuff from my linux server by
passing arguments into 'page' variable like '../../../../etc/passwd'

How was he able to pass that info again?!?!


Okey mighty one!

Try to do the same thing again and be successfull.

i know what you did last summer!

You took advantage of this is statemnt:

if page and os.path.exists( cgi_path + page ):

and manages to pass arbitrary values to page by giving input

of '../../../../etc/passwd' ehich is actually translated as:


if page and os.path.exists( '/home/nikos/public_html/cgi-bin/' + 
'../../../../etc/passwd' ):


So

1. you actually are passign a value to page
2. you passed value is in fact exist as a 
'pathname/to/a/linux/sensitive/file'



I know what i have to do now:

Alter the if to soemthing like:

if page and os.path.isfile( cgi_path + page ) and page should only 
allowed to be an actual file but only from within the 'cgi-bin' directory.


Hence, i altered the code to this:

if page and os.path.isfile( cgi_path + page ) in os.listdir( cgi_path ):

Try pass bogus values again into my database!

--
https://mail.python.org/mailman/listinfo/python-list


Re: To whoever hacked into my Database

2013-11-08 Thread Νίκος Αλεξόπουλος

Στις 9/11/2013 9:05 πμ, ο/η Νίκος Αλεξόπουλος έγραψε:

Στις 9/11/2013 8:37 πμ, ο/η Chris Angelico έγραψε:

On Sat, Nov 9, 2013 at 5:32 PM, Νίκος Αλεξόπουλος
 wrote:

I'am not saying out of arrogance but i was really under the
impression i had
secure my script.

And i had until i made some new changes last night, which i think i have
corrected now as we speak.


In other words, you closed off whatever you could see as being a
problem, and then boasted that the script was secure... until someone
proved to you that it wasn't. Your script is insecure by default, and
you're band-aid patching everything you happen to be made aware of.
What makes you think that it's now secure?

ChrisA




Its probably unwise to post the following snippet of code that validates
user input so an attacker wouldn't pass arbitrary values to my script
but what the heck.

==
# initiate some local variables
htmlvalid = pyvalid = False
path = '/home/nikos/public_html/'
cgi_path = '/home/nikos/public_html/cgi-bin/'

# define how the .html or .python pages are called
file = form.getvalue('file')# this value should come only
from .htaccess and not as http://superhost.gr/~nikos/cgi-bin/metrites.py
page = form.getvalue('page')# this value comes from
'index.html' or from within 'metrites.py'

# is it a python file or an html template?
if page and os.path.exists( cgi_path + page ):
 pyvalid = True
elif os.path.exists( file ):
 page = file.replace( path, '' )
 htmlvalid = True
else:
 file = 'forbidden'

.
.

if 'forbidden' in file:
 print( '''Δεν επιτρέπεται η απευθείας πρόσβαση
στο script παρά μόνον μέσω της αρχικής σελίδας!Ανακατεύθυνση σε
5...''' )
 print( '''http://superhost.gr";>''' )
 sys.exit(0)
==


Now, when it comes to database insertions i use this check to prevent
bogus data:

==
if cookieID != 'some_secret_here' and ( htmlvalid or pyvalid ) and
re.search(
r'(amazon|google|proxy|cloud|reverse|fetch|msn|who|spider|crawl|ping)',
host ) is None:
==

Even if i get re-hacked i'll find a security alternative.






How on earth did the hacker managed to alter the database again:

http://superhost.gr/?show=stats

i can't ing believe it!

He is actually trying to read sensitive stuff from my linux server by 
passing arguments into 'page' variable like '../../../../etc/passwd'


How was he able to pass that info again?!?!




--
https://mail.python.org/mailman/listinfo/python-list


Re: To whoever hacked into my Database

2013-11-08 Thread Νίκος Αλεξόπουλος

Στις 9/11/2013 9:19 πμ, ο/η Chris Angelico έγραψε:

On Sat, Nov 9, 2013 at 6:11 PM, Νίκος Αλεξόπουλος  wrote:

These 4 are yours for sure:

mail14.ess.barracuda.com
mail0.ess.barracuda.com
209.133.77.167.T01713-01.above.net
209.133.77.164.T01713-01.above.net

This one '89-145-108-205.as29017.net' is not because this originate from
Europe/London as my GeoIP part of my script detect and you live in
Australia.


I admire your logic. One of them can't be mine because it's in London,
but the others must be because they're in New York and California.
After all, there's no way I could have servers in England, though it's
quite natural to have them in America.

ChrisA





You are right. You could have servers anywhere in the world.
But i will assume the following hostnames are yours:

mail14.ess.barracuda.com
mail0.ess.barracuda.com

I'm quite sure this time because i notice that the last days when i make 
a post about my script these 2 hostnames were the first hits into my 
website and your comments are the most immediate responses i had in my 
threads just a few minutes after the hits.

--
https://mail.python.org/mailman/listinfo/python-list


Re: To whoever hacked into my Database

2013-11-08 Thread Νίκος Αλεξόπουλος

Στις 9/11/2013 8:45 πμ, ο/η Chris Angelico έγραψε:

On Sat, Nov 9, 2013 at 5:35 PM, Νίκος Αλεξόπουλος  wrote:

I believe these hostnames belong to you:

mail14.ess.barracuda.com
mail0.ess.barracuda.com
89-145-108-205.as29017.net
209.133.77.167.T01713-01.above.net
209.133.77.164.T01713-01.above.net

Correct me if i'm wrong.


You're wrong; that is, at least one of those does not belong to me.
Beyond that, I won't say.

ChrisA



These 4 are yours for sure:

mail14.ess.barracuda.com
mail0.ess.barracuda.com
209.133.77.167.T01713-01.above.net
209.133.77.164.T01713-01.above.net

This one '89-145-108-205.as29017.net' is not because this originate from 
Europe/London as my GeoIP part of my script detect and you live in 
Australia.

--
https://mail.python.org/mailman/listinfo/python-list


Re: To whoever hacked into my Database

2013-11-08 Thread Νίκος Αλεξόπουλος

Στις 9/11/2013 8:37 πμ, ο/η Chris Angelico έγραψε:

On Sat, Nov 9, 2013 at 5:32 PM, Νίκος Αλεξόπουλος  wrote:

I'am not saying out of arrogance but i was really under the impression i had
secure my script.

And i had until i made some new changes last night, which i think i have
corrected now as we speak.


In other words, you closed off whatever you could see as being a
problem, and then boasted that the script was secure... until someone
proved to you that it wasn't. Your script is insecure by default, and
you're band-aid patching everything you happen to be made aware of.
What makes you think that it's now secure?

ChrisA




Its probably unwise to post the following snippet of code that validates 
user input so an attacker wouldn't pass arbitrary values to my script 
but what the heck.


==
# initiate some local variables
htmlvalid = pyvalid = False
path = '/home/nikos/public_html/'
cgi_path = '/home/nikos/public_html/cgi-bin/'

# define how the .html or .python pages are called
file = form.getvalue('file')			# this value should come only from 
.htaccess and not as http://superhost.gr/~nikos/cgi-bin/metrites.py
page = form.getvalue('page')			# this value comes from 'index.html' or 
from within 'metrites.py'


# is it a python file or an html template?
if page and os.path.exists( cgi_path + page ):
pyvalid = True
elif os.path.exists( file ):
page = file.replace( path, '' )
htmlvalid = True
else:
file = 'forbidden'

.
.

if 'forbidden' in file:
	print( '''Δεν επιτρέπεται η απευθείας πρόσβαση στο 
script παρά μόνον μέσω της αρχικής σελίδας!	Ανακατεύθυνση σε 5...''' )
	print( '''content="5;URL=http://superhost.gr";>''' )

sys.exit(0)
==


Now, when it comes to database insertions i use this check to prevent 
bogus data:


==
if cookieID != 'some_secret_here' and ( htmlvalid or pyvalid ) and 
re.search( 
r'(amazon|google|proxy|cloud|reverse|fetch|msn|who|spider|crawl|ping)', 
host ) is None:

==

Even if i get re-hacked i'll find a security alternative.


--
https://mail.python.org/mailman/listinfo/python-list


Re: To whoever hacked into my Database

2013-11-08 Thread Νίκος Αλεξόπουλος

Στις 9/11/2013 8:20 πμ, ο/η Chris Angelico έγραψε:

On Sat, Nov 9, 2013 at 4:54 PM, Νίκος Αλεξόπουλος  wrote:

Στις 6/11/2013 5:25 μμ, ο/η Νίκος Γκρ33κ έγραψε:


Okey let the hacker try again to mess with my database!!!

He is done it twice, lets see if he will make it again!

I'am waiting!




I have to congratulate the hacher because as it seems s/he's done it again.

S/he's manages to actually pass fake filename values inside my db even after
my changes:


https://en.wikipedia.org/wiki/Hubris

ChrisA




I believe these hostnames belong to you:

mail14.ess.barracuda.com
mail0.ess.barracuda.com
89-145-108-205.as29017.net
209.133.77.167.T01713-01.above.net
209.133.77.164.T01713-01.above.net

Correct me if i'm wrong.
--
https://mail.python.org/mailman/listinfo/python-list


Re: To whoever hacked into my Database

2013-11-08 Thread Νίκος Αλεξόπουλος

Στις 9/11/2013 8:20 πμ, ο/η Chris Angelico έγραψε:

On Sat, Nov 9, 2013 at 4:54 PM, Νίκος Αλεξόπουλος  wrote:

Στις 6/11/2013 5:25 μμ, ο/η Νίκος Γκρ33κ έγραψε:


Okey let the hacker try again to mess with my database!!!

He is done it twice, lets see if he will make it again!

I'am waiting!




I have to congratulate the hacher because as it seems s/he's done it again.

S/he's manages to actually pass fake filename values inside my db even after
my changes:


https://en.wikipedia.org/wiki/Hubris

ChrisA




I'am not saying out of arrogance but i was really under the impression i 
had secure my script.


And i had until i made some new changes last night, which i think i have 
corrected now as we speak.

--
https://mail.python.org/mailman/listinfo/python-list


Re: To whoever hacked into my Database

2013-11-08 Thread Νίκος Αλεξόπουλος

Στις 9/11/2013 7:54 πμ, ο/η Νίκος Αλεξόπουλος έγραψε:

Στις 6/11/2013 5:25 μμ, ο/η Νίκος Γκρ33κ έγραψε:

Okey let the hacker try again to mess with my database!!!

He is done it twice, lets see if he will make it again!

I'am waiting!



I have to congratulate the hacher because as it seems s/he's done it again.

S/he's manages to actually pass fake filename values inside my db even
after my changes:

here is prrof:   http://superhost.gr/?show=stats

Now i need to hit my head into the wall until i understand how this thing



Here is the link proof of the hack because now i have deleted this bogus 
entries:   http://i.imgur.com/eqahBMj.png


Perhaps these '../../' attempts were actually an attempt to try reading 
sensitive server's data from within'/etc' so to gain root in my system.



Last night i have made some changes to the way i validate user input but 
as it seems the new scenario didn't work efficiently.


I just re-altered something and i'm curious if this can happen once again.

--
https://mail.python.org/mailman/listinfo/python-list


Re: To whoever hacked into my Database

2013-11-08 Thread Νίκος Αλεξόπουλος

Στις 6/11/2013 5:25 μμ, ο/η Νίκος Γκρ33κ έγραψε:

Okey let the hacker try again to mess with my database!!!

He is done it twice, lets see if he will make it again!

I'am waiting!



I have to congratulate the hacher because as it seems s/he's done it again.

S/he's manages to actually pass fake filename values inside my db even 
after my changes:


here is prrof:   http://superhost.gr/?show=stats

Now i need to hit my head into the wall until i understand how this thing
--
https://mail.python.org/mailman/listinfo/python-list


Re: datetime question

2013-11-08 Thread Νίκος Αλεξόπουλος

Στις 9/11/2013 12:49 πμ, ο/η Denis McMahon έγραψε:

On Sat, 09 Nov 2013 00:01:37 +0200, Νίκος Αλεξόπουλος wrote:


I saw the link and i'm wondering if it can be written in 1-liner.


Yes, but you have to rewrite all your code in perl to do this.




Please tell me and as a git i will provide you with 2 good pdfs i just 
found:


You can see them at my website if you click the blue download button.

The 1st is a Linux Bile and the 2nd is WebHosting for Dummies.
--
https://mail.python.org/mailman/listinfo/python-list


Re: datetime question

2013-11-08 Thread Νίκος Αλεξόπουλος

Στις 8/11/2013 11:29 μμ, ο/η Mark Lawrence έγραψε:

On 08/11/2013 21:11, Νίκος Αλεξόπουλος wrote:

Is there someway to write the following line even better with the
ability to detect daylight saving time by itself so i don't have to
alter the line manually when time changes?

lastvisit = ( datetime.utcnow() + timedelta(hours=2) ).strftime(
'%y-%m-%d %H:%M:%S' )# MySQL datetime format

Thanks.


http://stackoverflow.com/questions/19774709/use-python-to-find-out-if-a-timezone-currently-in-daylight-savings-time





I saw the link and i'm wondering if it can be written in 1-liner.
Don't get me wrong but i had the lastvisit calculated on 1 statement and 
i want to retain it this way.


Is it possible?
--
https://mail.python.org/mailman/listinfo/python-list


datetime question

2013-11-08 Thread Νίκος Αλεξόπουλος
Is there someway to write the following line even better with the 
ability to detect daylight saving time by itself so i don't have to 
alter the line manually when time changes?


lastvisit = ( datetime.utcnow() + timedelta(hours=2) ).strftime( 
'%y-%m-%d %H:%M:%S' )# MySQL datetime format


Thanks.
--
https://mail.python.org/mailman/listinfo/python-list


Re: To whoever hacked into my Database

2013-11-08 Thread Νίκος Αλεξόπουλος

Στις 8/11/2013 7:11 μμ, ο/η ru...@yahoo.com έγραψε:

On 11/08/2013 03:05 AM, Νίκος Αλεξόπουλος wrote:

I never ignore advices.
I read all answers as carefully as i can.
But nevertheless sometimes i feel things should have been better
implemented using my way.

Not of course that i know better, but thats better suited for me in the
level iam.


Most of the "advice" I've seen posted here has, as far
as I can tell, not intended to be useful but to serve
as a way to telling you are incompetent are in other ways
insulting or useless.  I think you are quite right to
ignore it (or tell the poster to get lost.)

Long before you showed up here, I noticed the tendency
to not answer questions directly but to jerk people off
by giving hints or telling them to do something other
than they want to do.

Often that is good because the original request was
for something that the OP really didn't want to do.
But sometimes the OP knows they want to do (but doesn't
want or is unable to clearly explain why) and when
they clearly state that, yes, they do want to do it
their way, their question should be answered in good
faith or, for those who just can't tell how to do
something "wrong", ignored.

Instead the response is typically a lot of hostility
directed at them for not "taking advice".  In other
words, the advice here is not free advice, but come
with the price that you are expected to except it
gratefully whether it was what you asked for or not.

I think you are quite right to reject advice that does
not do what you want and ask again for advice that does.

FWIW, I am quite sure there are other readers of this
group who feel the same way, but most people aren't
willing to subject themselves to the bullying that
will be directed at anyone who publicly agrees with you.
It is the same way in real life too as I'm sure
you know.

Just wanted to let you know that not everybody here
is an asshole.  It is just that assholes, by their
nature, are the loudest.



Thank you for your support rurpy.
Not all ppl in this list are rude and insulting.

--
What is now proved was at first only imagined! & WebHost
<http://superhost.gr>
--
https://mail.python.org/mailman/listinfo/python-list


Re: To whoever hacked into my Database

2013-11-08 Thread Νίκος Αλεξόπουλος

Στις 8/11/2013 8:19 μμ, ο/η Denis McMahon έγραψε:

On Fri, 08 Nov 2013 01:28:19 +0200, Νίκος Αλεξόπουλος wrote:


If i was completely incompetent i wouldn't had a working website and i
wasn't able to design my customers' webpages.


If your website is working, why do you keep posting here asking us how to
fix it?




Because at some parts i need some help, i'm a beginner and i 
unexperienced what it comes to something more advance.

--
https://mail.python.org/mailman/listinfo/python-list


Re: To whoever hacked into my Database

2013-11-08 Thread Νίκος Αλεξόπουλος

Στις 8/11/2013 7:01 μμ, ο/η unknown έγραψε:

On Fri, 08 Nov 2013 18:57:21 +0200, Νίκος Αλεξόπουλος wrote:


Στις 8/11/2013 6:48 μμ, ο/η unknown έγραψε:

On Fri, 08 Nov 2013 18:28:39 +0200, Νίκος Αλεξόπουλος wrote:


Στις 8/11/2013 6:06 μμ, ο/η Mark Lawrence έγραψε:


But let's not waste any more time on this.  Please get back to
checking your web site.  She might have been hacking again.  Or
little fingers from one of my highly paid contractors might have been
up to no good. Oh but I forgot, you've made it hacker proof now.
You'll sleep much better knowing your site is safe.  Or is it?




Many visitors per hour in my website.
They didn't manage to mess with the db again or the variables i'm
utilizing.

The hacker maybe a blondie and she cant get a workaround after my
changes.

At least lest hope she is a pretty hacker wannabe :-)


let me get this straight

You have no aptitude for programming,
your database skills are non-existent,
you have no clue regarding even basic debugging techniques,
you an an incompetent system administrator,
you cannot even follow basic instructions when you ask for assistance
Yet you feel you can make blond jokes and belittle someone who has
demonstrated the flaws in your set-up multiple times?

I have not laughed so much in years. You really should be on the stage,
there is one leaving in 10 minutes.




I have all of the above characteristics in a small degree.

If the mighty hacker is so good and i'm so bad in programming and
securing my script why cant she break bad again?

And why are you posting under your real name but as "unknown" instead?


Because I do not want a twit like you sending me direct emails.




Like i was in the mood of sending mail to a twat like youself.
--
https://mail.python.org/mailman/listinfo/python-list


Re: To whoever hacked into my Database

2013-11-08 Thread Νίκος Αλεξόπουλος

Στις 8/11/2013 6:48 μμ, ο/η unknown έγραψε:

On Fri, 08 Nov 2013 18:28:39 +0200, Νίκος Αλεξόπουλος wrote:


Στις 8/11/2013 6:06 μμ, ο/η Mark Lawrence έγραψε:


But let's not waste any more time on this.  Please get back to checking
your web site.  She might have been hacking again.  Or little fingers
from one of my highly paid contractors might have been up to no good.
Oh but I forgot, you've made it hacker proof now.  You'll sleep much
better knowing your site is safe.  Or is it?




Many visitors per hour in my website.
They didn't manage to mess with the db again or the variables i'm
utilizing.

The hacker maybe a blondie and she cant get a workaround after my
changes.

At least lest hope she is a pretty hacker wannabe :-)


let me get this straight

You have no aptitude for programming,
your database skills are non-existent,
you have no clue regarding even basic debugging techniques,
you an an incompetent system administrator,
you cannot even follow basic instructions when you ask for assistance Yet
you feel you can make blond jokes and belittle someone who has
demonstrated the flaws in your set-up multiple times?

I have not laughed so much in years. You really should be on the stage,
there is one leaving in 10 minutes.




I have all of the above characteristics in a small degree.

If the mighty hacker is so good and i'm so bad in programming and 
securing my script why cant she break bad again?


And why are you posting under your real name but as "unknown" instead?
--
https://mail.python.org/mailman/listinfo/python-list


Re: To whoever hacked into my Database

2013-11-08 Thread Νίκος Αλεξόπουλος

Στις 8/11/2013 6:06 μμ, ο/η Mark Lawrence έγραψε:


But let's not waste any more time on this.  Please get back to checking
your web site.  She might have been hacking again.  Or little fingers
from one of my highly paid contractors might have been up to no good. Oh
but I forgot, you've made it hacker proof now.  You'll sleep much better
knowing your site is safe.  Or is it?




Many visitors per hour in my website.
They didn't manage to mess with the db again or the variables i'm utilizing.

The hacker maybe a blondie and she cant get a workaround after my changes.

At least lest hope she is a pretty hacker wannabe :-)
--
https://mail.python.org/mailman/listinfo/python-list


Re: To whoever hacked into my Database

2013-11-08 Thread Νίκος Αλεξόπουλος

Στις 8/11/2013 4:02 μμ, ο/η Mark Lawrence έγραψε:

On 08/11/2013 10:09, Chris Angelico wrote:

On Fri, Nov 8, 2013 at 9:00 PM, Mark Lawrence
 wrote:

On 08/11/2013 09:52, Chris Angelico wrote:

Mar-Kal El-awrence! Able to leap tall bridges in a single bound, more
powerful than a steaming (and fuming) Greek webmaster, the Man of
Silicon, BREAMOREBOY!


Thank you for shouting out the name of the village that's at *THE*
center of
*THE* universe :)


I've no idea where that village is - or even that it's a village - all
I did was take your superhero name from your email address. :)

ChrisA



Poor old Nikos wouldn't even qualify as Bicycle Repair Man.  In fact I
doubt that he can ride a bike, or even a trike for that matter :)




If one of us were to feel sorry about himself, that would be you because 
of suffering of Autism disorder.


You have demonstrated significant difficulties in social interaction and 
behavior.


Seek help ASAP!
--
https://mail.python.org/mailman/listinfo/python-list


Re: To whoever hacked into my Database

2013-11-08 Thread Νίκος Αλεξόπουλος

Στις 8/11/2013 3:30 μμ, ο/η Mark Lawrence έγραψε:

On 08/11/2013 10:00, Νίκος Αλεξόπουλος wrote:



I have never exposed my client's data. Prove otherwise.


If your site has successfully been hacked *TWICE* then by definition
your clients data has been exposed.  Didn't you also hand out your
password, that's really secure, isn't it?



The only legal action that will happen will take place in your
Asperger's Syndrome sick imagination.


I must be winning as you've now had to resort to insults.  I assume that
you're jealous because my "Asperger Syndrome sick" mind knows what
"TypeError: 'NoneType' object is not iterable" actually means.  You
couldn't work it out despite Steven D'Aprano literally spelling it out
in words of one syllable or less.




Of course i know what it means. It says it clearly.

An object returned None as a result, and None is not something we can 
iterate upon. My question was actually referring to the reason of that 
object being empty instead of holding value(s) within it. It was more of 
a supreise that it didn't return back any data.

--
https://mail.python.org/mailman/listinfo/python-list


Re: To whoever hacked into my Database

2013-11-08 Thread Νίκος Αλεξόπουλος

Στις 8/11/2013 3:12 μμ, ο/η Tim Delaney έγραψε:

On 8 November 2013 21:00, Νίκος Αλεξόπουλος mailto:nikos.gr...@gmail.com>> wrote:

I have never exposed my client's data. Prove otherwise.


https://mail.python.org/pipermail/python-list/2013-June/648550.html

Or don't you consider giving the root password for a server containing
client data to a complete stranger to be "exposing" that data?

Tim Delaney



I gave the root password to Chris because i was under the false(as 
proven) impression that he was gonna actually help my code.


If i knew, that this wasn't his intention i would not give it away.
--
https://mail.python.org/mailman/listinfo/python-list


Re: To whoever hacked into my Database

2013-11-08 Thread Νίκος Αλεξόπουλος

Στις 8/11/2013 11:55 πμ, ο/η Mark Lawrence έγραψε:

On 08/11/2013 09:39, Νίκος Αλεξόπουλος wrote:


You wouldn't be able to write the scripts i have written.
All you do is criticize me, but you never ever have posted code to
anything i have asked.

Perhaps you can't even write a simple script.


That's again correct.  Everytime a question gets asked on the tutor
mailing list, I read about it in the manuals, something that to my
knowledge you've never done, then I post a reply.  I never reply to you
as I've no expertise in using Python on web sites, plus it's a waste of
time as you ignore the advice anyway.




I never ignore advices.
I read all answers as carefully as i can.
But nevertheless sometimes i feel things should have been better 
implemented using my way.


Not of course that i know better, but thats better suited for me in the 
level iam.

--
https://mail.python.org/mailman/listinfo/python-list


Re: To whoever hacked into my Database

2013-11-08 Thread Νίκος Αλεξόπουλος

Στις 8/11/2013 11:52 πμ, ο/η Mark Lawrence έγραψε:

On 08/11/2013 09:34, Νίκος Αλεξόπουλος wrote:

Στις 8/11/2013 11:15 πμ, ο/η Mark Lawrence έγραψε:

On 08/11/2013 01:32, alex23 wrote:

On 8/11/2013 7:39 AM, Ian Kelly wrote:

Unless the Python installation on Nikos' system has become self-aware
and is actively objecting to his code, I think that messages like
"Read a manual" and "Learn to code" inserted into a database (as seen
in the images that Nikos linked earlier) would normally suggest a
hacker.


I just assumed he'd written himself a to-do app and couldn't be
bothered
with the hussle of creating a separate table to store its items.



Made my day :)




And if you jump over a bridge it would make my day!


I feel no need to jump but thank you anyway.  When your customers start
taking legal action for you exposing their data, and when I start
visiting your web site and demanding data on my usage which you must
provide in accordance with EU law, then I'm hoping that you'll be kind
enough to us do this favour and jump.  Failing that the blow lamp and
piece of iron are still available, I just wish they'd been used months
ago.  No, I withdraw that last comment, the previous months have led to
some of the funniest threads I've ever seen on this list, and you've
been at the heart of them.  Thank you for making me laugh my socks off.




I have never exposed my client's data. Prove otherwise.

The only legal action that will happen will take place in your 
Asperger's Syndrome sick imagination.

--
https://mail.python.org/mailman/listinfo/python-list


Re: To whoever hacked into my Database

2013-11-08 Thread Νίκος Αλεξόπουλος

Στις 8/11/2013 11:19 πμ, ο/η Mark Lawrence έγραψε:

On 08/11/2013 08:59, Νίκος Αλεξόπουλος wrote:

Στις 8/11/2013 10:31 πμ, ο/η Chris Angelico έγραψε:

On Fri, Nov 8, 2013 at 7:20 PM, Νίκος Αλεξόπουλος
 wrote:

Fortunately for me they have all failed.
That means that i have *actually* made security of my scripts stronger.

Now whoever called me incompetent should think again before he
accused me of
so. :-)


https://en.wikipedia.org/wiki/Hubris

ChrisA




I have said this not out of arrogance but to shut some mounts calling me
complete incompetent.


Ignoring the bit about shutting mounts, which shows how much effort you
ever put into anything that you post, actually here I agree with you.
But don't get too excited, it's only because "completely" isn't a strong
enough adjective to use for your level of incompetence.




You wouldn't be able to write the scripts i have written.
All you do is criticize me, but you never ever have posted code to 
anything i have asked.


Perhaps you can't even write a simple script.
--
https://mail.python.org/mailman/listinfo/python-list


Re: To whoever hacked into my Database

2013-11-08 Thread Νίκος Αλεξόπουλος

Στις 8/11/2013 11:19 πμ, ο/η Mark Lawrence έγραψε:

On 08/11/2013 08:59, Νίκος Αλεξόπουλος wrote:

Στις 8/11/2013 10:31 πμ, ο/η Chris Angelico έγραψε:

On Fri, Nov 8, 2013 at 7:20 PM, Νίκος Αλεξόπουλος
 wrote:

Fortunately for me they have all failed.
That means that i have *actually* made security of my scripts stronger.

Now whoever called me incompetent should think again before he
accused me of
so. :-)


https://en.wikipedia.org/wiki/Hubris

ChrisA




I have said this not out of arrogance but to shut some mounts calling me
complete incompetent.


Ignoring the bit about shutting mounts, which shows how much effort you
ever put into anything that you post, actually here I agree with you.
But don't get too excited, it's only because "completely" isn't a strong
enough adjective to use for your level of incompetence.




You wouldn't be able to write the scripts i have written.
All you do is criticize me, but you never ever have posted code to 
anything i have asked.


Perhaps you can't even write a simpel script
--
https://mail.python.org/mailman/listinfo/python-list


Re: To whoever hacked into my Database

2013-11-08 Thread Νίκος Αλεξόπουλος

Στις 8/11/2013 11:15 πμ, ο/η Mark Lawrence έγραψε:

On 08/11/2013 01:32, alex23 wrote:

On 8/11/2013 7:39 AM, Ian Kelly wrote:

Unless the Python installation on Nikos' system has become self-aware
and is actively objecting to his code, I think that messages like
"Read a manual" and "Learn to code" inserted into a database (as seen
in the images that Nikos linked earlier) would normally suggest a
hacker.


I just assumed he'd written himself a to-do app and couldn't be bothered
with the hussle of creating a separate table to store its items.



Made my day :)




And if you jump over a bridge it would make my day!
--
https://mail.python.org/mailman/listinfo/python-list


Re: To whoever hacked into my Database

2013-11-08 Thread Νίκος Αλεξόπουλος

Στις 8/11/2013 10:31 πμ, ο/η Chris Angelico έγραψε:

On Fri, Nov 8, 2013 at 7:20 PM, Νίκος Αλεξόπουλος  wrote:

Fortunately for me they have all failed.
That means that i have *actually* made security of my scripts stronger.

Now whoever called me incompetent should think again before he accused me of
so. :-)


https://en.wikipedia.org/wiki/Hubris

ChrisA




I have said this not out of arrogance but to shut some mounts calling me 
complete incompetent.

--
https://mail.python.org/mailman/listinfo/python-list


Re: To whoever hacked into my Database

2013-11-08 Thread Νίκος Αλεξόπουλος

Στις 6/11/2013 5:25 μμ, ο/η Νίκος Γκρ33κ έγραψε:

Okey let the hacker try again to mess with my database!!!

He is done it twice, lets see if he will make it again!

I'am waiting!



I'am pleased to see that various ppl have tried to mess my db by

1. submitted my webiste to netcraft.com for secucirty vuln search

2. tried to pass arbitrary values to 'page' variable by doing
http://superhost.gr?page="some_string_here";

3. tried to access the sources of my scripts by
http://superhost.gr/~nikos/cgi-bin/metrites.py
http://superhost.gr/~nikos/cgi-bin/pelatologio.py
http://superhost.gr/~nikos/cgi-bin/files.py


Fortunately for me they have all failed.
That means that i have *actually* made security of my scripts stronger.

Now whoever called me incompetent should think again before he accused 
me of so. :-)

--
https://mail.python.org/mailman/listinfo/python-list


Re: To whoever hacked into my Database

2013-11-07 Thread Νίκος Αλεξόπουλος

Στις 8/11/2013 1:18 πμ, ο/η Grant Edwards έγραψε:

On 2013-11-07, ?? ??  wrote:

 8/11/2013 1:04 , ??/?? Chris Angelico :

On Fri, Nov 8, 2013 at 9:56 AM, ?? ?? 
 wrote:



Also i never claimed i was a professional coder,



But my customers,


If you have customers, then you're pretending to a professional.


which are all friends are getting what they are paying for.


If people are paying you, then you're pretending to be a professional.

Nobody said you can't be a professional while at the same time being
completely incompetent.  One would hope the market forces don't allow
such a situation to persist, but there are an awful lot of suckers out
there...




If i was completely incompetent i wouldn't had a working website and i 
wasn't able to design my customers' webpages.


You know some basic stuff and learn along the way, thats what people do, 
we didn't all born competent and ready just like you.


Also i don't have to explain my job or grant permission from Grant to 
start a business. I don't care if you think otherwise.

--
https://mail.python.org/mailman/listinfo/python-list


Re: To whoever hacked into my Database

2013-11-07 Thread Νίκος Αλεξόπουλος

Στις 8/11/2013 1:04 πμ, ο/η Chris Angelico έγραψε:

On Fri, Nov 8, 2013 at 9:56 AM, Νίκος Αλεξόπουλος  wrote:

Also i never claimed i was a professional coder, i am an amateur at a
beginner level and i do it out of hobby.


You've stated a number of times that your problems are critical
because you're losing customers. In English, "professional" means you
make money - that is, that you either get a salary for it or you have
paying customers. That's what we're objecting to, because we think
that you shouldn't - in fact, you *are* an amateur (doing it because
you love it) and you *should be* a non-professional (doing it for no
money); even though technically those words aren't opposites, they're
often treated that way.

ChrisA




But my customers, which are all friends are getting what they are paying 
for.

And that is a webpage design and a working website along with cPanel.
Its at my own domain that i'am experimenting not on server system wide 
changes.


I will improve on linux and python scripting over time, day by day
--
https://mail.python.org/mailman/listinfo/python-list


Re: To whoever hacked into my Database

2013-11-07 Thread Νίκος Αλεξόπουλος

Στις 8/11/2013 12:46 πμ, ο/η Tim Delaney έγραψε:

On 8 November 2013 09:45, Tim Delaney mailto:timothy.c.dela...@gmail.com>> wrote:

On 8 November 2013 09:18, Νίκος Αλεξόπουλος mailto:nikos.gr...@gmail.com>> wrote:

I feel a bit proud because as it seems i have manages to secure
it more tight. All i need to do was to validate user input data,
so the hacker won't be able again to pass bogus values to
specific variables that my script was using.


So we now have confirmation that Nikos' site is subject to SQL
injection attacks on anything that he is not specifically
validating. And I'm absolutely sure that he has identified every
location where input needs to be validated, and that it is
impossible to get past the level of validation that he's doing, so
the site is completely secure! Just like the last time he claimed
that (and the time before, and the time before that ...).


Not to mention the idiocy of exposing your web server logs to the
outside world ... (no - I didn't go there - I want no chance of getting
malware from his site).

Tim Delaney



It was necessary post post web server's logs by doing
tail -f '/usr/local/apache/logs/error_log'

so to display the error message i got.

Also i never claimed i was a professional coder, i am an amateur at a 
beginner level and i do it out of hobby.


I could have designed my website in a CMS( wordpress, joomla) but i like 
programming and wanted to design and learn to code at the same time.


Since i'm an idiot as you call me try to hack it yourself since you are 
so smart.


And i don;t think it was an sql injection by the way.
It was just a manipulation of the 'page' variable my script is using.
Hacker was able to pass bogus info to that variable.

I believe he passed values to var 'page' via URL like

http://superhost.gr/?page='

--
https://mail.python.org/mailman/listinfo/python-list


Re: To whoever hacked into my Database

2013-11-07 Thread Νίκος Αλεξόπουλος

Στις 7/11/2013 11:29 μμ, ο/η Denis McMahon έγραψε:

On Thu, 07 Nov 2013 01:01:38 -0800, Ferrous Cranus wrote:


Τη Πέμπτη, 7 Νοεμβρίου 2013 12:11:20 π.μ. UTC+2, ο χρήστης Mark Lawrence
έγραψε:



... hope that this time she destroys ...



So she is a SHE! How do you know that the person hacked into my DB is a
female?




If you were actually hacked, I'd guess it was most likely sql injection
using a hand crafted get or post request that exploited some
vulnerability that you have carelessly posted in an internet forum and
then ignored advice to make secure.


Its true that i need to be more careful when posting sensitive snippets.
Many times i have posted actual mysql passwords in clear text as seen at 
the pymysql connector and other sensitive information.


Now, i don't think s/he can be successful again.
I like to think that i have tighten script's security by validating user 
input before i utilize this information, especially in insertion time 
into the db.


http://superhost.gr/?show=log&page=index.html

The link above shows how many people visit my website and at the top 
entry with the unknown hostname, referer field told me that someone 
passed my website's url into http://netcraft.com to search the server 
for vulnera





--
https://mail.python.org/mailman/listinfo/python-list


Re: To whoever hacked into my Database

2013-11-07 Thread Νίκος Αλεξόπουλος

Στις 7/11/2013 11:45 μμ, ο/η Joel Goldstick έγραψε:

On Thu, Nov 7, 2013 at 4:39 PM, Ian Kelly  wrote:

On Thu, Nov 7, 2013 at 2:20 PM, Denis McMahon  wrote:

I think the hacker is a figment of Nick's imagination, or rather a
consequence of his broken python code corrupting his data.


Unless the Python installation on Nikos' system has become self-aware
and is actively objecting to his code, I think that messages like
"Read a manual" and "Learn to code" inserted into a database (as seen
in the images that Nikos linked earlier) would normally suggest a
hacker.
--
https://mail.python.org/mailman/listinfo/python-list


but... a very polite hacker





Not so polite, since in one arbitrary record into my clients db he 
placed the entry "Stupid Coder, Stupid Site".


But i'm happy that s/he cannot mess again with my databases.

I feel a bit proud because as it seems i have manages to secure it more 
tight. All i need to do was to validate user input data, so the hacker 
won't be able again to pass bogus values to specific variables that my 
script was using.


Prove me otherwise mighty one if i'm mistaken!
--
https://mail.python.org/mailman/listinfo/python-list


Re: Adding 'download' column to existing 'visitors' table (as requested)

2013-11-07 Thread Νίκος Αλεξόπουλος

Στις 7/11/2013 8:08 μμ, ο/η Neil Cerutti έγραψε:

On 2013-11-07, ?? ??
 wrote:

I called you an idiot, because in your previous and current
message you called me too.

I know that splitting information across tables and maintain
foreign keys for retain relationships between them is a
necessary thing but in my case i only just an extra pieces of
information to eb associated with my visitor, a possible file
download. and i have decided just to add an extra colum to the
existing 'visitors' database and this is adequate.


Non-normalized data is sometimes a fine idea. How you plan to use
the data once it is stored will be the deciding factor.


Exactly.


One big win with databases is that you can query them really
easily using SQL. Non-normalized data negates that advantage.

How would you write a query to discover all the visitors who
downloaded file XYZ? With your storage scheme, you can't. So by
storing the data this way, you are promising yourself that you'll
never need to write that query, or at least, you won't need to do
it very often.

That would be a problem yes.
But as you said above the deciding factor is the "how" we plan to use 
out stored data.


And my plan is to just display the records of all visitors per webpage 
with the last column being a list of this specific visitors 'downloads' 
as can be seen visually here:


http://superhost.gr/?show=log&page=index.html

'Δεν πραγματοποίηθηκαν ακόμη!' mean that this visitor hasn't download 
anything yet, if he does a drop down menu will appear in that place 
displaying his file picks.


People can download files from here:'http://superhost.gr/?page=files.py

(these torrent are just for testing reasons. later i will put my own 
selection of files)



--
https://mail.python.org/mailman/listinfo/python-list


Re: Adding 'download' column to existing 'visitors' table (as requested)

2013-11-07 Thread Νίκος Αλεξόπουλος

Στις 7/11/2013 5:11 μμ, ο/η Joel Goldstick έγραψε:

On Thu, Nov 7, 2013 at 9:37 AM, Chris Angelico  wrote:

On Fri, Nov 8, 2013 at 1:09 AM, Νίκος Αλεξόπουλος  wrote:

Why create a whole new 'downloads' table and associate it with the with a
foreign key with the 'visitors' table you idiot when you can just have an
extra column at the end of the current 'visitor's table?

Both 'downloader' and 'downlaod' is associated by being in the same record.

By your logic every time we want to store an extra piece of information we
have to create an extra database table.

Too much hussle for no good reason


First of all Nikos, you are not qualified to determine if there is
reason to design a database in any particular way, since you don't
understand what a relational database is.
Secondly, in earlier threads I provided you with a link to a wikipedia
article about first normal form and why it is a necessary component of
data base design.
If you don't want to use a database, good for you, but if you can't
get your website to work and you ask for help, then respond that the
help is 'too much hussle', you are disrespectful.
You don't bother me because you are lazy, and arogant, and whiny.  Or
that you lack skills.  You are a cargo cult programmer.  I know you
won't look that up.  You bother me because you are disrespectful.  The
most disrespectful person I have ever encountered on line.

On a side note to whoever hacks into Nick the idiots website -- why
not just take it down.  Then he won't have any need to spend his 20
euros, and there will be no code to fix.  Problem solved!







I called you an idiot, because in your previous and current message you 
called me too.


I know that splitting information across tables and maintain foreign 
keys for retain relationships between them is a necessary thing but in 
my case i only just an extra pieces of information to eb associated with 
my visitor, a possible file download.


and i have decided just to add an extra colum to the existing 'visitors' 
database and this is adequate.


I still don't know why you push me to create an extra table instead.

It may seem that i'm clue resistant sometimes and i'm but this is not 
because out of arogance but as a result of failign to under

--
https://mail.python.org/mailman/listinfo/python-list


Re: To whoever hacked into my Database

2013-11-07 Thread Νίκος Αλεξόπουλος

Στις 7/11/2013 6:45 μμ, ο/η Joel Goldstick έγραψε:

On Thu, Nov 7, 2013 at 11:34 AM, Mark Lawrence  wrote:

On 07/11/2013 13:47, Νίκος Αλεξόπουλος wrote:


Στις 7/11/2013 11:31 πμ, ο/η Ferrous Cranus έγραψε:


Τη Πέμπτη, 7 Νοεμβρίου 2013 11:15:02 π.μ. UTC+2, ο χρήστης Steve
Simmons έγραψε:


Please tell me you aren't storing details of customers and payments
on your Web > server.




Oh but i do!
I need this information to be accessible ONLY FOR ME via my website
'http://superhost.gr' i just need to secure it more tight.


Its not only for you, its for 'her' too.  Maybe next time she will
change your passwords so you can't get in.d


Even if "she" changes the root password(assuming she's somehow in 
control of my VPS), i can easily alter it in some other string of my 
liking very easily.

--
https://mail.python.org/mailman/listinfo/python-list


Re: To whoever hacked into my Database

2013-11-07 Thread Νίκος Αλεξόπουλος

Στις 7/11/2013 6:34 μμ, ο/η Mark Lawrence έγραψε:

On 07/11/2013 13:47, Νίκος Αλεξόπουλος wrote:

Στις 7/11/2013 11:31 πμ, ο/η Ferrous Cranus έγραψε:

Τη Πέμπτη, 7 Νοεμβρίου 2013 11:15:02 π.μ. UTC+2, ο χρήστης Steve
Simmons έγραψε:


Please tell me you aren't storing details of customers and payments
on your Web > server.



Oh but i do!
I need this information to be accessible ONLY FOR ME via my website
'http://superhost.gr' i just need to secure it more tight.



I think i have made it.

The hacker, didn't manage to mess again with either of my counters or
clients databases.

Too bad! I though 'she' was better than that!


She's just biding her time so as to cause you maximum pain!!!




Bring it on baby!

I like this challenge because it makes me improve on overall python 
script security(most of it being securing user input data before 
actually perform database queries).


I also understand than in my attempt to get help with my code i provided 
"too much of it" which was successfully utilized by the hacker to attack 
my website!


You didn't answer me though!
Is the hacker really a female?
And if she is, is she pretty? :)
--
https://mail.python.org/mailman/listinfo/python-list


Re: To whoever hacked into my Database

2013-11-07 Thread Νίκος Αλεξόπουλος

Στις 7/11/2013 3:59 μμ, ο/η Chris Angelico έγραψε:

On Fri, Nov 8, 2013 at 12:46 AM, Νίκος Αλεξόπουλος
 wrote:

How much will it cost to take to convert my current 'counters.py' script to
a 'webpy' framework style?

Please make a really good price.
We are talking about a small script.


My rates start at $100/hr and come with the requirement that you
actually listen to what I'm saying. Actually, you'll probably find
that you can skip the $100/hr if you just listen to the advice you've
been given for free on this list, but you asked for a "really good
price", and for this kind of work, I think the price I quoted is
exactly that.

ChrisA




--
100 bucks per hour? Oh My, i cant afford this at all.
All i can give is 20 euros for the conversions of the script to 
framework style.


Its not like you are going to create the script from scratch, you will 
just need to modify it in some fashion to make it frameworked because i 
don't have the slightest clue how to implement this.

--
https://mail.python.org/mailman/listinfo/python-list


Re: Adding 'download' column to existing 'visitors' table (as requested)

2013-11-07 Thread Νίκος Αλεξόπουλος

Στις 7/11/2013 3:52 μμ, ο/η Joel Goldstick έγραψε:

2. the download is remained associated with the person that made the
download since all this info is placed in the same record.

just think, all those folks who figured out databases were wrong.
Nikos has shown that you just need to put everything in a single
record.  Wow! look at that record with everything in it!  Its so cool
and it helped to refrain Nikos the idiot!



--
Why create a whole new 'downloads' table and associate it with the with 
a foreign key with the 'visitors' table you idiot when you can just have 
an extra column at the end of the current 'visitor's table?


Both 'downloader' and 'downlaod' is associated by being in the same record.

By your logic every time we want to store an extra piece of information 
we have to create an extra database table.


Too much hussle for no good reason


--
https://mail.python.org/mailman/listinfo/python-list


Re: To whoever hacked into my Database

2013-11-07 Thread Νίκος Αλεξόπουλος

Στις 7/11/2013 11:31 πμ, ο/η Ferrous Cranus έγραψε:

Τη Πέμπτη, 7 Νοεμβρίου 2013 11:15:02 π.μ. UTC+2, ο χρήστης Steve Simmons έγραψε:


Please tell me you aren't storing details of customers and payments on your Web 
> server.



Oh but i do!
I need this information to be accessible ONLY FOR ME via my website 
'http://superhost.gr' i just need to secure it more tight.




--
I think i have made it.

The hacker, didn't manage to mess again with either of my counters or 
clients databases. :-)


Too bad! I though 'she' was better than that!
--
https://mail.python.org/mailman/listinfo/python-list


Re: To whoever hacked into my Database

2013-11-07 Thread Νίκος Αλεξόπουλος

Στις 7/11/2013 12:06 μμ, ο/η Alister έγραψε:

On Thu, 07 Nov 2013 01:31:17 -0800, Ferrous Cranus wrote:


Τη Πέμπτη, 7 Νοεμβρίου 2013 11:15:02 π.μ. UTC+2, ο χρήστης Steve Simmons
έγραψε:


Please tell me you aren't storing details of customers and payments on
your Web > server.



Oh but i do!
I need this information to be accessible ONLY FOR ME via my website
'http://superhost.gr' i just need to secure it more tight.


Nicos, You do realise that at some point YOU are going to end up in gaol
unless you remove this site from the internet & get some professional
help in implementing it correctly.


How much will it cost to take to convert my current 'counters.py' script 
to a 'webpy' framework style?


Please make a really good price.
We are talking about a small script.

--
What is now proved was at first only imagined! & WebHost

--
https://mail.python.org/mailman/listinfo/python-list


Re: Adding 'download' column to existing 'visitors' table (as requested)

2013-11-07 Thread Νίκος Αλεξόπουλος

Στις 6/11/2013 7:59 μμ, ο/η Denis McMahon έγραψε:

On Wed, 06 Nov 2013 09:30:03 +0200, Nick the Gr33k wrote:


I have decided to take your advice.


No you haven't. You only think you have, but really you either haven't
understood the advice at all.


My implementation is like the following.
I do not use an extra table of downlaods that i asoociate with table
visitors with a foreing key but decided to add an additional 'download'
column into the existant visitors table:


No no no no no no no no no no nononononono no!

That's *NOT* the right way to do it.

And this is where I finally and terminally give up trying to help you.
I've had enough. You refuse to learn the right way to do it. You won't
listen to the opinions and suggestions of people with a great deal more
experience than you have in such matters. It's not going to work properly
in the end. I refuse to be associated with it any further.




--
Denis, you may choose to not help any further, thats acceptable as you 
personal choice.


I have to inform you though that my solution of adding an extra 
'download' column in my 'visitors' table has the benefits of


1. refrain me for creating one more table
2. the download is remained associated with the person that made the 
download since all this info is placed in the same record.


My solution works just fine and is giving no problems.
I cant overcome the urge though to try to use some database that can 
hold lists to a single

--
https://mail.python.org/mailman/listinfo/python-list


Cookie aint retrieving when visiting happens from a backlink.

2013-10-25 Thread Νίκος Αλεξόπουλος

[code]
Hello, i was happy to see that a python module for geoip2 came out.

But unfortunately when i tried to install it:

root@secure [~]# pip install geoip2[DB]
Downloading/unpacking geoip2[db]
  Running setup.py egg_info for package geoip2
Traceback (most recent call last):
  File "", line 16, in 
  File "/tmp/pip-build/geoip2/setup.py", line 29, in 
long_description=open('README.rst').read(),
  File "/usr/local/bin/python/lib/python3.3/encodings/ascii.py", 
line 26, in decode

return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe7 in 
position 2255: ordinal not in range(128)

Complete output from command python setup.py egg_info:
Traceback (most recent call last):

  File "", line 16, in 

  File "/tmp/pip-build/geoip2/setup.py", line 29, in 

long_description=open('README.rst').read(),

  File "/usr/local/bin/python/lib/python3.3/encodings/ascii.py", line 
26, in decode


return codecs.ascii_decode(input, self.errors)[0]

UnicodeDecodeError: 'ascii' codec can't decode byte 0xe7 in position 
2255: ordinal not in range(128)



Command python setup.py egg_info failed with error code 1 in 
/tmp/pip-build/geoip2

Storing complete log in /root/.pip/pip.log
root@secure [~]#
[/code]

What is wrong and the module cannot be installed?
--
https://mail.python.org/mailman/listinfo/python-list


Re: Cookie aint retrieving when visiting happens from a backlink.

2013-10-25 Thread Νίκος Αλεξόπουλος

Στις 25/10/2013 11:33 πμ, ο/η Chris Angelico έγραψε:

On Fri, Oct 25, 2013 at 7:25 PM, Νίκος Αλεξόπουλος
 wrote:

Isn't this strange?
No matter if you visit a webpage as a direct hit or via a referer the cookie
on the visitor's browser should have been present.

But it can only can be found and retrieved as a direct hit and _not_ from a
referrer backlink.


Trace your logs. You've been told this before; are you sure the
request is even getting to your server?


Please be more detailed to what you want me to check.


Fundamentally, you're caring about things that it's a LOT easier to
not care about. Just let things happen, and don't try to track people
so much. Not only will some people object to it (are you, for
instance, complying with EU regulations about cookies?), but you're
going to keep running into situations where you just *can't* track
people, no matter how hard you try.


If an expert want to hide from my tracking of course he can use a proxy, 
or a TOR service, or incognito Chrome mode or whatever to bypass cookie 
tracking. But the usual visitors wont even know these things and their 
browser will accept cookies.


I do this not as a way to track everybody, but to learn handling 
cookies, database storing of cookies ans stuff like that.


But i cannot overcome this weird baclink referring visits that tend to 
ignore cookies stored in the browser.


I need an explanation for that because it screwns my visitors databases.
--
https://mail.python.org/mailman/listinfo/python-list


Re: Cookie aint retrieving when visiting happens from a backlink.

2013-10-25 Thread Νίκος Αλεξόπουλος

Στις 25/10/2013 10:32 πμ, ο/η Chris Angelico έγραψε:

On Fri, Oct 25, 2013 at 6:22 PM, Νίκος Αλεξόπουλος
 wrote:

Can somebody explain why this is happening?

You can see this action yourself by hitting:

1. superhost.gr as a direct hit
2. by clicking superhost.gr's backlink from ypsilandio.gr/mythosweb.gr

You will see than in 2nd occasion another ebtry will appear in the database
here:

http://superhost.gr/?show=log&page=index.html


Issue closed, unable to replicate. Either something you're doing is
different from what you're describing, or your browser is behaving
differently. Look at the Set-Cookie headers coming back, and the
subsequent Cookie headers in requests, and see what you can learn.


There is no set of cookie returned back when visitor comes from a referer.

Isn't this strange?
No matter if you visit a webpage as a direct hit or via a referer the 
cookie on the visitor's browser should have been present.


But it can only can be found and retrieved as a direct hit and _not_ 
from a referrer backlink.


But thw browser is the same...
Why would it matter how superhost.gr is called?

--
What is now proved was at first only imagined! & WebHost
<http://superhost.gr>
--
https://mail.python.org/mailman/listinfo/python-list


Re: Cookie aint retrieving when visiting happens from a backlink.

2013-10-25 Thread Νίκος Αλεξόπουλος

Στις 25/10/2013 10:32 πμ, ο/η Chris Angelico έγραψε:

On Fri, Oct 25, 2013 at 6:22 PM, Νίκος Αλεξόπουλος
 wrote:

Can somebody explain why this is happening?

You can see this action yourself by hitting:

1. superhost.gr as a direct hit
2. by clicking superhost.gr's backlink from ypsilandio.gr/mythosweb.gr

You will see than in 2nd occasion another ebtry will appear in the database
here:

http://superhost.gr/?show=log&page=index.html


Issue closed, unable to replicate. Either something you're doing is
different from what you're describing, or your browser is behaving
differently. Look at the Set-Cookie headers coming back, and the
subsequent Cookie headers in requests, and see what you can learn.


There is no set of cookie returned back when visitor comes from a referer.

Isn't this strange?
No matter if you visit a webpage as a direct hit or via a referer the 
cookie on the visitor's browser should have been present.


But it can only can be found and retrieved as a direct hit and _not_ 
from a referrer backlink.


But thw browser is the same...

--
What is now proved was at first only imagined! & WebHost
<http://superhost.gr>
--
https://mail.python.org/mailman/listinfo/python-list


Cookie aint retrieving when visiting happens from a backlink.

2013-10-25 Thread Νίκος Αλεξόπουλος
Hello i having the following code to try and retrieve the visitor's 
saved cookie form the browser.


[CODE]
# initialize cookie and retrieve cookie from clients browser
try:
cookie = cookies.SimpleCookie( os.environ['HTTP_COOKIE'] )
cookieID = cookie['name'].value
except:
cookieID = 'visitor'
[/CODE]

It works as expected except form the fact from when the visitor enters 
my webpage(superhost.gr) by clicking a backlink of another webpage.


Then even if the cookie exists in his browser for some reason the try 
fails and except take actions.


Can somebody explain why this is happening?

You can see this action yourself by hitting:

1. superhost.gr as a direct hit
2. by clicking superhost.gr's backlink from ypsilandio.gr/mythosweb.gr

You will see than in 2nd occasion another ebtry will appear in the 
database here:


http://superhost.gr/?show=log&page=index.html
--
https://mail.python.org/mailman/listinfo/python-list


Re: Printing a drop down menu for a specific field.

2013-10-21 Thread Νίκος Αλεξόπουλος

Στις 21/10/2013 9:58 πμ, ο/η Steven D'Aprano έγραψε:

On Mon, 21 Oct 2013 09:07:17 +0300, Νίκος Αλεξόπουλος wrote:


  for row in data:
  (host, city, useros, browser, ref, hits, lastvisit) = row
  lastvisit = lastvisit.strftime('%A %e %b, %H:%M')

  print( "" )
  for item in (host, city, useros, browser, ref, hits,
  lastvisit):
  print( " %s " % item
  )

[...]

In the above code i print the record of the mysql table visitors in
each row like this:  http://superhost.gr/?show=log&page=index.html

Now, i wish to write the same thing but when it comes to print the
'lastvisit' field to display it in a  tag so all prior
visits for the same host appear in a drop down menu opposed to as i
have it now which i only print the datetime of just the latest visit of
that host and not all its visit datetimes.

I hope i made it clear what i want to achieve.



Any help would be appreciated.



Step 1:

Decide what counts as "the same visitor". Is it...?

- anyone with the same IP address?
- anyone with the same IP address and the same useros?
- anyone with the same IP address, the same useros, and the same browser?
- something else?


First let me show you the database insertion to start form there:

The definition of the same visitor in my case is basically a combination 
of they page the visitor tries to visit along with its hostname. At 
MySQL's definition iam implementing this as:


  unique index (counterID, host)


Up until now i was updating the record of the same visitor as follows:


# if first time visitor on this page, create new record, if visitor 
exists then update record
cur.execute('''INSERT INTO visitors (counterID, host, city, useros, 
browser, ref, lastvisit) VALUES (%s, %s, %s, %s, %s, %s, %s)
		ON DUPLICATE KEY UPDATE city = %s, useros = %s, browser = %s, ref = 
%s, hits = hits + 1, lastvisit = %s''',
	(cID, host, city, useros, browser, ref, lastvisit, city, useros, 
browser, ref, lastvisit) )

=


Since now i have decided to have more records for the same visitor if 
i'm gonna save its history of visits, i'm thinking that i can no longer 
update the same unique visitor record but save many records related to 
the same visitor. so i use this:



=
# ~ DATABASE INSERTS ~
=
try:
	# if first time for webpage; create new record( primary key is 
automatic, hit is defaulted ), if page exists then update record
	cur.execute('''INSERT INTO counters (url) VALUES (%s) ON DUPLICATE KEY 
UPDATE hits = hits + 1''', page )

# get the primary key value of the new added record
cID = cur.lastrowid

	# if first time visitor on this page, create new record, if visitor 
exists then update record
	cur.execute('''INSERT INTO visitors (counterID, host, city, useros, 
browser, ref, lastvisit) VALUES (%s, %s, %s, %s, %s, %s, %s)''',

   (cID, host, city, useros, browser, 
ref, lastvisit) )

con.commit()
except pymysql.ProgrammingError as e:
print( repr(e) )
con.rollback()
=


Are we good up until this point as it concerns the database insertions?
If we are then we can discuss how to present the saved data.


--
https://mail.python.org/mailman/listinfo/python-list


Re: Printing a drop down menu for a specific field.

2013-10-20 Thread Νίκος Αλεξόπουλος

Στις 21/10/2013 2:30 πμ, ο/η Νίκος Αλεξόπουλος έγραψε:

try:
 cur.execute( '''SELECT host, city, useros, browser, ref, hits,
lastvisit FROM visitors WHERE counterID = (SELECT ID FROM counters WHERE
url = %s) ORDER BY lastvisit DESC''', page )
 data = cur.fetchall()

 for row in data:
 (host, city, useros, browser, ref, hits, lastvisit) = row
 lastvisit = lastvisit.strftime('%A %e %b, %H:%M')

 print( "" )
 for item in (host, city, useros, browser, ref, hits, lastvisit):
 print( " %s " % item )
except pymysql.ProgrammingError as e:
 print( repr(e) )
===

In the above code i print the record of the mysql table visitors in each
row like this:  http://superhost.gr/?show=log&page=index.html

Now, i wish to write the same thing but when it comes to print the
'lastvisit' field to display it in a  tag so all prior
visits for the same host appear in a drop down menu opposed to as i have
it now which i only print the datetime of just the latest visit of that
host and not all its visit datetimes.

I hope i made it clear what i want to achieve.



Any help would be appreciated.
--
https://mail.python.org/mailman/listinfo/python-list


Printing a drop down menu for a specific field.

2013-10-20 Thread Νίκος Αλεξόπουλος

try:
	cur.execute( '''SELECT host, city, useros, browser, ref, hits, 
lastvisit FROM visitors WHERE counterID = (SELECT ID FROM counters WHERE 
url = %s) ORDER BY lastvisit DESC''', page )

data = cur.fetchall()

for row in data:
(host, city, useros, browser, ref, hits, lastvisit) = row
lastvisit = lastvisit.strftime('%A %e %b, %H:%M')

print( "" )
for item in (host, city, useros, browser, ref, hits, lastvisit):
print( " %s " % 
item )
except pymysql.ProgrammingError as e:
print( repr(e) )
===

In the above code i print the record of the mysql table visitors in each 
row like this:  http://superhost.gr/?show=log&page=index.html


Now, i wish to write the same thing but when it comes to print the 
'lastvisit' field to display it in a  tag so all prior 
visits for the same host appear in a drop down menu opposed to as i have 
it now which i only print the datetime of just the latest visit of that 
host and not all its visit datetimes.


I hope i made it clear what i want to achieve.
--
https://mail.python.org/mailman/listinfo/python-list


Re: Cookie gets changed when hit comes from a referrer

2013-10-09 Thread Νίκος Αλεξόπουλος

Στις 9/10/2013 9:36 μμ, ο/η Piet van Oostrum έγραψε:

Νίκος Αλεξόπουλος  writes:



# initialize cookie and retrieve cookie from clients browser
cookie = cookies.SimpleCookie( os.environ['HTTP_COOKIE'] )

if cookie.get('ID') is not None:
cookieID = cookie['ID'].value
else:
cookieID = random.randrange(0, )
cookie['ID'] = cookieID
cookie['ID']['domain'] = ".superhost.gr"
cookie['ID']['path'] = '/'
cookie["ID"]["expires"] = 60*60*24*365  # this cookie will 
expire in a year


As Ian already has told you (but apparently you didn't pay attention to), your 
expires is wrong. So if your cookies disappear you should get this right first.

from datetime import datetime, timedelta
expiretime = datetime.utcnow() + timedelta(days=365)

cookie["ID"]["expires"] = expiretime.strftime("%a, %d %b %Y %H:%M:%S GMT")



Expire is not the issue here, as i have it is working with no problem.
when i print the cookie expiration time is calculated properly.
Something else is going worng.

--
https://mail.python.org/mailman/listinfo/python-list


Re: Cookie gets changed when hit comes from a referrer

2013-10-09 Thread Νίκος Αλεξόπουλος

Στις 9/10/2013 5:43 μμ, ο/η Denis McMahon έγραψε:

On Wed, 09 Oct 2013 01:52:44 +0300, Νίκος Αλεξόπουλος wrote:


Στις 8/10/2013 10:29 μμ, ο/η Denis McMahon έγραψε:



Have you checked the cookie jar in the browser to see what value the
cookie has? Is that the value you think it should have? Note that
checking the cookie jar is a browser topic, not a python topic, so if
you don't know how to do that you're going to have to find the right
place to ask, WHICH IS NOT HERE!



Ideally you need to check what the server thinks it's setting the
cooking to, what the browser thinks it received as the cookie, and what
the server gets back afterwards to work out where the error is
happening.



Is there something i can try to isolate the problem and make it work?
By whole counters project is based on cookie handling now


See those last two paragraphs there that you quoted. You should have read
them.


ok so then tell me where i should ask this.

--
What is now proved was at first only imagined! & WebHost
<http://superhost.gr>
--
https://mail.python.org/mailman/listinfo/python-list


Re: Cookie gets changed when hit comes from a referrer

2013-10-09 Thread Νίκος Αλεξόπουλος

Στις 9/10/2013 4:33 πμ, ο/η Steven D'Aprano έγραψε:

On Wed, 09 Oct 2013 01:52:44 +0300, Νίκος Αλεξόπουλος wrote:


Is there something i can try to isolate the problem and make it work?


Of course there is. That is part of the job of the developer: hard work
trying dozens, maybe hundreds of different things until you isolate the
problem. There are no shortcuts, no magic button you can push to
immediately identify the source of the problem.

If you are not willing to spend hours, maybe days or weeks, working on
this problem, then you should hire a programmer who is, and stop fooling
yourself that you are a professional developer. An amateur who programs
for fun can just give up when a problem becomes too difficult and isn't
fun any more. A professional has to keep going.

Start by identifying which browsers this occurs on. You should test using
at least Firefox, Internet Explorer, Safari, Chrome and Opera, for as
many different versions as you can find. You should also test with less
common browsers such as Konqueror, Epiphany, lynx, links and others. See
if there is a pattern in which ones behave as you expect and which ones
don't.

You should also test with and without cookies enabled, ad-blockers, and
similar. Maybe you can replicate the problem if (say) the user accepts
the first cookie, then rejects it when they click Back.

If this only occurs with a single version of a single browser with
cookies enabled and no ad blocker, you should report it as a bug to the
browser developers. Make sure you give them enough detail to replicate
the problem. If it's an old version, they'll probably say Won't Fix, and
you'll just have to accept that your cookie handling code won't work for
some percentage of visitors.

Have you checked that the server is setting the cookie values you expect?
Have you checked the value of the cookie in the browser? If you don't
know how to do these things, this site will teach you everything you need:

https://duckduckgo.com/

Follow the links until you reach enlightenment. There are *thousands* of
pages on debugging programming problems.

If you find it is broken with *all* of the above browsers, then you
should suspect a bug in your Python code. In that case, since other
people have failed to reproduce the reported problem, you are obviously
doing something different than what you are telling us you are doing.
Only in this case should you come back here to ask for help with your
Python code. Before you do, read this, and follow the instructions:

http://www.sscce.org/

If you are not willing to do these things, then stop pretending to be a
professional developer, and admit that you are only programming for fun.
There is no shame in this -- not everyone is cut out to be a professional
programmer, just as not everybody makes a good doctor or taxi driver or
carpenter.



By whole counters project is based on cookie handling now


If you cannot solve the cookie problem, maybe you should reconsider the
decision to rely on cookies.




I managed t overcome it like this:

cur.execute('''UPDATE visitors SET cookieID = %s, host = %s, city = %s, 
useros = %s, browser = %s, ref = %s, hits = hits + 1, lastvisit = %s 
WHERE counterID = %s and host = %s''',

(cookieID, host, city, useros, 
browser, ref, lastvisit, cID, host) )

if not cur.rowcount:
# if first time visitor on this page, create new record, if visitor 
exists then update record
cur.execute('''INSERT INTO visitors (counterID, cookieID, host, city, 
useros, browser, ref, lastvisit) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)
ON DUPLICATE KEY UPDATE host = %s, city = %s, useros = %s, browser = %s, 
ref = %s, hits = hits + 1, lastvisit = %s''',
(cID, cookieID, host, city, useros, browser, ref, lastvisit, host, city, 
useros, browser, ref, lastvisit) )



But thats a not clear way to handle the cookie because i involve host to 
help me identify its recorde since when my website hit comes from areferrer.


i also tried adding the domain when i set the cookie but this didnt 
helped me at all:


# initialize cookie and retrieve cookie from clients browser
cookie = cookies.SimpleCookie( os.environ['HTTP_COOKIE'] )

if cookie.get('ID') is not None:
cookieID = cookie['ID'].value
else:
cookieID = random.randrange(0, )
cookie['ID'] = cookieID
cookie['ID']['domain'] = ".superhost.gr"
cookie['ID']['path'] = '/'
cookie["ID"]["expires"] = 60*60*24*365  # this cookie will 
expire in a year

i read some links from duckduckgo but that didnt help me solve this.
Please someone esle try to reproduce the problem by just using cgi and 
not mod_wsgi.


ps. Really why duckduckgo and not google.com ?

--
https://mail.python.org/mailman/listinfo/python-list


Re: Cookie gets changed when hit comes from a referrer

2013-10-08 Thread Νίκος Αλεξόπουλος

Στις 9/10/2013 7:53 πμ, ο/η Ian Kelly έγραψε:

On Tue, Oct 8, 2013 at 8:18 AM, Νίκος Αλεξόπουλος  wrote:

Also i have set:
ookie['ID']['expires'] = 60*60*24*365   #this cookie will expire in
a year


The Expires attribute takes a date.  If you're passing an interval in
seconds then you should use the Max-Age attribute instead.

That said, I think I misunderstood the problem initially.  You are
saying that when the user is on another site, and they press the
browser's Back button to return to your page, your host is not
recording a visit from the cookie you've given them?  This is probably
happening because the browser is not actually sending a request to
your web server when it navigates back, unless the user specifically
requests a refresh.  Otherwise, most browsers will just use the cached
page already in memory in this situation.  As far as the server is
concerned, nothing has happened.



No i dont mean that.

When a user hits my link on another website, for exmaple they are on 
ypsilandio.gr and they hit the link of superhost.gr then a new entry 
with a new cookie is appearing into my visitors table!


Where is the old cookie that was saved in my browser so it will get 
retrieved? I use chrome and i notice that when a visitor comes to my 
webpage form a referrer link the cookie's ID is always set to a new 
random value.


I have no idea why.
Why would it metter from where you sre coming from?
The cookie ust have beeen present in the visitor's browser, shouldnt it?

--
What is now proved was at first only imagined! & WebHost
<http://superhost.gr>
--
https://mail.python.org/mailman/listinfo/python-list


Re: Cookie gets changed when hit comes from a referrer

2013-10-08 Thread Νίκος Αλεξόπουλος

Στις 8/10/2013 10:29 μμ, ο/η Denis McMahon έγραψε:

On Tue, 08 Oct 2013 19:04:37 +0300, Νίκος Αλεξόπουλος wrote:


Can you help me with this particuler problem please?


Unfortunately I can't, because I am unable to reproduce the problem you
describe.

When I load my test page in the browser, then replace it with something
else by entering an address in the address bar and pressing return, then
use the back link followed by the reload one, I am back at my test page
with the original cookie value.

Of course, this is using my cookie etc code and mechanisms, and not
yours 

Now, either it's an issue in your python implementation of cookie
handling which isn't happening in my implementation, or it's something to
do with the way that your system passes data around (cgi) that doesn't
happen in mine (mod_wsgi), or it's happening in the browser you're
testing in, but not in my browser.

Have you checked the cookie jar in the browser to see what value the
cookie has? Is that the value you think it should have? Note that
checking the cookie jar is a browser topic, not a python topic, so if you
don't know how to do that you're going to have to find the right place to
ask, WHICH IS NOT HERE!

Ideally you need to check what the server thinks it's setting the cooking
to, what the browser thinks it received as the cookie, and what the
server gets back afterwards to work out where the error is happening.


Is there something i can try to isolate the problem and make it work?
By whole counters project is based on cookie handling now


--
What is now proved was at first only imagined! & WebHost
<http://superhost.gr>
--
https://mail.python.org/mailman/listinfo/python-list


Re: Cookie gets changed when hit comes from a referrer

2013-10-08 Thread Νίκος Αλεξόπουλος
Is there any better way to identif a previous visitor? i tried cookies 
which failed for me for the reason i opened this thread and host like 
follows:


# try to locate the visitor
		cur.execute('''SELECT * FROM visitors WHERE counterID = %s and host = 
%s''', (cID, host) )

data = cur.fetchone()

if not data:
# if first time visitor on this page, create new record
			cur.execute('''INSERT INTO visitors (counterID, host, city, useros, 
browser, ref, lastvisit) VALUES (%s, %s, %s, %s, %s, %s, %s)''',

   (cID, host, city, useros, 
browser, ref, lastvisit) )
else:
# since visitor exists just update his record
			cur.execute('''UPDATE visitors SET city = %s, useros = %s, browser = 
%s, ref = %s, hits = hits + 1, lastvisit = %s''', (city, useros, 
browser, ref, lastvisit) )

===

Please tell me if you can think fo something else.

--
https://mail.python.org/mailman/listinfo/python-list


Re: Cookie gets changed when hit comes from a referrer

2013-10-08 Thread Νίκος Αλεξόπουλος

Στις 8/10/2013 6:55 μμ, ο/η Denis McMahon έγραψε:

On Tue, 08 Oct 2013 13:04:34 +0300, Νίκος Αλεξόπουλος wrote:


I use this code to retrive or set a cookie to the visitor's browser if
present and identify him bu it.


You are aware that using cookies to track a user who doesn't want to be
tracked won't work, because he'll just tell his browser to not use
cookies, aren't you.

Nick, if a user doesn't want to be tracked, you can't track them. The
user controls all the data their machine sends to you. This means that
they can manipulate it. Nothing you can do will prevent this.



Yes iam aware of that, but its the best trcking method i can think of.
Tracking just the hostname is not accurate since with every router 
restart, that info is changing.


Tracking the visitor by settign a cookie to its browser is not 
perfect/accurate since he can manipulate its broswer data or flush the 
cookies but this is the best one can do after having people register on 
the webiste.


Or perhaps trying to identify the cookie + hostname is even better.

Can you help me with this particuler problem please?

--
What is now proved was at first only imagined! & WebHost
<http://superhost.gr>
--
https://mail.python.org/mailman/listinfo/python-list


Re: Cookie gets changed when hit comes from a referrer

2013-10-08 Thread Νίκος Αλεξόπουλος

Στις 8/10/2013 2:08 μμ, ο/η Ian Kelly έγραψε:

This question is really about HTTP, not Python, so you'd have better
luck asking elsewhere.  The most likely possibility is that the domain
doesn't match.  For example, the cookie is set for the domain
www.foo.com, and the other webpage is linking to foo.com.


I think this is the problem but iam not sure entirely how you mean.
Can you please explain it a bit more?

Shall i change 	cookie['ID']['path'] = '/' to something else so that 
never happens?


--
What is now proved was at first only imagined! & WebHost

--
https://mail.python.org/mailman/listinfo/python-list


Re: Cookie gets changed when hit comes from a referrer

2013-10-08 Thread Νίκος Αλεξόπουλος

Στις 8/10/2013 2:08 μμ, ο/η Ian Kelly έγραψε:

On Tue, Oct 8, 2013 at 4:04 AM, Νίκος Αλεξόπουλος  wrote:

I use this code to retrive or set a cookie to the visitor's browser if
present and identify him bu it.

All work well except the situation where the user visits my webpage by
clicking a backlink on another wbpage.

Then for some reason the cookieID changes to another value thus a new entry
appears into the database when insert happens.

What cna i do about that?


This question is really about HTTP, not Python, so you'd have better
luck asking elsewhere.  The most likely possibility is that the domain
doesn't match.  For example, the cookie is set for the domain
www.foo.com, and the other webpage is linking to foo.com.  Another
possibility is that the cookie is expiring because the browser session
was terminated, not because of anything to do with the other webpage.
Or it could simply be a bug or unusual setting in whatever browser
you're using to test it.



When i direct hit http://superhost.gr the cookie remains the same it is 
not lost.


Also i have set:
ookie['ID']['expires'] = 60*60*24*365   #this cookie will expire in a 
year

but that didnt also help much because the cookie is also changing when 
the hit comes through a referrer.


So, i cannot se the cookie down to its feet my whole insert or update 
procedure breaks and i have duplicate entried for the same hostnames.


Where shoudl i rely to identify a visitor?
I was relying on tis hostname(although i know that after a router reset) 
it changes, and then couple days ago i was thiking of relying to a 
cookie that i would/set retrive from the vistirs browser, but if it 
changes all the time i cannot evan rely to that.


--
What is now proved was at first only imagined! & WebHost
<http://superhost.gr>
--
https://mail.python.org/mailman/listinfo/python-list


Cookie gets changed when hit comes from a referrer

2013-10-08 Thread Νίκος Αλεξόπουλος

# initialize cookie and retrieve cookie from clients browser
cookie = cookies.SimpleCookie( os.environ.get('HTTP_COOKIE') )

if cookie.get('ID') is not None:
cookieID = cookie['ID'].value
else:
cookieID = random.randrange(0, )
cookie['ID'] = cookieID
cookie['ID']['path'] = '/'
print( cookie )

===
===

I use this code to retrive or set a cookie to the visitor's browser if 
present and identify him bu it.


All work well except the situation where the user visits my webpage by 
clicking a backlink on another wbpage.


Then for some reason the cookieID changes to another value thus a new 
entry appears into the database when insert happens.


What cna i do about that?
--
https://mail.python.org/mailman/listinfo/python-list


Re: inserting or updating appropriately

2013-10-08 Thread Νίκος Αλεξόπουλος

Στις 8/10/2013 12:15 μμ, ο/η Νίκος Αλεξόπουλος έγραψε:

Hello, i'am trying to insert a new record or update an existing one in
case counterID(stands for the page's URL) and cookieID(random number) is
the same:

 try:
 # if first time for webpage; create new record( primary key is
automatic, hit is defaulted ), if page exists then update record
 cur.execute('''INSERT INTO counters (url) VALUES (%s) ON
DUPLICATE KEY UPDATE hits = hits + 1''', page )
 # get the primary key value of the new added record
 cID = cur.lastrowid

 # if first time visitor on this page, create new record, if
visitor exists then update record
 cur.execute('''INSERT INTO visitors (counterID, cookieID, host,
city, useros, browser, ref, lastvisit) VALUES (%s, %s, %s, %s, %s, %s,
%s, %s)
ON DUPLICATE KEY UPDATE cookieID = %s, host =
%s, city = %s, useros = %s, browser = %s, ref = %s, hits = hits + 1,
lastvisit = %s
WHERE counterID = %s and cookieID = %s''',
(cID, cookieID, host, city, useros, browser,
ref, lastvisit, cookieID, host, city, useros, browser, ref, lastvisit,
cID, cookieID) )
=

Error is: ProgrammingError(ProgrammingError(1064, "You have an error in
your SQL syntax; check the manual that corresponds to your MySQL server
version for the right syntax to use near 'WHERE counterID = 1 and
cookieID = '3815'' at line 3"),)

i notticed that if i remove the WHERE clause in the last execute it
works but then its not updating properly.

Can this happen in 1-statemnt with the ON DUPLICATE KEY INVOLVED WITHOUT
BREAKING IT IN IN 2-STATEMNTS?

THANKS.


Actually what i want is this effect in cur.execute statement:

		# if first time visitor on this page, create new record, if visitor 
exists then update record
		cur.execute('''INSERT INTO visitors (counterID, cookieID, host, city, 
useros, browser, ref, lastvisit) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)''',

   (cID, cookieID, host, city, useros, 
browser, ref, lastvisit)

		cur.execute('''UPDATE visitors SET cookieID = %s, host = %s, city = 
%s, useros = %s, browser = %s, ref = %s, hits = hits + 1, lastvisit = %s

   WHERE counterID = %s and cookieID = 
%s''',
	   (cookieID, host, city, useros, browser, ref, lastvisit, cID, 
cookieID) )


--
What is now proved was at first only imagined! & WebHost
<http://superhost.gr>
--
https://mail.python.org/mailman/listinfo/python-list


inserting or updating appropriately

2013-10-08 Thread Νίκος Αλεξόπουλος
Hello, i'am trying to insert a new record or update an existing one in 
case counterID(stands for the page's URL) and cookieID(random number) is 
the same:


try:
		# if first time for webpage; create new record( primary key is 
automatic, hit is defaulted ), if page exists then update record
		cur.execute('''INSERT INTO counters (url) VALUES (%s) ON DUPLICATE KEY 
UPDATE hits = hits + 1''', page )

# get the primary key value of the new added record
cID = cur.lastrowid

		# if first time visitor on this page, create new record, if visitor 
exists then update record
		cur.execute('''INSERT INTO visitors (counterID, cookieID, host, city, 
useros, browser, ref, lastvisit) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)
	   ON DUPLICATE KEY UPDATE cookieID = %s, host = %s, city = %s, 
useros = %s, browser = %s, ref = %s, hits = hits + 1, lastvisit = %s

   WHERE counterID = %s and cookieID = 
%s''',
	   (cID, cookieID, host, city, useros, browser, ref, lastvisit, 
cookieID, host, city, useros, browser, ref, lastvisit, cID, cookieID) )

=

Error is: ProgrammingError(ProgrammingError(1064, "You have an error in 
your SQL syntax; check the manual that corresponds to your MySQL server 
version for the right syntax to use near 'WHERE counterID = 1 and 
cookieID = '3815'' at line 3"),)


i notticed that if i remove the WHERE clause in the last execute it 
works but then its not updating properly.


Can this happen in 1-statemnt with the ON DUPLICATE KEY INVOLVED WITHOUT 
BREAKING IT IN IN 2-STATEMNTS?


THANKS.
--
https://mail.python.org/mailman/listinfo/python-list


Re: Database statements via python but database left intact

2013-10-06 Thread Νίκος Αλεξόπουλος

Στις 6/10/2013 6:52 μμ, ο/η Adam Tauno Williams έγραψε:

Are you sure that you're committing your changes (either by having
autocommit set or using an explicit con.commit() call)?
http://geert.vanderkelen.org/dont-forget-the-commit-in-mysql/

I dont think that is the issue, because up until now i never used

commit and

all transaction were successfully were happening.


Depending on autocommit is a bug [when does commit happen then?  consistency is 
a real problem].  Code should always explicitly ate least COMMIT or ROLLBACK if 
not explicitly BEGIN.  Not to mention how much easier it makes it to read the 
code and understand the units of work.


Well, have you changed anything in your database configuration?


a big downside of autocommit - backend changes can break you app




try:
# locate the ID of the page's URL
cur.execute('''SELECT ID FROM counters WHERE url = %s''', page )
data = cur.fetchone()   #URL is unique, so should only 
be one

if not data:
#first time for page; primary key is automatic, hit is 
defaulted
cur.execute('''INSERT INTO counters (url) VALUES 
(%s)''', page )
cID = cur.lastrowid #get the primary key 
value of the new added record
else:
#found the page, save primary key and use it to issue 
hit UPDATE
cID = data[0]
			cur.execute('''UPDATE counters SET hits = hits + 1 WHERE ID = %s''', 
cID )



# find the visitor record for the (saved) cID and Cookie
		cur.execute('''SELECT * FROM visitors WHERE counterID = %s and 
cookieID = %s''', (cID, cookieID) )

data = cur.fetchone()   #cookieID is unique

if not data:
# first time visitor on this page, create new record
			cur.execute('''INSERT INTO visitors (counterID, cookieID, host, city, 
useros, browser, ref, lastvisit) VALUES (%s, %s, %s, %s, %s, %s, %s, 
%s)''', (cID, cookieID, host, city, useros, browser, ref, lastvisit) )

else:
# found the page, save its primary key for later use
vID = data[0]
# UPDATE record using retrieved vID
			cur.execute('''UPDATE visitors SET host = %s, city = %s, useros = %s, 
browser = %s, ref= %s, hits = hits + 1, lastvisit = %s
		   WHERE counterID = %s and cookieID = %s''', (host, city, useros, 
browser, ref, lastvisit, vID, cookieID) )


con.commit()
except pymysql.ProgrammingError as e:
con.rollback()
print( repr(e) )
sys.exit(0)

Before is qw your post i have chnaged it to this.
rollback() is correct where i placed it, i hope con.commit() is also 
correct too.


--
What is now proved was at first only imagined! & WebHost

--
https://mail.python.org/mailman/listinfo/python-list


Re: Database statements via python but database left intact

2013-10-06 Thread Νίκος Αλεξόπουλος

Στις 6/10/2013 12:45 πμ, ο/η Zero Piraeus έγραψε:

:

On Sun, Oct 06, 2013 at 12:02:14AM +0300, Νίκος Αλεξόπουλος wrote:

I neved had though of than an engine type could make so much mess.
MyISAM is the way to go then for my web development?
Why InnoDB failed to execute the queries?


Because you didn't commit. MyISAM doesn't support transactions, so when
you use it as the engine, your mistake happens to go unpunished.

Note that this is a weakness of MyISAM cancelling out a failure in your
code; it does *not* mean that MyISAM is better suited to your task.

By the way, Ned's right. At this point, this is no longer a Python
issue, and is off-topic for discussion here.

  -[]z.


Thanks Zero,

i will use con.commit() from now and on because yesterdays i lost 3 
hours trying to identify what was wrong with my MySQL statements in 
python and it turned out to be for no good reason.


--
What is now proved was at first only imagined! & WebHost
<http://superhost.gr>
--
https://mail.python.org/mailman/listinfo/python-list


Re: Select fails when cookie tried to get a numeric value

2013-10-05 Thread Νίκος Αλεξόπουλος

Στις 6/10/2013 2:36 πμ, ο/η Denis McMahon έγραψε:

On Sat, 05 Oct 2013 16:38:14 +0300, Νίκος Αλεξόπουλος wrote:


[my cookie code is fucked]


Hi Nick

I had never used python for www before yesterday. I had never used python
before about 6 months ago.

In the last 24 hours I have installed mod-wsgi on my apache web server,
and written test code that enables me to see the result of all
environment data, parse the get string, parse post data, set and parse
cookies, and save session data to a file specific to the cookie data.

There may be better ways to do some of it, but it works.

Here is a link to the text of my python file:

http://www.sined.co.uk/tmp/index.py.txt

Once you have read through it (there are comments) and understood how it
handles cookies and session data, you will realise that you can add and
modify any session data just by adding relevant items to and reading them
from the session data dictionary. The session data stays on the server,
the cookie simply identifies the session (and the session data file), and
hopefully is unique to the user.

Don't ask me any questions about why I did something the way I did it. I
did it that way because it works. If anyone knows a different way that
also works and maybe works better, feel free to discuss it. But Nick,
don't you dare suggest any change that doesn't work because you think it
looks better.

If you don't understand a module function that I've used, read the python
documentation for it.

If you think you have a question that is  not covered by the above
statements, feel free to ask me, here, why I wrote a given line number or
group of line numbers the way I did. However, see the notes above - the
answer will probably be "because it works that way".

If you quote the whole file or even large chunks of it here, I am
finished with trying to help you, ever!


Thank you Denis, i didn't knew about sessions up until i saw you post.
Your code is very advanced for me to read but i will try to "decode it"
I though that if we want to read something from our visitor, something 
we want, we have to save it to his browser a cookie, that we later 
retrieve within our python script's code.


What "sessions" do more compared to just using cookies?

i use 'cgi', but i noticed you used 'mod-wsgi'.
I want to ask you why you chose the latter? Is the latter better than 
the former?


Is it faster? Does it bahave the same way?
I my code works works with cgi, which it does, will the same code works 
with mod-wcgi?



--
What is now proved was at first only imagined! & WebHost
<http://superhost.gr>
--
https://mail.python.org/mailman/listinfo/python-list


Re: Database statements via python but database left intact

2013-10-05 Thread Νίκος Αλεξόπουλος

Στις 5/10/2013 11:31 μμ, ο/η Ian Kelly έγραψε:

Well, have you changed anything in your database configuration?
Whether MySQL uses transactions or not depends on which storage engine
is being used.  I suggest running a test insert with and without
commit to check whether you actually need it or not.



I cannot beleive it!

I have deleted the database and tables and recreted it.
By default it seems to use the InnoDB Engine which wouldn't let anythign 
get inserted/updated.


I then deleted the database recretaed and used at the end fo my create 
table statements the:


create table counters
(
  ID integer(5) not null auto_increment primary key,
  URL varchar(100) not null,
  hits integer(5) not null default 1,
  unique index (URL)
)ENGINE = MYISAM;

After that all mysql queries executed(inserted/updated) properly!

I neved had though of than an engine type could make so much mess.
MyISAM is the way to go then for my web development?
Why InnoDB failed to execute the queries?
--
https://mail.python.org/mailman/listinfo/python-list


Re: Database statements via python but database left intact

2013-10-05 Thread Νίκος Αλεξόπουλος

Στις 5/10/2013 10:29 μμ, ο/η Zero Piraeus έγραψε:

:

On Sat, Oct 05, 2013 at 10:16:46PM +0300, Νίκος Αλεξόπουλος wrote:

Excuse me for asking again today, but i see no error in the
following code, yes no isertion or update happens into the database:

[...]

When this code runs i check instantly my database via PHPMyAdmin and
i see that it was left intact.


Are you sure that you're committing your changes (either by having
autocommit set or using an explicit con.commit() call)?

http://geert.vanderkelen.org/dont-forget-the-commit-in-mysql/



I dont think that is the issue, because up until now i never used commit 
and all transaction were successfully were happening.


--
What is now proved was at first only imagined! & WebHost
<http://superhost.gr>
--
https://mail.python.org/mailman/listinfo/python-list


Re: Database statements via python but database left intact

2013-10-05 Thread Νίκος Αλεξόπουλος

Actually the whole code is this:

# 
=

# DATABASE INSERTS -
# 
=
if cookieID != 1977 and re.search( 
r'(msn|gator|amazon|yandex|reverse|who|cloudflare|fetch|barracuda|spider|google|crawl|pingdom)', 
host ) is None:


try:
# locate the ID of the page's URL
cur.execute('''SELECT ID FROM counters WHERE url = %s''', page )
data = cur.fetchone()   #URL is unique, so should only 
be one

if not data:
#first time for page; primary key is automatic, hit is 
defaulted
cur.execute('''INSERT INTO counters (url) VALUES 
(%s)''', page )
cID = cur.lastrowid #get the primary key 
value of the new added record
else:
#found the page, save primary key and use it to issue 
hit UPDATE
cID = data[0]
			cur.execute('''UPDATE counters SET hits = hits + 1 WHERE ID = %s''', 
cID )



# find the visitor record for the (saved) cID and Cookie
		cur.execute('''SELECT * FROM visitors WHERE counterID = %s and 
cookieID = %s''', (cID, cookieID) )

data = cur.fetchone()   #cookieID is unique

if not data:
# first time visitor on this page, create new record
			cur.execute('''INSERT INTO visitors (counterID, cookieID, host, city, 
useros, browser, ref, lastvisit) VALUES (%s, %s, %s, %s, %s, %s, %s, 
%s)''', (cID, cookieID, host, city, useros, browser, ref, lastvisit) )

else:
# found the page, save its primary key for later use
vID = data[0]
# UPDATE record using retrieved vID
			cur.execute('''UPDATE visitors SET host = %s, city = %s, useros = %s, 
browser = %s, ref= %s, hits = hits + 1, lastvisit = %s
		   WHERE counterID = %s and cookieID = %s''', (host, city, useros, 
browser, ref, lastvisit, vID, cookieID) )


except pymysql.ProgrammingError as e:
print( repr(e) )
sys.exit(0)



If at some point an error is made does that mean that no 
update/insertion happens?

PEhats that is why iam seeing no entries at all into my database tables?
--
https://mail.python.org/mailman/listinfo/python-list


Database statements via python but database left intact

2013-10-05 Thread Νίκος Αλεξόπουλος
Excuse me for asking again today, but i see no error in the following 
code, yes no isertion or update happens into the database:



try:
# locate the ID of the page's URL
cur.execute('''SELECT ID FROM counters WHERE url = %s''', page )
data = cur.fetchone()   #URL is unique, so should only be one

if not data:
#first time for page; primary key is automatic, hit is defaulted
cur.execute('''INSERT INTO counters (url) VALUES (%s)''', page )
cID = cur.lastrowid #get the primary key 
value of the new added record
else:
#found the page, save primary key and use it to issue hit UPDATE
cID = data[0]
cur.execute('''UPDATE counters SET hits = hits + 1 WHERE ID = %s''', 
cID )


When this code runs i check instantly my database via PHPMyAdmin and i 
see that it was left intact.

--
https://mail.python.org/mailman/listinfo/python-list


Re: Select fails when cookie tried to get a numeric value

2013-10-05 Thread Νίκος Αλεξόπουλος

Στις 5/10/2013 7:56 μμ, ο/η Andreas Perstinger έγραψε:

On 05.10.2013 16:24, Νίκος Αλεξόπουλος wrote:

# initialize cookie
cookie = cookies.SimpleCookie( os.environ.get('HTTP_COOKIE') )
cookie.load( cookie )


Watch:

 >>> cookie1 = cookies.SimpleCookie('ID=42')
 >>> cookie1.load(cookie1)
 >>> print(cookie1)
Set-Cookie: ID="Set-Cookie: ID=42"
 >>> cookie1.get('ID').value
'Set-Cookie: ID=42'

And now watch this:

 >>> cookie2 = cookies.SimpleCookie('ID=42')
 >>> print(cookie2)
Set-Cookie: ID=42
 >>> cookie2.get('ID').value
'42'

Explanation:

http://docs.python.org/3/library/http.cookies.html#http.cookies.BaseCookie.load


 >>> c = cookies.SimpleCookie('ID=42')
 >>> isinstance(c, dict)
True
 >>> c.items()
dict_items([('ID', )])

Bye, Andreas


Thank you very much Andreas,

it was this strnage behaviour that got me stuch for hours.
Now value gets returned properly.

--
What is now proved was at first only imagined! & WebHost
<http://superhost.gr>
--
https://mail.python.org/mailman/listinfo/python-list


Re: Select fails when cookie tried to get a numeric value

2013-10-05 Thread Νίκος Αλεξόπουλος

Στις 5/10/2013 7:42 μμ, ο/η Ned Batchelder έγραψε:


A better solution is to check to see if you got None:

 if cookie.get('ID') is None:
 # make a new cookie


I have tried everythign even wgat you suggested right now:
here is is:

# initialize cookie and retrieve cookie from clients broswer
cookie = cookies.SimpleCookie( os.environ.get('HTTP_COOKIE') )
cookie.load( cookie )

if cookie.get('ID') is not None:
cookieID = cookie['ID'].value
else:
x = random.randrange(0, 1)
cookie['ID'] = x
cookie['ID']['path'] = '/'
print( cookie )
cookieID = x

print( '''Content-type: text/html; charset=utf-8\n''' )
print( cookieID )

For some reason althogh the cookie does exist in my browser the returnd 
value of cookieI D = cookie['ID'].value is always: Set-Cookie: ID=7482


instead of just the number.
But why?  isnt value to return just the number?

You can see the result of the above code yourself at the top left when 
you visit: http://superhost.gr


it always retursn the whole string instead of just the number...

why can we isolate th damn number only?
in the else i manages to isolate it but not when i try to retrive it.
--
https://mail.python.org/mailman/listinfo/python-list


Re: Select fails when cookie tried to get a numeric value

2013-10-05 Thread Νίκος Αλεξόπουλος

Στις 5/10/2013 7:14 μμ, ο/η Νίκος Αλεξόπουλος έγραψε:

Στις 5/10/2013 7:08 μμ, ο/η Ned Batchelder έγραψε:


On 10/5/13 11:52 AM, Νίκος Αλεξόπουλος wrote:

Στις 5/10/2013 6:12 μμ, ο/η Ned Batchelder έγραψε:

On 10/5/13 10:40 AM, Νίκος Αλεξόπουλος wrote:

Στις 5/10/2013 4:53 μμ, ο/η Ned Batchelder έγραψε:


 From reading the bottom-most frame, you can see that the problem is
that "val" is an http.cookies.Morsel object.  This means you probably
tried to use a cookie object as data in your SQL query, and MySQL
doesn't know what to do with that object.  You'll have to use a more
primitive piece of data in your query.


# initialize cookie
cookie = cookies.SimpleCookie( os.environ.get('HTTP_COOKIE') )
cookie.load( cookie )
cookieID = cookie.get('ID')

# if browser cookie does not exist, set it
if not cookieID:
cookie['ID'] = random.randrange(0, 1)
cookie['ID']['path'] = '/'
cookie['ID']['expires'] = 60*60*24*365#this cookie will
expire in a month
cookieID = cookie.get('ID')
print( cookie )


In the above code i try to retrive the cookie form the visitor's
browser and if it does nto exist i create one.



For some reason i think CookieID nevers gets inserted itnot the
database that's why mysql's select statemnt fails.

When i print CookieID i was under the impression i would see a random
number like '5369' but instead it display the follwong.

Set-Cookie: ID="Set-Cookie: ID=5369"

The mysql filed CookieID is of datatype's int(5) so it cannto store
this value.

If iam correct and thi is trully the problem then how can i just get
the random number part out the whole string?

Do you see something wrong?
Why cookie['ID'] retuned this string back and not just the number?




Thanks for being patient.  Where you have this:

 cookieID = cookie.get('ID')

you actually want this:

 cookieID = cookie.get('ID').value

--Ned.



[Sat Oct 05 15:51:02 2013] [error] [client 108.162.229.114]   File
"/home/nikos/public_html/cgi-bin/metrites.py", line 84, in 
[Sat Oct 05 15:51:02 2013] [error] [client 108.162.229.114] cookieID =
cookie.get('ID').value
[Sat Oct 05 15:51:02 2013] [error] [client 108.162.229.114]
AttributeError: 'NoneType' object has no attribute 'value'



Nikos: you know enough to understand what is going on here.

This list will not serve you well if you take every error message and
paste it into an email without trying to get to the bottom of it
yourself.  At the very least, a Google search on, "AttributeError:
'NoneType' object has no attribute 'value'" will find you some answers.

I've said it before, I'll say it again:  slow down.

--Ned.



cookieID = cookie.get('ID').value

is not returning what you said it will return

and if cookie.get('ID') doenst exist it returns the error
AttributeError: 'NoneType' object has no attribute 'value'

These are 2 problem.

value aint being returned thw ehole Set-Cookie: ID=some_number is being
returned instead as tou cna see at http://superhost.gr/

and the second problem is

that if the cookie dosnt exist i get the error of: AttributeError:
'NoneType' object has no attribute 'value'

whne this line is tryign to be executed:
cookieID = cookie.get('ID').value

How can i deal with thse 2 problems?


The best solution i cna think of is put the whole thing into a try: block

try:
cookieID = cookie.get('ID').value
except:
cookie['ID'] = random.randrange(0, 1)
cookie['ID']['path'] = '/'
print( cookie )
cookieID = cookie['ID'].value

print( '''Content-type: text/html; charset=utf-8\n''' )

print( cookieID )
sys.exit(0)

That will avoid the NoneType errot but:

that still print out:
Set-Cookie: ID=7413

instead of just the number

--
What is now proved was at first only imagined! & WebHost
<http://superhost.gr>
--
https://mail.python.org/mailman/listinfo/python-list


Re: Select fails when cookie tried to get a numeric value

2013-10-05 Thread Νίκος Αλεξόπουλος

Στις 5/10/2013 7:08 μμ, ο/η Ned Batchelder έγραψε:


On 10/5/13 11:52 AM, Νίκος Αλεξόπουλος wrote:

Στις 5/10/2013 6:12 μμ, ο/η Ned Batchelder έγραψε:

On 10/5/13 10:40 AM, Νίκος Αλεξόπουλος wrote:

Στις 5/10/2013 4:53 μμ, ο/η Ned Batchelder έγραψε:


 From reading the bottom-most frame, you can see that the problem is
that "val" is an http.cookies.Morsel object.  This means you probably
tried to use a cookie object as data in your SQL query, and MySQL
doesn't know what to do with that object.  You'll have to use a more
primitive piece of data in your query.


# initialize cookie
cookie = cookies.SimpleCookie( os.environ.get('HTTP_COOKIE') )
cookie.load( cookie )
cookieID = cookie.get('ID')

# if browser cookie does not exist, set it
if not cookieID:
cookie['ID'] = random.randrange(0, 1)
cookie['ID']['path'] = '/'
cookie['ID']['expires'] = 60*60*24*365#this cookie will
expire in a month
cookieID = cookie.get('ID')
print( cookie )


In the above code i try to retrive the cookie form the visitor's
browser and if it does nto exist i create one.



For some reason i think CookieID nevers gets inserted itnot the
database that's why mysql's select statemnt fails.

When i print CookieID i was under the impression i would see a random
number like '5369' but instead it display the follwong.

Set-Cookie: ID="Set-Cookie: ID=5369"

The mysql filed CookieID is of datatype's int(5) so it cannto store
this value.

If iam correct and thi is trully the problem then how can i just get
the random number part out the whole string?

Do you see something wrong?
Why cookie['ID'] retuned this string back and not just the number?




Thanks for being patient.  Where you have this:

 cookieID = cookie.get('ID')

you actually want this:

 cookieID = cookie.get('ID').value

--Ned.



[Sat Oct 05 15:51:02 2013] [error] [client 108.162.229.114]   File
"/home/nikos/public_html/cgi-bin/metrites.py", line 84, in 
[Sat Oct 05 15:51:02 2013] [error] [client 108.162.229.114] cookieID =
cookie.get('ID').value
[Sat Oct 05 15:51:02 2013] [error] [client 108.162.229.114]
AttributeError: 'NoneType' object has no attribute 'value'



Nikos: you know enough to understand what is going on here.

This list will not serve you well if you take every error message and
paste it into an email without trying to get to the bottom of it
yourself.  At the very least, a Google search on, "AttributeError:
'NoneType' object has no attribute 'value'" will find you some answers.

I've said it before, I'll say it again:  slow down.

--Ned.



cookieID = cookie.get('ID').value

is not returning what you said it will return

and if cookie.get('ID') doenst exist it returns the error 
AttributeError: 'NoneType' object has no attribute 'value'


These are 2 problem.

value aint being returned thw ehole Set-Cookie: ID=some_number is being 
returned instead as tou cna see at http://superhost.gr/


and the second problem is

that if the cookie dosnt exist i get the error of: AttributeError: 
'NoneType' object has no attribute 'value'


whne this line is tryign to be executed:
cookieID = cookie.get('ID').value

How can i deal with thse 2 problems?

--
What is now proved was at first only imagined! & WebHost
<http://superhost.gr>
--
https://mail.python.org/mailman/listinfo/python-list


Re: Select fails when cookie tried to get a numeric value

2013-10-05 Thread Νίκος Αλεξόπουλος

Στις 5/10/2013 6:12 μμ, ο/η Ned Batchelder έγραψε:

On 10/5/13 10:40 AM, Νίκος Αλεξόπουλος wrote:

Στις 5/10/2013 4:53 μμ, ο/η Ned Batchelder έγραψε:


 From reading the bottom-most frame, you can see that the problem is
that "val" is an http.cookies.Morsel object.  This means you probably
tried to use a cookie object as data in your SQL query, and MySQL
doesn't know what to do with that object.  You'll have to use a more
primitive piece of data in your query.


# initialize cookie
cookie = cookies.SimpleCookie( os.environ.get('HTTP_COOKIE') )
cookie.load( cookie )
cookieID = cookie.get('ID')

# if browser cookie does not exist, set it
if not cookieID:
cookie['ID'] = random.randrange(0, 1)
cookie['ID']['path'] = '/'
cookie['ID']['expires'] = 60*60*24*365#this cookie will
expire in a month
cookieID = cookie.get('ID')
print( cookie )


In the above code i try to retrive the cookie form the visitor's
browser and if it does nto exist i create one.



For some reason i think CookieID nevers gets inserted itnot the
database that's why mysql's select statemnt fails.

When i print CookieID i was under the impression i would see a random
number like '5369' but instead it display the follwong.

Set-Cookie: ID="Set-Cookie: ID=5369"

The mysql filed CookieID is of datatype's int(5) so it cannto store
this value.

If iam correct and thi is trully the problem then how can i just get
the random number part out the whole string?

Do you see something wrong?
Why cookie['ID'] retuned this string back and not just the number?




Thanks for being patient.  Where you have this:

 cookieID = cookie.get('ID')

you actually want this:

 cookieID = cookie.get('ID').value

--Ned.



[Sat Oct 05 15:51:02 2013] [error] [client 108.162.229.114]   File 
"/home/nikos/public_html/cgi-bin/metrites.py", line 84, in 
[Sat Oct 05 15:51:02 2013] [error] [client 108.162.229.114] cookieID 
= cookie.get('ID').value
[Sat Oct 05 15:51:02 2013] [error] [client 108.162.229.114] 
AttributeError: 'NoneType' object has no attribute 'value'


--
What is now proved was at first only imagined! & WebHost
<http://superhost.gr>
--
https://mail.python.org/mailman/listinfo/python-list


Re: Select fails when cookie tried to get a numeric value

2013-10-05 Thread Νίκος Αλεξόπουλος

Στις 5/10/2013 6:06 μμ, ο/η Zero Piraeus έγραψε:

:

On Sat, Oct 05, 2013 at 05:40:23PM +0300, Νίκος Αλεξόπουλος wrote:

When i print CookieID i was under the impression i would see a
random number like '5369' but instead it display the follwong.

Set-Cookie: ID="Set-Cookie: ID=5369"


On Sat, Oct 05, 2013 at 05:47:54PM +0300, Νίκος Αλεξόπουλος wrote:

When i print CookieID i was under the impression i would see a
random number like '5369' but instead it display the follwong.

Set-Cookie: ID="Set-Cookie: ID=5369"


Please don't give identical or near-identical replies to multiple
messages in the thread; other members of the list are either reading all
of your posts or none of them, so repeating yourself like this is only
going to irritate whoever is reading.

Since printing cookieID doesn't produce the output you expect, the
obvious next step is to look up the documentation for whatever kind of
object it is. You can find out its type with

 type(cookieID)

... and then once you know that type (let's say for the sake of argument
it's a Biscuit object), find out about that type of object's attributes
either by googling for the docs or at the interpreter with

 help(Biscuit)

As previously mentioned, there's likely to be some kind of 'value'
attribute that will return just the number you want.

ni...@superhost.gr [~/www/cgi-bin]# python
Python 3.3.2 (default, Aug 26 2013, 06:41:42)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] on linux
Type "help", "copyright", "credits" or "license" for more information.

import os, random
from http import cookies
cookie = cookies.SimpleCookie( os.environ.get('HTTP_COOKIE') )

cookie.load( cookie )

cookieID = cookie.get('ID').value

Traceback (most recent call last):
  File "", line 1, in 
AttributeError: 'NoneType' object has no attribute 'value'


And if you go to my webpage http://superhost.gr at the top corner you 
see that allthough i use this code to get the value of the retrieved 
cookie or set the value if ti do


# initialize cookie and retrieve cookie from clients broswer
cookie = cookies.SimpleCookie( os.environ.get('HTTP_COOKIE') )
cookie.load( cookie )
cookieID = cookie.get('ID').value

# if browser cookie does not exist, set it
if not cookieID:
cookie['ID'] = random.randrange(0, 1)
cookie['ID']['path'] = '/'
cookie['ID']['expires'] = 60*60*24*365  #this cookie will 
expire in a month
print( cookie )
cookieID = cookie['ID'].value

print( '''Content-type: text/html; charset=utf-8\n''' )

print( cookieID )
sys.exit(0)

The output is: Set-Cookie: ID=1376

But how is this possible since we applied the .value attribute in the 
cookie?



--
https://mail.python.org/mailman/listinfo/python-list


Re: Select fails when cookie tried to get a numeric value

2013-10-05 Thread Νίκος Αλεξόπουλος

Στις 5/10/2013 6:12 μμ, ο/η Ned Batchelder έγραψε:

On 10/5/13 10:40 AM, Νίκος Αλεξόπουλος wrote:

Στις 5/10/2013 4:53 μμ, ο/η Ned Batchelder έγραψε:


 From reading the bottom-most frame, you can see that the problem is
that "val" is an http.cookies.Morsel object.  This means you probably
tried to use a cookie object as data in your SQL query, and MySQL
doesn't know what to do with that object.  You'll have to use a more
primitive piece of data in your query.


# initialize cookie
cookie = cookies.SimpleCookie( os.environ.get('HTTP_COOKIE') )
cookie.load( cookie )
cookieID = cookie.get('ID')

# if browser cookie does not exist, set it
if not cookieID:
cookie['ID'] = random.randrange(0, 1)
cookie['ID']['path'] = '/'
cookie['ID']['expires'] = 60*60*24*365#this cookie will
expire in a month
cookieID = cookie.get('ID')
print( cookie )


In the above code i try to retrive the cookie form the visitor's
browser and if it does nto exist i create one.



For some reason i think CookieID nevers gets inserted itnot the
database that's why mysql's select statemnt fails.

When i print CookieID i was under the impression i would see a random
number like '5369' but instead it display the follwong.

Set-Cookie: ID="Set-Cookie: ID=5369"

The mysql filed CookieID is of datatype's int(5) so it cannto store
this value.

If iam correct and thi is trully the problem then how can i just get
the random number part out the whole string?

Do you see something wrong?
Why cookie['ID'] retuned this string back and not just the number?




Thanks for being patient.  Where you have this:

 cookieID = cookie.get('ID')

you actually want this:

 cookieID = cookie.get('ID').value

--Ned.


Thank you Ned, indeed '.value' needed to just print the number.
Now i have it like this:

# connect to database
con = pymysql.connect( db = 'nikos_metrites', user = 'nikos_root', 
passwd = 't1abhp2r!', charset = 'utf8', host = 'localhost' )

cur = con.cursor()

# initialize cookie and retrieve cookie from clients broswer
cookie = cookies.SimpleCookie( os.environ.get('HTTP_COOKIE') )
cookie.load( cookie )

# if browser cookie does not exist, set it
if not cookie.get('ID'):
cookie['ID'] = random.randrange(0, 1)
cookie['ID']['path'] = '/'
cookie['ID']['expires'] = 60*60*24*365  #this cookie will 
expire in a month
print( cookie )
cookieID = cookie['ID'].value
# if browser cookie exist, just retrieve it
else:
cookieID = cookie.get('ID').value

and it does not output an error, but for some reason the inserting and 
selecting never happens.


here si the releveant code:


if cookieID != 1977 and re.search( 
r'(msn|gator|amazon|yandex|reverse|who|cloudflare|fetch|barracuda|spider|google|crawl|pingdom)', 
host ) is None:


try:
# find the visitor record for the (saved) cID and current host
		cur.execute('''SELECT * FROM visitors WHERE counterID = %s and 
cookieID = %s''', (cID, cookieID) )

data = cur.fetchone()#cookieID is unique

if not data:
# first time visitor on this page, create new record
			cur.execute('''INSERT INTO visitors (counterID, cookieID, host, city, 
useros, browser, ref, lastvisit) VALUES (%s, %s, %s, %s, %s, %s, %s, 
%s)''', (cID, cookieID, host, city, useros, browser, ref, lastvisit) )

else:
# found the page, save its primary key for later use
vID = data[0]
# UPDATE record using retrieved vID
			cur.execute('''UPDATE visitors SET host = %s, city = %s, useros = %s, 
browser = %s, ref= %s, hits = hits + 1, lastvisit = %s
	WHERE counterID = %s and cookieID = %s''', (host, city, useros, 
browser, ref, lastvisit, vID, cookieID) )


except pymysql.ProgrammingError as e:
print( repr(e) )
sys.exit(0)
=


Any ideas as to what i shoudld try?
the statemnt don't return any error back though and the cookieID is 
indeed now a proper number so i see no reason as to why they fail.


--
What is now proved was at first only imagined! & WebHost
<http://superhost.gr>
--
https://mail.python.org/mailman/listinfo/python-list


Re: Select fails when cookie tried to get a numeric value

2013-10-05 Thread Νίκος Αλεξόπουλος

Στις 5/10/2013 5:43 μμ, ο/η Ned Batchelder έγραψε:

On 10/5/13 10:30 AM, Νίκος Αλεξόπουλος wrote:

Στις 5/10/2013 5:28 μμ, ο/η Chris Angelico έγραψε:

On Sun, Oct 6, 2013 at 12:24 AM, Νίκος Αλεξόπουλος
 wrote:

But i have given you the line that produces the error:


The statement you quoted is an INSERT. The traceback quotes a SELECT.
These are not the same line of code. You still have not shown us the
actual line from the traceback.

ChrisA


Every mysql statemtns that involved cookieID fails.

in this example this:

# find the visitor record for the (saved) cID and current host
cur.execute('''SELECT * FROM visitors WHERE counterID = %s and
cookieID = %s''', (cID, cookieID) )
data = cur.fetchone()#cookieID is unique



Nikos, slow down.  Don't post three emails before someone has a chance
to respond.

To get help, you have to show the code that goes along with the
traceback.  Your subject line even says, "select fails", so you know it
is a select statement in the traceback.  You have to show us *that
code*, and more than one line.  You've shown the line here, but we don't
know what cID and cookieID are, so we can't help yet.

Saying "every mysql statement that involves cookieID fails" isn't
enough.  Show us the code containing the line that actually is failing
in that traceback.  Include enough of the code that we can figure out
what is going on.

You've said that you can do better here.  Please try to.

--Ned.


Before we get to the part that iam actually try to insert, select 
releveant records the mysql database we need to make sure that CookieID 
is a number.



# initialize cookie
cookie = cookies.SimpleCookie( os.environ.get('HTTP_COOKIE') )
cookie.load( cookie )
cookieID = cookie.get('ID')

# if browser cookie does not exist, set it
if not cookieID:
cookie['ID'] = random.randrange(0, 1)
cookie['ID']['path'] = '/'
cookie['ID']['expires'] = 60*60*24*365#this cookie will 
expire in a month

cookieID = cookie.get('ID')
print( cookie )


In the above code i try to retrive the cookie form the visitor's browser 
and if it does nto exist i create one.




For some reason i think CookieID nevers gets inserted itnot the database 
that's why mysql's select statemnt fails.


When i print CookieID i was under the impression i would see a random 
number like '5369' but instead it display the follwong.


Set-Cookie: ID="Set-Cookie: ID=5369"

The mysql filed CookieID is of datatype's int(5) so it cannto store this 
value.


If iam correct and thi is trully the problem then how can i just get the 
random number part out the whole string?


Do you see something wrong?
Why cookie['ID'] retuned this string back and not just the number?

If its not a number then it will not be selected or inserted properl 
into/from MySQL.

--
https://mail.python.org/mailman/listinfo/python-list


Re: Select fails when cookie tried to get a numeric value

2013-10-05 Thread Νίκος Αλεξόπουλος

Στις 5/10/2013 4:53 μμ, ο/η Ned Batchelder έγραψε:


 From reading the bottom-most frame, you can see that the problem is
that "val" is an http.cookies.Morsel object.  This means you probably
tried to use a cookie object as data in your SQL query, and MySQL
doesn't know what to do with that object.  You'll have to use a more
primitive piece of data in your query.


# initialize cookie
cookie = cookies.SimpleCookie( os.environ.get('HTTP_COOKIE') )
cookie.load( cookie )
cookieID = cookie.get('ID')

# if browser cookie does not exist, set it
if not cookieID:
cookie['ID'] = random.randrange(0, 1)
cookie['ID']['path'] = '/'
cookie['ID']['expires'] = 60*60*24*365  #this cookie will 
expire in a month
cookieID = cookie.get('ID')
print( cookie )


In the above code i try to retrive the cookie form the visitor's browser 
and if it does nto exist i create one.




For some reason i think CookieID nevers gets inserted itnot the database 
that's why mysql's select statemnt fails.


When i print CookieID i was under the impression i would see a random 
number like '5369' but instead it display the follwong.


Set-Cookie: ID="Set-Cookie: ID=5369"

The mysql filed CookieID is of datatype's int(5) so it cannto store this 
value.


If iam correct and thi is trully the problem then how can i just get the 
random number part out the whole string?


Do you see something wrong?
Why cookie['ID'] retuned this string back and not just the number?


--
https://mail.python.org/mailman/listinfo/python-list


Re: Select fails when cookie tried to get a numeric value

2013-10-05 Thread Νίκος Αλεξόπουλος

Στις 5/10/2013 5:28 μμ, ο/η Chris Angelico έγραψε:

On Sun, Oct 6, 2013 at 12:24 AM, Νίκος Αλεξόπουλος
 wrote:

But i have given you the line that produces the error:


The statement you quoted is an INSERT. The traceback quotes a SELECT.
These are not the same line of code. You still have not shown us the
actual line from the traceback.

ChrisA


Every mysql statemtns that involved cookieID fails.

in this example this:

# find the visitor record for the (saved) cID and current host
cur.execute('''SELECT * FROM visitors WHERE counterID = %s and cookieID 
= %s''', (cID, cookieID) )

data = cur.fetchone()#cookieID is unique

--
What is now proved was at first only imagined! & WebHost
<http://superhost.gr>
--
https://mail.python.org/mailman/listinfo/python-list


Re: Select fails when cookie tried to get a numeric value

2013-10-05 Thread Νίκος Αλεξόπουλος

Στις 5/10/2013 5:24 μμ, ο/η Νίκος Αλεξόπουλος έγραψε:

Στις 5/10/2013 4:59 μμ, ο/η Chris Angelico έγραψε:

On Sat, Oct 5, 2013 at 11:38 PM, Νίκος Αλεξόπουλος
 wrote:

cur.execute('''INSERT INTO visitors (counterID, cookieID, host, city,
useros, browser, ref, lastvisit) VALUES (%s, %s, %s, %s, %s, %s, %s,
%s)''',
(cID, vip, host, city, useros, browser, ref, lastvisit) )
===
The above code i wrote gives me the following error:


[Sat Oct 05 13:33:24 2013] [error] [client 108.162.229.114]   File
"/home/nikos/public_html/cgi-bin/metrites.py", line 209, in 
[Sat Oct 05 13:33:24 2013] [error] [client 108.162.229.114]
cur.execute('''SELECT * FROM visitors WHERE counterID = %s and
cookieID =
%s''', (cID, vip) )


No, I don't think it does give you that error! Nikos, you've been
around this group a good while; why can you not learn to read an
exception traceback? Find line 209, which (as Ned said) is the one to
focus on, and look at it. If you can't figure it out yourself, at the
VERY least do us all a courtesy and show us the actual code that's
having the problem!


But i have given you the line that produces the error:

# initialize cookie
cookie = cookies.SimpleCookie( os.environ.get('HTTP_COOKIE') )
cookie.load( cookie )
cookieID = cookie.get('ID')

# if browser cookie does not exist, set it
if not cookieID:
 message  = "ΑΠΟ ΔΩ ΚΑΙ ΣΤΟ ΕΞΗΣ ΔΕΝ ΣΕ ΕΙΔΑ, ΔΕΝ ΣΕ ΞΕΡΩ, ΔΕΝ ΣΕ
ΑΚΟΥΣΑ! ΘΑ ΕΙΣΑΙ ΠΛΕΟΝ Ο ΑΟΡΑΤΟΣ ΕΠΙΣΚΕΠΤΗΣ!!"
 cookie['ID'] = random.randrange(0, 1)
 cookie['ID']['path'] = '/'
 cookie['ID']['expires'] = 60*60*24*365#this cookie will expire
in a month



For some reason i think CookieID nevers gets inserted itnot the database
that's why mysql's select statemnt fails.

When i print CookieID i was under the impression i would see a random
number like '5369' but instead it display the follwong.

Set-Cookie: ID="Set-Cookie: ID=5369"

The mysql filed CookieID is of datatype's int(5) so it cannto store this
value.

If iam correct and thi is trully the problem then how can i just get the
random number part out the whole string?


The line is that is failign is any line of any insert update, sleect 
staments that thats cookieID invilded like:


[Sat Oct 05 14:26:24 2013] [error] [client 108.162.229.114]   File 
"/home/nikos/public_html/cgi-bin/metrites.py", line 219, in 
[Sat Oct 05 14:26:24 2013] [error] [client 108.162.229.114] 
cur.execute('''SELECT * FROM visitors WHERE counterID = %s and cookieID 
= %s''', (cID, cookieID) )



--
What is now proved was at first only imagined! & WebHost
<http://superhost.gr>
--
https://mail.python.org/mailman/listinfo/python-list


Re: Select fails when cookie tried to get a numeric value

2013-10-05 Thread Νίκος Αλεξόπουλος

Στις 5/10/2013 4:59 μμ, ο/η Chris Angelico έγραψε:

On Sat, Oct 5, 2013 at 11:38 PM, Νίκος Αλεξόπουλος
 wrote:

cur.execute('''INSERT INTO visitors (counterID, cookieID, host, city,
useros, browser, ref, lastvisit) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)''',
(cID, vip, host, city, useros, browser, ref, lastvisit) )
===
The above code i wrote gives me the following error:


[Sat Oct 05 13:33:24 2013] [error] [client 108.162.229.114]   File
"/home/nikos/public_html/cgi-bin/metrites.py", line 209, in 
[Sat Oct 05 13:33:24 2013] [error] [client 108.162.229.114]
cur.execute('''SELECT * FROM visitors WHERE counterID = %s and cookieID =
%s''', (cID, vip) )


No, I don't think it does give you that error! Nikos, you've been
around this group a good while; why can you not learn to read an
exception traceback? Find line 209, which (as Ned said) is the one to
focus on, and look at it. If you can't figure it out yourself, at the
VERY least do us all a courtesy and show us the actual code that's
having the problem!


But i have given you the line that produces the error:

# initialize cookie
cookie = cookies.SimpleCookie( os.environ.get('HTTP_COOKIE') )
cookie.load( cookie )
cookieID = cookie.get('ID')

# if browser cookie does not exist, set it
if not cookieID:
	message  = "ΑΠΟ ΔΩ ΚΑΙ ΣΤΟ ΕΞΗΣ ΔΕΝ ΣΕ ΕΙΔΑ, ΔΕΝ ΣΕ ΞΕΡΩ, ΔΕΝ ΣΕ 
ΑΚΟΥΣΑ! ΘΑ ΕΙΣΑΙ ΠΛΕΟΝ Ο ΑΟΡΑΤΟΣ ΕΠΙΣΚΕΠΤΗΣ!!"

cookie['ID'] = random.randrange(0, 1)
cookie['ID']['path'] = '/'
cookie['ID']['expires'] = 60*60*24*365  #this cookie will expire in a 
month



For some reason i think CookieID nevers gets inserted itnot the database 
that's why mysql's select statemnt fails.


When i print CookieID i was under the impression i would see a random 
number like '5369' but instead it display the follwong.


Set-Cookie: ID="Set-Cookie: ID=5369"

The mysql filed CookieID is of datatype's int(5) so it cannto store this 
value.


If iam correct and thi is trully the problem then how can i just get the 
random number part out the whole string?





--
What is now proved was at first only imagined! & WebHost
<http://superhost.gr>
--
https://mail.python.org/mailman/listinfo/python-list


Select fails when cookie tried to get a numeric value

2013-10-05 Thread Νίκος Αλεξόπουλος

# initialize cookie
cookie = cookies.SimpleCookie( os.environ.get('HTTP_COOKIE') )
cookie.load( cookie )
vip = cookie.get('ID')

...
...

# if browser cookie does not exist, set it
vip = random.randrange(0, 1)
cookie['ID'] = vip
cookie['ID']['path'] = '/'

# first time visitor on this page, create new record
cur.execute('''INSERT INTO visitors (counterID, cookieID, host, city, 
useros, browser, ref, lastvisit) VALUES (%s, %s, %s, %s, %s, %s, %s, 
%s)''', (cID, vip, host, city, useros, browser, ref, lastvisit) )

===
The above code i wrote gives me the following error:


[Sat Oct 05 13:33:24 2013] [error] [client 108.162.229.114]   File 
"/home/nikos/public_html/cgi-bin/metrites.py", line 209, in 
[Sat Oct 05 13:33:24 2013] [error] [client 108.162.229.114] 
cur.execute('''SELECT * FROM visitors WHERE counterID = %s and cookieID 
= %s''', (cID, vip) )
[Sat Oct 05 13:33:24 2013] [error] [client 108.162.229.114]   File 
"/usr/local/bin/python/lib/python3.3/site-packages/pymysql/cursors.py", 
line 100, in execute
[Sat Oct 05 13:33:24 2013] [error] [client 108.162.229.114] escaped_args 
= tuple(conn.escape(arg) for arg in args)
[Sat Oct 05 13:33:24 2013] [error] [client 108.162.229.114]   File 
"/usr/local/bin/python/lib/python3.3/site-packages/pymysql/cursors.py", 
line 100, in 
[Sat Oct 05 13:33:24 2013] [error] [client 108.162.229.114] escaped_args 
= tuple(conn.escape(arg) for arg in args)
[Sat Oct 05 13:33:24 2013] [error] [client 108.162.229.114]   File 
"/usr/local/bin/python/lib/python3.3/site-packages/pymysql/connections.py", 
line 650, in escape
[Sat Oct 05 13:33:24 2013] [error] [client 108.162.229.114] return 
escape_item(obj, self.charset)
[Sat Oct 05 13:33:24 2013] [error] [client 108.162.229.114]   File 
"/usr/local/bin/python/lib/python3.3/site-packages/pymysql/converters.py", 
line 31, in escape_item
[Sat Oct 05 13:33:24 2013] [error] [client 108.162.229.114] encoder 
= encoders[type(val)]
[Sat Oct 05 13:33:24 2013] [error] [client 108.162.229.114] KeyError: 



What is the nature of the error?
  ???

I'll iam trying to do is to give a cookie a random number.
--
https://mail.python.org/mailman/listinfo/python-list


Re: Can arbitrary code run in a server if someone's know just the MySQL password?

2013-10-02 Thread Νίκος Αλεξόπουλος

Στις 2/10/2013 8:39 μμ, ο/η Steven D'Aprano έγραψε:

On Wed, 02 Oct 2013 16:41:40 +0300, Νίκος wrote:


Στις 2/10/2013 4:25 μμ, ο/η Steven D'Aprano έγραψε:

On Wed, 02 Oct 2013 15:20:00 +0300, Νίκος wrote:


Is it possible for someone that knows the MYSQL password of a server
to run arbitrary code on a linux server?


Yes, it is possible.


Is that what might have happened and someone managed to upload the .html
file in '~/home/nikos/www/' ?


How the hell should I know? I am not a MySQL expert, and this is not a
MySQL forum.

Nikos, you embarrass me. I have gone out on a limb for you, and this is
how you thank me? You said you were improving, and yet here you go
completely ignoring the links I sent you, and continuing to ask off-topic
questions here.

Thanks for kicking me in the guts. I will remember this next time you ask
a question.



I just asked your opinion at this.
But i okey i will stop since this is not going us anywhere.

Neither will i replay to any more insulting comments.

--
What is now proved was at first only imagined! & WebHost

--
https://mail.python.org/mailman/listinfo/python-list