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
Treytor
Feb 8, 2003

Enjoy, uh... refreshing time!

jasonbar posted:


php:
<?php
// your html
ob_end_flush(); // note that you need not call ob_start()
flush();
sleep(5);
?>


This is working perfectly, thank you!

Now to answer your question as to what I am doing, exactly:

http://www.ecarddialer.com

Thanks again!

Treytor fucked around with this message at 11:55 on Jul 23, 2008

Adbot
ADBOT LOVES YOU

Dirk Pitt
Sep 14, 2007

haha yes, this feels good

Toilet Rascal
I need to find a library that allows for the creation of php to pdf on the fly. So far I have found fpdf.org and tcpdf.org to be the best, does anyone have any experience with either library? The built-in pdf support in php5 is not good enough for what i need to create. thanks!

Stephen
Feb 6, 2004

Stoned

Dirk Pitt posted:

I need to find a library that allows for the creation of php to pdf on the fly. So far I have found fpdf.org and tcpdf.org to be the best, does anyone have any experience with either library? The built-in pdf support in php5 is not good enough for what i need to create. thanks!

I've used the ezPDF extension with PHP before and it wasn't too terrible. You may want to check that one out too.

bt_escm
Jan 10, 2001

Dirk Pitt posted:

I need to find a library that allows for the creation of php to pdf on the fly. So far I have found fpdf.org and tcpdf.org to be the best, does anyone have any experience with either library? The built-in pdf support in php5 is not good enough for what i need to create. thanks!

domPDF will take an html page formatted with css2.1 and convert it to a pdf. It's really nice and it's free.

http://www.digitaljunkies.ca/dompdf/

Druck
Jul 25, 2002

"That's some kinda nice."
I made a friend of mine a WordPress site a few weeks ago, and on the site he has some news articles as well as original posts. I'm trying to figure out a way to have all the original posts on the home page, and all the news articles on a News page. I have all the news posts in the category "news" as well as the tag "news" and I can get all the original posts on the home page by using this code:

code:
<?php {query_posts("cat=-3");} ?>
Category 3 is news, so by doing that I get only original posts on the main page. However, I can't seem to create another page that acts just like the home page with the only difference being that line of code changed to a 1 instead of a 3. This seems like it should be real simple to do, I just can't figure it out. Any ideas?

jimbroof
Sep 4, 2003

my wife drew this for me :]
EDIT: Fixed - moved the "AddType" commands into the mime type section, apparently the guide I read was incorrect.

So i'm trying to set up php5.2.6 and apache 2.2.9 on my win xp sp2 box. I'm able to get apache running, but when I try to access a php file it returns a blank page (blank as in nothing in the source).

I have the following lines in my httpd.conf:


code:
<Directory "C:/Program Files/Apache Software Foundation/Apache2.2/cgi-bin">
    AllowOverride None
    Options None
    Order allow,deny
    Allow from all
</Directory>
AddType application/x-httpd-php .php .phtml .php3 .php4 .php5
AddType application/x-httpd-php-source .phps
code:
#BEGIN PHP INSTALLER EDITS - REMOVE ONLY ON UNINSTALL
PHPIniDir "C:/Program Files/PHP/"
LoadModule php5_module "C:/Program Files/PHP/php5apache2_2.dll"
#END PHP INSTALLER EDITS - REMOVE ONLY ON UNINSTALL
Am I missing something? Is there something else I need to have running to parse php?

TIA

jimbroof fucked around with this message at 03:02 on Jul 29, 2008

Zorilla
Mar 23, 2005

GOING APE SPIT

WHORENDOUS posted:

Am I missing something? Is there something else I need to have running to parse php?

TIA

In my experience, The CGI version of PHP 5 has always had a problem installing for me in IIS 6 that I tracked down to long paths with spaces in them. What happens when you try to install PHP to C:\PHP ?

jimbroof
Sep 4, 2003

my wife drew this for me :]

Zorilla posted:

In my experience, The CGI version of PHP 5 has always had a problem installing for me in IIS 6 that I tracked down to long paths with spaces in them. What happens when you try to install PHP to C:\PHP ?

Same thing :/

Jam2
Jan 15, 2008

With Energy For Mayhem
I am catching my rear end to enable the gd library in php5.

extension=php_gd2.dll is uncommented.

