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
spiritual bypass
Feb 19, 2008

Grimey Drawer

waffle iron posted:

At least it's not as bad as storing PHP in a database and then eval'ing.

That sounds like a great prank, but I'm sure someone's done it in a real application. :psyduck:

Adbot
ADBOT LOVES YOU

spiritual bypass
Feb 19, 2008

Grimey Drawer
The posting URL needs to point to a WSDL document; where I work, our customers give us URL's that look like this

http://soap.example.com/post.asmx

but what you want is

http://soap.example.com/post.asmx?WSDL

That might not be what's going on with you, but it's gotten me plenty of times.

spiritual bypass
Feb 19, 2008

Grimey Drawer
I hate to sound rude, but you might need to do a little reading about database normalization before you go much further. The issue of putting 'army' and 'navy' in different tables will become clear, you'll prevent lots of headaches, and the project will turn out better.

spiritual bypass
Feb 19, 2008

Grimey Drawer

J. Elliot Razorledgeball posted:

Can I install pdo_mssql on a PHP 4.x Linux installation?

At work I use MSSQL on Linux with PHP5 and I had to compile my own package. It's a huge pain.

spiritual bypass
Feb 19, 2008

Grimey Drawer
I've never even used PHP4 before, but I followed these instructions which helped me a great deal.
http://panthar.org/2006/06/15/php-with-mssql-on-ubuntu-606/

spiritual bypass
Feb 19, 2008

Grimey Drawer
I don't know what exactly is causing that, but if I was typing it then it would look like
code:
DELETE FROM spaces.stores st WHERE st.id = 4
I wish I could provide a better explanation, but your syntax just looks wrong to me.

spiritual bypass
Feb 19, 2008

Grimey Drawer

KarmaticStylee posted:

are there any programs or websites out there that can scan large php application files such as cakephp or wordpress for lines that send third parties sensitive information?

i know a fresh download of wordpress is fairly safe but other apps are harder to trust.

That's a very complicated task. I recommend running a test environment and sniffing the packets that come from it.

Or I could say something about reading the code yourself or using code that comes from a trustworthy source.

spiritual bypass
Feb 19, 2008

Grimey Drawer
I'm not too sure about what you already wrote, but how about using the backtick (`) to execute a command and use its results? As in `ls /home/royallthefourth/porn`

Anyone see any problems with that approach?

spiritual bypass
Feb 19, 2008

Grimey Drawer

VerySolidSnake posted:

won't that just open tons of connections to the database? Shouldn't there be a more efficient way to do this?

You could try using a database abstraction layer. I use MDB2 and its singleton ability.

spiritual bypass
Feb 19, 2008

Grimey Drawer

eHacked posted:

php 4

Don't do this to yourself. Anything before PHP5 is junk.

spiritual bypass
Feb 19, 2008

Grimey Drawer

Munkeymon posted:

That shouldn't have anything to do with php.ini. Forum data like posts and users ought to be stored in a database somewhere. The setting pointing it to said database would most likely be in a file in the forum software itself.

php.ini does have settings that affect DB interaction. I've had MSSQL date format (in php.ini) cause headaches on a Symfony app that took days to figure out.

spiritual bypass
Feb 19, 2008

Grimey Drawer
Did you check the permissions on those files? Do you just need to copy them in from another directory?

spiritual bypass
Feb 19, 2008

Grimey Drawer
What is this called?
I use it fairly often and I'd really like to have a name for it.

"<<<"

php:
<?php
$s = <<< text
THIS IS A BUNCH OF TEXT

MY FORMATTING IS PRESERVED ACROSS LINES
text;
?>

spiritual bypass
Feb 19, 2008

Grimey Drawer

Treytor posted:

Is there any way to pass a variable from one page to another within PHP without it being visible to the end user or using a database?

Write to a temp file?

spiritual bypass
Feb 19, 2008

Grimey Drawer
Any time I'm writing a regex, I test it in my browser first. This thing is pretty slick.
http://regexpal.com/

spiritual bypass
Feb 19, 2008

Grimey Drawer
Anyone ever use dtrace with PHP? If it works well, I may just switch our servers over to Solaris.

spiritual bypass
Feb 19, 2008

Grimey Drawer
GNUPlot makes nice graphs in a reasonable time frame. I used it plenty in college and enjoyed it. The website is ugly, but the graphs are actually pretty good.

spiritual bypass
Feb 19, 2008

Grimey Drawer
What do you get from print_r($_FILES)? Your upload is probably not doing what you're expecting.

spiritual bypass
Feb 19, 2008

Grimey Drawer
I think I've found it

php:
<?php
$file "temp/" $imagepath//This must be a typo
?>
I should be working on programs at work, but I'm doing this instead. Talk about low morale

:smith:

spiritual bypass
Feb 19, 2008

Grimey Drawer

Safety Shaun posted:

I'm messing around with the Google Maps API and Google's Latitude and wondered how I would construct a regex to return only "latitude_e6=[NUMBERS-INCLUDING-MINUS-SIGN]&longitude_e6=[NUMBERS-INCLUDING-MINUS-SIGN]" from the fopen() results. Possibly even throw those values into their own variables.

Thank you in advance

http://www.php.net/manual/en/function.parse-url.php

spiritual bypass
Feb 19, 2008

Grimey Drawer
What does the file look like?

spiritual bypass
Feb 19, 2008

Grimey Drawer
I'm pretty sure parse_url will do this without any need for regexes. It doesn't actually need to be a URL, it'll take anything formatted key1=value1&key2=value2

spiritual bypass
Feb 19, 2008

