DragonPrime - LoGD Resource Community
Welcome Guest
  • Good evening, Guest.
    Please log in, or register.
  • December 14, 2017, 10:28:29 PM
Home Forums News Downloads Login Register Advanced Search
* *
DragonPrime Menu
Resource Pages

  Show Posts
Pages: [1] 2
1  Game Administration, Installation and Configuration / The Idea Place / Re: questions about existing modules +suggestions on: Yesterday at 03:50:02 PM
It's very important to understand your own strengths and weaknesses; however, please note that this site is very low on activity, and the person who told you your suggestions would likely be easy and completed quickly was not serious. He was being sarcastic.

Even LotGD itself is not actively updated. If you want to have your ideas worked on, you should talk directly to programmers who might be interested rather than (or in addition to) posting them here.
2  Modules, Themes and other customizations for your game / Completed Modules for version 1.x.x / Re: Site Backup (Database & Files) v2.0 : File Submission/Discussion on: December 11, 2017, 07:42:12 PM
In this case, if you want to be able to restore directly from the backup without having to first initialize the database (or at least the now-missing accounts_output table), I think it'd be a good idea to split the database export into two statements.


('mysqldump --no-data -h'.$DB_HOST.' -u'.$DB_USER.' -p'.$DB_PASS.' '.$DB_NAME.' > '.$_SERVER['DOCUMENT_ROOT'].'/'.$filename.'_schema.sql'$output=array(), $worked);

exec('mysqldump --no-create-info --opt -h'.$DB_HOST.' -u'.$DB_USER.' -p'.$DB_PASS.' '.$DB_NAME.' --ignore-table='.$DB_NAME.'.accounts_output > '.$_SERVER['DOCUMENT_ROOT'].'/'.$filename.'_data.sql'$output=array(), $worked);

I was setting up a test for this and then realized I don't even have PHP installed locally, so I'm not sure if this works exactly as-is, but the concept is sound: Get a full schema-only dump with --no-data to make sure you have all of the tables, then get the data using your original call with --no-create-info (skips creation statements) so you won't get the unnecessary account data.

This way running the schema dump first then the data dump will result in a complete database, without breaking functionality that expects accounts_output to exist.

Warning: These exec statements are not safe. A good password is likely to contain special characters, and dropping those into a command like this will likely result in failure. Ideally, this would be where something like a parameterized function call would be used; this being PHP, that probably doesn't exist, which is presumably why escapeshellcmd exists.

It'd need to be tested, but something like this should be safer:


(escapeshellcmd('mysqldump ...'));
3  Modules, Themes and other customizations for your game / Completed Modules for version 1.x.x / Re: Mini Bosses by DaveS V5.03 on: December 09, 2017, 10:51:01 PM
If you check the arguments to that function, you can set it up to use a file instead of printing to the screen. That way no matter how the server is set up you don't have to worry about players seeing your logging... although this is something you should just be using locally or on a staging server while you're working on things that could potentially break the site or need to be reverted.
4  Modules, Themes and other customizations for your game / Completed Modules for version 1.x.x / Re: Mini Bosses by DaveS V5.03 on: December 08, 2017, 10:03:45 PM
While I haven't run a game in over a decade and I don't know the code well, I think the best way to go about this on your own is with logging. PHP normally just spits your output into the page, which is reasonable since it's just supposed to be a templating language, but you can use logging to write to a file.

error_log() is a function you can use to figure out exactly what's happening and in what order. If you put error_log calls into your code in the code you think is important, you can determine when and if it's being executed.

The way I do this in Python is to use logging calls, run the site locally, and watch the log while I use the site. You can do the same thing with the LotGD code.
5  Coding Support / Coding Support Desk / Re: Pets In The Gardens on: November 27, 2017, 11:51:57 PM
You're welcome. Note that the quotes are optional if your search term is a single word, but necessary if you want to search a phrase that contains spaces; you can also use single quotes, which you may need to if your phrase contains double quotes.

ack testphrase
ack "test phrase"
ack 'test "this" phrase'
6  Coding Support / Coding Support Desk / Re: How Do I Remove Color-Coding Notations From Page Headers? on: November 27, 2017, 11:50:08 PM
If you follow the procedure I suggested, you'll get the same as taking the difference between the old files you kept and your updated versions; they'll just be part of the git history (which you can browse or revert at any time). I think your best bet is to stick with the procedure I suggested; keep a couple copies in a couple places of your current files, just in case something catastrophic happens, which it can when you're new at this sort of thing. Wink
7  Coding Support / Coding Support Desk / Re: Pets In The Gardens on: November 26, 2017, 07:11:58 PM
Can it search for other code strings?

Not sure what you mean. It can search just about any string you want.

ack "String you want to search goes here"

Specifying the programming language and the directory to search are both optional (there are other options as well, including ignoring certain directories by name).
8  Coding Support / Coding Support Desk / Re: How Do I Remove Color-Coding Notations From Page Headers? on: November 26, 2017, 07:10:15 PM
Thanks.  Would have been nice to know about this before all my mucking around, LOL...sounds to me like this has to be maintained "as you go"

