Text MMORPG - King of Grinders (Web based Application)

341 views
Skip to first unread message

harry Singh

unread,
May 24, 2017, 7:47:52 AM5/24/17
to ring...@googlegroups.com
Basically I want to create my own Text based MMORPG game, something like syrnia, lyrania, manapot, gates of survival. 

Here is the Git repository of my files please check at MY GITHUB PAGE

I chose your language as I feel i can understand it better than other languages. I am creating this topic in hope that i will receive guidance on my project from your group directly. So the first task was have a basic understanding about your language and i did pretty good via tutorials, in some places i got stuck like running webpage on apache server, apache configuration etc, but somehow i was lucky to find their solution from within these forums only. 

My Road Map for this games Development till now

1. Learning basics of Ring language.
2. Home page accompanied by Registration and Login page
3. Chat System
4. Game Basics and In game Tutorials
5. Enhancing Game playability by introducing stuff like quests, clans, etc.

Only these 4 steps may become too long term, so its better to not plan further ahead, i will do later when i reach at least at step 3 :D

Thanks for reading this, and hopefully you guys help me with this project of mine. 

\---------------------------------------------------------

Now i am stuck at making the Homepage with registration, login page the very first step for a mmorpg and second step for my road map. I am doing steps as said in documentation, but am not able to. It throws errors even after copying ex25.ring, weblib.ring and datalib.ring in my htdocs folder. Hello world example ran pretty well so i am sure i didn't do any mistake like apache configuration, website setup etc. till that part for sure.
So hopefully someone might help me... this will be a long term project so i will be asking all my problems here only whatever encountered, this will serve as a big tutorial as well for the newbies like me that may be interested in your language later on. 

Error shown on running Ex25.ring is this 

Line 156 Error (R5) : Can't access the list item, Object is not list ! 
In method loadmodel() in file datalib.ring
called from line 171  In method connect() in file datalib.ring
called from line 168  In method connect() in file datalib.ring
called from line 193  in file C:/xampp/htdocs/kingofgrinders/ex25.ring

I uploaded database folder, temp, upload, and following ring files to the htdocs
- bootstrap, cookie, datalib, ex24 to ex30, ex25_users, index, mainpage, users, weblib and webpage

but except ex26.ring and ex28.ring all other files throw the same kind of error. And when i fill username, email and password in ex26 and then click register it again throws this error - 

Line 156 Error (R5) : Can't access the list item, Object is not list ! 
In method loadmodel() in file datalib.ring
called from line 171  In method connect() in file datalib.ring
called from line 168  In method connect() in file datalib.ring
called from line 10  in file C:/xampp/htdocs/kingofgrinders/ex27.ring 
Untitled.png
Message has been deleted

Mahmoud Fayed

unread,
May 24, 2017, 10:32:11 AM5/24/17
to The Ring Programming Language
Hello Harry

Revise the next information in datalib.ring

Class Database

    cServer
= "localhost"
    cUserName
= "root"
    cPassword
= "root"
    cDatabase
= "mahdb"

Just be sure you have the correct username and password
And the correct database name (MySQL)

Greetings,
Mahmoud



On Wednesday, May 24, 2017 at 2:47:52 PM UTC+3, harry Singh wrote:
Basically I want to create my own Text based MMORPG game, something like syrnia, lyrania, manapot, gates of survival. 

harry Singh

unread,
May 24, 2017, 10:43:53 AM5/24/17
to The Ring Programming Language


On Wednesday, May 24, 2017 at 8:02:11 PM UTC+5:30, Mahmoud Fayed wrote:
Hello Harry

Revise the next information in datalib.ring

Class Database

    cServer
= "localhost"
    cUserName
= "root"
    cPassword
= "root"
    cDatabase
= "mahdb"

Just be sure you have the correct username and password
And the correct database name (MySQL)

Greetings,
Mahmoud


Thanks, although i didn't revise them, i just created new database mahdb, and imported the default mahdb.sql given by your software to my phpadmin and bang it worked. :D 

Mahmoud Fayed

unread,
May 24, 2017, 10:48:48 AM5/24/17
to The Ring Programming Language
Hello Harry

Thanks for the information, Keep up the good work :D

