php

About exec() function and time

I'll show some code, first: echo exec("compile\\save.exe Untitled.c tmpUntitled.c"); I have a program, named save.exe and i want to know if it already stopped? If stopped, ok... Do something... If not, may be an error, or a loop... Now: I want to build same way to control the time that program use, and put a limit (time limit exceed,...

How to change the sequence of 'joins' in CakePHP?

I have the problem with the sequence of joins. The similar problem was in another question http://stackoverflow.com/questions/3343348/manipulating-order-of-joins-in-cakephp. The answer was to use Containable behavior. In my case that is unacceptable because I have deeper associations and containable generates too many queries. Containabl...

How to "hold" the page till submit responses with jquery

Hello, I was wondering if there's a simple way with Jquery to do something while the PHP process called by the forms gives a respond. PS: I'm well aware of the ajax functions to send POST data and on success do something. I'll explain I have a form on 1.php page that points to 2.php (just a script) that either redirects to the 1.php if...

How to obtain all CActiveRecords in yii

I would like to get name of all CActiveRecords in my app, is it possible? ...

PHP: An hour ago, x hours ago

Hi. So i have this function to show the time generated from the inserted unix format timestamp(time()): function get_time($timestamp) { $time = date('G:i', $timestamp); echo " at: ".$time; return $time; } I would like to expand this function and would like to do so if it has been under 24 hours, it should calculate and ech...

PHP url question.

Is there a way I can strip out the variables from a link using PHP for example, if I have a link that reads http://localhost/link/index.php?s=30&p=3 how would I strip out ?s=30&p=3 so my link reads http://localhost/link/index.php ...

Which Platform to choose Ruby on Rails or GWT?

Hi All, I have a need to create a web2.0 application with the following features: UI screens Integrate with a forum framework Integrate a blogging framework with the application Real time chat application (Optional) Integrate with a email server Based on your previous experiences, please suggest good frameworks, toolkits, etc whic...

Is it better to use pure DOM methods or string concatenation to generate a very dynamic xml file?

I basically have to query the database to grab all the active properties, then grab content under each property for sections such as accommodations/experiences, and based on that generate basically a site map. I'm wondering if I should go with using purely DOM methods ( would have me doing a hundred or so createElements, inside of loops...

scrape email addresses

fff.html is an email with email addresses in it some have href mailto links and some don't, i want to scrape them and output them into the following format [email protected],[email protected],[email protected] I have a simple scraper to get the ones that are href linked but something is wierd <?php $url = "fff.html"; $raw = f...

best way to replace a string ?

string '/home/adam/Projects/red/storage/22ff0bc0662bd323891844f6ed342cce2603490ec0_tumb_2.jpg' (length=85) what i need is just http://localhost/storage/22ff0bc0662bd323891844f6ed342cce2603490ec0_tumb_2.jpg what is the best way doing it ? i mean useing strlen ? substr_replace ? substr ? im a bit confused what is the best way doing thi...

What does preg stand for in PHP's functions?

Does anyone know what the preg in preg_match, preg_grep, etc. stand for? I know they use PCRE, which are 'Perl Compatible Regular Expressions.' ...

Is this query injection proof?

I am using PDO to talk to my database, and I wonder if casting a type like this $dbh->query("SELECT * FROM recipes WHERE id=".(int)$id); is sufficient to prevent sql injection? In this case $id is always an integer. I also wonder what would be a good way to prevent an injection in this kind of statement if the variable was a string. ...

Exception not tested with phpUnit?

Hi, I'm writing some unit test with phpUnit to test a Zend Framework application and I've got some issues with testing an exception in the changePassword function. The test doesn't fail, but in the coverage tool which generates html the "throw new Exception($tr->translate('userOldPasswordIncorrect'));" line isn't tested. public functio...

Why does HTML Purifier ignore my runtime created configuration settings?

Hello again, everyone! Naturally I am still fighting with HTML Purifier… So, my /config/purifier.php looks like: <?php defined('SYSPATH') or die('No direct access allowed.'); return array( 'settings' => array( 'HTML.Allowed' =>'a,b,strong,p,ul,ol,li,img[src],i,u,span,', 'HTML.MaxImgLength' => 250, 'CSS.MaxImgLength' =>...

Movable Type: Strange caching (I am super MT noob)

Hi all So, I have been asked to remove a menu item on a website running Movable Type. "No problem", I thought. So I log in, and try to figure out WHERE those damn templates can be edited. I finally find something that looks real, edit it, update the page and NOTHING HAPPENED. I then log in to the FTP and discovers, that ALL pages exam...

How to call php script from C code on Linux

Hi, just wanted to know how to call php script from running C code on Linux and pass a couple of parameters. Thanks ...

Is there something in Kohana similar to CakePHP's requestAction?

I have taken over a Kohana project that needs some modifications. It doesn't really seem to follow the conventional MVC patterns (at least what I've learned from CakePHP). I need to do some dirty hacks to get data from a controller within a view which I would use $this->requestAction(...) in CakePHP. My question is, is there anything si...

php script don't refreshes in browser

Hello. I have the following php code: <?php session_start(); .... $result=$db->query($query); $row=$result->fetch_assoc(); $_SESSION['id']=$row['id']; header('Location: http://www.blabla.com/successLoginPage.php'); php code on: successLoginPage.php <?php session_start(); echo $_SESSION['id']; Here is problem. When i do all things, ...

Insert into two tables from a single form

Insert into two tables from a single form. The first insert go in fine the second generates this error Duplicate entry '0' for key 1 any idea what is happening? $connection=mysql_connect ("localhost", "foo", "bar") or die ("I cannot connect to the database."); $db=mysql_select_db ("database", $connection) or die (mysql_error()); $query ...

Has anyone successfully transfered a CodeIgniter app to Kohana 3.x?

Since they are fundamentally different (PHP4 vs PHP5 based), this could be quite a headache I imagine. I would love to transfer my CI app to Kohana 3, but they only have migration tuts for transferring to Kohana 1.x and 2.x. ...