Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    PHP




Delete Ftp-folder Created Via Php Installation?


how do I delete a folder at my ftp-server, that was automatically
created through a installation script? I dont have the permission to
delete that folder :-(

I have already found the following script, but I dont know where exactly
do I need to execute it:

---------------------------------------------------
<?php
function delete($file) {
chmod($file,0777);
if (is_dir($file)) {
$handle = opendir($file);
while($filename = readdir($handle)) {
if ($filename != "." && $filename != "..") {
delete($file."/".$filename);
}
}
closedir($handle);
rmdir($file);
} else {
unlink($file);
}
}

delete("folderrname");
-------------------------------------------------

....whereas foldername at the end is the folder to be deleted.
?>




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Automated Gui Installation Of Created APPS
I write a few applications and when I submit them to my client by logging in to their server, creating the directories, uploading the files, running the mysql scripts.  When i installed a few programs such as moodle and phpbb I loved the way how seamless it was.

Is there an application or something out there that can create an installation file for me such as the ones used in phpbb.  I ask this before i go about creating my own most likely by looking at phpbb setup etc.

Folder Created, But No Access
thats an error i try to solve for quite a while already but didn't find a
solution yet.
My problem: I'm writing a little cms, that should create a folderstructure,
so that you can put files in via ftp.

My script (simplified):
mkdir("00000031",0777); // creates a folder named with the id of a
database-record e.g. 00000031
chmod("00000031",0777); // sets the rights again to be sure, because i
experienced problems with mkdir not doing it sometimes in the past
chdir("00000031"); // should change to the folder but leads to:

Warning: SAFE MODE Restriction in effect. The script whose uid is 611 is not
allowed to access 00000035 owned by uid 60000 in /[...]/admin/admin.php on
line 85

Its clear, the script belongs to me (user 611) but the folder belongs to the
PHPuser 60000.

The Trial to solve this using mit (chown("00000031",611); ) unfortunately
leads to:

Warning: chown failed: Operation not permitted in /[...]/admin/admin.php on
line 84

What can i do in order to get access to the folder, for putting more folders
and files inside?

Permissions On A Folder Being Created
Does anyone know why the folder being created here ends up with the permissions other than 777?

$userdirectory = "./users/$uname";
mkdir($userdirectory, 0777);

I want the folder to be 777 and it is not giving this permission

Created Two Versions Of Image In Folder
I was wonder if I could get some help on putting together a script that would loop through all the images in a folder and created two other images (a thumbnail and a largesize) for each image? Code:

User Permissions Problem With Created Folder.
I use an indexing script that generates thumbnails for pictures and
stores them, so the next time someone requests a directory listing,
the thumbnail is already there and needn't be re-created.

Now, the problem is, the script cant create the thumbnail folders
because the base folder is owned by a normal system user, while the
script-screated folders or images are owned by the httpd, www-data. Is
there a way to have folders/files be created under the correct system
user?

Some Files Created Automatically In Mysql Database Folder
i have created one database in mysql. first i have created all tables
are of innodb type then i converted all tables to myisam type. i know
that for each myisam type table three files are created tablename.frm
tablename.myi and tablename.myd.

i have created database before one month. today i checked database and
i show somefiles exist in database folder named
(1)#sql-644_27.frm
(2)#sql-644_1.frm
(3)#sql-638_1.MYI
(4)#sql-638_1.MYD
(5)#sql-638_1.frm
(6)#sql-478_5.frm

can anyone tell me what is these files and why is these files?

Delete Folder FTP
I am trying to delete a folder and all of its contents (folders, files) through ftp. I am trying to modify a script for deleting it locally. I don't get any errors with this, but nothing happens. Can someone point me in the right direction? Code:

How To Delete An Undeletable Folder!
I run PHP5 and was testing a script to allow users sampling a demo script
But to keep security high asides the usuals I create a new folder and a new set of scripts per each required demo with a folder extension created by a rand function. So first the folder is created and a set of tpl are copied in the new folder and written on.

To make a story short:
While testing on the production server I found some bugs and fixed them but the first trial attempt created a folder with a set of files that weight exactly as the tpl copied from and do have a correct PHP extension but refuses to be deleted or renamed or schmod etc... via FTP

Now that I am bugless I can indeed do whatever with then newly created folders and files but still cannot delete my first test.

When I try to del it it goes away but if I refresh it’s back there!

Delete Folder And Its Contents
is there any way of deleteing a folder and all of its contents using PHP?

Delete Image From Folder
I have some php scripts to upload images and delete it. But if I delete the image I only delete the image's data in the database, and the image still remains in the folder. My question is, how can I remove the image from the image folder?

Drag Files From One Folder To Another Folder (copy) .. Possible?
Is it possible to write codings PHP or Javascript.. GUI representation
of File handling (ie. Drag files from one folder to another folder (copy)
like our windows).. pls give me some reference codings like this..

Remove From $name (folder)/(folder)/[x]/ <-- If Exists To Just Get [x].
I'll be quite honest. I don't have the faintest idea
how to do this, while I can do other php without a problem. Once I
know how to go about it I'll be okay.
It's two things I think?
1. see if there's a trailing slash and delete it.
2. Remove the preceding path to /x, the folders and slashes, and
delete them.
and then I have x.

X by the way is the final folder in a website and this grabs it for
me.

<?
$name = $REQUEST_URI;
?>

Get Last Created ID...
When a user is created I need to create a directory for their images. How do I get back the ID just created from the DB? PHP Code:

PHP-created Images
I've been wondering - how do I make dynamic images in PHP (example - the
PHP and Zend logos when you do phpinfo().)? I have seen it done on several
websites and I want to do it.
Also, is there a correct way to use PHP to retrieve images? The only
way I've ever got this to work is using require(). Here is what I did
(note: it only works with ASCII encoded images, otherwise PHP errors):

