php

How do you get PHP, Symlinks and __file__ to work together nicely?

On my localhost box I have the following directory structure: /share/www/trunk/wp-content/plugins/otherfolders /share/www/portfolio/wp-content/symlink Where symlink is a symbolic link to /trunk/.../plugins/. Basically, this is because I need to test multiple WordPress installs and set them up, but I don't want to have to move plugins ...

PHPUnit: mocking the function

Is it possible to create a mock for the function? UPD1: $class->callback('callback_function'); I've tried to test whether callback_function was invoked once or not. ...

PHP: Possible to access class after page loads via ajax?

I wasn't sure if when a class is instantiated with code in PHP, if is stays in the servers cache where it would be possible to access it with ajax (php file), or if it just dies once the script finishes running. Is it possible to do this with a Keep-Alive connection or something? I know I'm showing my ignorance in web handle, but at th...

Cross-Site Scripting Phishing Through Frames

how we can protect Cross-Site Scripting Phishing Through Frames. ...

jcarousel and database query

hi im using a jcarousel: $(document).ready(function() { $('#mycarousel').jcarousel({ vertical: true, auto: 3, wrap: 'circular' }) }) so it is a circular config , i have a query like this : $sql=mysql_query("SELECT * FROM my_insujets, my_inmessages WHERE my_insujets.insujets_idforum = my_inmessag...

PHPUnit mock objects and method type hinting

I'm trying to create a mock object of \SplObserver using PHPunit and attach the mocked object to an \SplSubject. When I try to attach the mocked object to a class that implements \SplSubject, I get a catchable fatal error saying that the mocked object doesn't implement \SplObserver: PHP Catchable fatal error: Argument 1 passed to ..\A...

Wordpress function to send an email

I'm creating a wordpress plugin and I was wondering if wordpress has any function in its library to send emails? ...

How do you detect what page caused the Internal Server Error?

So, in my .htaccess file I have this ErrorDocument lines: ErrorDocument 500 http://www.example.com/500 Since my server runs multiple websites from the same core files, I just want to redirect all internal server errors to the same processing page. However, my problem is that it doesn't send any information about the page that cause th...

Can you use AJAX to echo out a file for download?

Hi, I wanted to let a user download a file by simply clicking a button. Thing is, the file doesn't actually exist - its just some dynamic content. So lets say: $('a.download').click(function(){ $.post('get.php'); }) and in my PHP: header("Cache-Control: public"); header("Content-Description: File Transfer"); header("Content-Dispos...

Mysql query with multiple ID columns and php

Hi guys. I have 2 joined tables, each one has a primary key column named id. SELECT t1.*, t2.* from t1 join t2 on t1.fk_id=t2.id When I run the query above, both id fields are selected (t1.id and t2.id). My question is, how can I select the correct ID while I am looping through the result set? If I select $result->id, I will get t...

Is there anyway to change default values for php curl options, for a script session or globally?

I'm using a framework which has curl handling encapsulated in the depths of it's class hierarchy. Basically I would like to change the way it does handle curl, without patching the files. It could be ideal if I could change curl defaults globally form outside. In php.ini or in similar way. Any way to accomplish this? ...

What is a "real" programming language?

Recently a teacher said "PHP isn't a real programming language", but only gave, in my opinion, weak justification: It's not compiled. It's scripted. It doesn't run on every platform. Is PHP not considered a "real" programming language? What is a "real" programming language? Must a language be compiled to be taken seriously? Backgr...

How do I check for an ajax request thats taking too long or just died out?

I'm using sajax here and at times my ajax queries seem to die out and theres no way for me to tell if something has gone wrong so I end up with an infinitely running preloader. What do I do? ...

How to share an instance across several php files a-la-Wordpress?

Greetings Everyone, I'm currently using Wordpress as my CMS and leveraging Facebook's Graph API for the user account/registration "stuff". My question is how do I use Facebook's PHP SDK (found here: http://github.com/facebook/php-sdk/), when Wordpress compiles several php files to output a single webpage? In other words, Wordpress' te...

Free to use api to access an sms gateway.

Hello, Im a php developer in need of a free service that offers an api that enables me to send one of my users a simple text message. I have a web app that allows you to receive updates (through sms), much like facebook or twitter when something new happens you get a text message updating you. I dont want to pay to use a service like t...

formatting javascript to be echoed out by php

I am trying to echo out some JavaScript, but I can't get the formatting right I start off by putting the javascript I want to out into a string $javascript = 'onmouseover="this.style.backgroundColor='blue'" onmouseout="this.style.backgroundColor='white'"'; and then echo it out like this $hint="<span $javascript>".$artistname->item...

How to install PHP Kohana framework?

I would like to install Kohana PHP framework. The site is on a shared web hotel. I have tried to follow the instructions on Kohana's website. Downloaded the latest stable realse (3.0.6.2) Unzipped the file to create a kohana directory Uploaded the folder to my shared hosting website. opened the url application/bootstrap.php ...and here...

How To Style Each WordPress Category Page Differently?

I am redesigning a blog, but they want me to style all category pages very differently. Layout and Colors. Further on they want me to design different post pages differently as well. For eg: they have a videos category, and on a video post they don't want the sidebar and want to center the video like theater mode. Is that level of custom...

Flatten array PHP 5 (not found solution in SOF search)

Assume I have arrays like: $arr['foo']['bar']['test'] = 'value'; $arr['noo']['boo'] = 'value'; $arr['goo'] = 'value'; $arr['hi'][] = 'value'; // $arr['hi'][0] $arr['hi'][] = 'value2'; // $arr['hi'][1] I need to convert this, to: $arr['foo[bar][test]'] = 'value'; $arr['noo[boo]'] = 'value'; $arr['goo'] = 'value'; $arr['hi[0]'] = 'valu...

Why is PHP interfering with my HTML5 MP4 video?

I'm writing a web app that serves H.264 encoded MP4 video. In Chrome and Safari, it does this via an HTML5 video tag. In order to control access to these videos, their contents are served via PHP using a really simply mechanism: header('Content-type: video/mp4'); readfile($filename); exit; No matter what I do, the videos will not str...