Apache has been restarted several times since.

Is there anything else that needs to be done to get the gd library enabled? Do I have to change anything in Apache?

Here's my phpinfo: http://dev.babaya.net/test.php

Jam2 fucked around with this message at 00:08 on Jul 30, 2008

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

:dukedog:

Jam2 posted:

I am catching my rear end to enable the gd library in php5.

extension=php_gd2.dll is uncommented.

Apache has been restarted several times since.

Is there anything else that needs to be done to get the gd library enabled? Do I have to change anything in Apache?

Here's my phpinfo: http://dev.babaya.net/test.php

Is there a specific error message and did you compile it with GD enabled?

Jam2
Jan 15, 2008

With Energy For Mayhem

drcru posted:

Is there a specific error message and did you compile it with GD enabled?

Problem solved. the gd.dll was not in the extension folder. Copied it across and it worked.

Also:

Where should extensions be held?

I read a guide on php that said c:\win\system32. Shouldn't they be kept in c:\php5\ or does it just depend on each individual installation?

Zorilla
Mar 23, 2005

GOING APE SPIT

Jam2 posted:

Problem solved. the gd.dll was not in the extension folder. Copied it across and it worked.

Also:

Where should extensions be held?

I read a guide on php that said c:\win\system32. Shouldn't they be kept in c:\php5\ or does it just depend on each individual installation?

This is a bit fuzzy in my head, but I think extensions only end up in c:\windows\system32 if no other path is specified in php.ini. By default, isn't it usually set to C:\PHP\ext or something? Maybe that's only if you use the MSI installer.

arkiteKt
Jan 2, 2006

I am an obese homosexual who uses a scooter!
I'm building a small comment system for a website and currently using PHP / XML / jQuery framework.

When someone posts a comment, I'm doing an htmlspecialchars before putting it into the database. However, when I grab this data as XML and use jQuery to prepend it to the page, javascript seems to translate back all the special-chars and output them as HTML.

End result: Tags like <a> and </a> are special-char when viewing the database row, but once it gets sent via XML to jQuery and outputted, they go back to <a> and </a>.

1) Is htmlspecialchars the best way to prevent against script/link injections?
2) Any fix to this (some sort of htmlspecialchars for jQuery?)

Thanks!

Zorilla
Mar 23, 2005

GOING APE SPIT

arkiteKt posted:

1) Is htmlspecialchars the best way to prevent against script/link injections?
2) Any fix to this (some sort of htmlspecialchars for jQuery?)

Thanks!

1) It seems ok. Also, if you have any queries that involve user input, make sure they're properly escaped.

Somebody else recommended to me before that you should probably store inputs into the database as purely as possible and then encode them upon reading them. (With XML, use CDATA blocks to store things like < and > in a way that doesn't conflict with the XML structure)

2) This is AJAX, right? I'm assuming you're retreiving the XML with jQuery. According to this, you can use the html() method to encode special characters.

Javascript or jQuery might be responsible for decoding your data on read. The data is encoded in the XML file, right?

Zorilla fucked around with this message at 04:43 on Jul 30, 2008

sonic bed head
Dec 18, 2003

this is naturual, baby!

arkiteKt posted:

I'm building a small comment system for a website and currently using PHP / XML / jQuery framework.

When someone posts a comment, I'm doing an htmlspecialchars before putting it into the database. However, when I grab this data as XML and use jQuery to prepend it to the page, javascript seems to translate back all the special-chars and output them as HTML.

End result: Tags like <a> and </a> are special-char when viewing the database row, but once it gets sent via XML to jQuery and outputted, they go back to <a> and </a>.

1) Is htmlspecialchars the best way to prevent against script/link injections?
2) Any fix to this (some sort of htmlspecialchars for jQuery?)

Thanks!

I don't know exactly but I think you're looking for this:
http://www.w3schools.com/jsref/jsref_escape.asp

arkiteKt
Jan 2, 2006

I am an obese homosexual who uses a scooter!

Zorilla posted:

2) This is AJAX, right? I'm assuming you're retreiving the XML with jQuery. According to this, you can use the html() method to encode special characters.

Thanks for your help, the jQuery docs were down last night and I figured it was something easy like this!

I was using the .html() method to set the html of the <li> element, but simply calling that was having the effect of translating all the special-chars back into html. Using .text() before that call ensures the special-chars stay that way!