Greetings,
Mahmoud

harry Singh

unread,
May 24, 2017, 11:43:13 AM5/24/17
to ring...@googlegroups.com
Now i found out that although its saying account created successfully after registering, but in database values are null for all four fields. Why is that? However it does insert a record everytime i register, a new line in database is created everytime. So i suppose parameters are not reaching the database, just the command to insert them is working.

Also please suggest a way with which i can share my this work in progress here on website for you guys and my friends to test out. 

Mahmoud Fayed

unread,
May 24, 2017, 3:56:30 PM5/24/17
to The Ring Programming Language
Hello Harry

I tested it again, I can add new users, Display them, Login, etc
I don't see this problem.

Provide screen shots, Examples about the (Data)

Please share what you are doing using GitHub ( http://github.com/ )

Greetings,
Mahmoud

harry Singh

unread,
May 25, 2017, 12:38:43 AM5/25/17
to ring...@googlegroups.com
Here is the Git repository of my files please check at MY GITHUB PAGE Attached are screenshots as well. But its funny, yesterday it was not working, for which i asked for help, but today when i turned on pc, it is working fine as you can see in screenshot of phpmyadmin that first record is null and second is mailmeharry. Funny bug needed restart of the PC ?

I also uploaded screenshot of my home page on the top post. Please check it out. 
Now i am stuck at linking buttons, i want to open page of Registration on clicking Register at the home page i created in KingofGrinders.ring file. How to accomplish this, you can check this file on the github link i provided above.

EDIT - Ha ha never mind i found it , i used formstart() instead of formpost () and i was able to load up registration page by click from home page :) 
I am enjoying this now :D will post here again if any other problem arise :D
Untitled.png
user creation.png

harry Singh

