php

Using preg_match to get filename

We use custom bbcode in our news posts [newsImage]imageName.jpg[/newsImage] And i'd like to use preg_match to get the imageName.jpg from between those tags. The whole post is stored in a variable called $newsPost. I'm new to regex and I just can't figure out the right expression to use in preg_match to get what I want. Any help is ap...

simple php to return an image returns an error

Trying to simply get an image returned. But the following returns an error 'An error occured.' Is it possible I need to configure php on my server differently? if ( isset ( $GLOBALS["HTTP_RAW_POST_DATA"] )) { // get bytearray $im = $GLOBALS["HTTP_RAW_POST_DATA"]; // add headers for download dialog-box header('Content-Type: image/j...

How should I store ftp log on credentials in a MySQL database?

Hey guys, I'm really just looking for some guidance. Here is the scenario: A user can add an FTP account via a password protected control panel. I need to save these credentials so that the FTP account can be connected to automatically. This is easy but I want to take the most secure approach possible. I was thinking of possibly encryp...

MN relationships in Doctrine

ZF has a very nice feature which is called findManyToManyRowset which returns you directly a collection of objects from a MN connection. The whole purpose of MN is to get the information from the other table, not from the connection table. We have this schema: - users - id - name - groups - id - name - user_has_groups - use...

Allow empty file inputs in Zend_Form

I have a simple form accomplished with Zend_Form which is retrieving all its parameters from an XML file. Form has a file input which I need to allow empty submits as well. I mean users should have the chance to leave this field empty. I tried various combinations of allowEmpty and required directives but no help. Below is the XML block...

$_post data not as expected

Hello I am using the following to generate a form: <form method="post" action=""> <input type="hidden" name="group_name" value="<?php echo $user_group ?>" /> <table width="100%" border="0"> <tr> <td>User</td> <td>Email</td> <td>&nbsp;</td> </tr> <?php foreach ($user_info as $key => $array) { while ($row = mysql_fet...

Rely on javascript to execute PHP script or manipulate hidden form elements and rely on PHP?

I wrote a JavaScript script that swaps two selected img tag src values. The point is to let the user rearrange a list of images. For sending the new order to a PHP script, I have two ideas: Have a button execute a JavaScript function that gathers the new order of images into an array of URLs. Then, rely on JavaScript to send the data...

how to secure sendmail on Centos for sending mails only from web app

We are using sendmail to send mails from our web app and we do not need to receive emails. Only our machine should be able to send emails from the sendmail server. What's the best way to make sure sendmail is running secure on our server. Again, we only need to be able to send mails using php's mail() function, nothing more. ...

Troubles with JSONP Request

Ok, I'm not 100% sure what I'm doing wrong here. Maybe I just need a second pair of eyes to reveal the error of my ways. I'm sending a JSONP request using jQuery from one domain (https://customerhub.net) to a PHP script on my domain (https://dankennedy.com) and getting a response from that script. I know the request is working because...

How can I read directory or file information using Ruby/Rails or possibly PHP?

Hi, I need to reprocess some files using attachment_fu, but not all of the files. I've seen a few posts asked about reading and listing files in a directory using Ruby, but does anyone know how to select the files based on the upload date or file parameters? I can use either the date parameters for when the file was uploaded or loo...

Apache serves incorrect page

To preface: this has got to be one of the strangest bugs I have ever seen, especially since it comes and goes. There exists a page called view.php and another page called save.php. The bug manifests when I request save.php - I instead get view.php. Request headers say save.php, and it happens in Firefox, IE, Chrome, Opera, Safari. It ha...

Lock Mysql table for write but allow read

Is there a way to lock a Mysql table only for write, so that another script can still make a SELECT query? I'm using this code to write to a table (executes almost every second): mysql_query("LOCK TABLES table WRITE;"); mysql_query("insert into... mysql_query("UNLOCK TABLES;"); and this to select (this script just freezes, probably b...

Get element content from a variable containing html

How do I use the DOM parser to extract the content of a html element in a variable. More exactly: I have a form where user inputs html in a text area. I want to extract the content of the first paragraph. I know there are many tutorials on this, but could not find any on extracting from variable and not a file(page) Thanks ...

Php script to automate Twitter Posts - Guidance

Hi I have a bit of PHP experience and I am tasked with making an automated script to post to twitter account. We have a RSS feed which is updated when we make a new article entry into the site, and would like to pass this info to the twitter script. I am speaking about the process of taking the latest RSS feed and moving it to the twitt...

PHP protect a folder.

I need to secure a folder. Website was done in PHP. There is an admin area with files like PDF, DOC… so; I cannot protect these files with session variable. Is there a way in PHP to protect a folder? Thank you ...

Is it everything I can do to make this upload form "safe"?

I did the same upload form for photo uploading like here. Is it everything I can do to protect my website or I need to add something? Thank you very much. ...

Does the file is being downloaded to site even if it's not supposed to be downloaded?

I am sure this is the one of the most epic titles ever. So, I have upload form like here. I made that people could upload their files only up to 1 MB. But, if I try to upload for example 1 GB file, it takes ages before it gives me an error. So, here comes a question. Before checking file's size, does that file is being downloaded in my h...

Flex - dataservice tests fine but not fine beyond that

I've got flex 4 and am trying to connect to a php dataservice. I've got paging enabled and have tweaked the default paging method so I can filter the results, ala "SELECT name, form FROM $this->tablename WHERE id='$q' LIMIT ?, ?". When I test the call via the built-in test function in Flex I get the results I want when I put in a filter ...

How to use cURL to fetch text

I'm trying to grab/fetch text from another URL using cURL. The location of where I grab the text from is within a blank HTML document with dynamic (not static) data, therefore there are no HTML tags to filter. This is what I've got so far: $c = curl_init('http://url.com/dataid='.$_POST['username']); curl_setopt(CURLOPT_RETURNTRANSFER, t...

java script function does not work .

hi .. This is my chats' sign out function. It works perfectly when I open the chat on a page alone.e.g. www.abc.com/chatbox/index.htm But when its with other elements in the same page using iFrame it will not work.e.g.www.abc.com/chat&paintIframe.htm This is my code <script type="text/javascript"> function singout(){ data="user=" + ""...