This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#301 2012-05-22 09:03:59

dreamod
New Scratcher
Registered: 2012-01-22
Posts: 100+

Re: Block Files

sparks wrote:

Yup!

I tried uploading a test block and I got "SQLConnectionError". My block importer found that error and reported it to me.  smile
I entered a fake password and that was detected.
If you see a block (or many) with test as a comment don't upload it.

Offline

 

#302 2012-05-22 14:43:48

sparks
Community Moderator
Registered: 2008-11-05
Posts: 1000+

Re: Block Files

I just checked the database and none of the blocks got through, which is good and bad  tongue  Thanks for testing it! I'm really stumped as to why there's an error at all though  hmm  I shall have to eyeball the code again!


http://img541.imageshack.us/img541/7563/scratchbetabanner.png

Offline

 

#303 2012-05-22 14:51:00

blob8108
Scratcher
Registered: 2007-06-25
Posts: 1000+

Re: Block Files

@dreamod: show the Squeaky code so we can see what you're POSTing.  smile


Things I've made: kurt | scratchblocks2 | this cake

Offline

 

#304 2012-05-22 18:26:59

Greenatic
Scratcher
Registered: 2009-05-03
Posts: 1000+

Re: Block Files

Could you provide an updated patch?   smile

(Or did you already update the project?)

Last edited by Greenatic (2012-05-22 18:27:30)

Offline

 

#305 2012-05-23 09:35:30

dreamod
New Scratcher
Registered: 2012-01-22
Posts: 100+

Re: Block Files

blob8108 wrote:

@dreamod: show the Squeaky code so we can see what you're POSTing.  smile

ok. heres the code:

Code:

"format everything properly"
t1 _ WeakKeyAssociation new value: (Array with: userNameMorph contents asString).
            t1 key: 'username'.
            t3 _ WeakKeyAssociation new value: (Array with: passwordMorph contents asString).
            t3 key: 'password'.
            t5 _ WeakKeyAssociation new value: (Array with: commentMorph contents asString).
            t5 key: 'comment'.
            t4 _ WeakKeyAssociation new value: (Array with: blockFile).
            t4 key: 'block'.
            t2 _ #() asOrderedCollection. "collect data into an array"
            t2 add: t1.
            t2 add: t3.
            t2 add: t5.
            t2 add: t4.
"upload block"
Cursor wait showWhile: [t2 _ (HTTPSocket httpPostDocument: URL "URL is a class variable with the value 'http://blocks.scratchr.org/remoteBlockUploader.php'" args: t1) content]

Offline

 

#306 2012-05-23 09:45:57

dreamod
New Scratcher
Registered: 2012-01-22
Posts: 100+

Re: Block Files

Greenatic wrote:

Could you provide an updated patch?   smile

(Or did you already update the project?)

I've posted my update for the block importer. I'm going to add a 'check automatically' setting as well. You can turn it off if you don't have internet. But you just right click the .block icon in the top left (you should have downloaded the image) and select 'check updates' or 'update patch' to update your block importer.

@Sparks: Every time I try updating the block update file it seems to replace all // with /, and that ruins the code because / is the division sign and // is the mod sign.

Offline

 

#307 2012-05-23 09:49:46

dreamod
New Scratcher
Registered: 2012-01-22
Posts: 100+

Re: Block Files

dreamod wrote:

Greenatic wrote:

Could you provide an updated patch?   smile

(Or did you already update the project?)

I've posted my update for the block importer. I'm going to add a 'check automatically' setting as well. You can turn it off if you don't have internet. But you just right click the .block icon in the top left (you should have downloaded the image) and select 'check updates' or 'update patch' to update your block importer.

@Sparks: Every time I try updating the block update file it seems to replace all // with /, and that ruins the code because / is the division sign and // is the mod sign.

correction: it replaces all \\ with \. sorry about that.

Offline

 

#308 2012-05-23 11:19:49

blob8108
Scratcher
Registered: 2007-06-25
Posts: 1000+

Re: Block Files

blob8108 wrote:

dreamod wrote:

it replaces all \\ with \.

An escaping problem!  yikes

@Sparks: try doing stripslashes($_POST['block']) before you process it (and before escaping it, of course  wink  ) — that seems to help fix it.

Edit: darn, doesn't fix the double slashes properly.  hmm

