コード例 #1
0
ファイル: AutoUpdater.php プロジェクト: Westie/OUTRAGEbot
 /**
  *	Download the ZIP file to the Resources directory.
  */
 static function processZipFile($sURL)
 {
     # Prepare the variables
     $sZipResource = ROOT . "/Resources/AutoUpdater.zip";
     $sZipFolder = ROOT . "/Resources/AutoUpdaterFolder";
     $sSystemFolder = ROOT . "/System/";
     # Download the file
     $sZip = file_get_contents($sURL);
     file_put_contents($sZipResource, $sZip);
     $pZip = new ZipArchive();
     $pZip->open($sZipResource);
     $pZip->extractTo($sZipFolder);
     unlink($sZipResource);
     # What is the folder name?
     $aZipFolder = glob(ROOT . "/Resources/AutoUpdaterFolder/*");
     # Move all the system files
     self::rmdir($sSystemFolder);
     rename("{$aZipFolder[0]}/System/", $sSystemFolder);
     println(" * {$aZipFolder[0]}/System/ -> {$sSystemFolder}");
     # Move the Start.php
     unlink(ROOT . '/Start.php');
     rename("{$aZipFolder[0]}/Start.php", ROOT . '/Start.php');
     println(" * {$aZipFolder[0]}/Start.php -> " . ROOT . '/Start.php');
     # And now, clean up our mess.
     self::rmdir($sZipResource);
     unlink($aZipFolder[0]);
     println(" > Successfully updated the System files.");
 }
コード例 #2
0
 public static function main(array $args = array())
 {
     $remoteControl = new RemoteControlWithUndo();
     $livingRoomLight = new Light("Living Room");
     $livingRoomLightOn = new LightOnCommand($livingRoomLight);
     $livingRoomLightOff = new LightOffCommand($livingRoomLight);
     $remoteControl->setCommand(0, $livingRoomLightOn, $livingRoomLightOff);
     $remoteControl->onButtonWasPushed(0);
     $remoteControl->offButtonWasPushed(0);
     println($remoteControl);
     $remoteControl->undoButtonWasPushed();
     $remoteControl->offButtonWasPushed(0);
     $remoteControl->onButtonWasPushed(0);
     println($remoteControl);
     $remoteControl->undoButtonWasPushed();
     $ceilingFan = new CeilingFan("Living Room");
     $ceilingFanMedium = new CeilingFanMediumCommand($ceilingFan);
     $ceilingFanHigh = new CeilingFanHighCommand($ceilingFan);
     $ceilingFanOff = new CeilingFanOffCommand($ceilingFan);
     $remoteControl->setCommand(0, $ceilingFanMedium, $ceilingFanOff);
     $remoteControl->setCommand(1, $ceilingFanHigh, $ceilingFanOff);
     $remoteControl->onButtonWasPushed(0);
     $remoteControl->offButtonWasPushed(0);
     println($remoteControl);
     $remoteControl->undoButtonWasPushed();
     $remoteControl->onButtonWasPushed(1);
     println($remoteControl);
     $remoteControl->undoButtonWasPushed();
 }
コード例 #3
0
ファイル: Configuration.php プロジェクト: Westie/OUTRAGEbot
 /**
  *	Loads a configuration file from a specific location.
  */
 static function ParseLocation($sLocation)
 {
     $sConfigName = substr(basename($sLocation), 0, -4);
     if ($sConfigName[0] == "~") {
         return false;
     }
     $aConfiguration = parse_ini_file($sLocation, true);
     if (!is_array($aConfiguration) || count($aConfiguration) <= 1) {
         println(" * Sorry, looks like the network {$sConfigName} failed to load!");
         return false;
     }
     $pConfig = new stdClass();
     $bSlave = false;
     foreach ($aConfiguration as $sConfigKey => $aConfigObject) {
         if ($sConfigKey[0] == "~") {
             $sConfigKey = substr($sConfigKey, 1);
             $pConfig->{$sConfigKey} = (object) $aConfigObject;
             continue;
         }
         $aConfigObject = array_merge(array("nickname" => $sConfigKey), $aConfigObject, array("slave" => $bSlave));
         $pConfig->Bots[$sConfigKey] = (object) $aConfigObject;
         $bSlave = true;
     }
     $sInstance = $sConfigName . ' (#' . uniqid() . ')';
     self::verifyConfiguration($pConfig, $sInstance);
     Core::addInstance($sInstance, new CoreMaster($pConfig));
 }