Yeah, version control is very much about recording changes over time. While your code and code comments should always be up to date, regardless of what came before, version control comments should document the changes made since the previous commit. That way you can look back at your commit history and see changes that might be entirely gone in your current code.

If you really want to start, you could:

  • Download a clean copy of the LotGD version you started with
  • Start a git repository in the clean copy's directory
  • Add all of the code and create the first commit from the clean code
  • Copy the contents of your current code into the clean directory, overwriting all files (don't overwrite the clean directory itself, just the contents, otherwise the git information will be deleted)

At this point, the outstanding changes in git should represent the changes you have made. If you want, you can try to add files in groups and make commits that approximate your changes. Otherwise you can just add all of your changes, make that a single "first update" commit, and make commits for individual changes going forward.

It's a bit of effort, and it depends on you getting the exact version of the game you started with, but if you want to start using version control it's one option.
9  Coding Support / Coding Support Desk / Re: How Do I Remove Color-Coding Notations From Page Headers? on: November 20, 2017, 08:12:42 PM
I am pretty sure I never messed with the sanitize function, I would have had no reason to.

Just curious...do you document all your code and especially your changes to the core code in the files?  If not, strongly recommended...

TGTarheel: Since LotGD is a download and not a repository you clone, if you intend to change it much, you could use git to track your changes (by creating a new repository in your LotGD directory with git init) so you can always see what you've changed (and why, as long as you use good commit messages).

Really, you could use any version control mechanism, but git is my favorite. git-flow is a really nice utility that provides some great convenience methods for managing branches. You can also set up a repository on GitHub or BitBucket (the latter allows private repos on a free account, which is nice) so you can always keep a web-browsable, up to date backup of your personal LotGD installation.
10  Coding Support / Coding Support Desk / Re: Pets In The Gardens on: November 20, 2017, 08:04:00 PM
For a well-maintained, powerful utility designed specifically to search code, I recommend ack. I've been using it for years instead of grep for searching projects.

This will search the modules/ directory for the text addnews( (the parenthesis will be interpreted as part of an incomplete regular expression if you don't escape it; this isn't necessary, but if you don't use it, you'll see a lot of comments in this directory that are just #://addnews ready):

you@yourpc:/tmp/lotgd$ ack --php "addnews\(" modules/

You could also just use this to search all PHP files in the current directory (recursively) for the string "addnews":

you@yourpc:/tmp/lotgd$ ack --php addnews
11  Village Square / General Discussion Area / Re: Help learning PHP and running an online game on: February 05, 2013, 12:46:51 PM
Back to the topic. If you want some videos to watch for PHP, I can immediately suggest PHPAcademy on YouTube. You also don't want to stick to JUST php. If you learn back-end you may as well learn front-end. Learn all of the wonderful features that HTML5 has to offer, and tie it in with CSS3. You can draw people in to a new source code if it is designed well. Maybe turn your computer into a local host and run .NET and buy a few books on how to code in C#, C++, C, F#, etc. If you learn the C family, start with #.

HTML5 and CSS3 are great, unless you actually want to learn practical web tech that will run on everything, in which case you need to be conservative and careful about what you use and how you use it.  Learning good XHTML/standard HTML and well-supported CSS are necessary if you want to understand and build widely-compatible front-end code, as is Javascript, which is and should be almost universally used via jQuery on projects that need to take advantage of non-markup client-side code.  Other JS libraries like Prototype are around but, in my experience, are not as widely-used or -supported.

The only practical back-end languages for the web -- that is, the ones you can expect to get work in or find a substantial number of people who are using it for the same purpose -- are Python, Ruby, and PHP (if you want to learn good programming practices, pick one of the first two).  Learning anything that's supposed to be hosted in Windows is a bad idea if your goal is web programming.  Staying with open-source Linux-based tools (no, mono doesn't make .NET a good choice) means you can always develop and deploy whatever you build without worrying about the rat's nest of security nightmares that come from Windows.  That way you can concentrate on finding your own loopholes without worrying about Microsoft's.

I don't even know what to say about recommending C/C++ and F# to someone who wants to learn web programming.  C is fine for learning very basic fundamentals that apply to many languages with similar syntax, notably PHP and Java, and C++ is good for learning a common approach to object-oriented development, but with the overhead of manual memory management (as well as the CLI- or IDE-centric nature of working with these languages) these are not good starting points for learning to develop for the web.  Even Java would be a better choice; you get the C-like syntax but you can also use it to develop for Android should you want to go to mobile.  As far as learning separate languages, picking up two with the same syntax misses the point; going to Python or Ruby in an actual web development context would be far better in terms of broadening your horizons and getting a better understanding of programming in general.  Functional languages like Erlang or Haskell would be even more eye-opening, but those have very limited communities around them for web development at this point.

Books are also nice, but the one thing you absolutely need to do is write the code.  I've read programming books both with and without supplementing them with examples and building code on my own, and if you're not writing code as you read, you can basically call it wasted time.  You'll understand the principles but as soon as you finish the book and try to apply them you'll realize how little of practical use you actually learned.  Following the examples and supplementing them with your own experimentation is the best way to maximize the value you get from a book.

One thing that's missing here is frameworks.  Once you understand a decent web dev language, pick a framework or two and learn them inside and out (studying more than one language is definitely a good idea, but let's face it, not many people have that much time on their hands).  If you're not using a framework for web development, you are certainly reinventing some wheels; some sites should be built from scratch, but that's a very, very small class that includes web services and not much else.  I was a programmer for years before I found this out, and it's very frustrating to think back on it now.

Python: Django, Flask
Ruby: Rails, Sinatra
PHP: Symfony, CodeIgniter

There's also no mention of DB technologies.  You need to understand data persistence to work on the web; the easiest-to-manage and most prevalent database system is MySQL.  Connecting to your database with an ORM is an extremely good idea and a great way to mitigate one of the worst potential bugs that ever was, the SQL injection attack, as well as being a great boon for maintainability and, often, efficiency.  There's a lot out there; PostgreSQL is more powerful, MongoDB/Cassandra/CouchDB/etc. are more flexible, and on and on, but for the vast majority of sites, starting with MySQL behind an ORM (which is provided with most of the above frameworks) is the quickest and safest way to get started without sacrificing too much power.
12  Modules, Themes and other customizations for your game / Completed Modules for version 1.x.x / Re: Dwellings on: January 28, 2013, 02:01:22 PM
I used to use XAMPP; it is (or was, when I last used it, many years ago) a good, reliable Apache/PHP/mySQL/kitchen sink single-file installer that instantly sets up a good test environment.  Granted, I would only ever run it on Windows, and only because getting those things running consistently in Windows and playing nicely together would otherwise be a horrible, painful waste of time.

If you end up building or working on websites with any frequency, having a solid local environment for development is necessary.  I wouldn't call any Windows environment a good fit unless you're actually building something that has to be released on Windows (e.g. something that requires native .NET or IIS), but if you're not interested in learning or working with Linux, in my opinion XAMPP is the safest bet.
13  Game Administration, Installation and Configuration / Game Administration Chat / Re: Core's error with Module Settings on: January 22, 2013, 07:43:48 PM
No need to be a complete jerk about it.  Never mind, good luck. Smiley
14  Game Administration, Installation and Configuration / Game Administration Chat / Re: Core's error with Module Settings on: January 22, 2013, 07:21:58 PM
While I am not familiar with the core code, I understand what you're saying, and there are some issues with this idea.

This partially depends on what interfaces exist and how you are "deleting all of the settings for a module."  If you are deleting a file on the file system, that is -- in all languages and frameworks -- an operation that is and should be completely separate from the database.  Attempting to monitor deletions would require a cron job watching the file system and conducting operations against the database based on deletions, which is an extremely dangerous idea in terms of accidental data loss.

In any other way, checking the files available and deleting "stale" settings based on this is a similarly flawed approach.  What if the file you're checking for is renamed?  What if there's a bug in your routine that results in missed files (for instance, the difference between environments in Windows, OS X, or even various flavors of Linux and BSD)?  There are many situations in which this could cause the loss of settings that do not appear to be relevant to an installed module.

That said -- and once again, I must reiterate that I am not familiar with what's actually going on -- the most correct way to do this would be to provide a module settings management interface, in which an administrator could view a list of modules for which settings are present but which do not appear to be installed, with the option to delete settings on a per-module basis.

If there is an existing module/package management interface, that should probably be giving the option to remove settings.  However, doing something like this without explicit admin approval is certain to result in justifiably irate users.

If there isn't a module management interface, or at least a module settings management interface, I would think that'd be a great candidate for its own module (or even a core upgrade). Smiley

More importantly, in my opinion, an appropriate fix for this fairly minor performance issue would indeed involve a core update to ensure that only active settings are being retrieved; however, this does require the existence of some sort of management interface that will allow the admin to specify what is actually installed and necessary, as determining this automatically is probably too error-prone to be feasible.
15  Game Administration, Installation and Configuration / Game Administration Chat / Re: Error Messages on: January 21, 2013, 01:01:55 PM
Certainly, but then that's why staging/development and production servers usually have different configurations.  People can't see your local environment, so it's definitely good to have error display and logging cranked all the way up; for production, though, error information should be sent to the server-side logs and not shown to the user.
Pages: [1] 2

DragonPrime Notices
Please take the time to read the FAQ and browse the DragonPedia

Support Us
No funds raised yet this year
Your help is greatly appreciated!
Recent Topics
DragonPrime LoGD
Who's Online
17 Guests, 0 Users
Home Forums News Downloads Login Register Advanced Search