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
DaTroof
Nov 16, 2000

CC LIMERICK CONTEST GRAND CHAMPION
There once was a poster named Troof
Who was getting quite long in the toof

fletcher posted:

I've had a dedicated server for a few years from them and I've registered all my domains through them, never really had an issue. I think the main complaint about GoDaddy is they are pretty aggressive with selling poo poo. You won't be able to talk to them on the phone without them trying to get you to renew poo poo in advance, and you can't buy a domain through their website without them trying to nickel and dime you every step of the way. I'm guessing this is why they are the most popular registrar though. Gotta make money, right?

That being said, the prices seem fine and the service has been reliable, which is really all I care about.

As far as the mail() issue, does a phpInfo() show a path to sendmail? Or maybe contact GoDaddy?

Their dedicated servers are somewhat better than their shared hosting, although there are still several companies I'd prefer to lease from than GoDaddy.

As for the mail problem, last I remember, GoDaddy requires all automated mail to use a particular mail server, which their shared servers aren't configured to use from the PHP mail() function. You should be able to configure a mail library that supports SMTP, like PHPMailer or SwiftMail, to use their required configuration. Search their FAQ. It's in there somewhere.

Adbot
ADBOT LOVES YOU

DaTroof
Nov 16, 2000

CC LIMERICK CONTEST GRAND CHAMPION
There once was a poster named Troof
Who was getting quite long in the toof

drcru posted:

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

What exactly do you need, whether it's more or less than what PHP provides, or just plain different? For example, in the template system I use for my framework, one of its primary benefits is to guarantee well-formed XML. Maybe you give a poo poo about that, maybe you don't.

Or maybe you just want to limit what your designers can do in the view portion of an MVC architecture. Like you want to make sure that arbitary SQL queries aren't executed at render time. That's a worthwhile goal, but do you need to enforce it in a secondary/proprietary domain language, or is a mandated convention good enough?

Lots of people will tell you that PHP is already a templating language, so you might as well use it directly instead of adding another layer to it. They're kinda right, but here's the rub: PHP, straight out the box, is an astoundingly lovely templating language. Anyone who works with MVC in PHP long enough will eventually want a more practical way to abstract the view, and the only people who think "plain PHP is good enough" are either inexperienced hacks or Rasmus Lerdorf himself.

Smarty is a lovely alternative because it's just PHP with a different syntax. Useful for limiting what can be performed in a view, but so bad at it that most implementations let you embed PHP into the templates anyway.

Long story short: there's no way to make this story short. Here be dragons.

DaTroof
Nov 16, 2000

CC LIMERICK CONTEST GRAND CHAMPION
There once was a poster named Troof
Who was getting quite long in the toof

gwar3k1 posted:

I haven't looked into templating, but if short tags are removed, how do you output dynamic content without also producing the html on the fly?

immediate answer: <?echo $variable?> and <?= $variable?> are the same when short tags (i.e. <?= ?>) are permissible

short answer: i output dynamic content by using mature libraries that actually do important stuff like sanitization

long answer: holy poo poo, are you serious? is the state of online php tutorials still that loving terrible, or did you stop reading them in 1998?

DaTroof
Nov 16, 2000

CC LIMERICK CONTEST GRAND CHAMPION
There once was a poster named Troof
Who was getting quite long in the toof

KuruMonkey posted:

Don't save the actual image data itself in a db. Save the image as a file, store the path to that file in the db.

this this this this this this this

DaTroof
Nov 16, 2000

CC LIMERICK CONTEST GRAND CHAMPION
There once was a poster named Troof
Who was getting quite long in the toof

Mackerel, the Thief posted:

This seems a bit complicated to me. Why not simply reference the text directly in the function and use the md5 hash of the string as the lookup key on the table?

code:
<?=transexual("I didn't murder my wife!"); ?>
code:
SELECT translated_text FROM translations WHERE hash = MD5( ? ) AND lang = 'de';
It just seems really difficult to remember the arbitrarily assigned key of whatever it is you're trying to translate when you could just pass the text in directly.

