php

What is a good php class for POP and/or IMAP email?

Recommendations please (from experience ideally, but anything is useful). Searching Google gives me too many choices, and I would like to know if there is a good one people use. ...

HABTM relationship on the same table in CakePHP

Hi, I was modeling a social networking style website where people would be able to have other people on their contacts list, i wanted to model this relationship as a HABTM relation on the Same table i.e User, is this a good idea? or is there a better way to do it? ...

Node no longer exists error with Zend_Session

Hi I am having issues with my my sessions using Zend Framework 1.7.6. The problem exists when I try and store an array to the session, the session namespace also stores other userdata. I am currently getting the following message in my stacktrace Fatal error: Uncaught exception 'Zend_Session_Exception' with message 'Zend_Session::st...

If statement

<a href="post.php?id=4&rows=<?php if ($_GET['rows']) echo $_GET['rows'] + 10; else echo "10"; ?>">Expand</a> Can I get this to only return true if the numbers are between 10 and 200? ...

Form input correction & database query- Codeigniter

Hey guys. I'm re-creating a registration for my website using codeigniter. On my previous page I did it in simple php and HTML. Now that I'm trying to recreate it in codeigniter I seem to be running into difficulties. The following code is a function that is called to validate an email address that the user puts in. It is supposed to q...

RegExp to strip HTML comments

Looking for a regexp sequence of matches and replaces (preferably php but doesn't matter) to change this (the start and end is just random text that needs to be preserved) IN: fkdshfks khh fdsfsk <!--g1--><div class='codetop'>CODE: AutoIt</div><div class='geshimain'><!--eg1--><div class="autoit" style="font-family:monospace;"><span cla...

Using PHP date to display weekly dates

I'm not really sure what to call this. But basically I want to be able to have a user click on "Popular Stories from This Week", and it will take them to a page that will have other stuff but mainly the dates. For example, July 10-17. I'm currently using this code: $seven_days_ago = date('j') - 7; $time_span = date('F ' . $se...

PHP and RegEx: Split a string by commas that are not inside brackets (and also nested brackets)

Two days ago I started working on a code parser and I'm stuck. How can I split a string by commas that are not inside brackets, let me show you what I mean: I have this string to parse: one, two, three, (four, (five, six), (ten)), seven I would like to get this result: array( "one"; "two"; "three"; "(four, (five, six), (ten...

PHP Username Password Solution

I am working on my first PHP based website, and I was wondering what solutions were out there for a username/password system? I have tried using a .htaccess file for basic security, and while it works, I want something a little easier for a layman to administer. Are there any other solutions out there that I could try? I don't have a dat...

Looking for ideas on a computer science course project.

Hey. I'm taking a course titled Principles of Programming Languages, and I need to decide on a project to do this summer. Here is a short version of what the project needs to accomplish: "The nature of the project is language processing. Writing a Scheme/Lisp processor is a project of this type. A compiler for a language like C or Pasca...

PHP and MYSQLi - Bind parameters using loop and store in array?

Below is my code for the function I am using to retrieve multiple data from my table, but I would like to use bind_result($array[0],...,..) to be generated automatically depending on number of fields i am selecting in the query. for example.. $query=select a,b,c,d,e from table;//selecting 5 fields ...... $stmt->execute();$stmt->bind_re...

What is another way of outputting data from an array rather than var_dump or print_r?

I'm on a 3rd party software and when I output the data from the array using var_dump() or print_r(), it comes out messy. Anyone know of a way to output the data in a hierarchical format or something more organized (or some script that does it for me)? Thanks! ...

How would you code an anti plagiarism site?

First, please note, that I am interesting in how something like this would work, and am not intending to build it for a client etc, as I'm sure there may already be open source implementations. How do the algorithms work which detect plagiarism in uploaded text? Does it use regex to send all words to an index, strip out known words like...

Could someone translate this to regular PHP?

// Decide which layout to use $oo->layout = ($oo->layout != "") ? $oo->layout : $oo->config->get("DefaultLayout", OO_DEFAULT_LAYOUT); $layout_file = sprintf("%s/%s.html", $layout_path, $oo->layout); // Load the page $oo->page = ($oo->page != "") ? $oo->page : $oo->action; $page_file = sprintf("%s/%s.html", $page_path, $oo->page); if (fi...

Strategy for supporting unicode & multi language in PHP5

Hi, I have heard that PHP6 will natively support unicode, which will hopefully make multi-language support much easier. However, PHP5 has pretty weak support for unicode and multi-language (i.e. just a bunch of specialized string functions). I was wondering what are your strategies to enable unicode and multi-languaage support in your ...

How to apply stripslashes() to all form elements prior to output with Zend_Form

How do I apply stripslashes() to all form elements prior to output with Zend_Form? I have tried: //the filter class lib_filters_Stripslashes implements Zend_Filter_Interface{ public function filter($value){ return stripslashes($value); } } ... ... ... //In the form $form->setElementFilters(array(new lib_filters_Stripsla...

XSS Attacks Prevention

I've found a "database" of many XSS attacks and while this list provides quite a big list of attacks are there are any other attacks that didn't fall in the XML, what to look out for and most unexpected? ...

Allowing PHP to change file and directory ownership and permission

Hi, I'd like to build a simple web app, which manages some directory on a server. I want to give people the option to use chown and chmod. What is the safest way to give PHP this permission? The quickest thing is just running Apache and PHP as root, but that doesn't seem to be a smart idea. One other thing I thought of, was creating a...

Query to be used in the conditions, when space in between the value

Hi! I am using JQuery and CakePHP for my application. I have a table Attributes(id,form_id,label,type) In this table, I have an entry like 1 1 First name Text 2 1 Lastname Text I have written a CakePhp query to retrieve the id given the form_id and the label $attri = $this->Attribute->find('all', array( 'fields'=> array('Attri...

Good study material for C#,JavaScript,PHP?

Hi all, I am a proficient C++/Qt coder, having worked only on desktop projects till now. I wanted to extend my knowledge base into the web realm. In this regard, can some of you suggest good reading material for C#,JavaScript and php? And are there any standards for these languages as there are for C,C++ like ANSI C,C99,C++0x etc. ...