unread,
May 25, 2017, 6:41:53 AM5/25/17
to ring...@googlegroups.com
My next problem is Forgot Password Page. Logic i designed for recovery of password is this. I changed the registration page and now while registering i take forgot password word from the users themselves (doesn't matter whatever they chose and even if they forget that its fine). Added an option to login page for forgot password as well. When user clicks it, it should bring him to another page where there is an option to send the forgot password word directly to email after typing username and emal in the given textboxes there. 
If username and email matches in our database then
Now after clicking that user should have got an email. And user has to type down the received email word in the input box. If its matched "change password" page should be shown to him where he can directly change his passwords.

I have got an idea to use SendEmail function and Template function to accomplish this basically. But the examples provided in documentation are not good enough for me. So i need your help here please. THanks. I updated my git page as well. https://github.com/mailmeharry2008/KingofGrinders
 I also tried writing html file sendfgtpwdmail.html (also uploaded in git), but it doesn't work too. I am sure i must have done funny mistake in it. Please correct it as well :D

Also wanted to ask whether ain't there any way for me to use form designer module of rnote.exe for web applications as designing tables, textboxes etc. by writing are more difficult rather than drawing them simply on GUI just like in Visual studio software?

Message has been deleted

Mahmoud Fayed

unread,
May 25, 2017, 6:59:18 PM5/25/17
to ring...@googlegroups.com
Hello Harry

(1) Don't share your email password in the source code.
Change your password, and don't put it in the source code again
I know that your account is protected (So this is not a private message), but it's better for security.

(2) Upload the database to GitHub too, So we can test the application and it's interactions with the database.

(3) "Funny bug needed restart of the PC ?"

It's not related to Ring, It's related to something else like
the MySQL client, Sockets/Network, Server, etc.

Ring just call the MySQL library functions as any other C library that we call from Ring.

(4) "Also wanted to ask whether ain't there any way for me to use form designer module of rnote.exe for web applications as designing tables, textboxes etc"

The Form Designer is written in Ring, It's designed for Desktop/Mobile apps using Qt
It can be updated to generate different code, if someone is interested to do that, Here is the file used for code generation :-
https://github.com/ring-lang/ring/blob/master/applications/formdesigner/filesystem/codegenerator.ring

(5) "I have got an idea to use SendEmail function and Template function to accomplish this basically. But the examples provided in documentation are not good enough for me"

Use SMTP, Not POP!, Example from documentation

sendemail("smtp://smtp.gmail.com:587",
        "em...@gmail.com",
        "password",
        "em...@gmail.com",
        "some...@yahoo.com",
        "somebo...@yahoo.com",
        "Sending email from Ring",
        "Hello
         How are you?
         Are you fine?
         Thank you!
         Greetings,
         Mahmoud")

(6) "I also tried writing html file sendfgtpwdmail.html (also uploaded in git), but it doesn't work too"

* The template function need an object as the second parameter (we pass the self as parameter)
    cTemp = Template("sendfgtpwdmail.html",self)

So to call it, You need to have "Self", i.e. call it from class method or braces

Correct code could be

New Page
{
    cTemp
= Template("sendfgtpwdmail.html",self)
# .....
# .....

* Don't use the See command in templates
Just use the equal mark after %
<%=   %>

Example:

<%= "Send email..." + nl %>

<%= "Done.." + nl %>

* Don't use <html>,  <body> and <title> tags in the template when you have
New Page
{
# .....

}

Because the Page object will add them.


Greetings,
Mahmoud

harry Singh

unread,
May 26, 2017, 12:48:56 AM5/26/17
to ring...@googlegroups.com
1. I was too careless regarding that password lol, sorry. I changed all my passwords relating to that now for security as well.
2. Yeah sure i will upload database file now.
3. :D
4. I am a noob, i can't even understand whats written in that form designer code lol how can i change it :D
5. and 6. Thanks for your precious guidance, now i want to call you sire as i feel you are mentoring me and that too at very high quality level. I appreciate it very much and hope you continue to provide me support like this and help me achieve my goal. I will try now what you suggested in point no. 5 and 6 right away.

Thanks again sire.

EDIT - uploaded sql file, and also modified my html file and forgotpassword.ring file as per your instructions but still nothing, on executing html file it shows whole code in it as it is and for executing forgotpassword.ring this error is thrown

eval Line (19) Error (C8) : Parentheses ')' is missing Content-Type: text/plain 

Content-Type: text/plain 


eval errors count : 1 
Content-Type: text/plain 


Line 164 Error in eval! 
In eval In function template() in file weblib.ring
called from line 9  in file C:/xampp/htdocs/kingofgrinders/forgotpassword.ring 

EDIT 2 - i edited the code in forgotpassword.ring and remove the unnecessary box code from it (reuploaded it on git), now error is changed it is this now . I made sure that password i typed in my html file is correct and email addresses too. Not sure about smtp, i wrote it same as you said... "smtp://smtp.gmail.com:587",

Line 12 Login denied 
In sendemail In function template() in file weblib.ring
called from line 9  in file C:/xampp/htdocs/kingofgrinders/forgotpassword.ring 
--------------------------------------------------------------------------------------------------------------------------------------
EDIT 3 - LOl i got an email regarding login attempt from less secure app, and gmail blocked it, maybe that was the reason, i turned on the less secure app logins now.. Now its good and working :) It says this now

Content-type: text/htmlNew Page { Send email... Done.. }

Any way to remove the content type: text/html message? I dont want to send CC message so for time being i used my own senders email in that section. But is their any way to stop sending that cc message? And for some reason ex25.ring doesn't work on my system, can you please take a look on that as well and resolve its errors.... its on my github repository as well. Error thrown by him is this :-

Line 340 Error (R20) : Calling function with extra number of parameters! 
In method hiddenvars() in file datalib.ring
called from line 340  In method gridview() in file datalib.ring
called from line 247  In method showtable() in file datalib.ring
called from line 213  In method routing() in file datalib.ring
called from line 11  in file C:/xampp/htdocs/kingofgrinders/ex25.ring 

Also to make things dynamic now i want to fetch email directly from forgotpassword.ring file and enter it in sendfgtpwdmail.html file directly in the place of Receivers email... , and also the fgtpwd word in database to the message of the email. How can i accomplish this? Another problem is that change password button should be shown below as its coded afterwards but change password button is shown upwards and the message of username and email matching is shown below, but i coded it first however. Please provide solution for this as well.



EDIT 4 - Never mind, corrected the problem of up and down. Now remaining problems are fetching email from forgotpassword.ring to sendfgtwpdmail.html and make content dynamic there for email message and recipients email. and that content type:text/html message is annoying lol please get it out of my screen, ex25.ring throwing above said error, and removing cc recipient.

EDIT 5 - Its cool now the current github code of sendfgtpwdmail.html is able to get email and fgtpwd from forgotpassword.ring file as well. But i cant put it in sendemail function by any way, please suggest something for that. I can see them via see commands only i.e. <%=a%> but when i write this in sendemail section for respective email and fgtpwd then it throws errors. I tried using brackets, inverted commas etc. but nothing worked. 

Other problems still stays as well i.e. ex25.ring, and that content type:text/html message on the forgotpassword.ring page in browser. Also removing cc in sendemail function seems impossible. Following is screenshot of that message :-


harry Singh

unread,
May 27, 2017, 12:24:17 AM5/27/17
to ring...@googlegroups.com
Yesterday i didn't received reply for my above said queries, what happened mahmoud?  Please reply them asap, its already so slow at getting replies once per day lol. 

I am sure you must be busy too in real life and can't spend much on us but still being a human i feel impatient lol :D  Now without anything to do in coding as being stuck up, i even started writing GDD, i uploaded it on my Github as well, hope people interested in making MMOs will be interested in it.

Mahmoud Fayed

unread,
May 27, 2017, 1:00:18 AM5/27/17
to The Ring Programming Language
Hello Harry

(1) Let changing the Form Designer for the future until you master the Ring Language.

(2) Don't call me sire, In this group we are friends working together to make Ring a better language.

(3) Don't expect the support from me only, Other members are reading these messages too and they will jump to help you at any time. Just try to take your time to solve the problem, because the more you do that, the more you will become better. I like your progress and how you solved a lot of problems alone. GREAT, Keep up the good work :D

(4) Don't edit the post after sending it. Just send a new message. Because I get email for each new message (I don't know about your edits until I open the forum!).

(5) I don't reply once per day. It depends. In some days I become very active (I may send many messages).

(6) You get this message "text/html message" as a result of using New Page { } more than one time
Just remove the second one in forgotpassword.ring - line 24

Greetings,
Mahmoud



harry Singh

unread,
May 27, 2017, 2:29:59 AM5/27/17
to ring...@googlegroups.com
1. Sure 
2. Thanks bro. Also thanks for star marking my git repository.
3. Yeah i welcome posts from anybody, but till now no one else posted any reply for me, so i think maybe not too many are doing web applications in ring language.  And thanks for the compliment ha ha its the first time someone encourage me like this, in other websites where i earlier went, people usually discouraged me and even received zero guidance from them, here is one sample of that  - http://www.dreamincode.net/forums/topic/403991-text-based-mmorpg/page__p__2321947__fromsearch__1&#entry2321947
4. That will be cool, i hesitated from it thinking that other people may think that i want to keep my posts up or keep my post count higher than them as is the case in usual forums out there. But now as i have your permission i will make sure to write new message everytime.
5. That will be very good, i want to increase my speed of developing my project as well. I hate getting stuck up in problems lol. Its fine if i take time, but some situations are hopeless.
6. I will try it right now, and there were other problems as well which i mentioned, ex25.ring not working and throwing the error, removing cc email from send email function and also how to add the dynamically acquired email and fgtpwd to sendemail function.

harry Singh

unread,
May 27, 2017, 3:20:48 AM5/27/17
to The Ring Programming Language
After removing new page i faced even more worst scenario lol, one of the text/html message is removed but one still remains and my main message is duplicated for some reason lol

see the screenshot here


Untitled.png

harry Singh

unread,
May 27, 2017, 6:49:41 AM5/27/17
to The Ring Programming Language
He he seemed all problems were due to template, i simply removed template thingy and instead written code in ring file itself for sendemail too, now everything is fine. Thanks.... (For cc i used temp...@temporary234342424234242434424234234.com, hopefully it doesn't exist lol) and ex25.ring error throwing is out of my knowledge thingy so i leave that up to you only lol :D

Bert Mariani

unread,
May 27, 2017, 8:12:51 AM5/27/17
to The Ring Programming Language
Hello Harry

"... , but till now no one else posted any reply for me ..."

If your postings are too long and rambling, and not to the point, with specific examples of the code and errors ....
It makes it hard for us to follow and understand.
As much as we all would like to help ...  I tend to get lost in your postings. 
So keep it brief and to the point.
One problem at a time..

Greetings
Bert Mariani

harry Singh

unread,
May 27, 2017, 8:28:07 AM5/27/17
to The Ring Programming Language
Hello bert, 

1. please check ex25.ring in my github repository and see why is it throwing error ....  Hope this is one problem only. 

2. I am stuck at another problem as well but want to spend some time on it myself before asking from the community :)

And thanks again for your post and suggestion. Now i will always write my queries in points like this only.

harry Singh

unread,
May 27, 2017, 11:19:09 AM5/27/17
to ring...@googlegroups.com
Now finally my forgotpassword.ring file is done, and is working fine. Now i am stuck in changepassword.ring file and unable to understand how to update the new password supplied by user and save it in database. 
I have example of insert for inserting, but can't find any example for updating and i tried roughly oUser.updatecolumn command as i saw in few modules of documentation, but it didn't worked. I uploaded changepassword.ring file in github again with what i have tried. Please tell whats the problem in that now ? 

Mahmoud Fayed

unread,
May 27, 2017, 6:46:40 PM5/27/17
to The Ring Programming Language
Hello Harry

(1) The problem is using oUser.Disconnect()  two times
in changepassword.ring  (In Line 19 and In line 35)
Just delete line 19

(2) Your SQL file (kingofgridners.sql) miss the next two commands
CREATE DATABASE `kingofgrinders`;
USE  kingofgrinders
;

Greetings,
Mahmoud

CalmoSoft

unread,
May 28, 2017, 12:50:08 AM5/28/17
to The Ring Programming Language
Hello Harry, Bert, Mahmoud,

I run the changepassword.ring but get the next error message:

Line 97 Error in first parameter,  input size < 1 ! 
In input In function loadvars() in file weblib.ring
called from line 88  in file C:/Ring/harry/changepassword.ring 

Greetings,
Gal Zsolt
(~ CalmoSoft ~)

harry Singh

unread,
May 28, 2017, 12:58:16 AM5/28/17
to The Ring Programming Language
1. Thanks now its working.
2. Well I just exported my phpadmin, i have no idea about the thing you wrote, but i still manually edited in github, hope i did it right, can you take a look on that?

harry Singh

unread,
May 28, 2017, 1:00:52 AM5/28/17
to ring...@googlegroups.com
Hello,
You can't directly use the ring files, only the ones i put UI in front are directly accessible.... Simply speaking changepasswordui.ring is frontend and changepassword.ring is backend, so backend function is accessible only from frontend.  :D Hope i am able to explain myself. If not please rewrite :D i will try something else too :D 

For best experience just use kingofgrinders.ring for start as its the home page.

CalmoSoft

unread,
May 28, 2017, 1:10:08 AM5/28/17
to The Ring Programming Language
Hello Harry, Bert, Mahmoud,

I run the kingofgrinders.ring but get the next error message:

Line 97 Error in first parameter,  input size < 1 ! 
In input In function loadvars() in file weblib.ring
called from line 88  in file C:/Ring/harry/kingofgrinders.ring

harry Singh

unread,
May 28, 2017, 1:13:48 AM5/28/17
to The Ring Programming Language
Did you imported the sql file from github before running that?
 

harry Singh

unread,
May 28, 2017, 1:22:32 AM5/28/17
to The Ring Programming Language
Also make sure you have all the other github files in a folder named kingofgrinders in your htdocs folder (which must include that weblib.ring file too)

CalmoSoft

unread,
May 28, 2017, 1:25:05 AM5/28/17
to The Ring Programming Language
Hello Harry,

Yes i downloaded all the files from GitHub.

harry Singh

unread,
May 28, 2017, 1:29:47 AM5/28/17
to The Ring Programming Language
Thanks for reply, so what about import? Did you imported kingofgrinders.sql to your phpadmin as well..... To do this you have to go first at http://localhost/phpmyadmin/ in your browser, then click the import. I have posted a screenshot for that too, check it :-
Untitled.png

CalmoSoft

unread,
May 28, 2017, 1:35:27 AM5/28/17
to The Ring Programming Language
Hello Harry,

I downloaded the next files:

harry Singh

unread,
May 28, 2017, 1:37:04 AM5/28/17
to The Ring Programming Language
So is it working now? 

Mahmoud Fayed

unread,
May 28, 2017, 1:39:11 AM5/28/17
to The Ring Programming Language
Hello Gal

To avoid the error message
Just run the Ring source file from the web browser.

Greetings,
Mahmoud

harry Singh

unread,
May 28, 2017, 1:45:05 AM5/28/17
to The Ring Programming Language
Hello Mahmoud,

Please check the sql file edit that i did as per your suggestion. Maybe i messed it up thats why gal is getting error too?

Thanks 

CalmoSoft

unread,
May 28, 2017, 1:45:06 AM5/28/17
to The Ring Programming Language
Hello Mahmoud,

How can I run the Ring source file from the web browser?

harry Singh

unread,
May 28, 2017, 1:47:07 AM5/28/17
to The Ring Programming Language
Gal just do this go to your browser and type this http://localhost/kingofgrinders/
u will see all the pages that you have in your htdocs folder here and you can click on kingofgrinders.ring file here and it will start.

CalmoSoft

unread,
May 28, 2017, 1:55:03 AM5/28/17
to The Ring Programming Language
Hello Harry,

http://localhost/kingofgrinders/ not accessible for me.

harry Singh

unread,
May 28, 2017, 2:02:02 AM5/28/17
to The Ring Programming Language
Well first to be clear i am on windows, i am not sure about how to do it if you are in any other Operating System?
and if its not accessible to you, then it means the phpmyadmin is also not accessible for you that i showed in screenshot in one of my posts above. If thats the case then that means you dont have xampp server running apache and mysql in it..... Here is screenshot for that if both are on :-
Untitled.png

Mahmoud Fayed

unread,
May 28, 2017, 2:07:11 AM5/28/17
to The Ring Programming Language
Hello Harry

The file is correct, keep up the good work

Hello Gal

In Ring documentation, web development chapter, You will see how to use Apache web server with Ring, just follow the steps in the documentation.

Greetings,
Mahmoud

harry Singh

unread,
May 28, 2017, 2:27:08 AM5/28/17
to The Ring Programming Language
Thanks, I wanted to know is there any other way to get variables from previous page. For example :- In ex29.ring i wrote these lines

formstart("MainGamePageUI.ring")
 
 divstart
([ :style= styletextcenter() + stylegradient(52) ])
 submit
([:value = "Lets Play"  ])
 formend
()
 divend
()

As you know that ex29.ring already holds all the info from database in oUser thingy... I want to pass on that information directly without using textboxes (as done in most cases of documentation) to the upcoming MainGamePageUI.ring, so how to accomplish this thing?? 

harry Singh

unread,
May 28, 2017, 2:42:37 AM5/28/17
to The Ring Programming Language
Another question :-

1. How to do formpost without textboxes?
2. How to check the sessionid on each and every page that i am going to make in future as all those pages will be accessible to the user who had done login successfully. Any person with failed login or without login should not be able to access those pages ?

harry Singh

unread,
May 28, 2017, 3:00:47 AM5/28/17
to The Ring Programming Language
Hey found solution for first problem i.e. using hidden method :)
I used same to obtain session id as well, but still not sure if it will work and what check should i put in every page for session id so that unauthenticated users don't access that page?

