php

LDAP users list using php

function getUsers() { $process = new process(); $process->s_Host('domain.com'); $process->s_Domain('domain.com'); $process->s_LdapSecure(false); if($process->LdapConn()){ if($process->LdapBind()){ $filter = "(&(&(objectCategory=person)(objectClass=user)"; ...

Optimize PHP function

Hi, I have a function that detects all files started by a string and it returns an array filled with the correspondent files, but it is starting to get slow, because I have arround 20000 files in a particular directory. I need to optimize this function, but I just can't see how. This is the function: function DetectPrefix ($filePath, $...

Error with propel-generate-crud in Symfony 1.0

When I try to generate a CRUD test for a new project I am getting a PHP Warning and a Fatal Error. The errors relate to files that it cannot find, however, I have checked and the files are definitely there. The error text is 'require_once(lib/model/map/QuestionMapBuilder.php): failed to open stream: No such file or directory in c:\webr...

How to improve on PHP's XML loading time?

Dropping my lurker status to finally ask a question... I need to know how I can improve on the performance of a PHP script that draws its data from XML files. Some background: I've already mapped the bottleneck to CPU - but want to optimize the script's performance before taking a hit on processor costs. Specifically, the most CPU-co...

What is the best way to cache files in php?

hi , i'm using Smarty with my php code and i like to cache some of website pages so i used the following code : // TOP of script ob_start(); // start the output buffer $cachefile ="cache/cachefile.html"; // normal PHP script $smarty->display('somefile.tpl.html') ; $fp = fopen($cachefile, 'w'); // open the cache file for writing fwri...

REST vs. RPC

Hello, I'm building my own ajax website and I'm contemplating between REST and RPC. If my server supported Servlets I'd just install persevere and end the problem but my Server doesn't support Servlets. RPC is simpler to code (imo) and can be written in PHP easily. All I need is a database query executer. I'm using the Dojo Toolkit an...

Magento Custom Module, Fatal error: Call to a member function setFormAction()

When I hit my module on this url http://localhost/xxx/index.php/TradeEnquiry I get this error Fatal error: Call to a member function setFormAction() on a non-object in C:\wamp\www\stockdisplays\app\code\local\Stock\Tradeenquiry\controllers\IndexController.php on line 55 Line 55 is this: $this->getLayout()->getBlock('tradeen...

Parse Error in PHP

The following code: <?php if ($_SERVER['REQUEST_METHOD'] != 'POST'){ $self = $_SERVER['PHP_SELF']; ?> Generates this error: Parse error: syntax error, unexpected $end in /home/idghosti/public_html/testground/mma/include/header.php on line 26 What is wrong with my code? ...

Using regular expressions

I am trying to match emails from one of my own sites using a regular expression. Using preg_match_all($pattern,$site,$array) the results I get are duplicate. So for example, using: $pattern = '/[\w-]+@([\w-]+\.)+[\w-]+/i'; I get: Array ( [0] => [email protected] [1] => [email protected] [2] => [email protected] [3] => sales@...

get city state from google map

I'm using google map api for showing location. In that i case i need option to get city sate zip from google map marker. In map , user can move the marker to position it after drag finished it will return the city, state and zip. I have successfully get the lat and lng but how can i get the city , state and zip. please help me as soon as...

Restart Apache from php on windows

I'm making a really simple virtual host administrator in my office intranet (on a windows pc) and I'm trying to restart the apache service from php when a new virtual host is created. But I can't manage to do it, I tried with apache -k restart, httpd -k restart with the system, shell_exec, exec passthru; I also tried using a batch file ...

Google Safe Browsing API Code for PHP?

I've looked around but have been unable to find any classes or sample code (in php) for the google safe browsing api. Would you happen to know where I might find it? G-Man ...

How to access Magento user's session from outside Magento?

Im trying to access the Magento customer session in another part of my website. domain.com/shop/ <- Magento domain.com/test.php The shop itself works like a charm, however im trying to determine within test.php if a customer is logged in, so I can display his name with a link to his cart. Contents of test.php so far: <?php require_o...

PHP classes error

Hello. I have three files: one called sql.php witch has a class db that I use to ease the get results operation from MySQL; one called session.class.php that has class session (extending class db) witch I use to make my basic operations as functions... like check_login function witch I use to check if user is logged in; and another one c...

MySQL - Please help with optimization, I am not sure how

Hi I would really appreciate it if some of you could help optimize my tables, as they currently take extremely long to execute because of the following issues: Main table: game { game_id [PRIMARY KEY] *team_id *stadium_id home_score opponent_score date tour half_home_score half_opp_score attendance ref...

Another PHP Syntax Error

This is the error Parse error: syntax error, unexpected '}' in /home/idghosti/public_html/testground/mma/include/footer.php on line 9 This is the code: <?php } else { error_reporting(0); if (mail($to, $subject, $msg, "From: $email\r\nReply-To: $email\r\nReturn-Path: $email\r\n")) //Message sent! ...

Best practice: JSON/JQuery/Codeignitor with different tabs

I am creating a calendar list system, that has tabbed dates on top, with data listings below it. I think I know how to use JSON and load the data with JQUERY into a div, but I am not sure how to load it dynamically, based on which tab I selected. How would I do this, and what's the best practice? I am using the codeignitor framework. ...

Can anyone explain the following PHP Code ?

Hello Can anyone explain the following PHP Code ? function get_param($param_name, $param_type = 0) { global $HTTP_POST_VARS, $HTTP_GET_VARS; $param_value = ""; if (isset($_POST)) { if (isset($_POST[$param_name]) && $param_type != GET) $param_value = $_POST[$param_name]; elseif (isset($_GET[$...

APC Caching with variable includes

I have been doing some research on APC Caching with PHP and found that conditional includes just don't work. Like: if($a) { include('a.php'); } else { include('b.php'); } My question is: Can I get around this with variable includes? Such as: if($a) { $file = 'a.php'; } else { $file = 'b.php'; } include($file); Wo...

MySQL: How many minutes ago was DB updated?

I need to keep a field in a data-base and update it with a time somehow, then later I need to check that time to see if it was over 30 minutes ago or not, and if not, how minutes left until 30? I am going to be doing this with PHP+MySql can anyone tell me the simplest way to do this? Thanks!! ...