A fixed key can be useful, for example, in case the REQUEST_LOGIN phrase changes from "Login required" to "Please log in to continue."

DaTroof
Nov 16, 2000

CC LIMERICK CONTEST GRAND CHAMPION
There once was a poster named Troof
Who was getting quite long in the toof

Plorkyeran posted:

Well yes, and I already agreed that there are potential performance issues and that you should hash them if it does turn out to be a problem, and I would rather hope that anyone working on a site large enough that the performance impacts are foregone would have to ask basic questions about how to handle translations. Is there some problem caused by very long keys other than potential slow performance and the extra storage space?

Potential slow performance is much more likely to be a problem than extra storage space. Also, 400-character keys are just a big pain in the rear end to work with. A key like "terms of service" is going to be a lot easier to remember, and a lot more contextually relevant whenever the copy needs to change, than a paragraph of legalese.

DaTroof
Nov 16, 2000

CC LIMERICK CONTEST GRAND CHAMPION
There once was a poster named Troof
Who was getting quite long in the toof

Lumpy posted:

If they can change the file you are using now, they can change a file like this:

php:
<?
$error_codes = array( // DON'T TOUCH THIS LINE

 "ERROR_CODE" => "Some definition",
 "ANOTHER_ONE" => "Whee, this is fun",


); // DON'T TOUCH THIS LINE EITHER
?>

My concern about letting them update a PHP script is that typos could cause fatal errors. If a non-technical user sees a web page that looks like this:

Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ')' in /var/www/html/errors.php on line 384


...it might as well be an air horn commanding them to have a panic attack.

DaTroof
Nov 16, 2000

CC LIMERICK CONTEST GRAND CHAMPION
There once was a poster named Troof
Who was getting quite long in the toof

Doctor rear end in a top hat posted:

Now that I've made myself look like an idiot, I should mention that there's only one scenario I've used it for.

User posts to something like this using AJAX:
php:
<?
  $conn = mysql_connect();
  foreach($_POST as $key => $value)
  $$key = mysql_real_escape_string($value);
  $query = "SELECT * FROM users WHERE name = '$name' AND email = '$email'"
  $result = mysql_query($query, $conn);
  /*output results or some poo poo*/
?>
I know it's lazy, but it's something like 10 variables and I was changing the names. Can someone point out how this can go wrong? All I can see is them setting something to the $conn variable, at which point the query would fail.

The fact that your example is too trivial to expose much of an attack vector doesn't change the fact that it's a terrible habit with the potential to open crippling security holes. It is not safer than turning on register_globals. Please do not recommend it.

DaTroof
Nov 16, 2000

CC LIMERICK CONTEST GRAND CHAMPION
There once was a poster named Troof
Who was getting quite long in the toof

Golbez posted:

You don't have to declare anything in PHP. $i = 5, $s = 'fnord', etc.

But I've noticed I tend to declare arrays:

[snip]

and I realized I could drop the first line there; square-bracket syntax creates if it does not exist, I believe. Is there any drawback to this apart from code clarity? It suddenly occurred to me that it seemed weird to insist on declaring my arrays.

With strict errors enabled, referencing an undefined variable triggers a notice. Also, as McGlockenshire demonstrated, it can cause unexpected problems elsewhere and make your code harder to debug. You can get away with it, but it's not best practice.

DaTroof
Nov 16, 2000

CC LIMERICK CONTEST GRAND CHAMPION
There once was a poster named Troof
Who was getting quite long in the toof

Golbez posted:

Referencing, yes. Setting to, no. If I did "echo $foo[1]" before declaring $foo, that'd throw a notice. But doing "$foo[1] = 'bar'" won't throw an error, even if $foo hasn't been declared. So far as I know.

Yeah, you're right. Setting $foo[] or even $foo[1] will quietly declare $foo as an array. But that doesn't change the case where $foo is unset because the loop that would have populated it never iterated.

DaTroof
Nov 16, 2000

CC LIMERICK CONTEST GRAND CHAMPION
There once was a poster named Troof
Who was getting quite long in the toof

Unacknowledged posted:

