Jump to content

Unexpected Variable


d22552000

Recommended Posts

<?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 == "..") {

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 !== &#38;#147;$source/$entry&#38;#148;) {
copyr(&#38;#148;$source/$entry&#38;#148;, &#38;#147;$dest/$entry&#38;#148;);

 

to:

if ($dest !== "source/$entry") {
copyr("source/$entry","dest/$entry");

Link to comment
Share on other sites

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 !== &#38;#147;$source/$entry&#38;#148;) {
copyr(&#38;#148;$source/$entry&#38;#148;, &#38;#147;$dest/$entry&#38;#148;);

 

to:

if ($dest !== "source/$entry") {
copyr("source/$entry","dest/$entry");

 

this site butchers my code.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 ();

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 -,-.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 -,-.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.