コード例 #4
0
ファイル: WebLeadFormTest.php プロジェクト: tymiles003/X2CRM
 protected function assertAccountCreated()
 {
     $lead = Accounts::model()->findByAttributes(array('name' => 'testAccount'));
     $this->assertTrue($lead !== null);
     X2_TEST_DEBUG_LEVEL > 1 && println('account created');
     return $lead;
 }
コード例 #5
0
 public function releaseBall()
 {
     println("A gumball comes rolling out the slot...");
     if ($this->count != 0) {
         $this->count = $this->count - 1;
     }
 }
コード例 #6
0
 public static function main(array $args = array())
 {
     $remoteControl = new RemoteControl();
     $light = new Light("Living Room");
     $tv = new TV("Living Room");
     $stereo = new Stereo("Living Room");
     $hottub = new Hottub();
     $lightOn = new LightOnCommand($light);
     $stereoOn = new StereoOnCommand($stereo);
     $tvOn = new TVOnCommand($tv);
     $hottubOn = new HottubOnCommand($hottub);
     $lightOff = new LightOffCommand($light);
     $stereoOff = new StereoOffCommand($stereo);
     $tvOff = new TVOffCommand($tv);
     $hottubOff = new HottubOffCommand($hottub);
     $partyOn = array($lightOn, $stereoOn, $tvOn, $hottubOn);
     $partyOff = array($lightOff, $stereoOff, $tvOff, $hottubOff);
     $partyOnMacro = new MacroCommand($partyOn);
     $partyOffMacro = new MacroCommand($partyOff);
     $remoteControl->setCommand(0, $partyOnMacro, $partyOffMacro);
     println($remoteControl);
     println("--- Pushing Macro On---");
     $remoteControl->onButtonWasPushed(0);
     println("--- Pushing Macro Off---");
     $remoteControl->offButtonWasPushed(0);
 }
コード例 #7
0
ファイル: docs_commands.php プロジェクト: sevir/toffy-lite
function generateDocs($folder = 'creamture')
{
    if (!file_exists('docs/' . $folder)) {
        println('Docs folder doesn\'t exists');
        return;
    }
    $daux_global = array('docs_directory' => '../../../docs/' . $folder, 'valid_markdown_extensions' => array('md', 'markdown'));
    if (file_put_contents('docs/global.json', json_encode($daux_global)) === FALSE) {
        println('Error writing global conf in docs folder');
        exit;
    }
    require_once 'vendor/justinwalsh/daux.io/libs/daux.php';
    foreach (glob('docs/assets/templates/*') as $directory) {
        if (strpos('.', $directory) < 0) {
            @rmdir('vendor/justinwalsh/daux.io/templates/' . $directory);
        }
    }
    //Copy alternative imgs, js and templates
    directory_copy('docs/assets/templates', 'vendor/justinwalsh/daux.io/templates');
    if (file_exists('docs/assets/' . $folder . '_img')) {
        directory_copy('docs/assets/' . $folder . '_img', 'vendor/justinwalsh/daux.io/img');
    }
    $Daux = new \Todaymade\Daux\Daux(realpath('docs/global.json'));
    $Daux->initialize();
    if (!file_exists(PUBLICPATH . 'docs/' . $folder)) {
        mkdir(PUBLICPATH . 'docs/' . $folder, 0777, TRUE);
    }
    $Daux->generate_static(PUBLICPATH . 'docs/' . $folder);
    println('Docs generated in public folder');
}
コード例 #8
0
ファイル: TestingAuxLib.php プロジェクト: tymiles003/X2CRM
 public static function log($str)
 {
     if (X2_TEST_DEBUG_LEVEL > 0) {
         /**/
         println("\n[" . date('H:i:s', time()) . "] " . $str);
     }
 }
