Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Acer Pilot
Feb 17, 2007
put the 'the' in therapist

:dukedog:

epswing posted:

Naw it was Charlie Rackoff, CS program at the University of Toronto. I guess it's a common phrase, because it does get the point across rather well.

His wiki is both hilarious and awful. Also, greetings fellow Canadian goon :canada:

Adbot
ADBOT LOVES YOU

Acer Pilot
Feb 17, 2007
put the 'the' in therapist

:dukedog:

You can try moving the form processor to another file and change your script to link to it. eg.

<form method="post" action="check.php">

Your problem right now is that you're checking the form even if nothing has been entered yet.

Acer Pilot
Feb 17, 2007
put the 'the' in therapist

:dukedog:

How do you guys implement "friendly" error messages?

I'm making a browser game and I don't want to put bring users to a new error page and possibly get them killed in the game.

I can only think of two options: show the error on the current page or use sessions and output the error on a page where they can still run away from other people. I want to keep away from using sessions though.

Acer Pilot fucked around with this message at 12:12 on Apr 20, 2010

Acer Pilot
Feb 17, 2007
put the 'the' in therapist

:dukedog:

Anybody here have some sort of template system or maybe general alternative to Smarty?

Acer Pilot
Feb 17, 2007
put the 'the' in therapist

:dukedog:

Lumpy posted:

Are you looking for something "lighter" than smarty, or a better MVC framework?

Something "lighter."

Acer Pilot
Feb 17, 2007
put the 'the' in therapist

:dukedog:

MrMoo posted:

But what are you looking for that is more than just PHP itself?

True, how do you guys do it? I've never tried before.

Acer Pilot
Feb 17, 2007
put the 'the' in therapist

:dukedog:

Has anyone come up with/found any way to implement a low footprint chat system with PHP? I'm running Apache 2 so probably no Comet.

I was thinking of temporarily storing messages in xcache or memcache but not really sure if that's a good way to go.

Acer Pilot
Feb 17, 2007
put the 'the' in therapist

:dukedog:

MrMoo posted:

Very low footprint, Facebook Live Stream:

http://developers.facebook.com/docs/reference/plugins/live-stream

That's kinda cool, don't know how comfortable people would be displaying their real names in a game though. Know of anything that you can run locally?

Acer Pilot
Feb 17, 2007
put the 'the' in therapist

:dukedog:

I'm trying to make sure players only hit with their weapons a percentage of the time (70%, 34%, etc) but it doesn't seem that my functions are very accurate.

Attempt 1:
code:
	private function weighted_random(&$weight)
	{
		$weights = array(($weight/100), (100-$weight)/100);
		$r = mt_rand(1,1000);
		$offset = 0;
		foreach($weights as $k => $w)
		{
			$offset += $w*1000;
			if($r <= $offset)
				return $k;
		}
	}
Attempt 2:
code:
	private function weapon_fired(&$weight)
	{
		$hit = array();
		for($i = 0; $i < $weight; $i++)
			$hit[] = true;
		for($i = $weight; $i < 100; $i++)
			$hit[] = false;
		shuffle($hit);
		return $hit[mt_rand(0,100)];
	}
What's wrong with these?

Acer Pilot
Feb 17, 2007
put the 'the' in therapist

:dukedog:

Begby posted:

I have no idea what your functions are supposed to be doing, they seem a bit convoluted with the arrays and all.

Instead, imagine you are rolling a 100 sided die to compute this. Lets say your hit percentage is 65%. In that case when you roll the die if the number is 65 or less, thats a hit. If the number is 66 or greater, then that is a miss.

So all you need to do is pick a random number between 1 and 100 for each shot, then see how that number compares to your hit percentage.

Thanks, the way I had it was a bit much.

Acer Pilot
Feb 17, 2007
put the 'the' in therapist

:dukedog:

Bob Morales posted:

Let's pretend we have an imaginary message board. The messages are stored in a table with a thread_id and sub_forum_id. Threads and forums are stored in their own tables.

The threads have a sub_forum_id, so if you click on sub forum 'games', all the threads that have the sub_forum_id of '5' or whatever games is, will show up. Likewise, when you click on the thread 'Super Mario Brothers', all the messages with the thread_id '50' show up.

Here's my question: Which way would be commonly used to keep track of the replies, views, and post counts in each forum?

Forum: Threads: Posts
Games 57 302
Chat 23 98

Thread: Posts: Views:
Hello! 23 299
Anyone play it? 56 23432

Would it be stupid to query the database for all threads, and then posts that belong in each forum, every time someone calls up the forum index page? I guess we're already querying the DB for all the thread titles etc each time, or is that something that shouldn't be done every time either?

What about updating the thread counters (and then the sub forum counters) every time a post is made?

