• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Executing with non-xf PHP

Jeremy

Well-known member
#6
Quick glance looks like it happens on certain events, so realistically shouldn't need cached.
PHP:
<?php

class myCallback {
  public static function callback() {
    // do its work here. initalize, etc.
  }
}
 

Jeremy

Well-known member
#8
Why are you changing the actual class to static? You'll have to create a new instance of said class within the PHP:
PHP:
<?php

class MyCallBack {
    public static function callback() {
        $CServerRcon = new CServerRcon('pass', 'port', 'third argument');
        $CServerRcon->sendCommand('command');
    }
}
You won't change CServerRcon at all. If you wanted it all self contained you could do:
PHP:
<?php
class CServerRcon {
  // current class

  public static function callback() {
    $self = new self();
  }
}
(self may not work in that instance, but I think it will).
 

silence

Well-known member
#9
Why are you changing the actual class to static? You'll have to create a new instance of said class within the PHP:
PHP:
<?php

class MyCallBack {
    public static function callback() {
        $CServerRcon = new CServerRcon('pass', 'port', 'third argument');
        $CServerRcon->sendCommand('command');
    }
}
You won't change CServerRcon at all. If you wanted it all self contained you could do:
PHP:
<?php
class CServerRcon {
  // current class

  public static function callback() {
    $self = new self();
  }
}
(self may not work in that instance, but I think it will).
$*(#@$ Alright
Why are you changing the actual class to static? You'll have to create a new instance of said class within the PHP:
PHP:
<?php

class MyCallBack {
    public static function callback() {
        $CServerRcon = new CServerRcon('pass', 'port', 'third argument');
        $CServerRcon->sendCommand('command');
    }
}
You won't change CServerRcon at all. If you wanted it all self contained you could do:
PHP:
<?php
class CServerRcon {
  // current class

  public static function callback() {
    $self = new self();
  }
}
(self may not work in that instance, but I think it will).
One more: how would I call that class then? (since just CServerRcon would be locally called and i rather have that bulky script in a separate file)
 

Jeremy

Well-known member
#10
What do you mean how would you call that class? You have to set the callback to be MyCallBack::callback() (for my example), and then require the CServerRcon file and initialize and use it as any other normal class.
 

silence

Well-known member
#11
What do you mean how would you call that class? You have to set the callback to be MyCallBack::callback() (for my example), and then require the CServerRcon file and initialize and use it as any other normal class.
Oh so literally include/require the file in that callback?
 

silence

Well-known member
#14
Weird issue in that script:
fwrite() expects parameter 1 to be resource, null given

Why wouldn't it be writing to the global variable even though it's set to do so?