Genericide
Jan 20, 2004

Any of you guys work with multi-language sites?
Current system we use is like this:

php:
<?
require_once('translations/thispage_thislanguage.php');
echo $translations['welcome'];
?>
Where translations/thispage_thislanguage.php contains:

php:
<?
$translations['welcome'] = 'Welcome to our site etc etc';
?>
This works, but it leads to repetition of translations, and no way to fall-back to English if the default phrase / language combo isn't available.

Anyone use anything more sophisticated? One thought has been language "packs" that get included in any relevant pages (a downloads "pack", etc), which pulls everything out of a database (bonus: can be updated by non-developers.)

duz
Jul 11, 2005

Come on Ilhan, lets go bag us a shitpost


nikjohns posted:

This works, but it leads to repetition of translations, and no way to fall-back to English if the default phrase / language combo isn't available.

To fall back on english, include the english translation first, then include the alternate language. That way anything missed by the alternate language will have already been assigned by the english pack.

Genericide
Jan 20, 2004

duz posted:

To fall back on english, include the english translation first, then include the alternate language. That way anything missed by the alternate language will have already been assigned by the english pack.

You're quite right, and to clarify: This is already in use on a ridiculous number of pages, so while we could go back and fix it like that, we'd prefer a proper one off solution to make it awesome. Or at least not crap.

minato
Jun 7, 2004

cutty cain't hang, say 7-up.
Taco Defender
Use gettext.

Looks like this:
php:
<?
$some_string = _("Welcome to our site");?>
In a Smarty template (which I highly recommend you use) with the gettext extension, it looks like this:
code:
<h1>{t}Welcome to our site{/t}</h2>
If the translation isn't available or not found, the English version is used.

You'll need to write a script to extract the strings from your code. The xgettext tool already supports extracting them from PHP, but you may need something custom for Smarty.

Unboxing Day
Nov 4, 2003

In the process of creating a CMS Made Simple module, I've encountered a bit of a poser. To test to see if it was something "wrong" with CMSMS or PHP itself, I created a simplified version of my poser:

php:
<?php
// index.php

class Coolio
{
  function Coolio()
  {
    require_once("inc.php");
  }

  function WhatIsIt($string)
  {
    return "<p>WhatIsIt is being called from ".$string."</p>";
  }
}

$nothing = new Coolio();

?>

php:
<?
// inc.php
echo $this->WhatIsIt("Coolio");
SubCoolio();

function SubCoolio()
{
  echo $this->WhatIsIt("SubCoolio");
}
?>

The output of this code is:

code:
WhatIsIt is being called from Coolio

Fatal error: Using $this when not in object context in /home/outpost/workspace/test/inc.php on line 7
I know that I can 'fix' the error by simply passing a $this reference to SubCoolio, but I am curious as to why $this disappears as soon as the function in the include is called. What's happening here?

Unboxing Day fucked around with this message at 22:13 on Jul 30, 2008

Jam2
Jan 15, 2008

With Energy For Mayhem
I would like to put together a team of PHP developers to do develop sites for companies under the management group that I work for. We're based in the Caribbean, and there aren't many good developers available. I'm turning to you guys here on the forums

I want to put together a team of up-and-coming developers/designers to work part-time and long distance for our company. I don't need to see a huge portfolio of work or clientele. Just looking for some people interested in working on some cool projects.

I honestly don't have a handle on the technical side of development (poo poo... it's ALL technical)so I am also looking for an experienced PHP developer-goon to serve as a consultant and/or team coordinator.

Some of the things we will be developing:

-general site design and CMS development
-news site design
-audio streaming (from our two B&M radio stations)
-live voting, interactive apps
-chat apps
-SMF and wordpress customization

All in all, it will be about 6 or 7 web sites within the next year. Some of the sites will be revenue generating platforms and there will be opportunities for equity share.

Also, is this even the right place to post this? If not, where should I put this?

Standish
May 21, 2001

Emo Businessman posted:

I know that I can 'fix' the error by simply passing a $this reference to SubCoolio, but I am curious as to why $this disappears as soon as the function in the include is called. What's happening here?
"require", "include" and their variants do simple text inclusion, so what you've really got from PHP's point of view is:
php:
<?php
 // index.php 
