php

Merge entries in CakePHP

Let's say I have a Model, for example User, and I want to merge two instances of this Model, say merge User2 into User1. Explicitly this is what I mean: If a field is already filled in User1, it should remain the same If a field is missing in User1 but is present in User2, it should be copied If SomeModel BelongsTo User, every instance...

How do I prevent access to domain subfolders when hosting two domains using the same webspace?

I have two domains that point to the same root folder of my webspace. My root directory is setup like so: /domain1 /domain2 /shared Where requests to... http://www.domain1.com/* should do an internal redirect to http://www.domain1.com/domain1/* http://www.domain2.com/* should do an internal redirect to http://www.domain2.com/domain...

"Did you mean" feature on a dictionary database

I have a ~300.000 row table; which includes technical terms; queried using PHP and MySQL + FULLTEXT indexes. But when I searching a wrong typed term; for example "hyperpext"; naturally giving no results. I need to "compansate" little writing errors and getting nearest record from database. How I can accomplish such feaure? I know (actua...

file_get_contents("php://input") or $HTTP_RAW_POST_DATA, which one is better to get the body of JSON request?

And from the client side, which request type (GET or POST) is better to use, to send JSON data if I use XmlHTTPRequest? My application use this stream of data for either retrive data form database and execute some functionality in PHP. EDIT: My question was inspired from this answer: http://stackoverflow.com/questions/813487/how-to-pos...

Prevent comment form re-submission

I'm got a comment form for an article and i'd to prevent re-submission. I notice that Worpdress handles this very well (going back doesn't cause the browser to request a form re-submission), but I can't figure out how they do it, even though our methods are very similar. My Script User visits mydomain.com/article/1/article_title.html ...

conditional php help

How can I wrap this entire statement below in a condition? So If the variable $uprice = 0 then I don't want to to display any of the code below <?php if (Mage::helper('weee')->typeOfDisplay($_item, array(0, 1, 4), 'sales') && $_item- >getWeeeTaxAppliedAmount()): ?> <?php echo $this->helper('checkout')->formatPrice($_item->getCal...

Why not use PHP's built-in session handling?

Is there currently - or has there ever been - any serious or significant problem with PHP's built-in session handling? I mean, it's always worked for me and my projects. But I see some codebases and frameworks out there seem to use a custom handler. Is this reinventing the wheel? Or improving on some flaws? What flaws? ...

Where can I found GD compatible fonts?

Hello there! I'm using GD to display some text. The default font is Courier (or something similar)... I want to use another font and I found this function: imageloadfont that requires a .gdf file. I've search on Google to see if I find some nice fonts, but I didn't find anything. I see there's a script to convert a PNG file to a GDF, bu...

Curve-fitting in PHP

Hi, I have a MySql table called today_stats. It has got Id, date and clicks. I'm trying to create a script to get the values and try to predict the next 7 days clicks. How I can predict it in PHP? ...

If exist in array (php)

There are two arrays, that are given for $link from foreach. One time $link must be a first arrow, and a third - the second. So: 1 array: Array ( [width] => 800 [height] => 1142 [hwstring_small] => height='96' width='67' [file] => 2010/04/white-1051279.jpg [sizes] => Array ( [thumbnail] => Array ( [file] => white-1051279-100x150.jp...

spawn an entirely separate proccess in linux via bash

I need to have a script execute (bash or perl or php, any will do) another command and then exit, while the other command still runs and exits on its own. I could schedule via at command, but was curious if there was a easier way. ...

How to access a plugin model from a regular controller in PHP Cake 1.1

Hopefully a simple question: I've a plugin which uses a set of tables (kb_items, kb_item_tags, etc). and I'd like to be able to access these models from another controller (say, my Pages controller), thus: class PagesController extends AppController{ function knowledgebase(){ $items = $this->KbItem->findAll(...); } } I am admitted...

facebook app building locally

is it possible to develop facebook app locally on using facebook php scripts so that the callback url need not be http://abc.com and can be http://127.0.0.1 or something like that i mean can i not use it to build an app locally on my system ...

wordpress sidebar and loop php code distorts each other

Hi, I've edited the single.php to suit my needs and it works. I only left in the part of the loop in in which is as follows: <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <div <?php post_class() ?> id="post-<?php the_ID(); ?>"> <div class="entry"> <?php the_content('<p class="serif">Read the rest of...

Which web application modular structure is better ?

backend/ module1 module2 module3 frontend/ module1 module2 module3 or modules/ module1/ frontend backend module2/ frontend backend module3/ frontend backe...

facebook graph api don´t publish to news feed

hi, im trying to update my news feed on facebook. Im using the new graph api. I can connect to graph, but when i try to publish some content to the feed object, nothing happens. here´s my code: <?php $token = "xxxx"; $fields = "message=test&access_token=$token"; $c = curl_init("http://graph.facebook.com/me/feed"); curl_setopt($c,"...

PHP5 getrusage() returning incorrect information?

I'm trying to determine CPU usage of my PHP scripts. I just found this article which details how to find system and user CPU usage time (Section 4). However, when I tried out the examples, I received completely different results. The first example: sleep(3); $data = getrusage(); echo "User time: ". ($data['ru_utime.tv_sec'] + ...

Find IonCube PHP files

The pSek server hosting company installed 54 PHP extensions for no reason, and while going through the list of unneeded extensions I noticed IonCube, which I want to get rid of quickly. What's a good way to find out if we have any PHP files encrypted with it? ...

PHP programming logic inquiry

Hello there. With the help of this community, I just recently solved some issues with PHPExcel reading multiple files through a foreach(). Now it seems I've got logic issues. I'm reading some excel files and extracting some data from them. This data are student grades. You can check a lightly modified code (I didn't paste it here becau...

Use an instance of an object throughout the site with PHP

Hello Guys, How will I use an instance of an object that is initially loaded throughout the whole site? I want $myinstance to be used everywhere. $myinstance = new TestClass(); Thanks! ...