コード例 #9
0
ファイル: X2TestCase.php プロジェクト: shuvro35/X2CRM
 public static function tearDownAfterClass()
 {
     if (X2_TEST_DEBUG_LEVEL > 0) {
         println("");
     }
     parent::tearDownAfterClass();
 }
 public static function main(array $args = array())
 {
     $gumballMachine = new GumballMachine(10);
     println($gumballMachine);
     $gumballMachine->insertQuarter();
     $gumballMachine->turnCrank();
     $gumballMachine->insertQuarter();
     $gumballMachine->turnCrank();
     println($gumballMachine);
     $gumballMachine->insertQuarter();
     $gumballMachine->turnCrank();
     $gumballMachine->insertQuarter();
     $gumballMachine->turnCrank();
     println($gumballMachine);
     $gumballMachine->insertQuarter();
     $gumballMachine->turnCrank();
     $gumballMachine->insertQuarter();
     $gumballMachine->turnCrank();
     println($gumballMachine);
     $gumballMachine->insertQuarter();
     $gumballMachine->turnCrank();
     $gumballMachine->insertQuarter();
     $gumballMachine->turnCrank();
     println($gumballMachine);
     $gumballMachine->insertQuarter();
     $gumballMachine->turnCrank();
     $gumballMachine->insertQuarter();
     $gumballMachine->turnCrank();
     println($gumballMachine);
 }
コード例 #11
0
 public static function main(array $args = array())
 {
     $remoteControl = new RemoteControl();
     $livingRoomLight = new Light("Living Room");
     $kitchenLight = new Light("Kitchen");
     $ceilingFan = new CeilingFan("Living Room");
     $garageDoor = new GarageDoor("");
     $stereo = new Stereo("Living Room");
     $livingRoomLightOn = new LightOnCommand($livingRoomLight);
     $livingRoomLightOff = new LightOffCommand($livingRoomLight);
     $kitchenLightOn = new LightOnCommand($kitchenLight);
     $kitchenLightOff = new LightOffCommand($kitchenLight);
     $ceilingFanOn = new CeilingFanOnCommand($ceilingFan);
     $ceilingFanOff = new CeilingFanOffCommand($ceilingFan);
     $garageDoorUp = new GarageDoorUpCommand($garageDoor);
     $garageDoorDown = new GarageDoorDownCommand($garageDoor);
     $stereoOnWithCD = new StereoOnWithCDCommand($stereo);
     $stereoOff = new StereoOffCommand($stereo);
     $remoteControl->setCommand(0, $livingRoomLightOn, $livingRoomLightOff);
     $remoteControl->setCommand(1, $kitchenLightOn, $kitchenLightOff);
     $remoteControl->setCommand(2, $ceilingFanOn, $ceilingFanOff);
     $remoteControl->setCommand(3, $stereoOnWithCD, $stereoOff);
     println($remoteControl);
     $remoteControl->onButtonWasPushed(0);
     $remoteControl->offButtonWasPushed(0);
     $remoteControl->onButtonWasPushed(1);
     $remoteControl->offButtonWasPushed(1);
     $remoteControl->onButtonWasPushed(2);
     $remoteControl->offButtonWasPushed(2);
     $remoteControl->onButtonWasPushed(3);
     $remoteControl->offButtonWasPushed(3);
 }
コード例 #12
0
 public static function main(array $args = array())
 {
     $foo = CoolerSingleton::getInstance();
     $bar = HotterSingleton::getInstance();
     println($foo);
     println($bar);
 }
コード例 #13
0
 public function prepare()
 {
     println("Preparing " . $this->name);
     $this->dough = $this->ingredientFactory->createDough();
     $this->sauce = $this->ingredientFactory->createSauce();
     $this->cheese = $this->ingredientFactory->createCheese();
 }