What about having an automated process just update the numbers every 1 or 5 minutes? Would I do that with just a cron job? Or would I have some custom maintenance script that is running all the time, doing things as I set them up (sounds like re-writing cron)

Well, Invision Board has a table just for topics and it stores the total number of posts, threads, the last topic id, and last poster name. Take it as you will.

Edit: It's probably best to do it this way since you don't want to scan through all your posts every time someone loads the index. If my Invision forum did that it'd probably eat up all the RAM going through 400,000 poo poo posts.

Acer Pilot
Feb 17, 2007
put the 'the' in therapist

:dukedog:

As long as you're not storing credit card information in your database or working for a bank, you should be fine with just salting your hashes. Try and have a different salt for every person though.

Acer Pilot
Feb 17, 2007
put the 'the' in therapist

:dukedog:

I don't see anything MySQL related in your code. Did you forget to paste something?

Acer Pilot
Feb 17, 2007
put the 'the' in therapist

:dukedog:

Have any of you ever written a "custom application" for Invision Board? I'm trying my hand at it but the documentation isn't as full as I'd hoped.

Acer Pilot
Feb 17, 2007
put the 'the' in therapist

:dukedog:

Fehler posted:

Only for 2.3, and I guess you are using IP.Board 3? Usually their documentation is pretty good though, at least compared to some other stuff I worked with...

Yep, IP.Board 3, it seems like quite a bit has changed from version 2 but at least it looks like you don't have to have people edit any files now.

Acer Pilot
Feb 17, 2007
put the 'the' in therapist

:dukedog:

Would you guys store a bunch of hashed values that expire onto MySQL, onto ram (xcache), or something else?

I'm generating a bunch of expiring links for a game every time a player moves and don't know where I should be storing them.

Acer Pilot
Feb 17, 2007
put the 'the' in therapist

:dukedog:

michael30404 posted:

I'm a noob from the geocities days and I'm having trouble getting a site with the codeigniter framework to work properly. The company who made the site for my friend kindof jerked him around. It took legal threats to get them to deliver on the site, so while they claim it's complete who knows.

I've uploaded the site folders to root on the server but when I go to the domain it gives me a 404 error. I am using a freehost site until I verify this site works and then I'll purchase a domain.

I edited the config file to point to the correct domain. The php version running on the host is 5.2.17 so that shouldn't be a problem. Where should I start? I've never deployed a site using codeigniter before (php really at all). Thanks!

Did you put the actual site in /root or something like /home/username/public_html?

Acer Pilot
Feb 17, 2007
put the 'the' in therapist

:dukedog:

michael30404 posted:

I was sent a zip for the website. Upon opening the zip, there is a public folder and a log folder. I uploaded the contents of the public folder right to root. It contains assets and system folders, as well as index.php and htaccess file. The index file is just instructions for what I'm assuming is the CodeIgniter framework. The folder public>system>application>views> has php files that have actual content for the website. The index file in that directory (like in pretty much every directory) is a 403 message about forbidden access. When trying to access those files ie: domain.com/public/system/applications/views/contact.php I got the same 404 error.

What's the directory structure look like for your host? Are you uploading these files through FTP, SFTP, or something else?

Acer Pilot
Feb 17, 2007
put the 'the' in therapist

:dukedog:

Can you post a link to the website?

Or maybe tell us what folders you see when you initially login to the site through FTP.

Acer Pilot
Feb 17, 2007
put the 'the' in therapist

:dukedog:

You'd need to recompile PHP with the settings you want enabled.

Acer Pilot
Feb 17, 2007
put the 'the' in therapist

:dukedog:

What's a safe way to detect if a file is an MP3?

Acer Pilot
Feb 17, 2007
put the 'the' in therapist

:dukedog:

McGlockenshire posted:

If you're on a Unix, you can shell out to the "file" command and parse the result. Calling "file -b foo.mp3" should result in something like "Audio file with ID3 version 23.0 tag, MP3 encoding". "file -bi foo.mp3" should result in the MIME type "audio/mpeg"

Thanks, that sounds reasonable.

This doesn't seem safe:

php:
<?
$file_sanitized = escapeshellarg($file);

echo exec("file -bi $file_sanitized");
?>
Ideas?


Thanks for this too, next time I recompile PHP I'll consider adding this module.

Acer Pilot fucked around with this message at 23:20 on Sep 20, 2011

Acer Pilot
Feb 17, 2007
put the 'the' in therapist

:dukedog:

McGlockenshire posted:

It depends. If you control the filename, then it's totally safe. If the user controls the filename, as long as you've either filtered out non-alphanumerics or are also using escapeshellcmd, then you should be OK.

Thanks, this is what I'm using right now. I control the filename but you never know.