harry Singh

unread,
May 28, 2017, 10:33:34 AM5/28/17
to The Ring Programming Language
Finally after lots of hits and trials i designed GUI for main game page. At least the basic structure. Its really tough to write GUI via codes :(
Anyways MainGamePageUI.ring is ready, please check it guys, and Mahmoud please suggest things that asked earlier for security purposes.... Or anything where i can improve, as i am sure i did all by noobish way, and all hit and trials :D

harry Singh

unread,
May 28, 2017, 10:44:45 AM5/28/17
to The Ring Programming Language
Suggestions i seek now are as following:-

1. Security from sql injection attacks, and prevent direct access to pages that are meant to be opened only after login.
2. Is it possible to do everything in my MainGamePageUI.ring only, like chat, game itself, which will require autoupdate of page every few seconds.. via AJAX or something like that as i heard they directly update page without need for additional pages? 
3. Is there Any example for making chat? I am totally ???? on this module.
4. Anything else that i may have missed but should be necessary for an MMORPG, which comes to your mind?

harry Singh

unread,
May 29, 2017, 7:35:20 AM5/29/17
to The Ring Programming Language
Updated github with my todays efforts :-

1. Still didn't received answer to my yesterday post above. Please reply to it asap
2. I wrote the chat code and am done till inserting username, time and message in database (its working fine), but i have no idea how to show it back to my UI page. Please tell the code to do so.  And there is one problem in inserting in database as well i.e. during refresh it insert the previous chat message entered automatically, on double click it insert twice too. So whats the solution for this problem as well? 

Mahmoud Fayed

unread,
May 29, 2017, 2:47:16 PM5/29/17
to ring...@googlegroups.com
Hello Harry

(1)  "Security from sql injection attacks"

The Data Library prepare strings before passing them to the Server to avoid SQL Injection
Also if you want, You can do more testing on this yourself.
The next three rules are important for security
Rule (1) : Don't trust any data entered by the user
Rule (2) : Work on what must be allowed and allow it only (Minimum level of permissions)
Rule (3) : Test and try different ways to discover any holes in your system

(2) "prevent direct access to pages that are meant to be opened only after login."

The file weblib/users.ring contains the next function as an example about how to check the user

Func checkuser

       oUser = new UsersModel

       oUser.Connect()

       lResult = oUser.FindWith("sessionid",aPageVars["sessionid"])

       new page {

               if lResult

                       text("User Name : " + oUser.username )

               else

                       text("Please Login First!")

               ok

       }

       oUser.Disconnect()


Create your function that return True/False and use it as a check in the start of each page that requires login.

(3) " Is it possible to do everything in my MainGamePageUI.ring only, like chat, game itself, which will require autoupdate of page every few seconds.. via AJAX or something like that as i heard they directly update page without need for additional pages"

Sure you can use JavaScript and AJAX to do that
It's JavaScript question, You will find thousands of pages on the Internet that explain how to do that

But there are other ways too

You can create HTML Form and set the Target attribute as iFrame name

We used this to execute Ring code online : http://ring-lang.sourceforge.net/cgi-bin/ringlang.cgi

In the form we set Target = "codeoutput"
And we define it using : html(`<iframe name="codeoutput" width="100%" style="background-color:white;"></iframe>`)
And we have a button to submit the form : Input { type = "submit" classname="btn btn-primary btn-block" value = "Execute" }


BootStrapWebPage() 
{
Title = "The Ring Programming Language"
html(template("main.rhtml",NULL))
div {
classname = :container
div
{
id = "div3"
color = "black"
backgroundcolor = "white"
width = "100%"
form
{
method = "POST"
Action = website  
Target = "codeoutput"
input { type="hidden" name="page" value=1 }
Table
style = stylewidth("100%") + stylegradient(3)
TR
{
TD { align="center" WIDTH="10%" text("Code :") }
TD {
html(`<textarea name  = "cCode" rows="5" style="width : 100%; ">See "Hello, World!" + nl</textarea>`)
}
}
}
Input { type = "submit" classname="btn btn-primary btn-block" value = "Execute" }
Table
style = stylewidth("100%") + stylegradient(34)
TR
{
TD { align="center" WIDTH="10%" text("Output :") }
TD {
html(`<iframe name="codeoutput" width="100%" style="background-color:white;"></iframe>`)
}
}
}

}
}

}
html(template("footer.rhtml",NULL))
}