I'm using a form to distribute free / paid copies of my band's new album. I've got my file headers setup correctly as far as I can tell, however, the transfers almost always get cut off. The file sizes of the 3 different zips range from 68MB-454MB, however none of the transfers of these files ever complete, so I don't think the size is relevant (though what the hell do I know). Also, I'm only sending 1 at a time in case my wording is bad.

I have had a transfer complete 1 time, which has so far been an anomaly. I'm desperately looking for any advice.

It sounds like the script is timing out. The default time limit is usually 30 seconds. You should be able to change max_execution_time in php.ini or use the set_time_limit() function. http://us.php.net/function.set-time-limit

DaTroof
Nov 16, 2000

CC LIMERICK CONTEST GRAND CHAMPION
There once was a poster named Troof
Who was getting quite long in the toof

McGlockenshire posted:

You don't need no steenking template engine. The rant is prehistoric but accurate.

prehistoric, yes. accurate, no. php tries to be a programming language and a templating language at the same time, and that's why it sucks. you need to use a framework to fix its liabilities. it could be an existing framework like codeigniter, or it could be something you accidentally start building out of sheer necessity. by the time your framework is stable, you'll realize that php in the view is too likely to gently caress it up, so you might as well plan a dsl from the get-go and save yourself infinite tears... even if your dsl is just a subset of php that the framework sanitizes

"php everywhere" is the worst thing you could recommend for an application with wide deployment. the second worst is smarty

DaTroof
Nov 16, 2000

CC LIMERICK CONTEST GRAND CHAMPION
There once was a poster named Troof
Who was getting quite long in the toof

McGlockenshire posted:

Implementing a template language or even a freaking dsl on top of a language that does a perfectly adequate job at templating is just as insane as saying that you "need" to use a framework.

That's the rub, though. I think PHP is a sloppy and unwieldy language for templates. Maybe it's just personal preference, but I'd rather have a templating system between the controller and the view.

I suppose you don't "need" to use a framework, but the practicality of a framework increases with the complexity of the project.

bobthecheese posted:

OK, in terms of templating systems that I've actually LIKED, phpTAL is an oft-forgotten option.

I agree. phpTAL's a good one.

DaTroof
Nov 16, 2000

CC LIMERICK CONTEST GRAND CHAMPION
There once was a poster named Troof
Who was getting quite long in the toof

KuruMonkey posted:

1: frameworks and template engines are not the same thing; saying using one is dumb does not imply saying that using the other is dumb.

I mentioned both because I was responding to this:

mcGlockenShire posted:

Implementing a template language or even a freaking dsl on top of a language that does a perfectly adequate job at templating is just as insane as saying that you "need" to use a framework.


KuruMonkey posted:

2: re-implementing a subset of PHP's features in PHP but meanwhile inventing a new syntax to do it with, and parsing that syntax in PHP, is both dumb and redundant.

Using PHP for templates is dumb and fragile.

DaTroof
Nov 16, 2000

CC LIMERICK CONTEST GRAND CHAMPION
There once was a poster named Troof
Who was getting quite long in the toof

SETEC Astronomy posted:

Sorry, I'm at work right now, so I can't verify it. I appreciate your humoring me, though.

I probably will use mod_rewrite, but I wanted to show the simplest version of the idea for these purposes.

Based on your description of what you're doing, I suspect that you would be better served by session variables. Maybe I'm wrong, but if you're willing to go into more detail about what you're trying to do, someone might be able to recommend a better (and MORE SECURE) solution.

DaTroof
Nov 16, 2000

CC LIMERICK CONTEST GRAND CHAMPION
There once was a poster named Troof
Who was getting quite long in the toof

Hammerite posted:

Actually - scratch this comment. I've never used the mysql library and I'm not 100% confident that what I wrote here is true.

MySQL accepts quoted numbers and treats non-numeric strings as zero.

DaTroof
Nov 16, 2000

CC LIMERICK CONTEST GRAND CHAMPION
There once was a poster named Troof
Who was getting quite long in the toof

Black Eagle posted:

Changed to decimal and updated the table. Works now. Why wasn't it working?

I'd guess it's a precision error.