php:
<?
$file_sanitized = escapeshellarg($file);
$file_type = exec(escapeshellcmd("file -bi $file_sanitized"));
?>
Anybody have any other ideas to make this "safer?"

Acer Pilot
Feb 17, 2007
put the 'the' in therapist

:dukedog:

How much RAM does he have and does he have a my.conf setup?

Acer Pilot
Feb 17, 2007
put the 'the' in therapist

:dukedog:

You probably shouldn't be using globals...

Acer Pilot
Feb 17, 2007
put the 'the' in therapist

:dukedog:

Scaramouche posted:

Any exploit experts in the house? I'm helping someone else now who keeps getting their personal website 'hacked', but I'm pretty sure it's just some automated script someone is running somewhere. They're on:
- cPanel 11.30.5 (build 6)
- Apache 2.0.63
- PHP 5.2.14
- MySQL 5.0.92-community
- Perl 5.8.8
- RHEL5 2.6.18-194.11.3.el5

The 'hack' is that once a month (same day 3 months so far) someone gets in somehow and makes a 'flickr.com' and 'blogger.com' folder in the public_html root. Then, 3 days later, if those directories still exist, they'll insert some files that allow them to 1) upload their own files (in flickr.com) and 2)make database queries (in blogger.com). These appear to be .gifs/.jpgs using some kind of mime type exploit with commands base64 encoded at the end of the binary file. In a way I don't care about the latter part, because I want to stop them from making the files/folders in the first place.

I'm pretty good with (Windows+.Net) security, but am pretty well out to sea on this Lunix/php stuff. What I've done (based on googling around):
1. Moved the admin code for cPanel into a different directory and reset the permissions
2. Changed the password on the 'main' cpanel account (they were using it as their FTP account. Over wireless.), made separate new FTP accounts so the 'main' cpanel account is never used over cleartext again
3. Checked all files modified past date (x) (nothing related found)
4. Checked all database rows modified past date (x) (nothing related found)

Since I've done this the two folders have appeared again, same day as the previous two months. Has anyone run across this before?

Did your friend actually clean out or re-image the server after getting hacked? There might still be something on there.

Acer Pilot
Feb 17, 2007
put the 'the' in therapist

:dukedog:

Optimus Prime Ribs posted:

Isn't IPB just as lovely?
I haven't used it since back when it was free, so they may have improved it. But it was pretty awful back then.

IPB is pretty great actually. I've been using it for a few years now and it hasn't failed me. The new spam monitoring stuff is pretty handy and the forums, overall, are very sleek.

Acer Pilot
Feb 17, 2007
put the 'the' in therapist

:dukedog:

e: ignore this.

Something else was broken.

Acer Pilot fucked around with this message at 07:10 on Mar 23, 2012

Acer Pilot
Feb 17, 2007
put the 'the' in therapist

:dukedog:

You could have also just used alluvion.

http://www.alluvion.org/authdb.txt

Acer Pilot
Feb 17, 2007
put the 'the' in therapist

:dukedog:

emoltra posted:

I'm using json_decode on a json file that contains both empty values and null values, does anyone know why php would read both of them as null?

Running the empty() function on both of them returns true and if I do if($variable == null) they're both match the condition.

It's because PHP. Try to see if isset() works for you.

Acer Pilot
Feb 17, 2007
put the 'the' in therapist

:dukedog:

Never use the mysql_ or mysqli_ functions. They're very old and deprecated.

Look into PDO as well: http://php.net/manual/en/book.pdo.php

Acer Pilot
Feb 17, 2007
put the 'the' in therapist

:dukedog:

How do you guys like PhpStorm? It's on sale for $25 right now.

http://www.jetbrains.com/specials/index.jsp

Kind of thinking about it but using EditPlus and a VM seem to work fine.

Acer Pilot
Feb 17, 2007
put the 'the' in therapist

:dukedog:

Flaggy posted:

Any reason my website would be throwing these up all of the sudden? It makes no sense since none of the pages have been touched.

Are you out of space?

Acer Pilot
Feb 17, 2007
put the 'the' in therapist

:dukedog:

You should post your code first so we can tell you what's going wrong.

Acer Pilot
Feb 17, 2007
put the 'the' in therapist

:dukedog:

Is there a go to framework for implementing a rest api? I'm guessing there's something in pear, if that still exists.

Been awhile since I've written in php so any help would be appreciated.

Thanks

Acer Pilot
Feb 17, 2007
put the 'the' in therapist

:dukedog:

Not very big, basically an over glorified crud app that just grabs stuff from a MySQL db. Just want to switch the site to use more JavaScript and would be nice to keep php out of the presentation layer.

Adbot
ADBOT LOVES YOU

Acer Pilot
Feb 17, 2007
put the 'the' in therapist

:dukedog:

Don't do it! Use prepared statements/PDO/whatever they call it now.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply