php

Ruby string#crypt in c# and php

I have a ruby client program that encrypts a password with string#crypt like so encrypted = password.crypt(SALT) # removing first two characters which actually are the salt for safety return encrypted[2, encrypted.size - 2] it then sends it to a server for comparison with it's stored pre-encrypted string. how ever I need to be a...

Search in more than one table - give result as one column.

Hey stackoverflow - This is my first question here. I have 2 tables in my mySQLdb. [tab_artist] |id|artist|count [tab_songtitle] |id|songtitle|artistId Im trying to select from both tab_artist.artist and tab_songtitle.songtitle as suggest where searchclause = m I have tried this SELECT artist, songtitle AS suggest FROM tab_ar...

use curl to download indirect image file

I am try to download image files from url from the following code, but it doesn't return the right content from the server. The image can be rendered in browser by loading the url or downloaded using curl in shell mode, but not in php execution. In php execution, the header's content type returned from the server is 'text/html' instead o...

I'm looking for an english language word list

Does anyone know where I could locate an english language word list in the form of a SQL dump? I found a word list online but it's a large plain text file; the words are delimited by a new line character. I tried writing a PHP script to loop through the words and insert them in to the database but quickly ran in to memory issues just re...

PHP: Dealing With MySQL Connection Variable

What is the best way to deal with the $db_conn variable once I create a mysqli object? I've been using $GLOBALS['_sql'] = new mysqli(...); But this seems dirty. The alternative that I've seen is to be constantly passing the connection var to every function that calls it, but that's a huge pain. ...

PHP: Limit a string based on specified character length and number of paragraphs.

Ok so I know limiting strings is fairly easy when it comes to simply truncating and preserving html tags and stuff... but I'm kinda brain%^$%'d when I came to this scenario: I have a div box with a fixed height. I need to limit the strings echoed inside it so that it fits. It does pretty well with preserved html tags and all but it brea...

how can I cache the images coming from other website.

I there a way that i can cache the images coming from other websites? I want to have a local copy of the images using cache in PHP so that the site will load faster. ...

More efficient access to an multi-dim array

I'm trying to nicely output a data array (with Kohana v2.3.4), and am thinking there has to be a more efficient and elegant way to do this. My array looks like this: array('category_id' => value, 'category_title' => value, 'posts' => array( 'id' => value, 'title' => value, ... )) And here's how I'm outputting it in my view (some arr...

Using Abstract classes with PHP

I'm new to PHP, and was trying to create an Abstract class with a mix of abstract and non-abstract methods, and then extend the class to implement the abstract methods. The following is portions of my two class files: <?php require_once 'Zend/Db/Table/Abstract.php'; abstract class ATableModel extends Zend_Db_Table_Abstract { abstra...

PHP - recursive regular expressions

In a project I have a text with patterns like that: {| text {| text |} text |} more text I want to get the first part with brackets. For this I use preg_match recursively. The following code works fine already: preg_match('/\{((?>[^\{\}]+)|(?R))*\}/x',$text,$matches); But if I add the symbol "|", I got an empty result and I don't kn...

(Lightweight) backup strategies for a LAMP application stack?

I'm researching some lightweight tools to backup a LAMP stack. The two most imporatant pieces are the php codebase and the mysql database. I can tar/bz2 the code and a mysqldump and restore it on a new server (if the old one crashes) and this is more or less fine. Anyway, are there more complete solutions to this? e.g. track and...

Live updates using JQuery?

At the moment, I have a Javascript (JQuery) front-end which periodically makes requests to a seperate, PHP script which returns posts. For the sake of efficiency, however, I'd like to simply add new results to the array, not even looking at existing posts. As it stands, I've attempted to do so with times (i.e. "SELECT * FROM table WHER...

PHP spl_autoload

i dont really get the docs for spl_autoload bool spl_autoload_register ([ callback $autoload_function ] ) from my understanding, it will try to run functions registered when php comes across a class not loaded already. so example, public function autoload() { require ('nonLoadedClass.php'); } spl_autoload_register(autoload); $...

Post to Facebook fan page from backend?

I am trying to write a Facebook application that can post to a Facebook fan page (not a user page), using streamPublish. However, I'm having a hard time finding documentation on how to let the backend program stay "logged in" between sessions. I've deduced that it has something to do with the session secret and key, but I've found no goo...

Compare and merge two word documents using php

Hi All, I am doing a project on online medical transcription training. For that we are not allowed the original documents to the users. User must type all the contents he hear and he uploads the documents to the server. Then the Original document will be compared or merged to his edited document and the result file will be downloaded t...

PHP preg_replace non-greedy trouble

I've been using the following site to test a PHP regex so I don't have to constantly upload: http://www.spaweditor.com/scripts/regex/index.php I'm using the following regex: /(.*?)\.{3}/ on the following string (replacing with nothing): Non-important data...important data...more important data and preg_replace is returning: more ...

ServiceLocator and the Open/Closed Principle

I'd like to: Make commonly required services visible to all classes that need them, with a minimum of boilerplate, and without sacrificing testability! It's a small project and I think DI might be overkill, but maybe I'm wrong? Anyhow, I have been focusing on the ServiceLocator pattern as described by Martin Fowler In a client clas...

Twitter Search Results - API / Atom Feed

So I've got somewhat of a cool task and I'm just thinking it over. I'm more a designer so I thought I'd tap into the bright minds on here. I am creating a basic page that displays the results from a twitter search results page. Put simply, I am displaying an atom feed with HTML. I'd like to do it with PHP, unless someone has something b...

how to get confirmation of newsletter that user read it or not

i want confirmation that my newsletter is open by customer or not ...

PHP[OOP] - How to call class constructor manually?

Please see the code bellow: 01. class Test { 02. public function __construct($param1, $param2, $param3) { 03. echo $param1.$param2.$param3; 04. } 05. } 06. 07. $params = array('p1','p2','p3'); 08. 09. $ob = new Test; 10. 11. if(method_exists($ob,'__construct')) { 12. call_user_func_array(array($ob,'__construct'),$...