php

Command Line PHP with shell_exec works for root but not others

I have a very simple script that is to test if running a shell_exec (or backtick operator) basically works: #!/usr/bin/php5 <?php echo "This is a PHP script\n"; echo `ls -l /home/stoysnet/`; Unless I run this as root, it always gives me: $ ./foo.php This is a PHP script Warning: _shell_exec(): Permission Denied in /home/stoysnet/f...

PHP - PRE-select drop down option

Using the example at the following URL: http://www.kavoir.com/2009/02/php-drop-down-list.html How can I have that drop down menu pre-select one of the options such as 'Apple'? EDIT: Addition info function showForm() { global $sProduct, $name, $product, $header_file, $footer_file, $form_width, $form_background, $form_border_color, $fo...

do file uploads have to be store before virus scanned?

Quick question guys, I am trying to configure a virus scanner to scan file uploads by users and am just curious whether they must be stored on the server before being scanned or if you can scan before saving the file? I am running apache on linux with php. Any advice appreciated. ...

codeigniter and OOP general question regarding calling functions, and the parent constuctor

Ok so I have some gaps in my understanding of PHP OOP, classes and functions specifically, this whole constructor class deal. I use both Zend and CI but right now Im trying to figure this out in CI as it is less complicated. So all Im trying to do is understand how to call a function from a view page in code igniter. I understand that m...

zend framework version trouble

Hi, am 100% sure I downloaded and extracted version 1.8 of ZF, but then when I go to console and typed "zf show version" it says am using 1.9.6, yes I do have 1.9.6 but it is "Compressed" and untouched, how could this be possible ?, I double checked my system variables, there's no evidence of ZF there. I also checked my php.ini file, it'...

WHERE clause confusion with PDO

I'm having some trouble understanding how to use prepared statements, when you need to match one value against several columns at once. In other words what instead of doing this: $stmt = $dbh->prepare("SELECT * FROM REGISTRY where name = ?"); $stmt->bindParam(1, $name); I wanted to do this: $stmt = $dbh->prepare("SELECT * FROM REGI...

How do I identify an OpenID provider as requiring Directed Identity?

I am trying to extend the LightOpenID PHP library to "discover" that an identity provider requires Directed Identity. This should be easy as the library is beautifully well written and wonderfully clean but I don't know how to identify these types of providers. A couple things I've tried: I looked through the OpenID specs on the subjec...

What does this PHP (function/construct?) do, and where can I find more documentation on it?

Simple question. Here is this code. $r = rand(0,1); $c = ($r==0)? rand(65,90) : rand(97,122); $inputpass .= chr($c); I understand what it does in the end result, but I'd like a better explanation on how it works, so I can use it myself. Sorry if this is a bad question. If you're unsure of what I'm asking about, its the (...

Selecting from 2 tables in a single query

I have a table that I'm querying for value 43 in the second field and I return the value of the third field SELECT t1_field3 FROM table1 WHERE t1_field2=43 this returns 19, 39,73 t1_id t1_field2 t1_field3 ----- --------- --------- 1 43 19//// 2 43 39//// 3 ...

PHP secure logon script - md5 hash is not matching the hash i wrote to the database in a previous script?

I am trying to cobble together a login script in PHP as a learning project. This is the code for my database write when the user registers. Both of these values are written to the database. $this->salt = md5(uniqid()); $this->password = md5($password.$salt); Upon logging in, the following function is fired. function challengeLogin...

Importing a large delimited file to a MySQL table

I have this large (and oddly formatted txt file) from the USDA's website. It is the NUT_DATA.txt file. But the problem is that it is almost 27mb! I was successful in importing the a few other smaller files, but my method was using file_get_contents which it makes sense why an error would be thrown if I try to snag 27+ mb of RAM. So how...

Pear HTML BBcode Hyperlink

Has anyone used the PEAR HTML BBcode Package? I don't really understand why hyperlink target _blank does not open a new tab in firefox. SQL INSERT Snippet (string) [url=http://site.com t=_blank]Link[/url] PHP Require PEAR require_once 'HTML/BBCodeParser.php'; $options = @parse_ini_file('BBCodeParser.ini'); $parser = new HTML_BBCo...

Convert string to variable in PHP?

Hey guys, How do I go about setting a string as a literal variable in PHP? Basically I have an array like $data['setting'] = "thevalue"; and I want to convert that 'setting' to $setting so that $setting becomes "thevalue". Thanks for any help! ...

Command Line arguments - PHP

Am trying the following php script which finds out the maximum between 2 numbers, it accepts the arguments through command line. I check whether the input is provided right, based on the number of command line arguments. <?php function larger($arg1,$arg2) { return max($arg1,$arg2); } if($argc > 3 || $argc < 3) print 'Invalid Arg...

php preg_match pattern to extract a specific information, regex

I need to extract a specific Id from a html document but the problem is that the id must not "be used". Here is the html content http://pastebin.com/wF2dx8JZ As you may see there are different html blocks . Some of them contain the "Used" word so I need to extract only the first id which is not used. Basically I can write a simple p...

Is it possible to parse and apply patch files in PHP?

The idea is to have a PHP script parse a given .patch file and will apply the given patch accordingly. Assume that the script has no access to command line so the script will have to do the parsing itself. Is there a library somewhere? ...

Frontend Intertag Communication

Hey all, I've had a question that I've been wondering for a while. I'm making a templating system for front-ends where tags are interpretted (like Smarty). I was wondering if there is value in having the tags be able to communicate with the HTML document and other "Smartyish" tags. I was hoping that the community would have some thought...

Pinging CS Servers

Hello, This has been bothering me for awhile, can some one show me how to ping a counter strike server. I just want to ping the server and see if it is online, thats all. I found many small snippets online that were using fsock and UDP to do this but none of them actually did the job i wanted it to do. Most of the ones i found were s...

PHP Modify the return of a loop over and over.

Basically I want to do a php loop that base64_encodes its self 5 times. //For example i want to encode "test" which is "dGVzdA==" then we encode "dGVzdA==" which is "ZEdWemRBPT0=" then encode "ZEdWemRBPT0=" which is "WkVkV2VtUkJQVDA9" I can't figure out how to create a loop that modifies its self each time it runs. // this is what i h...

Community based translating system

Since we don't funds to hire translators for getting multiple languages translated we want the community to do the translation for us. Its a social network. I can't find any good open souce framework to auto do this. Thinking something like: User selects a language, system displays random sentences and user will translate it. Then other ...