class Coolio 
{   
    function Coolio()   
    {
        // inc.php
        echo $this->WhatIsIt("Coolio"); 
        SubCoolio(); 
        function SubCoolio() 
        {   
             echo $this->WhatIsIt("SubCoolio"); 
        } 
    }   
    function WhatIsIt($string)   
    {     
        return "<p>WhatIsIt is being called from ".$string."</p>";   
    } 
} 
$nothing = new Coolio(); 
?> 
Nested functions in PHP can't see their parent function's scope.

Stephen
Feb 6, 2004

Stoned

Jam2 posted:

Also, is this even the right place to post this? If not, where should I put this?

You'll probably want to make an entirely new thread in this forum for the most responses.

Also, enable your email in your control panel so us losers without premium accounts can send you a message!

G-Dub
Dec 28, 2004

The Gonz

Stephen posted:

Also, enable your email in your control panel so us losers without premium accounts can send you a message!

I'm not sure - would you want someone without a platinum account to work for you? I know I wouldn't

fletcher
Jun 27, 2003

ken park is my favorite movie

Cybernetic Crumb

Stephen posted:

Also, enable your email in your control panel so us losers without premium accounts can send you a message!

Maybe after your first paycheck you can splurge on some platinum and support the forums that helped you get the new job!

Jam2
Jan 15, 2008

With Energy For Mayhem

Stephen posted:

You'll probably want to make an entirely new thread in this forum for the most responses.

Also, enable your email in your control panel so us losers without premium accounts can send you a message!

Email enabled and thread posted:

Assembling a team of up-and-coming developers/designers (Inquire Within)

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



Anyone know what it means when mb_detect_encoding returns an empty string? Clearly it's failing at detecting the encoding, but the drat thing has to have some encoding (and it should be UTF-8). Also, when I try to call mb_convert_encoding on the same strings, I get an error about not being able to detect the encoding type, which sort of makes sense considering the first problem.

minato
Jun 7, 2004

cutty cain't hang, say 7-up.
Taco Defender

Munkeymon posted:

Anyone know what it means when mb_detect_encoding returns an empty string? Clearly it's failing at detecting the encoding, but the drat thing has to have some encoding (and it should be UTF-8).
UTF8 looks identical to ASCII if all the character codes are below 127.

I've found it really hard to reliably detect an encoding. And it doesn't help that some people seem to equate Windows-2352 with ISO-8859-1.

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



minato posted:

UTF8 looks identical to ASCII if all the character codes are below 127.

I've found it really hard to reliably detect an encoding. And it doesn't help that some people seem to equate Windows-2352 with ISO-8859-1.

OK, so does anyone know a better way to find (and corect) the encoding? I think I stopped using utf8_encode because mb_* supported more encodings.

Also:

quote:

Encoding (used by Opera):
iso-8859-1 (windows-1252)
heh

Munkeymon fucked around with this message at 15:29 on Aug 4, 2008

minato
Jun 7, 2004

cutty cain't hang, say 7-up.
Taco Defender
I use a complicated system that involves throwing the text out to this little application that's used in Firefox's test harness. The app's job is to help test the encoding detection of Firefox, you just send it some text via stdin and it tells you what it thinks the encoding is. But apart from requiring the app to shell out to an external program, it requires building Firefox from source with all the test stuff enabled which is a horrible process. Thankfully I don't have to do it very often - just when trying to parse NNTP/mail posts from Outlook which breaks standards by not including the encoding.

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

:dukedog:

I want to keep track of all the places somebody's been on a map in an array (possibly).

What would the best way to store this on MySQL? Note: they may not be visiting these places in order. The places will just be represented by numbers.

I was thinking textfield in the database separated by commas. But that doesn't sound so efficient.

Zorilla
Mar 23, 2005

GOING APE SPIT

drcru posted:

I was thinking textfield in the database separated by commas. But that doesn't sound so efficient.

How big is this project? If you think you can fit what you need inside VARCHAR fields instead of using LONGTEXT, go for it, but unless this project is huge, you probably won't see any performance difference. According to this, it looks like you'd only save 3 bytes of space for data 232 - 1 characters or less if you went with VARCHAR instead of LONGTEXT.

If you're just talking about storing multiple pieces of data in a single field, JSON is probably the way to go since you can make your lists multidimensional if need be and PHP already provides functions for converting these strings to and from arrays.

