php

Strip document root from full server path in PHP

OK, I have defined a PHP constant that points to a file on the server like this: define('SOME_FILE', str_replace('//', '/', str_replace('\\', '/', dirname(__FILE__) . '/foo-bar.txt'))); SOME_FILE will contain a full path + filename which is useble in PHP functions like include, fopen, etc. Now if I want to use this path as an URL in m...

$_GET Variables - How to ensure privacy?

I've written a licensing script for some modifications I release freely, and part of my terms and conditions states that upon installation the modification will send the following information for storing in my database:- Domain Name where the mod is installed Email address of the site owner Modification name Modification version number ...

closing php tag in string stops syntax highlighting

In my vim files, when I have a closing php tag in a string, my syntax highlighting stops at that point Example: <?php ... Everything good up to this point $xml = '<?xml version="1.0"?>'; $foo = 'bar' <-- starting here I loose highlighting to the end of the file ?> I'm running version 7.2.245. anyone have ideas why this happens...

Recover Generated Ids from Multiple Insert Query

I want to execute a query of the form: INSERT INTO table(field1, field2) SELECT field1, field2 FROM table WHERE id IN ( 4, 8, 15, 16, 23, 42 ) Where id is the auto_increment'ing primary key of table. After executing this statement, I want to know what all the new id's that just got generated are. How can I recover this information? I'...

Regular expression to extract data inside an html code php

hello, how can i extract the data inside this html code <dl class="col1"> <dt>Type:</dt> <dd><a href="/browse/102" title="More from this category">Audio &gt; Audio books</a></dd> i need to extract the Audio > Audio books from the html code using regex in php ...

MySQL structure for following multiple content types

I'm building a web app that will (ideally) allow users to follow discussion threads (which are in Q&A format like this site), but also follow other content types, such as firms and schools that have profile pages. (The site is intended to help with professional job-seeking, so the back-end provides a bare-bones profile page for firms, s...

Adding mysql module to php as nonroot

The php on the server is compiled without mysql module so I cannot run mysql_connect in php. I do not have root access. Is there a way for me to solve this problem, perhaps parsing in some files during runtime? Thanks in advance. ...

PHPUnit "Mocked method does not exist." when using $mock->expects($this->at(...))

I've run into a strange issue with PHPUnit mock objects. I have a method that should be called twice, so I'm using the "at" matcher. This works for the first time the method is called, but for some reason, the second time it's called, I get "Mocked method does not exist.". I've used the "at" matcher before and have never run into this. ...

Server Redirect from example.html to script.php?url=example

I have a really convoluted website that I need to work on. I was thinking on creating a single "home" php file that includes the main stuff (menu, sidenav, head, etc) and inserting the content for every page. I already have the content from all the pages separated so I have a duplicate of the site where all the html files have only the i...

How to run Wordpress admin on a different subdomain?

Hello, I have the requirement of running the Wordpress admin over https. We use a cdn to deliver cached content for the site but the cdn cannot accept secure traffic (only one SSL cert per IP allowed, and we run several sites off it). I cannot control redirects for httpS://www.mysite.com/. I would like to have: http://www.mysite.com/b...

convert unix timestmp to date

how to I convert a unix timestamp 1280214000 to human readable date? thanks ...

Zend Framework - Set No Layout for Controller

I have a Controller that I want to use for ajax scripts to call and set session variables, get information, etc. How do I set it so that that particular controller doesn't use the default layout (specifically NO layout) so that it can send XML/JSON messages back and forth? I have an inkling I should use a custom route but I do not know m...

How do I create same username and password at phpBB forum as the username and password already saved

Hi. I have a site where all users need to sign up with username and password. Today I added the phpBB forum to my site. The problem is that users need to sign up for my site and the phpBB form separately. Can I just add to the phpbb_users db with php at the same time as they register for my site? In that case I need to know what kind o...

PHP Code on Separate Server From Apache?

This is something I've never seen done, and I'm not turning up in my research, but my boss is interested in the idea. We are looking at some load balancing options, and wonder if it is possible to have apache and php installed on multiple servers, managed by a load balancer, but have all the actual php code on one server, with the vario...

Smarty check if undefined

i am getting errors if smarty variable is undefined. Here is the code: < input type="text" value="{$data.allKeywords} id='keyId' /> I am getting the error: Undefined index: allKeywords. I know the variable - $data.allKeywords is undefined but should it not ignore it if a variable is undefined? Is there a way to check if it is unde...

How expensive is find('count') in CakePHP?

I have a CakePHP application where I am trying to get a count of how many of each type of post a user has. I am also using the paginate helper to display all the user's posts on their profile. I could: 1) Make a find('all', $conditions) request for all the user's posts then parse that for the counts I need (by going post by post and chec...

kohana 3 + swift mailer

i'm using swift mailer from github for kohana framework 3, on localhost i have no troubles, but when i use it on hoster server it throws an error: Fatal error: Class 'Swift_DependencyContainer' not found in */application/vendor/swift/dependency_maps/cache_deps.php on line 3 how can i bypass it? ...

How to declare many-to-many relationships if the join table is in a different database?

For example, posts table is in db1, categories table and category_post_join table are in db2. How to declare a many-to-many relationship between Post model and Category model? 'categories'=>array(self::MANY MANY, 'Category', 'category_post_join (post_id, category_id)') works only if all tables are in the same database. ...

Uploading images to Remote Server, iPhone

Hello, I would like to take images from library, or camera and upload them to a remote server, where I could then retreieve a URL for each image uploaded. Im looking to get started from scratch. And am looking for some help on where to start. Im need to do this the simplest way, php and mysql. Where should I start?! Also, I rather no...

PHP: fire a 403 or 404 error?

hey guys, fast but weird question. is it possible to kind of force a 403 or 404 error. i have a kind of admin page, where i'm trying to preven hackers from getting into my filesystem on my server. (the path get's delivered over the url and it would be possible to just pass a ../ into it and get up in my filestructure - i know that's not ...