(4) "Is there Any example for making chat? I am totally ???? on this module"

Ring is a language to implement your ideas in your way.
Just think how you want to do it then do it (You have HTML/CSS/JavaScript in the Client side , and Ring, MySQL at the server)
You can do it.

Greetings,
Mahmoud

Mahmoud Fayed

unread,
May 29, 2017, 3:31:36 PM5/29/17
to The Ring Programming Language
Hello Harry

You will need to update weblib.ring - to use the Target attribute in the Form Class.

https://github.com/ring-lang/ring/blob/master/ringlibs/weblib/weblib.ring

Also you can update the Data Library
https://github.com/ring-lang/ring/blob/master/ringlibs/weblib/ringapp/datalib.ring

I updated them to produce better error messages based on your experience while using them.
Error messages like
* Error (WebLib-1) : REQUEST_METHOD is empty ! - Run this script from the browser
* Error (DataLib-1) : Can't connect to the database server!

Greetings,
Mahmoud

harry Singh

unread,
May 30, 2017, 1:10:42 AM5/30/17
to ring...@googlegroups.com
Thanks for the reply, but my main problem still stays.... i.e. How to show my chat table from database to the main UI page in browser directly, i tried using ouser.read function but it doesn't display in browser anything....??

I updated my weblib and datalib from your place as well.

