php

How to check if a given value is a valid URL

I need some function to check is the given value is a url. I have code: <?php $string = get_from_db(); list($name, $url) = explode(": ", $string); if (is_url($url)) { $link = array('name' => $name, 'link' => $url); } else { $text = $string; } // Make some things ?> ...

PHP / JS image creation

I'm wondering if this is possible: user uploads a picture which is then presented to him in the browser. The image is placed inside a div that has predefined image as background. User can drag and drop his uploaded image inside the boundaries of this div. It would be something along the lines of uploading a pic of yourself and then pos...

native functions overweight in xdebug profiler output

hi i have a problem with xdebug on a FreeBSD server. on that server xdebug profiler's cachegrind files say that executing time of native functions (such as DOMDocument::load() or XSLTStylesheet::importStylesheet) is about 50% of total script execution time. and with profiler turned off those functions work for less than 0.1% on my own ...

Magento email template format date of invoice

Hi, I'm trying to apply the german format of a date to a Magento email. I can get the invoice date with {{var invoice.created_at}} but that gives me "2010-05-21 15:46:24". I would like to have 21.05.2010 and PHP doesn't work in the templates. I'm totally new to Magento so please be patient :-P Greetz Spanky ...

PHP CURL saving multiple XML url links ?

I'm trying to save 3 XML url links to write to local xml cache copy of them. But 2 of the XML url links with parameters passed after ? aren't saving at all ? only allteams.xml gets saved into multicache folder while other 2 urls don't get saved ? there must be a better way to do this ? <?php $urls=array( 'http://remotedomain.com/api/...

Understanding <?php print $node->content['body']['#value']; ?> in Drupal

Hi, sorry, this is a really noob question... When I want to print part of the $content array within node.tpl.php (for example), I'll use something like <?php print $node->content['body']['#value']; ?> I just want to understand what the -> is all about. Presumably this indicates that $node is something other than a normal array? ( Othe...

PHP read XML properties

I have the following XML data which is generated by a webservice <?xml version="1.0" encoding="UTF-8"?> <rsp xmlns="http://worldcat.org/xid/isbn/" stat="ok"> <isbn oclcnum="263710087 491996179 50279560 60857040 429386124 44597307" lccn="00131084" form="AA BC" year="2002" lang="eng" ed="1st American ed." title="Harry Potter and...

How should I pass a MySQL database link to a class in PHP?

Hey all, I'm trying to make a small CMS for fun but I'm getting caught up on some semantics with OOP. I have a basic database class and then I have an administrator class. The admin class has to make database queries, so what I've been doing is having the admin class extend the db class and then passing the link to the db resource via c...

How do I find the 1st and 3rd columns from a 3byX grid

I have the following foreach foreach( $array as $v ) { if( SOME LOGIC HERE ) $class = "first"; if( SOME LOGIC HERE ) $class2 = "third"; print '<span class="$class $class2">$v["name"]</span>'; } I want to set $class1 to be 'third' for every 1st, 4th, 7th, 10th (3n - 2) and $class2 to be set to 'third' for 3rd, 6th, 9th...

Can I use external PHP scripts in wordpress?

Hi I'm new in wordpress. I want to create a website to display my product stocks. An I want to use wordpress to maintain the content of the website. I was wondering is there any way of using my own PHP scripts to access my 'product database' information within from WP and display them. Bascially, wordpress will use it's own database f...

What's the best method to protect login cookie data in PHP?

I'm creating a login system in PHP, and I want to know how to best protect the user information string in my cookie. I was thinking of encrypting the string with a key somehow? Is this the best way? I'm kinda new to this. Thanks in advance. ...

Doctrine Join DQL

I's like to do a join between 2 tables on a specific ID. At the moment, I have this DQL: $q = Doctrine_Query::create() ->select('e.*, i.itemName, i.itemtypeId') ->from('Model_EventItem e') ->leftJoin('Model_Item i ON e.itemId = i.itemId') ->where('e.eventitemId = ?', $event->eventId) ->orderB...

How to call a php function within <script> tag from coldfusion 9

I have this nice big Dev Kit written in PHP, but the application I'm currently developing is in CFML. In an attempt to avoid rewriting the PHP, I'm going to try to just wrap the PHP in CF <script> tags and call the PHP functions when I need them. Does anyone have any idea how to call one of those PHP functions inline in CF? ...

How to encrypt fields in XML document with PHP and RSA / Triple DES

I am developing an application for schools in South Africa which is required to submit data in XML format to the State IT Agency for statistical processing. I am currently generating the XML files using PHP's DOMDocument class. My files have gone through a first stage verification process. The next stage is to implement encryption and c...

POST a file string using cURL in PHP?

I was wondering if it is possible to post a file - along with other form data - when the file is just a string? I know that you can post a file that is already on the filesystem by prefixing the filepath with "@". However I'd like to bypass creating a temporary file and send just the file as a string, but I am unsure how to construct t...

append quotes to a variable

Hi Guys, I've got a variable in a php function of mine which is passed into a SQL query. I'm wondering how do I append " and " either side of it without actually turning it into a string? Thanks. ...

How to remove extra <p> in WordPress?

I'm new to wordpress and currently developing a theme on it. I have noticed that Wordpress adds <p> tags all over the page. Do you know any plugin or a workaround to avoid this? ...

Error returning a valid object back from viewSubscription() from php soap request

Hello, I am trying to connect to Yudu's web service via soap/php. When I send this test, I am getting the following fault response and code: ERROR: env:Server-java.lang.RuntimeException: com.yudu.webservice.InternalError If I dont specify a subscriptionId I get the following fault: Client-SOAP-ERROR: Encoding: object hasn't 'subscrip...

PHP, jQuery, selecting all divs within the parent div

I am looking for a generalised selector function that does the following: $(".data").click(function(){ //insert proper selector )}; <div class="one"> <div class="data">text</div> <div class="data">text</div> <div class="data">text</div> </div> <div class="two"> <div class="data">text</div> <div class="data">text</div> <div class="d...

Using mod_rewrite to hide .php from the end of URLs

I've got a site where all the pages are php scripts, so the URLs end .php. I've added the following to a .htaccess file, and I can now access the .php files without the .php extension: RewriteEngine On # Turn on rewriting RewriteCond %{REQUEST_FILENAME}.php -f # If the requested file with .php on the end exists RewriteRule ^(.*)$ $1...