Floats are only accurate to a certain degree of precision. (One obvious example: the precise value of 1/3 is impossible to store as a terminating [hexa]decimal, so it gets rounded to 0.33333333333333. Close, but not exact.) Because of this, precision errors sometimes occur during data type conversions, especially when they're getting passed between different systems. In other words, the representation of 1.2 that came from PHP may not be exactly equal to the representation of 1.2 that got stored in MySQL.

DaTroof
Nov 16, 2000

CC LIMERICK CONTEST GRAND CHAMPION
There once was a poster named Troof
Who was getting quite long in the toof

Doctor rear end in a top hat posted:

PHP tries to be 'helpful' and assumes you meant the string 'bareword', which would evaluate to true. I've read numerous times that this 'feature' is going to be removed in upcoming versions. I think they're hesitant because a lot of terrible programmers use this and their poo poo will break.

It's definitely a dumb "feature" but at least it triggers an E_NOTICE.

DaTroof
Nov 16, 2000

CC LIMERICK CONTEST GRAND CHAMPION
There once was a poster named Troof
Who was getting quite long in the toof

Yay posted:

This latter method demonstrates why your original code won't throw errors (though it may throw warnings/notices; I really can't remember)

php:
<?
function foo() {}
function bar($baz) {}

foo('bar');  // No errors
bar();       // Throws a "missing argument" warning (in 5.3, at least)
?>

DaTroof
Nov 16, 2000

CC LIMERICK CONTEST GRAND CHAMPION
There once was a poster named Troof
Who was getting quite long in the toof

Optimus Prime Ribs posted:

Is it not possible to create a reference to a function in PHP?

Yes, but the variable needs to be a string representation of the function name:

php:
<?
$fooFunc = 'foo';
$barFunc = 'bar';
?>
Your version throws notices because foo and bar are undefined constants. PHP treats them as strings after reporting the errors.

DaTroof
Nov 16, 2000

CC LIMERICK CONTEST GRAND CHAMPION
There once was a poster named Troof
Who was getting quite long in the toof

Optimus Prime Ribs posted:

All right, that makes sense.
Would that mean that the code 'foo'() will call the function "foo"?

(not that I would ever need to do that; just making sure I understand)

Hahaha, I wouldn't have been surprised if that worked, but apparently it doesn't. The string has to be in a variable, not a literal or a constant.

DaTroof
Nov 16, 2000

CC LIMERICK CONTEST GRAND CHAMPION
There once was a poster named Troof
Who was getting quite long in the toof

Knyteguy posted:

Those CI functions do sanitize the form data (for the most part).