harry Singh

unread,
May 30, 2017, 1:26:34 AM5/30/17
to The Ring Programming Language


Another question added to my previous query here :-
1. How to show my chat table from database to the main UI page in browser directly, i tried using ouser.read function but it doesn't display in browser anything....??
2. how to do data validation. For eg :- say i dont want user to enter more than 30 characters in the username box and restrict him to enter only numbers and alphabets, how can i do that? 

Mahmoud Fayed

unread,
May 30, 2017, 1:55:47 AM5/30/17
to The Ring Programming Language
Hello Harry

(1) Check examples that display the table data
http://ring-lang.sourceforge.net/doc1.3/web.html#crud-example-using-mvc

(2) The len() function return the string/list size
cValue = "Hello"
if len(cValue) <= 30
   see
"Good"
else
   see
"Extra letters!"
ok

(3) Check this tutorial in PHP - You can learn about the HTML/JavaScript part.
https://code.tutsplus.com/tutorials/how-to-create-a-simple-web-based-chat-application--net-5931

Greetings,
Mahmoud

harry Singh

unread,
May 30, 2017, 2:22:24 AM5/30/17
to ring...@googlegroups.com
1. I checked that already in documentation, but am not able to understand such complex things i mean whats that olanguage, ocontroller, otranslation, and myadd and mysubpage. So totally ??? on this thing. So can't do even trial and hits :D
 