Grimey Drawer
I'm trying to get the output of a shell command and it's only returning the first element of a long output.
php:
<?php
$output shell_exec('pwgen');
print($output);
?>
only gives me something like
code:
mohD1ahj
instead of
code:
ohbePh6d aCi3ouz1 xee2uSoh Cha6niLi EbieD1wu Aim9oruJ AhM1ni2e Fahm9Yah
Seo4agh0 eeZ0eiSh Zai8eigh EiNu9aid noBaig6I aiS7biel ieQu9eh9 nae7AhTh
eeshooY7 Oov0eree aew7Sho2 eeha2aiF baut1Oph tooj9niB Xohph4ki Kath4ih9
ShohF7Da FeiGe5ei yohYee5o Lu7oota8 vohRat7e xeeZei4i eB8aht9o Eeghue1G
Is there a way to make shell_exec give me the correct output or do I need to make some crazy workaround with temp files?

spiritual bypass
Feb 19, 2008

Grimey Drawer

ShoulderDaemon posted:

Manpages are helpful!

Thanks for the tip. I thought I knew how to use the program, but I certainly wasn't expecting this. I don't often write programs that interact with the shell; is this sort of changing behaviour common?

spiritual bypass
Feb 19, 2008

Grimey Drawer
No, passthru still behaves the same way.

spiritual bypass
Feb 19, 2008

Grimey Drawer
You could load them into an array and then use array_search.

spiritual bypass
Feb 19, 2008

Grimey Drawer

Hammerite posted:

How about a way to use prepared statements that doesn't use any object-oriented notation? i.e. no -> and no ::

Why?

spiritual bypass
Feb 19, 2008

Grimey Drawer

Hammerite posted:

I would like to be able to say that object oriented notation appears precisely nowhere in my site's scripts

royallthefourth posted:

Why?

spiritual bypass
Feb 19, 2008

Grimey Drawer

karma_coma posted:

Let's pretend I've been writing PHP for a decade now. Let's also pretend that almost none of it has been OOP. Let's then pretend that I want to learn OOP. Is there a great tutorial/book/etc that will point me in the right path?

I can use PEAR classes and poo poo with no problems.. I just want to write my own :(

If you want to learn OOP, PHP is not the best language to learn it in. I've messed around with Ruby a little and it seems to be a nice language with a better take on OOP. In PHP, it's more like there's a set of OO features rather than it being an OO language from the ground up.

Once you understand OOP, learning how to do it in PHP won't be a problem.

spiritual bypass
Feb 19, 2008

Grimey Drawer
If you wanna be clever and make something horrible, you could define functions called red(), green(), and blue() and then call them as $color().

spiritual bypass
Feb 19, 2008

Grimey Drawer

supster posted:

jesus did you really just suggest that?

I noted that it's horrible.

The bullshit I maintain at work has this all over the place. It makes the code nearly impossible to trace!

spiritual bypass
Feb 19, 2008

Grimey Drawer

Hanpan posted:

I appreciate the response, but optimizing is what I enjoy most about coding PHP. This is more of a hobby project more than anything, so I want to make sure I am doing things in the best possible ways so I know how things should be done.

The way things should be done
  1. Plan what you want the computer to do
  2. Make a flowchart of it (or anything with a rigid structure)
  3. Transform that into code
  4. Make note of all the bugs
  5. Fix all the bugs
  6. Make it faster (but only if it's too slow)
Seriously, don't worry about speed until it's too slow. For most applications on modern desktops and servers, it's never even an issue.

spiritual bypass
Feb 19, 2008

Grimey Drawer
PHP doesn't interact with the browser; people just use PHP to generate HTML.

If you want to do something to change the behavior of the page, use HTML, CSS, and JavaScript.

You'll want to head over to the JavaScript thread and ask there, but I'll say right now that I doubt it's possible outside of Flash (which is a poison to the web).

spiritual bypass
Feb 19, 2008

Grimey Drawer
I like NetBeans and xdebug. You'll need authority over the webserver you're working with, so I recommend running your project locally.

Also, print_r all over the place.

spiritual bypass
Feb 19, 2008

Grimey Drawer

josh04 posted:

Speaking of which, what's people's opinion around here with regards to netbeans? I'm a big fan, it's so much less effort than eclipse was to set up and use, but I'm told it's less powerful.

EDIT: For PHP development, obviously.

I love NetBeans for PHP, but I find it also does great stuff for Java, C, and Ruby. I don't like to use it as a database frontend, though.

I also love the CSS editor and the JavaScript hints that tell you about browser compatibility.

spiritual bypass
Feb 19, 2008

Grimey Drawer
I don't know what to tell you about the database itself, but the classes sound like a task for the decorator pattern.

spiritual bypass
Feb 19, 2008

Grimey Drawer
You could use the string-as-function feature to call your PHP code based on a function name stored in the database.

I realize that's horrible, but it's less horrible than storing an entire function there.

spiritual bypass
Feb 19, 2008

Grimey Drawer

hallik posted:

I have a class with a bunch of methods, and comments in front of each method. Is there a way to grab all those comments in a array or something so I can echo them in an API page?

<edit> Just had a friend tell me, use ReflectionClass which is working great. nevermind. :)

Are you writing actual PHPdoc? If not, it's easy to do and you should start doing it.

spiritual bypass
Feb 19, 2008

Grimey Drawer
'x' == 0 evaluates to false. Also, isNumeric() is a good function.

Adbot
ADBOT LOVES YOU

spiritual bypass
Feb 19, 2008

Grimey Drawer

gwar3k1 posted:

You're putting variables in quotes. I imagine it's printing either "$front" or "$dot_separated" instead of the values of those.

Nah, double quotes will use the value of variables you put into them. Single quotes won't, though.

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