<?php

switch ($imgnum)
{
case "1":
require ("/home/img/menubutton.gif");
break;
case "2":
require ("/home/img/userprfl_bt.gif");
break;
case "3":
require ("/home/img/srch.gif");
break;

//etc...

case "":
default:
require ("/home/img/error.gif");
break;
}

?>

Created A Php Upload Using Mac OS X
Is it possible to create a PHP uploading file so that I can place images/text into a destination that I have assigned "write-only?"

If so, could you point me to a URL (URI) or sample code that tells me how to copy the file into the folder I want on  my Mac OS X.

Uploaded File Ok But Not Created
I'm trying to perform a very simple file upload page and everything seems to go just fine. The $_FILES var is populated with valid data (file size, name, mime type, even from a win remote computer) but the file just doesn't exists... It points to /tmp/php[random garbage] but there's no file starting with 'php'. /tmp is world-writeable so I don't see what the problem is. PHP Code:

IE Won't Display Gif Created By GD Threw Php.
So if I create a gif image using the source below the image won't
display at all in IE. I just get a red X. It displays right with
Firefox and it also displays okay if i open it up in Paint or *name your
image software here*. Why won't it display in IE? Is there something
I need to do special to make it work?

#!/usr/bin/php
<?
$DOTS = 5000;
$WIDTH = 6300;
$HEIGHT = 6300;

$im = imagecreatetruecolor($WIDTH, $HEIGHT);

for($i = 0; $i < $DOTS; ++$i){
imagesetpixel($im , rand(1, $WIDTH - 1), rand(1, $HEIGHT - 1),
imagecolorallocate($im, 250, 250, 250));
}

imagegif($im, "../public_html/map.gif");
imagedestroy($im);

?>

Problems In IE With Created Gifs
Wondering if anyone else has had problems with gifs created by php or if
anyone sees a problem with this code.

Symptom: created jpegs work fine and created gifs work fine in Netscape and
Firefox and when directly viewed.

IE displays gif fine *via internet* BUT off of a CD or local HTML file it
won't display the file.

I have run a dozen gifs through the process and it has happened to every one
of them.