コード例 #14
0
ファイル: stc.php プロジェクト: rodchyn/short-tag-converter
function convert_dir($dir, $echo = false)
{
    $converted_files = array();
    if ($handle = opendir($dir)) {
        while (false !== ($entry = readdir($handle))) {
            if ($entry != '.' && $entry != '..') {
                $full = $dir . '/' . $entry;
                if (is_dir($full)) {
                    $converted_files = array_merge($converted_files, convert_dir($full, $echo));
                } else {
                    if (end(explode('.', $full)) == 'php') {
                        if (convert_file($full)) {
                            $converted_files[] = $full;
                            if ($echo) {
                                println("Converted: " . $full);
                            }
                        }
                    }
                }
            }
        }
        closedir($handle);
    }
    return $converted_files;
}
コード例 #15
0
ファイル: creamator.php プロジェクト: sevir/toffy-lite
 public function run($command = FALSE, $params = array())
 {
     $this->_loadCommands();
     //read the params
     //$params = func_get_args();
     if ($command) {
         $command_info = $this->_getInfoFunc($command);
         if ($command_info) {
             if (!isset($command_info['num_parameters']) || $command_info['num_parameters'] > count($params)) {
                 //shows helps
                 $this->help($command);
             } else {
                 //Run the command
                 println('Running command: ' . $command);
                 println('');
                 call_user_func_array($command, $params);
                 println('');
             }
         } else {
             println('Sorry the command ' . $command . ' doesn\'t exists');
             println('');
         }
     } else {
         println('I need the name of the command!!!');
         println('');
     }
 }
コード例 #16
0
ファイル: _init.php プロジェクト: suzutan/twitter-namechecker
function select_account()
{
    $accounts = get_auth_keys();
    //Show Account List
    if (count($accounts) < 1) {
        println("Please authenticate account.");
        println("eg) php auth_request.php");
        exit(1);
    }
    println("Please select the account.");
    foreach ($accounts as $screen_name => $token) {
        println(sprintf("@%s", $screen_name));
    }
    //input screen_name
    echo ">@";
    while (true) {
        //input
        $screen_name = strtolower(trim(read()));
        //authenticate user check
        if (!array_key_exists($screen_name, $accounts)) {
            println("Please select the authenticated account");
            echo ">@";
            continue;
        }
        break;
    }
    return ["screen_name" => $screen_name, "access_token" => $accounts[$screen_name]["access_token_key"], "access_token_secret" => $accounts[$screen_name]["access_token_secret"]];
}
コード例 #17
0
 protected function simulate($duckFactoryOrQuackable)
 {
     if ($duckFactoryOrQuackable instanceof AbstractDuckFactory) {
         $redheadDuck = $duckFactoryOrQuackable->createRedheadDuck();
         $duckCall = $duckFactoryOrQuackable->createDuckCall();
         $rubberDuck = $duckFactoryOrQuackable->createRubberDuck();
         $gooseDuck = new GooseAdapter(new Goose());
         println("\nDuck Simulator: With Composite - Flocks");
         $flockOfDucks = new Flock();
         $flockOfDucks->add($redheadDuck);
         $flockOfDucks->add($duckCall);
         $flockOfDucks->add($rubberDuck);
         $flockOfDucks->add($gooseDuck);
         $flockOfMallards = new Flock();
         $mallardOne = $duckFactoryOrQuackable->createMallardDuck();
         $mallardTwo = $duckFactoryOrQuackable->createMallardDuck();
         $mallardThree = $duckFactoryOrQuackable->createMallardDuck();
         $mallardFour = $duckFactoryOrQuackable->createMallardDuck();
         $flockOfMallards->add($mallardOne);
         $flockOfMallards->add($mallardTwo);
         $flockOfMallards->add($mallardThree);
         $flockOfMallards->add($mallardFour);
         $flockOfDucks->add($flockOfMallards);
         println("\nDuck Simulator: Whole Flock Simulation");
         $this->simulate($flockOfDucks);
         println("\nDuck Simulator: Mallard Flock Simulation");
         $this->simulate($flockOfMallards);
         println("\nThe ducks quacked " . QuackCounter::getQuacks() . " times");
     } else {
         if ($duckFactoryOrQuackable instanceof Quackable) {
             $duckFactoryOrQuackable->quack();
         }
     }
 }