$this->input()->post() does NOT sanitize for queries. You should either escape the values or use query binding (http://codeigniter.com/user_guide/database/queries.html).

DaTroof
Nov 16, 2000

CC LIMERICK CONTEST GRAND CHAMPION
There once was a poster named Troof
Who was getting quite long in the toof

Fleur Bleu posted:

I'm just looking things up as I go along, so I started with mysqli. If I have enough time I'll try and do everything in PDO instead. The manual has a lot of options, which is good, but I lack the knowledge to make the right choices.

Mysqli also supports parameterized queries (although I prefer PDO's syntax). You're better off using those instead of escaping all the input and building the raw statement in code.

DaTroof
Nov 16, 2000

CC LIMERICK CONTEST GRAND CHAMPION
There once was a poster named Troof
Who was getting quite long in the toof

The Gripper posted:

There's one thing about mysqli_stmt_bind_param() that can just gently caress right off: the first paramater being $types.

YES. I've used a wrapper around Mysqli that treats every parameter like a string, and I don't think there's even one example of the conversion causing different results. It's a completely worthless interface wart.

DaTroof
Nov 16, 2000

CC LIMERICK CONTEST GRAND CHAMPION
There once was a poster named Troof
Who was getting quite long in the toof

Golbez posted:

You're thinking of the ID that identifies the session. We're talking about a check number that gets saved to the session. $_SESSION is server-side, it never goes to the cookie.

In the example that DarkLotus provided and baquerd referenced, the token is a hash of session_id(), which is constant for the duration of the session.

DaTroof
Nov 16, 2000

CC LIMERICK CONTEST GRAND CHAMPION
There once was a poster named Troof
Who was getting quite long in the toof

The Gripper posted:

I think if you make multiple inputs with the same name, PHP will create an array from the $_GET or $_POST vars where duplicates are available. So really all you'd need to do is duplicate an <input ...> </input> block with the same name and submit away.

Close. If they have the same name, the value in $_GET/$_POST will simply be the last one received; but if you bracket the end of it (e.g., <input type="text" name="website[]" />), all the values will be appended to an array.

php:
<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    print_r($_POST);
}
?>
<form action="" method="post">
    <input type="hidden" name="foo" value="one" />
    <input type="hidden" name="foo" value="two" />
    <input type="hidden" name="bar[]" value="one" />
    <input type="hidden" name="bar[]" value="two" />
    <input type="submit" value="Post" />
</form>
code:
Array
(
    [foo] => two
    [bar] => Array
        (
            [0] => one
            [1] => two
        )

)

DaTroof
Nov 16, 2000

CC LIMERICK CONTEST GRAND CHAMPION
There once was a poster named Troof
Who was getting quite long in the toof

teethgrinder posted:

Does anyone have a suggestion for a(n API) documenter? Been messing around with phpDocumenter, but it's kind of low-rent. My boss wants something that looks like Yii's: http://www.yiiframework.com/doc/api/

Unfortunately it looks like Yii's is probably an app using their own framework or something. They released a version for others to create static pages, but it seems to only export the actual framework and nothing from our app. As well it hasn't been updated in two years, and isn't nearly as nice as what they have currently published.

ApiGen looks like it has a lot of potential followed by phpDocumenter2. I've also looked at Doxygen, HeaderDoc, ROBODoc, ThimbleDoc & TwinText.

I think I'm just going to have to beat either ApiGen or phpDocumenter2 into submission.

Zym has a nice template for phpDocumentor that's similar to Yii's design: http://zymengine.com/dev/news/30-phpdoc-extjs-converter-template

DaTroof
Nov 16, 2000

CC LIMERICK CONTEST GRAND CHAMPION
There once was a poster named Troof
Who was getting quite long in the toof

mooky posted:

I want to use it to send notifications to users regarding their account. An opt-in SMS message option.
I don't know if I would ever need a reason to have a dedicated number/address to receive messages but it might help if my users knew the number that SMS numbers would be sent from.

What do you mean by shortcode? php API would be best, even if they don't have a published php library, I can code one myself.

Twilio can give you a dedicated number starting at $1 a month.

A shortcode is a four-to-five-digit number you can use for SMS instead of a phone number, like the ones American Idol uses for voting. They start around $1000 a month.

There's a PHP SDK for the Twilio API. Very easy to use. I got a trial account and had a demo app working in a few hours.

DaTroof
Nov 16, 2000

CC LIMERICK CONTEST GRAND CHAMPION
There once was a poster named Troof
Who was getting quite long in the toof

IcedPee posted:

I don't foresee it being a very big deal.

[...]

Edit: Oh, I guess I'm gonna have to do user accounts and eventually PayPal for transactions, too. I forgot about that.

This seems... familiar. And not in a good way

You're best off mirroring your production environment as closely as possible. If it's a LAMP, set up a LAMP for development. A WAMP might come close enough, but you'll probably run into platform exceptions every now and then.

If you're a big fan of unnecessary cross-platform debugging against a unique production environment and endless futility headaches, go ahead and use IIS.

Adbot
ADBOT LOVES YOU

DaTroof
Nov 16, 2000

CC LIMERICK CONTEST GRAND CHAMPION
There once was a poster named Troof
Who was getting quite long in the toof

Vintersorg posted:

Any recommendations for PDF generation? One of the guys here used to use FPDF but I am reading about TCPDF being a better alternative.

These will basically be certificates they print out plus they think maybe table markers and name tags. So it'll take information from a form and pop it into a PDF document.

I've had good luck generating PDFs from HTML with dompdf.

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