function thumbnail ($src_file, $path) {
$orig = $path . '/' . $src_file;
list($w,$h,$type) = getimagesize($orig);
if ($type == 2) { // jpeg
$src_img = imagecreatefromjpeg("$orig");
$name = "thmb_" . $src_file;
$thmb_and_path = $path . $name;
if(!file_exists($thmb_and_path)) {
$image_info = getimagesize($orig);
$src_width = $image_info[0];
$src_height = $image_info[1];
$dest_height= 80;
$dest_width = ($dest_height/$src_height) * $src_width;
$quality = 30;
$dst_img = imagecreatetruecolor($dest_width,$dest_height);
imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $dest_width,
$dest_height, $src_width, $src_height);
imagejpeg($dst_img, $thmb_and_path, $quality);
chmod("$thmb_and_path", 0777);
imagedestroy($src_img);
imagedestroy($dst_img);
}
} else if ($type == 1) { // gif
$src_img = imagecreatefromgif("$orig");
$name = "thmb_" . $src_file;
$thmb_and_path = $path . $name;
if(!file_exists($thmb_and_path)) {
$image_info = getimagesize($orig);
$src_width = $image_info[0];
$src_height = $image_info[1];
$dest_height= 80;
$dest_width = ($dest_height/$src_height) * $src_width;
$quality = 30;
$dst_img = imagecreatetruecolor($dest_width,$dest_height);
imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $dest_width,
$dest_height, $src_width, $src_height);
imagejpeg($dst_img, $thmb_and_path, $quality);
chmod("$thmb_and_path", 0777);
imagedestroy($src_img);
imagedestroy($dst_img);
}
}
return $thmb_and_path;
}

Populate A Table That Is Already Created
I'm trying to run some script to populate a table that is already created. When I run the below code I am getting the completed message at the end, but my data is not going into my table....is there something incorrect with this code that is causing the issue? Code:

Cant Use Include In A Created Php File, Why?
I run the below code to create a new php file

$fp2 = fopen("a.php", "w");
$P1= "<?php include ("template.php"); ?>";
fwrite ($fp2, $P1);
fclose ($fp2);

when I then display a.php in ie, I get a blank page if I copy a.php to my computer, then ftp it back, I get a full page of text and images as expected.

How To Get Value From A Dynamically Created Textbox
how to get value from a dynamically created textbox using php

Knowing If Cookie Was Created?
Is there anyway, in php, to use the script to check if the cookie (made by setcookie) was actually created?

How Do I Display A Dynamiclly Created Xml Doc
simple question from a man whose never used xml with php.

i am created a doc with DomDocument - thats the easy part. what do i do to make it display as an xml doc? add a doctype? how do i do that?

Get The Name Of All Classes Created In A Php Script ?
Is there a way to get the name of all classes created in a php script ?

New Table Created From Variable
Is it possible to create a table in a mysql database using a variable that originated from a form? I've searched the net for some info on this, but have had no success.

Basically I want an admin to be able to set up a weekly round of football, and have a new table created for that round, based on teams set up each week using a form. The admin would enter the round number, and that would be the name of the new table.

The teams listed in the form would simply be posted in the table after it is created with a game ID. So far, I only know how to create a table by running a sql query, but the admin won't know how to do that, I'd rather if it could be done using a form.

Functions Created In Eval()
I am trying to be able to execute portions of code stored in a database using eval(). My question is, if I create a function inside of an eval() statement, can it be executed from code outside of the eval statement. For example, if I have the following code in my database:

function test() { echo 'test'; }

And retrieve it from the database as $test, and have this code:
eval($test);
test();

Should the function call work correctly? The reason I ask is because when I tried to do this, I got a "Call to undefined function:" error, and I'm trying to figure out if it's something I did wrong, or if I just can't do that.

Aligning Text On GD Created Image
I am trying to align text onto a GD created image and I can't get it to work. Here is my function which gets the width and height of the image passed to it.

Problems With Multiple Images Created From Gd2
Here's what i originally set out to do: i created a function called autoThumb:

function autoThumb($imgPath, $thumbWidth) {

$im = ImageCreateFromJpeg($imgPath);
//get source dimensions
$sourceWidth = ImagesX($im);
$sourceHeight = ImagesY($im);
$proportion = $thumbWidth/$sourceWidth;
$thumbHeight = round($sourceHeight*$proportion);
$thumbImg = ImageCreateTrueColor($thumbWidth, $thumbHeight);
ImageCopyResized($thumbImg, $im, 0, 0, 0, 0, $thumbWidth, $thumbHeight, $sourceWidth, $sourceHeight);
echo('<img src="'.ImageJpeg($thumbImg).'">');
ImageDestroy($thumbImg);
ImageDestroy($im);
}//end autoThumb

obviously, it's purpose is to create a thumbnail of a pic given the path to the pic and the desired thumbnail width. the first time i call the function, everything seems to go fine.

autoThumb("../imgs/guitar.jpg", 160);

but if i call it a second time

autoThumb("../imgs/guitar.jpg", 160);

the second image doesn't display. furthermore, if i put any text before the autoThumb call, the image doesn't display - only the code of the jpg.

Image Created With Gd Are Downloaded Non Displayed!!!
I use a gd function for create png image for show graphs, but some user told that is unable to see the graph but the PC ask for download the image.

Finding Date File Created
What function will return the time a file was created? I see
filemtime(...) returns the time that file was last Modified and
fileatime(...) returns the time that a file was last accessed but what
about created?

How To Read File Created With Encoded Name
Windows XP has the builtin support for other languages, for example,
Chinese, from which I can create a file with the name directly encoded
in Chinese, and it's not the unicode (unreadable chars). PHP seems to
have problem read such files, my question is how to make it work? I
tried some stuff from the utf8_encode/decode manual page and some
sample code, nothing worked for me ...

Saving A Dynamically Created Png Image
I have a web site that responds to a user request by sending an image generated dynamically. the request page call is something like this
<img id = "picid" src= "generateimage.php?$picName">

Where $picName holds the parameters needed for a particular image

generateimage.php sends the request to the server which generates the image as $pngstr and responds:

header("Content-Type: image/png".chr(13).chr(10));
header("Content-Length: ".strlen($pngstr).chr(13).chr(10).chr(13).chr(10));
echo $pngstr;

Now, I want the user to be able to right click the image and save it with a given name - related to but not exactly $picName, as a png.

I also have a set of images forming an animation generated in much the same way as the single image described above. How could I have the user save these? is there an animated png yet?

Naming A Newly Created File
I want to make adding pages to a web page easier. All the pages follow the same template, so making a template would make my life easier. I understand how to make the template, but I have two questions.

First, in order to make a template, do I have to have the pages store into mysql db?
Second, how do I actually have php name the page, so that it can be added to the site? (i.e. stuff.php) Where and how does this get created?

Somtimes PDFs Created On The Fly Don't Display
I am having real trouble with is getting generated pdfs to display on other peoples computers. Everything works fine on my computer and the other computers in our house. With everyone else Acrobat Reader just comes up blank or with an image in the top left corner or wants to down load a file. I am lost at what to do. I have been told it is a bug in IE and will work in some versions but not in others. Could this be true? Code:

Dynamically Created Image Into String
i have a dynamically created image represented by an imagehandler, but
i don't wanna output to the browser or a file. is it possible to read
that image directly into a string?

Displaying Images In Php Created Emails
I have created a php script that sends html emails and attachements. I couldnt figure out how to send an html email so that when the reciever opens his email, the images are displayed in the table and not as seperate attachements. I have used both activemaillib and php's mail function

The only way I succeeded was using hyperlinks in the table that fetches the email from a server, but some people download emails, close their internet connections and then read their emails.

Saving A Php Created Graphic To Two Different Folders
how I can save a php created graphic to two different folders? I want to save the graphic to the images folder that is in the folder that has the php code. The other folder will be in a different location that php code folder. Here is my code:

Redirecting To The ID Of Newest Item Created
I have a form that a user submits which creates a product. I want the user to be redirected to product.php?product_i=(the new product id)

