d22552000 Posted August 13, 2007 Share Posted August 13, 2007 <?PHP *SNIPPED OUT* $s = "../" . $p . "/forum"; $d = "../../VB3.6.7/forum"; copyr($s,$d); function copyr($source, $dest){ if (is_file($source)) { $c = copy($source, $dest); return $c; } if (!is_dir($dest)) { $oldumask = umask(0); umask($oldumask); } // Loop through the folder $dir = dir($source); while (false !== $entry = $dir->read()) { [b]if ($entry == "." || $entry == "..") {[/b] continue; } if ($dest !== $source/$entry) { copyr($source/$entry, $dest/$entry); } } // Clean up $dir->close(); return true; } *SNIPPED OUT* ?> It's the only remaining error. Unexpected variable on the bolded line: if ($entry == "." || $entry == "..") { Quote Link to comment Share on other sites More sharing options...
NArc0t1c Posted August 13, 2007 Share Posted August 13, 2007 Firstly, $somecontent = $somecontent . "content"; Could be $somecontent .= "content"; Secondly, The while loop is done wrong of somewhat.. Try doing this(I think this is what you meant: while ($entry !== false && $entry == $dir->read()) { And where is the entry variable's contents? Edit: OR changed to And Quote Link to comment Share on other sites More sharing options...
Orio Posted August 13, 2007 Share Posted August 13, 2007 NArc0t1c thats not what he means in this statement... Try replacing this: while (false !== $entry = $dir->read()) { With: while (($entry = $dir->read()) !== false) { Maybe php is misunderstanding you somehow. Orio. Quote Link to comment Share on other sites More sharing options...
lemmin Posted August 13, 2007 Share Posted August 13, 2007 Are you sure it isn't the lines below it? Maybe it only looks like this after you posted it here, but I don't think PHP can parse those quotes. If infact they are like that, try to change them: if ($dest !== &#147;$source/$entry&#148;) { copyr(&#148;$source/$entry&#148;, &#147;$dest/$entry&#148;); to: if ($dest !== "source/$entry") { copyr("source/$entry","dest/$entry"); Quote Link to comment Share on other sites More sharing options...
d22552000 Posted August 13, 2007 Author Share Posted August 13, 2007 I DONT EVEN KNOW WHAT I MEAN IN THIS STATMENT. I did not make the dir fetch code. Quote Link to comment Share on other sites More sharing options...
d22552000 Posted August 13, 2007 Author Share Posted August 13, 2007 Are you sure it isn't the lines below it? Maybe it only looks like this after you posted it here, but I don't think PHP can parse those quotes. If infact they are like that, try to change them: if ($dest !== &#147;$source/$entry&#148;) { copyr(&#148;$source/$entry&#148;, &#147;$dest/$entry&#148;); to: if ($dest !== "source/$entry") { copyr("source/$entry","dest/$entry"); this site butchers my code. Quote Link to comment Share on other sites More sharing options...
Orio Posted August 13, 2007 Share Posted August 13, 2007 NArc0t1c thats not what he means in this statement... Try replacing this: while (false !== $entry = $dir->read()) { With: while (($entry = $dir->read()) !== false) { Maybe php is misunderstanding you somehow. Orio. You should really try this. Orio. Quote Link to comment Share on other sites More sharing options...
lemmin Posted August 13, 2007 Share Posted August 13, 2007 I understand that you don't have ampersands and number signs everywhere, but it would appear that you are using "open quotes" and "closed quotes" instead of identical quotes on both sides. Just try to overwrite your current quotes with new ones to make sure that isn't the problem. Quote Link to comment Share on other sites More sharing options...
d22552000 Posted August 13, 2007 Author Share Posted August 13, 2007 no, thats again the site.. I fixed all the openand closed ones. I checked... trust me -,-. Ive beenb tryign to get this one script wroking for a few hours now, (check the forum check the post itme of "copy folder"). I dunno about thsi script.. if you have somethign to copy folders.... oh and Orio, I tried that, and no go. same error. Quote Link to comment Share on other sites More sharing options...
lemmin Posted August 13, 2007 Share Posted August 13, 2007 Try changing it to this, for testing purposes: while(false !== $entry = true) { if ($entry == "." || $entry == ".."){ continue; } if ($dest !== "$source/$entry"){ copyr("$source/$entry", "$dest/$entry"); } } If you still get the error when it is like that, then the error is not in that part of the code. Also, it will be an endless loop if it works. Quote Link to comment Share on other sites More sharing options...
d22552000 Posted August 13, 2007 Author Share Posted August 13, 2007 Uh... works... Its copying files... but is the script still gonna work? or was that just a test? TRUE = Fault.Error(this_script.TIMEOUT); The script reached its 300 seconds execution limit. hmmmmm its supposed to MAKE a/forum lol. Warning: dir(../a/forum) [function.dir]: failed to open dir: No such file or directory in C:\Inetpub\wwwroot\Registration\vbcreate.php on line 26 Fatal error: Maximum execution time. Fatal error: Maximum execution time (); Quote Link to comment Share on other sites More sharing options...
d22552000 Posted August 13, 2007 Author Share Posted August 13, 2007 !? Quote Link to comment Share on other sites More sharing options...
lemmin Posted August 13, 2007 Share Posted August 13, 2007 It should work as an endless loop, but I would assume you want it to stop somewhere. Try leaving the code like that and only putting changing the line: while(false !== $entry = true) back to: while (false !== $entry = $dir->read()) If this runs (it probably wont), it was a syntax. If you get the error again, it is possible that your dir() function failed. try changing the line: $dir = dir($source); to: @$dir = dir($source) or die("dir() function failed"); If that error gets outputted, make sure your $source variable has the correct location and that you have access to it. Quote Link to comment Share on other sites More sharing options...
d22552000 Posted August 13, 2007 Author Share Posted August 13, 2007 Script works now EXCEPT FOR: Warning: dir(../d/forum) [function.dir]: failed to open dir: No such file or directory in C:\Inetpub\wwwroot\Registration\vbcreate.php on line 28 Fatal error: Call to a member function read() on a non-object in C:\Inetpub\wwwroot\Registration\vbcreate.php on line 29 just to update, this is the source im using now -,- <?PHP echo "Please be patient, this is long step..<br /><br />"; $n = $_POST['n']; $p = $_POST['p']; $g_link = mysql_connect( '127.0.0.1', 'root', '') or die('Could not connect to server.' ); mysql_query('CREATE DATABASE ' . $n . ';'); mysql_select_db($n, $g_link) or die('Could not select database.'); $s = "../" . $p . "/forum"; $d = "../../VB3.6.7/forum"; copyr($s,$d); recursive_mkdir('c:/Inetpub/wwwroot/$p'); recursive_mkdir('c:/Inetpub/wwwroot/$p/forum'); function copyr($source, $dest){ if (is_file($source)) { $c = copy($source, $dest); return $c; } if (!is_dir($dest)) { $oldumask = umask(0); umask($oldumask); } // Loop through the folder $dir = dir($source); while (false !== $entry = $dir->read()) { if ($entry == "." || $entry == ".."){ continue; } if ($dest !== "$source/$entry"){ copyr("$source/$entry", "$dest/$entry"); } } // Clean up $dir->close(); return true; } echo "Writing Config..<br /><br />"; $filename='C:/Inetpub/wwwroot/'.$p.'/forum/includes/config.php'; $somecontent = "\$config['Database']['dbname'] = '" . $n . "';\$config['Database']['tableprefix'] = '';"; $somecontent = $somecontent . "\$config['Database']['technicalemail'] = '';\$config['Database']['force_sql_mode'] = true;"; $somecontent = $somecontent . "\$config['MasterServer']['servername'] = 'localhost';\$config['MasterServer']['port'] = 3306;"; $somecontent = $somecontent . "\$config['MasterServer']['username'] = 'root';\$config['MasterServer']['password'] = '';"; $somecontent = $somecontent . "\$config['MasterServer']['usepconnect'] = 0;\$config['Misc']['admincpdir'] = 'admincp';"; $somecontent = $somecontent . "\$config['Misc']['modcpdir'] = 'modcp';\$config['Misc']['cookieprefix'] = 'bb';"; $somecontent = $somecontent . "\$config['Misc']['forumpath'] = '';\$config['SpecialUsers']['canviewadminlog'] = '1,2';"; $somecontent = $somecontent . "\$config['SpecialUsers']['canpruneadminlog'] = '1';\$config['SpecialUsers']['canrunqueries'] = '';"; $somecontent = $somecontent . "\$config['SpecialUsers']['undeletableusers'] = '';\$config['SpecialUsers']['superadministrators'] = '1,2';"; $somecontent = $somecontent . "\$config['Misc']['maxwidth'] = 2592;\$config['Misc']['maxheight'] = 1944;"; // In our example we're opening $filename in append mode. // The file pointer is at the bottom of the file hence // that's where $somecontent will go when we fwrite() it. if (!$handle = fopen($filename, 'a')) { echo "Cannot open file ($filename)"; exit; } // Write $somecontent to our opened file. if (fwrite($handle, $somecontent) === FALSE) { echo "Cannot write to file ($filename)"; exit; } echo "Success"; fclose($handle); require('C:\Inetpub\VB3.6.7\sql.php'); //onesql(); echo "sql1 done <br />"; //twosql(); echo "sql2 done <br />"; //thrsql(); echo "sql3 done <br />"; //fursql(); echo "sql4 done <br />"; echo '<br /><br /><br /><br /><a href="http://24.86.150.207/' . $n . '/forum/admincp/index.php">Login to AdminCP</a>'; ?> uh....... mkdir doenst seem to work -,-. IM ON WINDOWS PEOPLE, NOT LINUX. I do not have to do ANY chmodding. thiis is depresing I might have to do ftp_mkdir -,-. Quote Link to comment Share on other sites More sharing options...
lemmin Posted August 13, 2007 Share Posted August 13, 2007 I would suggest echoing out $source at the beginning of your copyr function, just to see what it is. Go through your folders and make sure that it is a valid folder and the you have access to it. If your php file is in the root dir, it (most likely) won't have access to a directory below it. Quote Link to comment Share on other sites More sharing options...
d22552000 Posted August 13, 2007 Author Share Posted August 13, 2007 I have eliminated that as a proble,.. but for some reason... I CANNOT CREATE DIRECTORIES USING PHP SCRIPTS!!!!? Warning: dir(./e) [function.dir]: failed to open dir: No such file or directory in C:\Inetpub\wwwroot\vbcreate.php on line 26 Warning: dir(./e/forum) [function.dir]: failed to open dir: No such file or directory in C:\Inetpub\wwwroot\vbcreate.php on line 26 Warning: dir(./e/forum/admincp) [function.dir]: failed to open dir: No such file or directory in C:\Inetpub\wwwroot\vbcreate.php on line 26 It can't make folders -,- do I gotta us ftp_mkdir -,-,-,-,- cause that's a pain in the arse. Quote Link to comment Share on other sites More sharing options...
lemmin Posted August 13, 2007 Share Posted August 13, 2007 Try using the same code but changing the directory you are creating to be in the same directory as your php file that is creating it. If it still gives you the problem, you probably don't have write access on the server. I think you need 777 to do this. Quote Link to comment Share on other sites More sharing options...
d22552000 Posted August 13, 2007 Author Share Posted August 13, 2007 I am on a windows system. I do not need to CHMOD. Neither do I have CRONTABS. Quote Link to comment Share on other sites More sharing options...
lemmin Posted August 13, 2007 Share Posted August 13, 2007 If you do a standalone file with a simple isdir($yourdir) check in it, does it return true or false? Quote Link to comment Share on other sites More sharing options...
d22552000 Posted August 13, 2007 Author Share Posted August 13, 2007 uh.... befor emkdir it says false after mkdir it says true... but there is no folder there. and If I try to copy files, it says no folder is there. Quote Link to comment Share on other sites More sharing options...
lemmin Posted August 13, 2007 Share Posted August 13, 2007 That's pretty cool. Are you doing all this locally? Is mkdir() returning true? It still seems to me like it isn't giving you access to write to that folder. Try right clicking on the folder that you will being making the new folder in and going to properties and security. From there, click add, type in Everyone and hit enter. Then, click on the full control check box. See if it still gives you those errors. Quote Link to comment Share on other sites More sharing options...
d22552000 Posted August 13, 2007 Author Share Posted August 13, 2007 I thoguht about that too, but there is no security tab -,-. Quote Link to comment Share on other sites More sharing options...
lemmin Posted August 13, 2007 Share Posted August 13, 2007 Even better, you are probably not an administrative user. Try logging in as an admin account and see if you still get the errors. Quote Link to comment Share on other sites More sharing options...
d22552000 Posted August 13, 2007 Author Share Posted August 13, 2007 I AM the only administrator. its a confusing story, ive had my server up for some years now, and reinstall windows ocassionaly. Inetpub might be under old security permissions... oh and I can finally make directories! hers what I did: while (!is_dir($p)) { mkdir($p); chdir('../'); i++; } echo i; apparnetly when I tried to make a folder it used the include_dir in my php.ini file... -,-. So I told it to backtrack until its allowed to make the folder. the output is like: 19 =,=, I told you, the server IS messy. but I have a new problem... HOW TO COPY A WHOLE DIR OF FILES TO ANOTHER??? I have tried two different scripts to do this and they have both failed. copyr($s,$d); function copyr($source, $dest){ if (is_file($source)) { $c = copy($source, $dest); return $c; } if (!is_dir($dest)) { $oldumask = umask(0); umask($oldumask); } // Loop through the folder $dir = dir($source); while (false !== $entry = $dir->read()) { if ($entry == "." || $entry == ".."){ continue; } if ($dest !== "$source/$entry"){ copyr("$source/$entry", "$dest/$entry"); } } [/code that one doesnt even do anything, not a single echo or even a file made -,-. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.