Last edited by blob8108 (2012-05-23 13:24:40)


Things I've made: kurt | scratchblocks2 | this cake

Offline

 

#309 2012-05-23 11:29:06

dreamod
New Scratcher
Registered: 2012-01-22
Posts: 100+

Re: Block Files

blob8108 wrote:

dreamod wrote:

it replaces all \\ with \.

An escaping problem!  yikes

what do you mean by "escaping problem"?

Offline

 

#310 2012-05-23 11:47:10

blob8108
Scratcher
Registered: 2007-06-25
Posts: 1000+

Re: Block Files

sparks wrote:

I just checked the database and none of the blocks got through, which is good and bad  tongue  Thanks for testing it! I'm really stumped as to why there's an error at all though  hmm  I shall have to eyeball the code again!

Is this still the code you're using?

If so, I think I have an idea of the problem:

* On line 54, you've set the $query variable, but not actually run mysql_query($query). Might want to add that in  tongue

* None of your values passed to the INSERT query appear to be escaped, as far as I can tell (using mysql_escape(), for example), so you might have some problems with values containing apostrophes — as well as it being a rather large security problem  hmm

As a final note: on lines 44 and 58 it might be better to do something like "SELECT * FROM blocks WHERE name='$blockspec' LIMIT 1;" (where blockspec is escaped, naturally) rather than "SELECT * FROM `blocks`", and then just do $exists = mysql_num_rows($result) > 0. Should help reduce the load on the server.

Hope that helps!  smile


Things I've made: kurt | scratchblocks2 | this cake

Offline

 

#311 2012-05-23 12:21:03

blob8108
Scratcher
Registered: 2007-06-25
Posts: 1000+

Re: Block Files

dreamod wrote:

blob8108 wrote:

@dreamod: show the Squeaky code so we can see what you're POSTing.  smile

ok. heres the code:

Code:

"format everything properly"
t1 _ WeakKeyAssociation new value: (Array with: userNameMorph contents asString).
            t1 key: 'username'.
            t3 _ WeakKeyAssociation new value: (Array with: passwordMorph contents asString).
            t3 key: 'password'.
            t5 _ WeakKeyAssociation new value: (Array with: commentMorph contents asString).
            t5 key: 'comment'.
            t4 _ WeakKeyAssociation new value: (Array with: blockFile).
            t4 key: 'block'.
            t2 _ #() asOrderedCollection. "collect data into an array"
            t2 add: t1.
            t2 add: t3.
            t2 add: t5.
            t2 add: t4.
"upload block"
Cursor wait showWhile: [t2 _ (HTTPSocket httpPostDocument: URL "URL is a class variable with the value 'http://blocks.scratchr.org/remoteBlockUploader.php'" args: t1) content]

Apologies — as I'm definitely not a Squeak person (other than the vague reading I had to do to write Kurt) — how can I run this in my copy of Squeak/Scratch/your mod? I can't figure out how to add a method/run that code. I downloaded your Block Importer from here, but presumably that's not your latest version.

All I wanted to do was have a look at what it's sending, to see what the PHP script makes of it...  smile


Things I've made: kurt | scratchblocks2 | this cake

Offline

 

#312 2012-05-23 12:32:19

dreamod
New Scratcher
Registered: 2012-01-22
Posts: 100+

Re: Block Files

blob8108 wrote:

dreamod wrote:

blob8108 wrote:

@dreamod: show the Squeaky code so we can see what you're POSTing.  smile

ok. heres the code:

Code:

"format everything properly"
t1 _ WeakKeyAssociation new value: (Array with: userNameMorph contents asString).
            t1 key: 'username'.
            t3 _ WeakKeyAssociation new value: (Array with: passwordMorph contents asString).
            t3 key: 'password'.
            t5 _ WeakKeyAssociation new value: (Array with: commentMorph contents asString).
            t5 key: 'comment'.
            t4 _ WeakKeyAssociation new value: (Array with: blockFile).
            t4 key: 'block'.
            t2 _ #() asOrderedCollection. "collect data into an array"
            t2 add: t1.
            t2 add: t3.
            t2 add: t5.
            t2 add: t4.
"upload block"
Cursor wait showWhile: [t2 _ (HTTPSocket httpPostDocument: URL "URL is a class variable with the value 'http://blocks.scratchr.org/remoteBlockUploader.php'" args: t1) content]