2. Thanks that will really help for length, but what about disallowing special characters?
3. I will look into it... EDIT - I looked it its php and jquery(), again i didn't understood php thats why i came for ring, if i had known php i would have stayed there only lolz, so no way i can understand that example. However this http://ring-lang.sourceforge.net/cgi-bin/ringlang.cgi seems better option that you told, i will do trials and hits on this one :)

harry Singh

unread,
May 30, 2017, 10:06:26 AM5/30/17
to The Ring Programming Language
Converted my page format to the bootstrapwebpage and added that iframe thing.... But still cant do anything in it. On typing and clicking on button it gives server error.... Please check whats wrong with it now?

Also tell any easy way to get chat table into that iframe...

harry Singh

unread,
May 30, 2017, 11:16:47 AM5/30/17
to ring...@googlegroups.com
1. Converted my page format to the bootstrapwebpage and added that iframe thing.... But still cant do anything in it. On typing and clicking on button it gives server error.... Please check whats wrong with it now?
 
2. Any other easy way to get chat table from database into that iframe other than view class which is so complex looking?

3. For validation and using len() function on textboxes what should be done?  

4. In forgotpassword.ring the last else text("bad username!") doesn't seem working and instead throws someother error if we use a non-database username, can you tell whats the problem in there?

Mahmoud Fayed

unread,
May 31, 2017, 12:11:31 AM5/31/17
to The Ring Programming Language
Hello Harry

Study the next chapters from Ring documentation

(1) http://ring-lang.sourceforge.net/doc1.3/mysql.html

(2) http://ring-lang.sourceforge.net/doc1.3/strings.html

In the Data Library, When you create a Model object, you can use the next method
Query() to execute SQL Statement
QueryResult() to get the output as a List

Greetings,
Mahmoud
Reply all
Reply to author
Forward
Message has been deleted
0 new messages