コード例 #18
0
ファイル: functions.php プロジェクト: RoBorg/SpriteGen
/**
 * Output a variable in a readable format
 *
 * @param mixed  the variable to print
 * @param string a CSS class name
 */
function printR($str, $class = '')
{
    print '<pre class="' . $class . '" style="text-align: left; background-color: #ffffff !important; color: #000000 !important;">';
    ob_start();
    print_r($str);
    print html(ob_get_clean());
    println('</pre>');
}
 public static function main($args)
 {
     $enumeration = new MyArrayEnumeration($args);
     $iterator = new EnumerationIterator($enumeration);
     while ($iterator->hasNext()) {
         println($iterator->next());
     }
 }
 public static function main($args)
 {
     $iterator = new MyArrayIterator($args);
     $enumeration = new IteratorEnumeration($iterator);
     while ($enumeration->hasMoreElements()) {
         println($enumeration->nextElement());
     }
 }
コード例 #21
0
ファイル: tests.php プロジェクト: oscarholmedo/googl-php
function assert_url($is)
{
    if (!preg_match('|^http(s)?://[a-z0-9-]+(.[a-z0-9-]+)*(:[0-9]+)?(/.*)?$|i', $is)) {
        exit(1);
    } else {
        println('Passed!');
    }
}
コード例 #22
0
ファイル: doctor.php プロジェクト: bafs/parvula
function test($str, $fn)
{
    println($str, 1);
    if (0 === ($res = $fn(0))) {
        echo '> OK' . PHP_EOL;
    }
    echo PHP_EOL;
    return $res;
}
コード例 #23
0
 public static function main(array $args = array())
 {
     $factory = new SimplePizzaFactory();
     $store = new PizzaStore($factory);
     $pizza = $store->orderPizza("cheese");
     println("We ordered a " . $pizza->getName() . "\n");
     $pizza = $store->orderPizza("veggie");
     println("We ordered a " . $pizza->getName() . "\n");
 }
コード例 #24
0
 public function prepare()
 {
     println("Preparing " . $this->name);
     $this->dough = $this->ingredientFactory->createDough();
     $this->sauce = $this->ingredientFactory->createSauce();
     $this->cheese = $this->ingredientFactory->createCheese();
     $this->veggies = $this->ingredientFactory->createVeggies();
     $this->pepperoni = $this->ingredientFactory->createPepperoni();
 }
コード例 #25
0
 public function dim($level)
 {
     $this->level = $level;
     if ($level == 0) {
         off();
     } else {
         println("Light is dimmed to " . $level . "%");
     }
 }
コード例 #26
0
 public function myPrint()
 {
     print "  " . $this->getName();
     if ($this->isVegetarian()) {
         print "(v)";
     }
     println(", " . $this->getPrice());
     println("     -- " . $this->getDescription());
 }
コード例 #27
0
ファイル: 03CDCIFrame.php プロジェクト: Nazg-Gul/gate
 function DrawContentSettingsForm($title, $field)
 {
     if ($title != '') {
         println("<b>{$title}:</b><br>");
     }
     $this->DrawImageLimits($field . '_image');
     $this->DrawFileLimits($field . '_file');
     return true;
 }
コード例 #28
0
 public static function main(array $args = array())
 {
     $tea = new Tea();
     $coffee = new Coffee();
     println("Making tea...");
     $tea->prepareRecipe();
     println("Making coffee...");
     $coffee->prepareRecipe();
 }
コード例 #29
0
 public function setTemperature($temperature)
 {
     if ($temperature > $this->temperature) {
         println("Hottub is heating to a steaming " . $temperature . " degrees");
     } else {
         println("Hottub is cooling to " . $temperature . " degrees");
     }
     $this->temperature = $temperature;
 }
コード例 #30
0
 public static function getInstance()
 {
     if (self::$uniqueInstance == NULL) {
         println("Creating unique instance of Chocolate Boiler");
         self::$uniqueInstance = new ChocolateBoiler();
     }
     println("Returning instance of Chocolate Boiler");
     return self::$uniqueInstance;
 }