Apologies — as I'm definitely not a Squeak person (other than the vague reading I had to do to write Kurt) — how can I run this in my copy of Squeak/Scratch/your mod? I can't figure out how to add a method/run that code. I downloaded your Block Importer from here, but presumably that's not your latest version.

All I wanted to do was have a look at what it's sending, to see what the PHP script makes of it...  smile

Ok. Do this, right click the .block on the top left and select update patch ( or check for updates). You want to update it and then right click a block and select upload block. When an SQLConnectionError appears hold control (or command) and press okay. Than a debugger will appear and you can see results. Ask me for more help if needed.

Offline

 

#313 2012-05-23 12:59:00

blob8108
Scratcher
Registered: 2007-06-25
Posts: 1000+

Re: Block Files

dreamod wrote:

Ok. Do this, right click the .block on the top left and select update patch ( or check for updates). You want to update it and then right click a block and select upload block. When an SQLConnectionError appears hold control (or command) and press okay. Than a debugger will appear and you can see results. Ask me for more help if needed.

Thanks!  smile  Well, it's definitely not your code, as far as I can tell. If that helps at all.  tongue


Things I've made: kurt | scratchblocks2 | this cake

Offline

 

#314 2012-05-23 13:05:58

dreamod
New Scratcher
Registered: 2012-01-22
Posts: 100+

Re: Block Files

blob8108 wrote:

dreamod wrote:

Ok. Do this, right click the .block on the top left and select update patch ( or check for updates). You want to update it and then right click a block and select upload block. When an SQLConnectionError appears hold control (or command) and press okay. Than a debugger will appear and you can see results. Ask me for more help if needed.

Thanks!  smile  Well, it's definitely not your code, as far as I can tell. If that helps at all.  tongue

I just hope this ends up working. I could probably make one for panther and BYOB as well.

Offline

 

#315 2012-05-23 13:10:23

dreamod
New Scratcher
Registered: 2012-01-22
Posts: 100+

Re: Block Files

dreamod wrote:

blob8108 wrote:

dreamod wrote:

Ok. Do this, right click the .block on the top left and select update patch ( or check for updates). You want to update it and then right click a block and select upload block. When an SQLConnectionError appears hold control (or command) and press okay. Than a debugger will appear and you can see results. Ask me for more help if needed.

Thanks!  smile  Well, it's definitely not your code, as far as I can tell. If that helps at all.  tongue

I just hope this ends up working. I could probably make one for panther and BYOB as well.

'one' being an uploader. So an uploader for the Panther and BYOB mods.

Offline

 

#316 2012-05-23 13:15:39

blob8108
Scratcher
Registered: 2007-06-25
Posts: 1000+

Re: Block Files

dreamod wrote:

Ok. Do this, right click the .block on the top left and select update patch ( or check for updates). You want to update it and then right click a block and select upload block. When an SQLConnectionError appears hold control (or command) and press okay. Than a debugger will appear and you can see results. Ask me for more help if needed.

I now can't scroll in the block area, having updated it to 2.6 from 2.22. Any reason?  smile


Things I've made: kurt | scratchblocks2 | this cake

Offline

 

#317 2012-05-23 13:19:19

dreamod
New Scratcher
Registered: 2012-01-22
Posts: 100+

Re: Block Files

blob8108 wrote:

dreamod wrote:

Ok. Do this, right click the .block on the top left and select update patch ( or check for updates). You want to update it and then right click a block and select upload block. When an SQLConnectionError appears hold control (or command) and press okay. Than a debugger will appear and you can see results. Ask me for more help if needed.

I now can't scroll in the block area, having updated it to 2.6 from 2.22. Any reason?  smile

Oh, no. There's a weird glitch in just that image. But if you file-out the 'working' changes into another image then it works. I'll put up a working image. Sorry for the inconvenience.

Offline

 

#318 2012-05-23 13:23:14

blob8108
Scratcher
Registered: 2007-06-25
Posts: 1000+

Re: Block Files

dreamod wrote:

blob8108 wrote:

I now can't scroll in the block area, having updated it to 2.6 from 2.22. Any reason?  smile