The problem i'm having is that i dont know the ID of the new product created because the table is set to auto increment. How would i go about finding out the new ID and redirecting to that new product after it has just been created?

Displaying Dynamicly Created Images
I'm working on the registration page of my website, and am building in a system where the user has to read something out of a dynamically created image. I can create the image just fine, but how do I get it to display in a web page? Code:

Retrieve ID Of Newly Created Record
I have created a form to add a new record to my table. There is a field in the table however whose value will be generated using a given text string and the id number of the record.

For example suppose the ID of the record is 1030 then the string generated value will be something like

thisismystring1030

Does anyone know how I can retrieve the record ID as soon as I have created the record so that I can generate the value as mentioned above?

Just out of curiosity my next step after this is to create a session variable which willl store the record ID however I have never used these before.  Can anyone point me in the right direction?

Sorting Files By Date Created/updated
I use the following code to delete out of date backups.How can I have it delete the oldest file first? The files are sorted with sort($filelist);I need them to be sorted by date. PHP Code:

Mysql Query To Get Rec's Created In Last 30 Days
can you write a mysql qery to retrieve all rows from a table where the
date collumn is equal to a value (date) from now to 30 days ago?

Dynamicly Created Page, With Refereing Url Shown
I have loads of domain names but none have any hosting space associated. They are however all entered into my DNS, so when any of them are visited, the visitor ends up at the (unused) home page of my dns server.

I would like to put a php (or perl, or whatever else is suitable) page here so the visitor is shown a more freindly page.

So, for example, a "Welcome to domain.com, this page is under construction / for sale" type page is what I would want. So all I would need to do for each domain to have it's own page would be to enter the domains in to my DNS and the rest would be automatic.

Printer Functions And GD Created Image (Windows)
I have created an image using GD lib and now I would like to print it
using the Printer functions (on Windows XP). Does anyone know how to
write the image in memory to the printer (I assume I can use the Printer
functions)?

(Is there a method that involves saving it as a file first?)

Including A Function, And The Variable Created Within Cannot Be Found
I include the following function:

<?php
function login($members_only) {
if (isset($_COOKIE['login'])) {
$login = explode("|split|",$_COOKIE['login']);
$login = array("username"=>$login[0],"password"=>$login[1]);
}
else if ($members_only == 1) {
header("Location: login.php");
}
}
?>

in a file called account.php:

<?php
require("website-includes/login.inc.php");
login(1);
[snip]
?>

The problem is that I need to be able to access $login outside of the
function within the page that calls it. Is this possible? I'm new to
functions and before I was just including code, but I am told functions are
better.

Session Variables In Remote File Not Created
I'm rewriting my login script to improve the security >alot< and make it easier to update. I have my login.php, and a seperate file of functions.

Everything works but when I try to set a new session variable in the remote file (functions file).

The functions file is linked to the login.php via require(); and is not .php extention (parse errors fix). My code to set a new session variable works in the login.php (but not in remote file - problem), and is:

$_SESSION['var1'] = "textstring";
$_SESSION['var2'] = $textvar;

^^in functions file

The only difference in my login.php file the session variable is set: $_SESSION['var3'] = funct1(); <<which returns a string.

Php Created Popup Error Message Page
I have created a system using PHP & Javascript that works OK except that I want a neat display of error messages. Error messages caught at the client are displayed in a Javascript alert, which is fine. But errors caught at the server are not as well displayed and therefore I thought that I would ask if anyone has produced a "popup error message page" that would look similar to a Javascript alert but would originate at the server.

Include Gd-created Image AND Variables Used To Create It...
I am trying to make my own captcha. I have the image creation part done, but I can't get the image into an php/html page. I have tried include('file'), but it throw image/png headers, and confuses the script (does that make sense?).

Is there a way I can include the file that creates the image (image.php) as an image, along with the variables used to create it?  ($string for example)

Accessing Dynamically Created HTML Forms
Basically I have a form dynamically created by results from a database. As such it's going to be different ever time it's used. For each row in the database I want to have a drop-down list. So my HTML form looks like this: Code:


Copyright © 2005-08 www.BigResource.com, All rights reserved