|
|
Posted in Computers & Tech / Databases
Author: rockarolla Total-Replies: 3 While I was trying to connect to my database or even create one using PhP mySQL I was given the followoing error: Lost connection to MySQL server at 'reading initial communication packet', system error: 111 in Has somebody encontered a similar report? I have my database created using the cpanel together with a user name and password. I wonder if it is a server issue? What can you do if you have not access to the configuration files?
Tue Feb 5, 2008
Reply New Discussion
Posted in Free Web Hosting / Hosting Support & Help
Author: soleimanian Total-Replies: 10 hi i lost MySQL Databases and Privileges!!? please restore my databases
Thu Nov 10, 2005
Reply New Discussion
Posted in Computers & Tech / Software / Bulletin Board Systems / Invision Power Board
Author: moonwitch Total-Replies: 0 Well, I am running Win 2k Pro, on a PII 333MHz, server software is Apache2 running on port 5000. Php is PHP 5 and MySQL is a clean/fresh install of MySQL 4.1. I unzipped IPB, followed the instructions that came with it, when I get to the point where I have to enter the data to connect to the DB (DB is made with user and all that - thank you m^3) this is the error I get Warning: mysql_connect() [function.mysql-connect]: Lost connection to MySQL server during query in C:\Program Files\Apache Group\Apache2\htdocs\forum\ips_kernel\class_db_mysql.php on line 120 Fatal error: Maximum execution time of 30 seconds exceeded in C:\Program Files\Apache Group\Apache2\htdocs\forum\ips_kernel\class_db_mysql.php on line 117 Any ideas?? EDIT -> found solution Ok so this was the original code in class_db_mysql.php CODEif ($this->obj['persistant']){ $this->connection_id = mysql_pconnect( $this->obj['sql_host'] , $this->obj['sql_user'] , $this->obj['sql_pass'] ); } else { $this->connection_id = mysql_connect( $this->obj['sql_host'] , $this->obj['sql_user'] , $this->obj['sql_pass'] ); } if ( ! $this->connection_id ) { $this->fatal_error(); return FALSE; } if ( ! mysql_select_db($this->obj['sql_database'], $this->connection_id) ) { $this->fatal_error(); return FALSE; } return TRUE; } The piece that gave me the error was CODEif ($this->obj['persistant'])I solved it by changing the 'persistant' to 'default'!! And it works
Wed May 4, 2005
Reply New Discussion
Posted in Computers & Tech / Databases
Author: nakulgupta Total-Replies: 12 My friends have a little forum running here. The problem is that quite often we get the following message when we try to open the page: QUOTEWarning: mysql_connect(): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in /home/vhosts/rohit.bizhat.com/forums/db/mysql4.php on line 48Warning: mysql_error(): supplied argument is not a valid MySQL-Link resource in /home/vhosts/rohit.bizhat.com/forums/db/mysql4.php on line 330 Warning: mysql_errno(): supplied argument is not a valid MySQL-Link resource in /home/vhosts/rohit.bizhat.com/forums/db/mysql4.php on line 331 phpBB : Critical Error Could not connect to the database Why does this happen and what can we do to avoid it??
Fri Mar 25, 2005
Reply New Discussion
Posted in Astahost / Hosted Members Support
Author: Mark420 Total-Replies: 4 Well imagine you actually paid money for this hosting like i did!! Once again they mess with the hosting..once again they inform NO ONE. Once again ALL thier customers are stating at blank sites for over a day now. I get NO response from making a trouble ticket. I get NO response from Live support. And this is NOT the first time this has happened, I have been suspended for paying my bills on time and got no apology for this - again lost a whole day getting this sorted out. ANother time they moved the servers for some reason, I lost my sites for over 24 hours then. And theeres me looking at 99% uptime WTF does that mean to XISTO? Also the speeds of the hosting well I must say its as bad as being hosted here!@!@ I wait and i wait most days for the MYsql server to react, It honestly is better on the free hosting servers. one VERY UN SATISIFIED customer who is waiting for the hosting to come back just to grab his files and go to www.hostgator.com Yes and I used to be a Xisto fan..today left with EGG on my face cos I reccommended Xisto to others, now they are screaming at me "WHERES MY WEBSITE GONE?"
Wed Apr 30, 2008
New Discussion
Posted in Astahost / Hosted Members Support
Author: Quatrux Total-Replies: 25 I just noticed some errors on my sites, about php and mysql: "Warning Error: (mysql_connect() [function.mysql-connect]: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)) in file siteFunctions.php on line 75" "MySQL Failure: Database connection error: "Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) (localhost)" But sometimes there is an error and sometimes/usually there isn't, so thought to bring this to this topic Strange, but my Wordpress Template/Skin changed to default one, I didn't do anything
Sat Apr 7, 2007
New Discussion
Posted in Astahost / Your Voice! Your Review..
Author: 8ennett Total-Replies: 17 I used Byethost for over a year as it was the best php and mysql host on the web I had found up to that point (let's face it, all the other free hosts suck), the problem with others was incompatibility issues etc. like one, it wouldn't upload css files because they were barred, yet it was on the allowed list, and I never got a response from support no matter what. Byethost were great except their php extensions for free users was very limited, the SMTP extension and GD2 extension weren't included in free hosting and their smtp filters were a major pain in the ass. Also I had trouble using GreyBox (http://orangoo.com/labs/GreyBox/), basically it wouldn't load up. Also when I tried to run flash apps I had made on my website, the page containing the app would redirect to one of their sponsors instead. What Opaque has envisioned with astahost, ks etc. is truly incredible and I not only have the utmost respect for what he is doing here, but found it to be probably the greatest webhost yet. Forget byethost (I started with a 0lx sub-account but then realised byethost was the main supplier and not a reseller option), Opaque has given you something unique and not widely broadcast, make the most of it because he is losing money but gaining respect and his dream from what he is doing here! Then I discovered this website and have not looked back since.
Tue Jul 6, 2010
Reply New Discussion
Posted in Computers & Tech / How-To's and Tutorials / Programming / PHP
Author: 8ennett Total-Replies: 13 This tutorial is the first part in what will soon become a series of in-depth PHP tutorials to create your very own web community. The quality and features of this web community will be enough to rival many packages already out on the web which people are trying to sell. So not only can you save money by building it yourself, but you will have in-depth knowledge of exactly how the site has been built and can add more and more to it with ease. Over all the web community will contain forums, chat rooms, profile pages, advanced admin options, forum moderators, news feeds and even a module engine. Ok, let's get started. ======================================================== PHP Web Community: Part 1 Advance User Account System First of all you will need to download the PHP files - Download Now it is recommended you use PHP 5+, MySQL and your PHP server NEEDS to include the GD2 library. Also your server will needed a working SMTP server so your site can send out emails. Also for ease of use your users will be required to have a working javascript browser. Once you have extracted your files, you will need to create a new database (you can name it anything) and run the file 'tables.sql' located in the extracted folder. Once you have run this sql file in your favourite MySQL console then delete this file. Next up go into the 'lib' folder and open config.php. All the PHP files have been fully commented as to what each line is/does. Fill out the first four variables defined with your database connection details. The other variables in the config file are: $configsitename: Fill this in with what ever you are going to call your site $configsiteaddress: The base url of your site without trailing slashes, eg. http://www.mysite.com/test $configsiteadminemail: The administrators EMail address $configsitewhoseonline: This value is in seconds. If a user has been online within the past amount of seconds then on the login page they will be displayed as part of the online users value. $configsitedisable: If a person attempts to login to an account that is not their own and they have gotten the password wrong X amount of times (X being defined below) then the account is disabled for this many amount of seconds. $configsitedisableamount: This is the amount of times a person can get their account password wrong before their account is disabled for the above defined amount of seconds. $configsitewrongimage: If a user gets the captcha image wrong this amount of times then they are automatically logged out. This is to prevent bots from automatically logging in to an account. Now if you didn't understand what some of the above variables are defining then don't worry, as you go through this tutorial you will understand. Also, in part 2 of this series we will be making an admin panel that will make it easier to edit these values so you don't have to keep editing the config.php file. Once your site has been configured it will now be fully functional. I would suggest at this point you register an account for yourself and once it has been registered go in to your database and modify the following fields: Validated: Set this to Yes so you don't need to bother checking your email Type: Set this to 'Super' which will make this account in to a Super Admin account. Ok now we can set about describing each php document and what their functions are. In order to access the site now all you need to do is open the index.php in your web browser. This is the only file you will now need to type in as all the other php files are includes. index.php If you open this file up you will find each line of php is fully commented login.php This file handles our login credentials. If you go through the php at the top of the file then you will see what each line of the code does and how it affects the login. This page will also display how many users are registered with your site (including banned, disabled and unvalidated accounts) and how many users are currently online (people who have been online within the past X amount of minutes pre-defined in the config.php file). Now the amount of users that are online is currently only updated when they fill in the login page, however once we get on to the part 2 chapter of this series we will be updating their online status every time they interact with the website once logged in. If a person attempts to guess a users password then after they get the password wrong the amount of times we defined in the config file then the account will be disabled for however long will set it to again in the config file. ![]()
As you can see the pages aren't going to look very pretty, however that is not a topic for discussion in this tutorial. If you are unfamiliar with CSS and image design then I suggest you look up a seperate tutorial on that topic register.php Now obviously this page is going to handle our users registration to your website. As you will see in the php file, each line is commented and describes the different types of checks on the users submitted data so we won't run through these again. ![]() As long as the checks pass on the user submitted data then an email will be sent out to the users email address and this will contain a link which the user can easily click to activate their account. This is so you can verify that the email address the user has given you is in fact real. Another feature of this is checking that the username is not already being used. If it is found that someone else has this username then it will offer alternatives. They can choose to use one of these alternatives or change their desired username. ![]() If there are any problems with the user submitted data then the registration form will automatically fill out again with the info previously provided (except the confirm pass field). This is just so the user doesn't get more and more frustrated having to fill out an entire form over and over again if their usernames aren't available. lostpass.php This page is going to deal with our lost password information. If a user requests their password to be reset then an email will be sent out to them with a link. As a security measure this whole process won't affect their password at all until they have clicked a link with a valid password reset code associated with their account AND have entered a new password. This is so others can't reset a persons password and lock out their account or gain access illegally. After a valid link has been clicked ![]() imagever.php This php file will be displayed after user has logged in (and their account has been validated) and is a way to prevent automated logins. It will display a captcha image which the user must enter to continue logging in and they will be automatically logged out if they get the image wrong a pre-defined amount of times in our config file. Again, the file is fully commented and will explain everything in detail. The image itself is generated using the randomImage.php file which is also commented. ![]() I suggest you create your own background images and these are located in the base directory of the site name cbg1.JPG to cbg5.JPG and one of these are randomly selected each time the image is loaded. Please not it is important if you are running a linux server to have the JPG extension in UPPERCASE as if they are in lowercase then linux won't recognise the extension. It took me a while to figure that one out validate.php This file will handle our account validation information. If a user attempts to login without having validated their account then they will be taken to a page that displays their currently registered email address and the user can opt to change their email address, and after doing so a new email will be sent out to the new address containing a fresh validation link (the old cold previously sent out will become obsolete and unusable). They can also simply resend the validation email in case they had to disable a spam filter etc. on their email account. ![]() If they click a link which contains a valid activation code then this page will simply activate their account and take them to the image verification page without displaying any other details. If they enter an invalid code then an error message will be displayed and they will be taken back to the login page or to the resend validation email page depending on wether or not they are logged in.
We now have ourselves an advanced user account system with full features. I wouldn't advise expanding on this to continue creating your site without read part 2 in this series of tutorials which will detail key security features to prevent unauthorised access to the site and also continue updating your online status as you navigate the logged in site. Feel free to ask questions and add comments concerning this tutorial and let me know if you found it to be informative. Can I also add, although this is a free tutorial and will eventually create a web community website of the same quality as other developers sell online, you are not free to modify the code and slap a price tag on it. It is designed to be free, you can develop it as much as you like and add/take features from it however selling it is NOT an option.
Tue Aug 3, 2010
Reply New Discussion
Posted in Computers & Tech / Databases
Author: bhupinder Total-Replies: 17 Well i have the codes for my game i got them from a friend of mine. He bought them from MCcodes.com and now i am tring to install MySQL to it.. but no luck with all other web host. I don't yet have a account for Astahost but "localhost" will not work no matter what host it is.. the last host that worked was from freehostia but it doesn't support cron jobs. mysql4.freehostia.com was the hostname but the rest of the web host i tried did not tell me the host name they just said to use "localhost" which doesn't work so does anyone know whats wrong? or what hostname i should use?
Mon Jan 7, 2008
New Discussion
Posted in Computers & Tech / Programming / Scripting / PHP
Author: 8ennett Total-Replies: 2 So this tutorial is designed for people who want to start creating their own modules for the Praetorian Game Engine. It assumes you have a basic knowledge of PHP, MySQL, HTML and CSS. PGE isn't just about using the engine to create yourself a game limited by the modules that are available for you to download from the project site, but about giving you a platform to easily develop your own additions to your game easily and professionally and with little effort. This tutorial will cover the following concepts:
There isn't much different when developing modules and addons, the setup files, directory structures, icons and so on are all identical. All you need to remember is when developing a module the directory it is contained in will be modules/mymodule and with addons it is modules/downtown/addons/myaddon. For the purpose of this tutorial we will assume you are developing a module. Directory Structure Directory structure is very important in module development as PGE looks for specific files when installing and running your module. In your local copy of PGE, go to the root directory then to modules/ and create a new folder. Now the name of this folder is going to be your modules system name so try to make it unique otherwise it may conflict with a different modules system name which would mean you could only install one or the other. Maybe think of a prefix for your module names such as codeteam_mymodule. Also be sure to make your folder name all lowercase to prevent confusion. So lets say you have created the directory modules/abc_bank. It's important to add here, if you are creating an addon instead of a module then you will need to create a 15x15 gif image named icon.gif (modules/downtown/addons/abc_bank/icon.gif) and this icon will be displayed next to your addons name in the Downtown module. If you are making a module then you don't need to create this icon. Module Setup Create the new php file 'modules/abc_bank/setup.php'. This file contains all the setup information and general PGE config for your module and is included in every instance of your module when playing the game. The setup is simply a list of variables with their appropriate values. Some of these variables are required and others are optional. Required Variables $modulename = The name displayed on the module installation screen $moduleversion = The version number of your module (text string) $moduleauthor = Your name or your development teams name $modulewebsite = Your website address $moduledescr = A brief description of your module $menuname = This is the default name of the main left menu item or downtown item if an addon $menupermissions = Default module permissions, possible values are Super, Admin, Mod, User (use no spaces, eg. SuperAdminModUser) Optional Variables $viewinprison = Only set this if you want your module to be loadable even when the player is in prison (not available for addons) $viewinhospital = Same as above except applies when in hospital instead of prison There are other variables that can be put in here which will be covered later in the tutorial. It is also important to remember that your setup.php variables must be contained within an if statement that tests if the variable $setupinclude is set. This variable is set just before this setup file is included in PGE and is a means of preventing the setup page from being accessed directly (by typing http://www.mysite.com/modules/abc_bank/setup.php) instead of being included. Since this page really only contains variables then it's not so important but it's good to get in to the habit, especially with your main and admin pages. So here is an example setup.php file which we will use for our bank module. CODE<?phpif (isset($setupinclude)){ $modulename = "PGE Bank"; $moduleversion = "1.0"; $moduleauthor = "Martyn Bennett"; $modulewebsite = "http://www.drug-mann.com"; $moduledescr = "A bank where a player can deposit and withdraw their money to keep it from getting mugged."; $installq[0] = "ALTER TABLE `".$configprefix."userlist` ADD `bank` INT( 20 ) NOT NULL DEFAULT '0'"; $uninstallq[0] = "UPDATE ".$configprefix."userlist SET money=money+bank"; $uninstallq[1] = "ALTER TABLE `".$configprefix."userlist` DROP `bank`"; $menuname = "Bank"; $menupermissions = "SuperAdminModUser"; $viewinprison = true; $viewinhospital = true; } ?> As you can see this is our bank setup file and can be view whilst in both hospital and prison, default permissions are for everyone and the menu name is just Bank. Also notice the install query and the uninstall queries. When installing the module we add an extra field to the USERLIST table called bank where players can deposit their money, and when uninstalling first we put all the money in the bank back in to the players hand first, then we remove the bank field from the table. Also notice the [0] and [1] increment. You could alternatively use the php array() function to set your $uninstallq variable like so: CODE$uninstallq = array(0=>"UPDATE ".$configprefix."userlist SET money=money+bank", 1=>"ALTER TABLE `".$configprefix."userlist` DROP `bank`");Either way is fine, as long as PGE can loop through the array to execute each query. You may have notice the variable $configprefix in the queries there as well just before the userlist table name. That will be explained to you later in the databases section. Main And Admin Pages Now you have your setup file you are ready to start creating your module. In the abc_bank directory create another new file and name it abc_bank.php. When searching the directories for each module to load PGE will look for a file with the EXACT same name as the directory it's in. It won't work if you put in an index.php file or such like, so make sure it is the same as the directory name. Next inside your new abc_bank.php file you will need to include the following php code just like with the setup file: CODE<?phpif (isset($homeinclude)){ // Your module goes here } ?> The $homeinclude variable ensures that it is PGE accessing the php page instead of someone just typing in to their browser http://www.mysite.com/modules/abc_bank/abc_bank.php. Be sure that all your module content is contained within this IF statement, and if you create other php files in your module and include them in your abc_bank.php file then use the same system to ensure they are not being accessed outside of PGE. This is also the reason why it is essential that GLOBAL VARIABLES are turned off in your php.ini file before you can install PGE. If you want your module to include an admin panel where game admins can change certain aspects of your module then you will need to create two new directories and a couple of files. First create a directory (in your abc_bank directory) named images (again, all lowercase) then inside that create an image named admin.png. This is going to be the icon displayed on the PGE module admin tab, it can be any dimensions as PGE automatically resizes it. You don't need to create this icon, however it creates a sense of individuality between modules. Next, in the abc_bank directory again create a new folder name admin and in that create a php file named admin.php (so modules/abc_bank/admin/admin.php). Remember to enclose the contents of this module inan IF statement the same as with the abc_bank.php file. Now you have the template for creating your module and it is now installable and uninstallable. Give it a go by going in to the addons and modules section of the admin panel and clicking install on the list of uninstalled modules. Database Management The key thing to remember when running your queries is that the database connection is already open and so there is no need to run mysql_connect(), mysql_select_db() mysql_close() as this is all done for you. Running mysql queries is simply a matter of putting in mysql_query(). If you do enter any of these functions that have already been run then it could cause problems in PGE. There is another important thing you need to know about running mysql queries. When typing in your query and declaring the table name, you MUST insert the config variable named $configprefix. This is a PGE config variable (covered in the next section) and it is for people who require a table prefix for their databases. So the table name is userlist however the web host requires all table names have a prefix of myname_, the table userlist then becomes myname_userlist. The PGE admin should have configured the table prefix before hand in PGE so the prefix myname_ is stored in the variable $configprefix. So instead of running the following query: CODEmysql_query("SELECT id FROM userlist WHERE name='8ennett'");You would instead run this query: CODEmysql_query("SELECT id FROM ".$configprefix."userlist WHERE name='8ennett'");Which translates into "SELECT id FROM myname_userlist WHERE name='8ennett'". If you fail to insert the $configprefix variable before your table names then on copies of PGE that require a table prefix the query will fail, resulting in your module not being fully compatible with a large portion of PGE installations. Available Config Variables So all the standard config variables are available to your modules without needing to call them. You must also remember that these are reserved variables so writing new values in to them in your module can seriously mess up PGE. On top of the config variables being avaiailble, the entire contents of the USERLIST table for the current player is stored as an array in $_SESSION['user']. So if you want to access the current players money it is stored in $_SESSION['user']['money'], or the current players name then $_SESSION['user']['name'] and so on. Here is a list of the config variables: $confighost = Database host $configuser = Database username $configpass = Database password $configdb = Database name $configprefix = Table prefix $configport = Database port $configenginerelease = The current release version of PGE $configsitename = Your sites name $configsiteaddress = The base address of your site $configsiteadminemail = Main admins email address $configsitecopyright = Who owns the copyright on the site $configsitestyle = The current style of the site $configsitecharset = The character set for all text $configsiteerrorbox = The error box used to display messages $configsiteerrorboxtimeout = The amount of time an error box is displayed for in seconds $configsitewhoseonline = How long a player is inactive in seconds before being classed as OFFLINE $configsitedisable = How long in seconds a players account is disabled if they enter the wrong pass $configsitedisableamount times $configsitewrongimage = How many times a player gets the anti-spam question wrong before they are logged out $configsitedisableamount = How many incorrect logins before the account is disabled $configshowimage = The odds a player is taken back to the anti-spam question $configavatarsize = The max size of a players avatar file in bytes $configsiteleveluphp = The amount of hpmax a player receives when levelling up $configsitelevelupen = Same as above but with energy, enmax $configsitelevelupst = Same again but with stamina, stmax $configsitelevelupxp = The multiplier for next xp goal $configsmtp = The method used to send emails $configsmtpserver = The SMTP server used to send emails $configsmtpport = The SMTP Port $configsmtpusername = If SMTP server requires SSL validation this is the username $configsmtppassword = Same as above but the password $configmailphploc = The location of the PEAR Mail.php file $configmailvalid = The email sent out to validate an account $configmailpass = The email sent out for a lost password $configsiteintro = The introduction text displayed on the index page of the site $configsiteregoff = The BBCode message displayed on the index page when new registrations are turned off $configsiteservoff = The BBCode message displayed when the server is turned off Error and information messages You may have noticed the messages that pop up in a time-delayed box on the screen when using PGE. These error boxes are very easy to set and use BBCode so you can stylise your messages and include images as well if you like. To display a message simply set the variable $error with your message, that's it. PGE will then convert that string in to an message box alert using the default errorbox. So if you want to set an error alert and set the text to red you would use the following code: CODE$error = '[colour=#FF0000]You have entered an invalid number[/colour]';This will then display an errorbox alert with your message in red text in it. Styles and layout Adhering to the styles layout is important, because if someone decides to change their site style to a different one you want your module to change with it right? It would probably be best if you went through one of the existing PGE modules to get a fuller idea of the styles you can use for different html elements and have a look through the default stylesheet too. I'll outline some key styles here for you now on constructing a basic framework to display your module in. To create the main container for your window it is simply a table with two cells, the table being given a class name of "moduletable", the first cell (and first row) is "moduletablehead" and the second cell (and second row) is "modulerow". Here is the example code: CODE<table cellpadding="0" cellspacing="0" class="moduletable"><tr> <td class="moduletablehead">Bank</td> </tr> <tr> <td class="modulerow">Module content goes here</td> </tr> </table> So you can see that in the first cell is where you put the header for your module and the second is where the rest of the module content goes to. Remember also about the limitations of width. The width of free space inside your module container is at maximum 570px-580px. Anything wider than this will begin disfiguring the layout of PGE. Custom cron jobs PGE has four seperate cron jobs to work with, one that runs every five minutes (try to avoid using this as it can start to bog down the server the more players there are), one that runs every hour on the hour, one that runs daily and one that runs weekly (the server is taken offline during these last two as they are usually the heaviest on the database and need to adjust players stats all at once without giving anyone an advantage). There are two seperate methods for adding your own cron job/s to PGE. The first is very simple and similar to queries that run when installing and uninstalling modules. Create a new array in your setup.php file and name the variable either $cronfive[0], $cronhour[0], $cronday[0] or $cronweek[0] depending on how often you want the query to run. So example code: CODE$cronday[0] = "UPDATE ".$configprefix."userlist SET bank=bank+(bank*0.02) WHERE bank>0";Now this statement runs once a day and adds 2% interest to everyones bank account where players actually have money in the bank. Now this method is only for running standard mysql queries. Sometimes you need to add a bit more and run certain tests, check variables and so on which requires php to achieve so this is incorporated in the second method. To run a php script that contains all the data you need for your cron create a new file in your modules/abc_bank/ directory named either cronfive.php, cronhour.php, cronday.php or cronweek.php and PGE will call this php script when it is time to run the cron. To prevent unauthorised running of the cron as with the admin and main pages, contain all the php in the script in an IF statement like so: CODE<?phpif (isset($runcustomcron)){ // Cron php goes here } ?> Available classes and functions I'm not going to run through the entire list of available functions, that will be available in the PGE Developers Handbook once it has been written. I'll outline a couple of important functions which will give your module a more integrated feel with PGE. CODEuserName($userid);$userid is the id of whatever players name you want to display. Try to avoid echoing $_SESSION['user']['name'] and instead use this function. It displays the users name, makes the name a hyperlink to their account and the title of the anchor is the players account type (Admin, Moderator, User) and is displayed when you mouse over the link. CODEgetProfileImage($userid);Returns the file path of a players avatar image and returns the path to the nopic.png image if the player hasn't uploaded an avatar. Use in the src="" in a <img> html tag like '<img src="<?php echo getProfileImage($_SESSION['user']['id']); ?>" />'. CODEgetNPCImage($npcid)The same as the above function however input the NPC's id instead and it will return the NPC's image. CODEresizeImage($originalImage, $return, $toWidth, $toHeight)This function is used to scale down images so they do not disfigure your modules. $originalImage is the link to where the original image is. $return has a value of either width or height and returns the scaled down value of the $return. $toWidth is the maximum width of the scaled image and $toHeight is the same but with height. This feature is commonly used with the getProfileImage() and getNPCImage() functions like so: CODE<img src="<?php echo getProfileImage($_SESSION['user']['id']); ?>" title="<?php echo $_SESSION['user']['name']; ?>" width="<?php echo resizeImage(getProfileImage($_SESSION['user']['id']), 'width', 150, 150); ?>" height="<?php echo resizeImage(getProfileImage($_SESSION['user']['id']), 'height', 150, 150); ?>" border="0"/>CODEBBCode($str);Formats $str and replaces all BBCode tags (eg. [colour=#FF0000]Error[/colour]) with html tags that give the effect of the BBCode. You will need to echo this function as it only returns the string, it doesn't echo it. CODEcheckUserTransfer($id1, $id2, $alert, $type);You may offer players the ability to transfer items and cash between each other. This function should be run to when ever a player tries to initiate a transfer between account. It first checks to see if the players have the same IP, if they do the function returns a false value and inputs a new case in the admin/mod case list outlining what type of transfer. If the players have the same IP AND have identical passwords it probably means they are one and the same person with multiple accounts and both accounts are automatically disabled and the function still returns a false value. If everything is fine then this function returns a true value. $id1 is the userid of the player initiating the transfer. $id2 is the player $id1 is trying to send to. $alert is the BBCode friendly alert message input in the admin/mod case file and $type is the name of the alert type ('Money Transfer', 'Item Transfer' etc.). Here is an example of its use: CODEif (checkUserTransfer($_SESSION['user']['id'], $otherplayer['id'], '[user]'.$_SESSION['user']['id'].'[/user] tried to send .number_format($moneytosend).' to [user]'.$otherplayer['id'].'[/user]', 'Money Transfer')){// Continue sending money } else { $error = '[colour=#FF0000]Could not send money![/colour]'; } Conclusion So this is a rough guideline for developing your own modules for PGE. This version of the tutorial is accurate for PGE version 0.9.1b and should probably be compatible with later versions too. I hope this is helpful and gets you on your way. It's taken me some time to write lol I had to have several breaks so I didn't end up repeating myself and stop making sense. Ironically I have written this tutorial to both get you going on developing your modules and to pay off my arrears with my webhost so I can put the project site back up. Have fun and happy developing!
Sat Aug 27, 2011
Reply New Discussion
Posted in Computers & Tech / How-To's and Tutorials / Programming / PHP
Author: Feelay Total-Replies: 41 Hi! It was a long time ago I created a tutorial, so I've decided to create a new one This time, I am going to teach you, how to create a "user profile page". Lets say I am logged in on my account, and want to view someone else account information (in this case, only his username, but you can add more things later). Then I'll press on a link, that will take me to his user profile. But before you can do that, you will have to create a register script, and a login script. If you don't know how to create any of those, you can find tutorials here: Login-Scipt Tutorial Register-Script Tutorial You will be using the same database, as the earlier tutorials. Before I start, I just want to say that I would never have learned this, without some guys here on Astahost. So don't give me all the credits. I think that vujsa, mastercomputers, Mordent and ethergeek, deserve some credits too. Because they teached me some of these things, that I am going to teach you. Lets start with the "Member List". To be able to see all the members that's registered on the page, with a link to their profile, we need a member list page. Lets start with the code. Members.php CODE<?phpsession_start(); require 'database.php'; $nuser=$_SESSION['user']; $auser=$_SESSION['admin']; if($nuser){ $userfinal=$nuser; }elseif($auser){ $userfinal=$auser; } if(isset($userfinal)){ $Members = mysql_query("SELECT user FROM characters WHERE level ='1' ORDER BY exp DESC") or die(mysql_error()); $numRowsMembers = mysql_num_rows($Members); ?> <table border="0"> <?php for($count = 1; $count <= $numRowsMembers; $count++) { $name = mysql_fetch_array($Members); ?> <tr> <?php echo '<td><a href="member_profile.php?username=' . $name['user'] . '">' . $name['user'] . '</a></td>'; ?> </tr> <?php } ?> </table> So.. This is the Member List. I called it "members.php". I think you want to know what it does, or? The first thing we do, after the PHP tag, is starting a session. Not so hard.. Then we require the database file (I'll add it in the end of this tutorial). Then, I create two variables. The "$nuser" is for the "non-admin" user (normal user). The "$auser" is for the "Admin" user. After that I've created theese two variables, I check if the user is an Admin, or a Normal user, and insert the $nuser and $auser variable in the $userfinal variable. now it is easy to check if the user is logged in. Instead of first checking if a Normal user is logged in, and then check if an admin is logged, I check if both is logged in, much faster. (hard to explain Now this explanation was for the "if(isset($userfinal)){" part. After that, I create two new variables again. The first one will get all the "Normal users" from the database. The other one will retrieve the number of rows from the first query. Then I create an Invisible Table, so that the names looks good, and so that the table don't screw up the design (if you use one.) But OFC, if you want to make the table visible, you can change the "border" to a number larger than 0. Now after that, we create a for-loop, to show all the names on the screen (the member list), and all the names, will have a link to their profile. easy, wasn't it? If there is something you didn't understand, you are free to contact me and ask. Now lets begin with the "member_profile" page. member_profile.php CODE<?phpsession_start(); require 'database.php'; $nuser=$_SESSION['user']; $auser=$_SESSION['admin']; if($nuser){ $userfinal=$nuser; }elseif($auser){ $userfinal=$auser; } if(isset($userfinal)){ $username = $_GET['username']; $user = mysql_query("SELECT * FROM user WHERE username = '$username'"); $user=mysql_fetch_assoc($user); if($user['level'] > 1){ die("You cant view an Admins profile!"); } echo "<h1>User Info</h1>"; echo "<b>Username:".$user['username']."<br>"; echo "<br>"; echo '<form name="backlistfrm" method="post" action="members.php">'; echo '<input type="submit" value="Back to The List">'; echo '</form>'; echo "<br>"; ?> Here we start like we did in the first page. After the php tag, We start a session, and require the database file. then we create two variables ($auser = admin and $nuser= normal user). Then we create the $userfinal variable, to check if the user is logged in later in the script. Then we create some variables. CODE$username = $_GET['username'];CODE$user = mysql_query("SELECT * FROM user WHERE username = '$username'");CODE$user=mysql_fetch_assoc($user);Now we check if the user that we selected is a normal user, or an admin. If the user is an admin, an error will occur that the user can't view the admins profile. If you want you can remove this part: CODEif($user['level'] > 1){die("You cant view an Admins profile!"); } This will make the users able to view an admins profile. Then the info about the user will be shown. In this case, I've only added the username of the user -> CODEecho "<b>Username:".$user['username']."<br>";But OFC, you can add more. Just change the user inside the ['...'] to something else from the database table, that you want to show. (lets say you want to show the users Admin level instead of his username, then you can change the $user['username'] to $user['level'].) The last thing I do in this script, is adding a button that will take the user back the the member_list. And here is the database.php file: CODE<?$con = mysql_connect('localhost','mysql_username','mysql_password'); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db('databasename'); ?> the first thing we do here, is: Open a connection to the mysql server. If the connection failed, the code will write an error then, we select the database we want to use. If you find anything spelled wrong, or any code that I wrote, that is wrong, or if you find something that is not working as it should, paste the wrong word(s) or the wrong code(s) or the error(s), and I'll fix them. Regards //Feelay You are not allowed to copy anything from this tutorial, and paste it outside of this topic, without my permission. But you are allowed to copy/paste parts of it, inside this topic.
Sun May 25, 2008
Reply New Discussion
Posted in Computers & Tech / Databases
Author: vujsa Total-Replies: 17 Well, sounds like you have a lot of work ahead of you... I learned PHP and MySQL from a book called PHP Fast & Easy Web Development 2nd Edition by Julie C. Meloni Here is a list of related books: http://www.amazon.com/s/ref=nb_ss_b/104-22...amp;x=0&y=0 While I suggest learning PHP5 as soon as possible, I must stress that having a good book for nearly any version of PHP is very helpful. This book shows how to do many of the tasks that you want to improve upon and I still refer to the book frequestly. I also have a copy of PHP 5 Unleashed by John Coggeshall Many of these books are available used for very little money (less than $5.00 US). I'll add more information as I get time. vujsa
Thu Nov 15, 2007
Reply New Discussion
Posted in Computers & Tech / Programming / Scripting / PHP
Author: Feelay Total-Replies: 50 kill me if you want.. but I still don't understand xD You mean that the "$Health" is the mysql_query for the current health and that the "$updated" is for the "last time the health was updated" colum = Both is mysql_queries =?
Thu Feb 7, 2008
Reply New Discussion
Posted in Astahost / Announcements / Archives
Author: vhortex Total-Replies: 23 QUOTE (nightfox)See? Either you or someone else would have been complaining about data loss later on if it wasn't for that protection! [N]F Link: view Post: 91189 you know, it piss me off when i cant see my test site due to disk problem with the server. then i realize that i am on a different timezone.. good thing i read this thread before.. and yes this is helpfull.. *************** anyway.. i dont care now if the disk will lock or not, i am doing my test now locally on my pc and by the time i finish the test site.. the new accounts have been moved completely.. though on the lost files and data.. i lost some data and files.. seems that there must be a warning to be sent or a timeframe for a non safe updates of file.. my files was gone, around 7 of them and mySQL database have rolled back a few minutes [3-4mins] and lost some database tables.. the server seems to have a time delay before it locks the files and the SQL database.. on the part of the SQL database.. some rollbacks do occur.. no worries anyway on my side since it was a test site.. the other users may have been affected though and have symptoms like mine.. by the way.. i am on smarty engine and part of my templates are on the database.. this may also contribute..
Thu Nov 9, 2006
New Discussion
Posted in Astahost / Hosted Members Support / cPanel
Author: Cloak Total-Replies: 11 cPanel: An Overview What all the features in cPanel are, and how to use them [Written by Cloak / AstaHosting.com] This tutorial is intended to provide a quick overview of all of the features that are available in cPanel when you receive hosting from AstaHost. You can find further help when you login to cPanel; this tutorial is best used for quick reference, as I've tried to keep explanations brief, to the point, and easy to understand. It is also assumed that you will be using the default theme when accessing cPanel. This little tutorial is broken into sections relavent to what area they detail in cPanel:
Email Management Tools:
This allows you to add or remove email accounts from your hosting package. So just say you wanted to set up the email address 'me@mysite.com', you would do it from within here. Read Webmail cPanel comes packaged with a number of webmail clients. These allow to use your email accounts that are registered with your hosting account (see above) to be used from within a browser window, in the same way that you might use the popular Hotmail or Yahoo! webmail services. These are especially useful for if you are wanting to check our email when you are away from your home computer, so that you don't need to set up any accounts on that computer (eg. in Outlook Express). Default Emails Here, you can set your 'default' email account. This controls how undelivered email - that is, email received that is addressed to a non-existant address - is handled, and where it is routed. You also have the option of using :fail: to bounce the message back to the sender, informing them that it wasn't delivered; or :blackhole: to delete all un-delivered email. Auto Responders This allows you to have a preset message automatically sent to the sender of each email the selected account receives. For example, you could set it so that each time an email arrives in the inbox of 'me@mysite.com', a message is automatically sent back to the person who sent it saying 'Thank you for contacting me. Your message will be reviewed, and I will get back to you as soon as possible'. They are more or less the equivalent of an answering machine for your email address. E-mail Filtering This allows you to set, change, and remove email filters that protect all accounts from SPAM and other unwanted mail. For example, you can filter out messages that contains the text 'Prescription drugs'. You can also define where you want the text to be searched for - eg. in the header, the from field, the subject field, the body field, etc. So if you had a filter that sprung messages containing 'prescription drugs' in the body, it would ignore any messages that contained that string in the subject. Aliases / Forwarding An email forwarder, or alias, will automatically send on or forward every message received in one of your accounts to another email address. This is effectively the same as adding email address in the 'Carbon-Copy' field when sending a message. Email Address Trace This shows the route each message takes when it is sent via email. It shows each 'hop' the data makes - that is, each server it is sent through. Mailing List You can manage your mailing lists here, adding, editing, or deleting existing ones. Mailing lists allow you to have a list of email addresses you want to email at the same time, so you don't have to email each person in a group individually. They are especially useful for areas such as newsletters and other material that is distributed on a regular basis. Site Management Tools:
As the name obviously suggests, this allows you to change your cPanel password. This will also affect your root FTP password. FTP Manager Allows you to manage FTP accounts and sessions. You can create new and delete existing FTP accounts, manage anonymous FTP usage, and control FTP sessions. If, for example, you had a friend who you wanted to be able to upload to your site. You could create a directory '/friend', and then create a new FTP account called 'friend' which allows them to only access the directory you assign to them - in this case, '/friend'. It gives you a safe way of allowing other people to upload to your site without having to give them your root password, which gives whoever has it complete control over your account. Disk Usage Viewer This page shows a conveniently-organized summary of how much space each directory in your account is using, sorted in descending order by size (largest first). It makes it easy for you to spot areas of your site which are taking up a lot of space, so can you can easily decide which areas to address if you are running out of space. File Manager This is like the HTML equivelent of an FTP client that you can use with your site. It allows you to control all files and directories - edit or delete existing ones, create new ones, move existing file and directory structures around, as well as uploading and downloading files. Index Manager This allows you to control how directory indexes are used. As some of you would probobly know, a default index is generally titled 'index.[htm/html/shtml/php/etc]'. However, if no existing index is present, the contents of a directory will be displayed in index form by default. Here, you can control how this information is displayed, or whether to display it at all. Frontpage Extensions Here you can control your Frontpage extensions, which allow to publish your websites directly from Microsoft Frontpage. Options include installing Frontpage extensions on a domain, re-installing them incase they become corrupted, or uninstalling them completely. Web Protect You can easily password protect different directories under your site using this feature. Whenever someone tries to access that directory, it will use basic HTTP authentication - which is the same form of authentication used to login to cPanel - to allow or deny access to that person. You can also add, remove, or edit different users, so that you can allow more than one person access to that directory. Custom Error Pages This feature allows you to customize your error pages as you like, so that when a visitor experiences an error (eg. 404 - Not Found), they might not just get the standard '404 - Not Found' page. (For a complete list of HTTP error codes, see appendix). Hotlink Protection This feature allows you to prevent people from 'hotlinking' to your files. 'Hotlinking' is when someone puts links to your files on their website, so it uses up your bandwidth and doesn't give you or your site any credit for the files whatsoever. This is especially a problem with images, where people want your image on their site, but instead of uploading it to their server, they 'hotlink' to it. Preventing this form of data theft is sometimes vital for website owners, however, it mightn't suit everyone. If, for example, your forum avatar or signature is linked to directly from your site, then it won't be displayed. Sub Domains A subdomain is like a secondary domain under your domain name - eg. 'subdomain.mysite.com'. Subdomains have many uses, such as seperating different areas of your site, setting up accounts, etc. A subdomain is used in the same way a top-level domain (eg. mysite.com) is used. Parked Domains When you register a top-level domain - for example, mysite.com - you need to part it on the server that you wish to host it on. This is where you do that. A Parked domain will act from the root of your account ('/'), so you should only park a domain if you want it to be your main access URL. You also have to set the DNS' for your domain to that of the host - in this case, ns1.astahost.com (primary) and ns2.astahost.com (secondary), and give them 24-72 hours (1-3 days) to propagate accross the Internet. You will not be able to park or use your domain name until you have let the DNS configuration fully propagate. See also 'Add-on Domains'. Add-On Domains An add-on domain is similar to a parked domain, however, rather than being set as the root, it is 'added-on' to your account. For example, if 'mysite.com' was parked with your account, then all files in your public_html directory would be able to be accessed via that domain name. If you were to add it on, then a new directory would be created that would act as the root for that site. An add-on domain is useful if you are wanting to host more than one site on your account. Please note that because this is still a top-level domain, DNS propagation needs to take place before using it (see 'Parked Domains'). Manage Redirects Here you can manage all the redirects within your website. These will automatically redirect traffic from one area of your site to another. This is usually used when a web page or file has been moved to another location, so that anyone visiting your site doesn't become lost and unable to find what they are looking for. MySQL Databases MySQL is one of the most widely used and powerful databasing solutions available for online use, and can easily be combined with PHP or Perl. Here, you can setup new databases, manage existing ones, and manage users for your database. It is also worth noting that all databases created under your account will be prefixed with your account name - for example, if your account was 'myaccount', and you created a database 'mydatabase', then it would become 'myaccount_mydatabase'. The same applies to MySQL users. This means that characters such as the underscore will be discarded when creating a database. Also, do not try to add the prefix when creating an account, as it is done automatically and anything in the database name is added thereafter - eg., 'myaccount_mydatabase' would become 'myaccount_myaccountmydatabase'. See also 'phpMyAdmin'. phpMyAdmin phpMyAdmin is a very useful utility that comes with your cPanel account. It allows you to browse, create, modify, and delete your databases structure and data. Please note that all changes made with this tool are instant and irreversable - ie. there is no 'undo' function, and it doesn't wait for you to 'save' the changes before making them. Backup [to be advised] IP Deny Manager This allows you to ban visitors by IP address from accessing any area of your site. Please note that once an IP is banned, anyone using that IP address will not be able to access any area or file within your entire website. It is only applied to the root directory of your site - meaning that you can't only block the person with the IP address xxx.xxx.xxx.xxx from accessing 'mysite.com/directory'; they will not be able to access anything under 'mysite.com' at all. Because many people use dial-up Internet, a lot of your visitors might have dynamic IP addresses, meaning that they change every time the person re-connects to the Internet. People can also use proxy servers, or route through other connections to get to your site. As such, this should not be relied upon as a sole method of protection from a certain user. Analysis and Log Files:
This shows detailed statistics for every time someone has accessed your site, either by FTP or the web (HTTP). The stats are organized into categories, and are relatively easy to read. Sub Domain Stats This shows the same statistics as 'Web / FTP Stats', but only for a selected subdomain. This makes it easy to isolate which areas of your site are receiving the most 'hits' (or visits), taking the most bandwidth, etc. See also 'Web / FTP Stats'. Error Log This shows the last 300 errors that users have received when visiting your web site. This includes access errors, permission errors, etc. (See Appendix for HTTP Error codes). Raw Log Manager This allows you to schedule a raw log backup or removal at the end of each month. Raw Access Logs These are the 'raw' server logs relating to your site. Basically, that means they are the same stats shown in 'Web / FTP Stats', but they have not been organized or formatted in anyway. They are shown exactly as the web server logs them. Advanced Tools:
Cron Jobs 'Cron jobs' are tedious and repetetive tasks that need to be done, but that might take a long time if done by hand. You can configure them to automatically be executed to your choosing. A relative understanding of UNIX-based operating systems would help when using this feature. Mime Types A MIME type is what tells your browser what to do with files with certain extensions. It's how your browser knows to download a .zip file seperately, but open a .html file as a web page. Be careful when editing MIME types; if you set something incorrectly, it can cause your site not to function as it should (or at all). See also 'Apache Handlers'. Apache Handlers Apache is the web server that powers this host, and all sites under it. Apache Handlers are the server-side equivelent of a MIME type - instead of telling the browser what to do with certain files, they tell the server what to do with them. For example, they tell the server to pass a '.php' file to the PHP engine, but to send a '.html' file straight to the client. Please note that they only operate on files by extension, not content - so if you rename a '.jpg' file to '.html', then it will be treated as a HTML file (or whatever it is set to handle files with a '.html' extension). See also 'MIME Types'. Manage OpenPGP Keys [From the documentation]: QUOTEOpenPGP is a tool for secure online communication. CPanel uses GnuPG for its public-key cryptography so that users may communicate securely. Each person gets a pair of keys, called the public key and the private key. Each person's public key is published while the private key is kept secret. Messages are encrypted using the intended recipient's public key and can only be decrypted using their private key.Networking Tools Offers the domain name lookup (reverse DNS lookup), and trace route utilities, which are used for establishing host/network information. SSL Manager Manages SSL certificates, signing requests, and keys. Also allows you to install SSL on the server. Preinstalled Scripts:
The CGI center has a variety of pre-installed CGI scripts that you can easily add to your site, without having to manually upload them and then set them up. Addon Scripts Provides a number of different fully-featured scripts and packages that can be freely used with your site. It provides an easy alternative to having to obtain, then upload, and then set up the applications included in this library. Some of the popular choices include Invision Power Board, phpBB, and PHP-Nuke. See also 'Fantastico'. Agora Shopping Cart An easy-to-use e-commerce tool that allows you to easily setup a shopping cart on your site. Java/CGI Chat Room Allows to include real-time Java or CGI chat on your site, such as those seen in public chat servers. Please be aware that these scripts might use large amounts bandwidth, which could quickly exceed your monthly allocation. See also 'PhpMyChat Room'. PhpMyChat Room Another real-time chat script, but in PHP. See also 'Java/CGI Chat Room'. phpBB Allows you to easily install the phpBB forum on your website. See also 'Addon Scripts'; 'Fantastico'. Search Engine Submit Automatically submits your site to a number of popular searc engines, meaning that you don't have to do it manually. Fantastico A library of pre-installed scripts that can be easily set up in minutes, saving you the time of manually uploading and then installing, setting up, and managing them. It also automatically takes care of other required processes, such as setting up MySQL databases etc. See also 'Addon Scripts'. Language and Theme:
Allows you to select the language in which cPanel is operated in. Theme Allows you to select from a range of different themes in which cPanel will appear. It only affects the visual look of cPanel, and does not change any features etc. Appendix HTTP Error/Status codes
// EOF(); Well, that pretty much does it for now. If you have any questions pertaining to any areas covered in this tutorial, then please feel free to post them here. -Cloak.
Fri Aug 27, 2004
Reply New Discussion
|