I'm currently using the following code in my cms to check if visitor is logged in as admin so that he can edit the current page:
if($_SESSION['admin']=="1")
{
echo "<a href="foobar/?update">edit</a>";
}
But I'm worried that the code is unsafe. Can't $_session variables easily be modified by the user?
What would be a safer pra...
We've recently enabled APC on our servers, and occasionally when we publish new code or changes we discover that the source files that were changed start throwing errors that aren't reflected in the code, usually parse errors describing a token that doesn't exist. We have verified this by running php -l on the files the error logs say a...
I'm learning php pdo; my environment is : NetBeans 6.5.1, XAMPP 1.7.0 and I have this code, which it seems to connect.
If I change dbname to a non existent one, it raises exception "db not exists"
If I change user, it raises "login incorrect")
but when I call $cn->query, it raises:
An unhandled Win32 exception occurred in apache...
Hi there,
I've been using a drupal 4.7 installation for many years, and have had a recent problem crop up. That is, the rewritten URLs are now displaying these characters: ?q= in every drupal generated URL as follows: http://sitename.com/?q=path/alias , where before it would be: http://sitename.com/path/alias .
My best guess as to why...
I am using CodeCharge Studio to finish a large PHP application. This question isn't really CCS related, but a bit more general. I have a web form that is supposed to allow CRUD capabilities with a certain SQL Server table, but the Inserts keep failing without throwing any errors. What would be the best way to debug this?
...
I am developing a new project in CodeIgniter (CI), and would like to find a CI solution to this current issue. I've got one image, which resembles a picture frame. I would like for uploaded images to be modified to have this frame in their background.
Example:
The first picture is the frame. The second is the uploaded image (after res...
Hi all,
I have a collection of black and white JPEG's stored on my server. These images are symbol based, where the symbol is a collection of black lines on a white background.
I am trying to use GD to replace the black colour with another colour on the fly based on a variable passed. Currently, I am:
Getting the JPEG as: $image = ima...
PHP was the undisputed king of easy webapp development, until Ruby on Rails, Django, and other dynamic programming frameworks appeared. What are, in your opinion, PHP's strengths against the newcomers?
...
We're looking for someone to help us enhance & maintain our high-quality, php-based prototype of a transactional web app. Ideally, who can communicate well, and do both front- and back-end web development (as well as smart/gets things done, etc.). Among other more general things, I've been using this question:
Given this:
$foo = ...
Hello, i have a hashing algorithm in C#, in a nutshell, it is:
string input = "asd";
System.Security.Cryptography.MD5 alg = System.Security.Cryptography.MD5.Create();
System.Text.UTF8Encoding enc = new System.Text.UTF8Encoding();
byte[] hash = alg.ComputeHash(enc.GetBytes(input));
string output = Convert.ToBase64String(hash);
// out...
I've seen on site like flickr or brightkite, a personnal email is provided to the users.
If the user mail somethin to this adresse, the content is posted on his public profile.
How can I do that on a web application ?
...
Hi,
I've been trying to make this work for the last couple of hours. I have a simple stored proc called get_log_entries:
CREATE DEFINER=`root`@`localhost` PROCEDURE `get_log_entries`(p_min_id INT)
BEGIN
SET p_min_id = IFNULL(p_min_id, -1);
SELECT * FROM db_log WHERE item_id > p_min_id;
END
It's dead simple and it returns results ...
EDIT: the script mentioned in the question, and the other script pointed among the answers, both work just fine with multibyte strings - turned out my problem was elsewhere.
Does anyone know of such implementation? The script at http://phpjs.org/functions/view/469 works well, just not on multibyte strings.
...
Part 1
I want to build a PHP Zend Framework application that users can sign up to use. When they register, I would like the application to create a sub-domain that points to their public page, that serves up content specific to that client.
For example: http://mywebapp.com/username or http://username.mywebapp.com
Update: "Using sub-do...
Lets say I have this code:
<?php
class hello {
var $greeting = "hello";
function hello(){
echo $this->greeting;
return;
}
}
$hello1 = new hello;
$hello2 = new hello;
$hello4 = new hello;
?>
How do I get it to echo all the names of instantiated objects (and if possible their respective class), so that it ec...
I am running into what seems to me to be a bug in the Advantage Database PHP Extension (I know, I know...). I've reported it as a bug, but still haven't heard anything back, so I thought I'd run it by you guys.
Working Code:
for ($i = 0; $i < 100; $i++)
{
$connection = ads_connect( 'DataDirectory=\\some\path\;ServerTypes=2;RightsCh...
I have a interesting problem that I think is server related. I want CSV data to be saved as a CSV file when a user clicks a button. It works fine on my development server, but on the production it just echo's the content to the page. My guess is that it must be a server issue, but I'm really not sure what it could be. Can GZIP affect...
I have a joins table which brings a users table and a Communications table together.
I have the appropriate relationships built in Cake.
When I use 'var $scaffold;' in the controllers everything links up perfect. I can view, add, and edit records in both directions. However, when I remove the 'var $scaffold feature through the Bake conso...
I have a PHP app that creates a CSV file which is forced to download using headers. Here's the relevant part of the code:
header('Content-Type: application/csv');
header("Content-length: " . filesize($NewFile));
header('Content-Disposition: attachment; filename="' . $FileName . '"');
echo $content;
exit();
What I'd like to do is r...
I've got hierarchal data in the database, stored in Modified Preorder Tree Traversal format. I'm pulling the data in a query that looks something like "SELECT ID, Left, Right, Name, etc FROM Table ORDER BY Left;". I'm trying to convert this data from a flat array the DB gives me into a tree-structure which I will then output as JSON wi...