For instance, one person's data could look like this:

php:
<?
$data = array(
    "name"=>"Joe Blow",
    "locations"=>array(
        "Brockway",
        "Augdenville",
        "North Haberbrook"
    ),
    "didthetripsuck"=>true
);

?>
...and get converted to this with json_encode():

code:
{"name":"Joe Blow","locations":["Brockway","Augdenville","North Haberbrook"],"didthetripsuck":true}
So if you need to store arrays, this is probably the way to go.

Zorilla fucked around with this message at 12:42 on Aug 2, 2008

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

:dukedog:

Thanks but unfortunately we don't have PHP5 installed yet :(.

How crappy and or efficient are serialize and unserialize?

The array may reach up to 375 items per person and map so I'm a little worried about how well it would handle if there are, worst case, 5000 users and 15 maps.

MrEnigma
Aug 30, 2004

Moo!

drcru posted:

Thanks but unfortunately we don't have PHP5 installed yet :(.

How crappy and or efficient are serialize and unserialize?

The array may reach up to 375 items per person and map so I'm a little worried about how well it would handle if there are, worst case, 5000 users and 15 maps.

You can install the JSON stuff through PECL if you want (I believe this will work through PHP4), or ZendFramework has one also.

serialize will work, but then you need to write it out to a file each time. Which will work, but if you have easy access to a mysql db, you should set it up in there.

It could get kind of messy, but you'd have multiple tables.
Users (which contains a users_id, datetime column, place_id, rating, etc)
Places (which contains the places_id, name, location, features about that place, etc)

Pretty easy to join from Users to Places to get your data out, just figure out the user id, select them all out joining on places, ordering by time. If the places are always going to be unique (like long/lat) then you could probably just put that data right in the users table.

Safety Shaun
Oct 20, 2004
the INTERNET!!!1
I'm creating a little quiz script and I'm looking for ideas on how I can ask the database if the answer they have clicked on is correct without transmitting any visable indication in the source that he should click a certain one.

My database fields (that we'll use in this query) are
q_id (Unique ID of that question)
q_question (The question at hand)
q_correcta (The correct answer)
q_seconda (A wrong answer)
q_thirda (Another wrong answer)
q_fourtha (The last wrong answer)

I could transmit the answer back
php:
<?
<input type="button" value="Answer Here">?>
and compare that field to the correcta on submission, but I'm assuming it will start spitting out "wrong answer" messages when the correct answer is clicked if the answer contains certain characters. At the moment the desisn is using one form, with 4 submit buttons but I feel to pass the necesary information on, I'd need to use 4 forms, 4 buttons.

Would I need to have a variable inside each form with an md5 of the answer like so (x4)
php:
<?
<form method="POST">
    <input type="hidden" name="answer" value="xxxxxMD5HERExxxxx">
    <input type="submit" name="Answer1" value="This Is Answer 1"></p>
</form>?>
Can anybody point me in a direction of a simpler solution or clarify that I am indeed heading in the right direction before I over complicate this even more?

jasonbar
Apr 30, 2005
Apr 29, 2005

Safety Shaun posted:

quiz stuff
Does it have to be one button per answer? This seems like a perfect case to use radio buttons for the responses and have one submit button for the entire quiz.

Standish
May 21, 2001

Safety Shaun posted:

I could transmit the answer back
php:
<?
<input type="button" value="Answer Here">?>
and compare that field to the correcta on submission, but I'm assuming it will start spitting out "wrong answer" messages when the correct answer is clicked if the answer contains certain characters.
htmlspecialchars() and mysql_real_escape_string().

G-Dub
Dec 28, 2004

The Gonz
You could just give each answer a value of 1-4 then store in the database what number of answer is correct. Compare the answer to the input, no crazy characters.

Adbot
ADBOT LOVES YOU

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

:dukedog:

MrEnigma posted:

You can install the JSON stuff through PECL if you want (I believe this will work through PHP4), or ZendFramework has one also.

serialize will work, but then you need to write it out to a file each time. Which will work, but if you have easy access to a mysql db, you should set it up in there.

It could get kind of messy, but you'd have multiple tables.
Users (which contains a users_id, datetime column, place_id, rating, etc)
Places (which contains the places_id, name, location, features about that place, etc)

What are your thoughts on just using implode/explode?

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