Oh, no. There's a weird glitch in just that image. But if you file-out the 'working' changes into another image then it works. I'll put up a working image. Sorry for the inconvenience.

At the risk of being thick — how precisely do I do that?  tongue  "Save image for end-user" didn't work...


Things I've made: kurt | scratchblocks2 | this cake

Offline

 

#319 2012-05-23 13:23:57

dreamod
New Scratcher
Registered: 2012-01-22
Posts: 100+

Re: Block Files

blob8108 wrote:

dreamod wrote:

blob8108 wrote:

I now can't scroll in the block area, having updated it to 2.6 from 2.22. Any reason?  smile

Oh, no. There's a weird glitch in just that image. But if you file-out the 'working' changes into another image then it works. I'll put up a working image. Sorry for the inconvenience.

At the risk of being thick — how precisely do I do that?  tongue  "Save image for end-user" didn't work...

I'll take care of that for you and give you a good working link, for the newest block importer and image.

Offline

 

#320 2012-05-23 13:27:03

dreamod
New Scratcher
Registered: 2012-01-22
Posts: 100+

Re: Block Files

this is the newest link to the block importer: http://www.mediafire.com/?bjdyg9wd965onla

Offline

 

#321 2012-05-23 13:50:05

sparks
Community Moderator
Registered: 2008-11-05
Posts: 1000+

Re: Block Files

blob8108 wrote:

sparks wrote:

I just checked the database and none of the blocks got through, which is good and bad  tongue  Thanks for testing it! I'm really stumped as to why there's an error at all though  hmm  I shall have to eyeball the code again!

Is this still the code you're using?

If so, I think I have an idea of the problem:

* On line 54, you've set the $query variable, but not actually run mysql_query($query). Might want to add that in  tongue

* None of your values passed to the INSERT query appear to be escaped, as far as I can tell (using mysql_escape(), for example), so you might have some problems with values containing apostrophes — as well as it being a rather large security problem  hmm

As a final note: on lines 44 and 58 it might be better to do something like "SELECT * FROM blocks WHERE name='$blockspec' LIMIT 1;" (where blockspec is escaped, naturally) rather than "SELECT * FROM `blocks`", and then just do $exists = mysql_num_rows($result) > 0. Should help reduce the load on the server.

Hope that helps!  smile

Oh! What a stupid mistake  tongue  Fresh eyes are always useful! I'll add it in a few hours after I've eaten and remeber to escape the string  smile

Would you like to join the developer team (i.e have access to the admin page?)


http://img541.imageshack.us/img541/7563/scratchbetabanner.png

Offline

 

#322 2012-05-23 14:13:08

blob8108
Scratcher
Registered: 2007-06-25
Posts: 1000+

Re: Block Files

sparks wrote:

Oh! What a stupid mistake  tongue  Fresh eyes are always useful!

Yup, I've done the same thing many times...  tongue

Would you like to join the developer team (i.e have access to the admin page?)

Sure! Sounds great — I can't commit to doing anything, though, if you see what I mean  smile

Last edited by blob8108 (2012-05-23 14:23:43)


Things I've made: kurt | scratchblocks2 | this cake

Offline

 

#323 2012-05-23 14:22:27

blob8108
Scratcher
Registered: 2007-06-25
Posts: 1000+

Re: Block Files

dreamod wrote:

this is the newest link to the block importer: http://www.mediafire.com/?bjdyg9wd965onla

Thanks!  smile  This download's taking forever, though -_-  tongue


Things I've made: kurt | scratchblocks2 | this cake

Offline

 

#324 2012-05-23 14:27:41

dreamod
New Scratcher
Registered: 2012-01-22
Posts: 100+

Re: Block Files

blob8108 wrote:

dreamod wrote:

this is the newest link to the block importer: http://www.mediafire.com/?bjdyg9wd965onla

Thanks!  smile  This download's taking forever, though -_-  tongue

It includes a mac application, change-set (patch), image, changes, source, help, languages (no extra translations), and a few block files. Enjoy.  smile

Offline

 

#325 2012-05-23 17:18:05

rookwood101
Scratcher
Registered: 2011-07-29
Posts: 500+

Re: Block Files

You should use mysql_real_escape_string()

I plan on writing a topic on code security and practises tommorow, so be sure to read it!


http://i.imgur.com/zeIZW.png

Offline

 

Board footer