示例#1
0
function sql($sql, $type = "query", $fetchmode = 'default')
{
    global $db;
    if (empty($db) || !is_object($db) || get_class($db) != "DB") {
        $dbh = FreePBX::Create()->Database();
        $db = new DB($dbh);
    }
    switch ($fetchmode) {
        case 'DB_FETCHMODE_ASSOC':
            //You guessed it, looking for string constants!
        //You guessed it, looking for string constants!
        case DB_FETCHMODE_ASSOC:
            //simulate craptacular function from previous versions
            //that didn't even work correctly! sweet :-/
            //(The integer shouldnt go there)
            if ($type == 'getAssoc') {
                $results = $db->{$type}($sql, true);
            } else {
                $results = $db->{$type}($sql, array(), DB_FETCHMODE_ASSOC);
            }
            break;
        case DB_FETCHMODE_ORDERED:
            $results = $db->{$type}($sql, array(), DB_FETCHMODE_ORDERED);
            break;
        case 'default':
            $results = $db->sql($sql, $type);
            break;
        default:
            throw new Exception("Unknown SQL fetchmode of {$fetchmode}");
            break;
    }
    return $results;
}
示例#2
0
 protected function configure()
 {
     $this->setName('motd')->setDescription(_('Prints MOTD'))->setDefinition(array(new InputArgument('args', InputArgument::IS_ARRAY, null, null)));
     //banners should be base64 encoded, Why? Because php likes to randomly shift multiline variables. Also makes it all look super cryptic :-/
     $this->banner = "IF9fX19fICAgICAgICAgICAgICBfX19fICBfX19fX18gIF9fDQp8ICBfX198IF9fIF9fXyAgX19ffCAgXyBcfCBfXyApIFwvIC8NCnwgfF8gfCAnX18vIF8gXC8gXyBcIHxfKSB8ICBfIFxcICAvIA0KfCAgX3x8IHwgfCAgX18vICBfXy8gIF9fL3wgfF8pIC8gIFwgDQp8X3wgIHxffCAgXF9fX3xcX19ffF98ICAgfF9fX18vXy9cX1wgICAgIA==";
     $this->supporturl = 'http://www.freepbx.org/support-and-professional-services';
     $this->FreePBX = \FreePBX::Create();
 }
示例#3
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $FreePBX = \FreePBX::Create();
     $args = $input->getArgument('args');
     session_id($args[0]);
     session_start();
     $output->writeln(sprintf(_('Unlocking: %s'), $args[0]));
     if (!isset($_SESSION["AMP_user"])) {
         $_SESSION["AMP_user"] = new \ampuser('fwconsole');
         $_SESSION["AMP_user"]->setAdmin();
         $output->writeln(_('Session Should be unlocked now'));
     }
 }
示例#4
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $FreePBX = \FreePBX::Create();
     $args = $input->getArgument('args');
     //If we don't have a session file, it is probably not a valid session
     if (!file_exists(session_save_path() . '/sess_' . $args[0])) {
         $output->writeln(sprintf(_('Unlocking: %s Failed, Invalid session'), $args[0]));
         return;
     }
     session_id($args[0]);
     session_start();
     $output->writeln(sprintf(_('Unlocking: %s'), $args[0]));
     if (!isset($_SESSION["AMP_user"])) {
         $_SESSION["AMP_user"] = new \ampuser('fwconsole');
         $_SESSION["AMP_user"]->setAdmin();
         $output->writeln(_('Session Should be unlocked now'));
     }
 }
示例#5
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $args = $input->getArgument('args');
     $FreePBX = \FreePBX::Create();
     $astMan = $FreePBX->astman;
     if ($astMan->connected()) {
         $astMan->Command('dialplan reload');
         $res = $astMan->Command('dialplan show ' . $args[0]);
         $lines = explode("\n", $res['data']);
         $output->writeln('Context ' . $args[0] . ': ');
         foreach ($lines as $line) {
             if (strpos($line, '=>')) {
                 $i++;
                 $output->writeln($line);
             }
         }
         if ($i < 1) {
             $output->writeln(_('May be invalid Check your spelling'));
         }
     }
 }
示例#6
0
 private function abortShutdown($output)
 {
     $freepbx = \FreePBX::Create();
     $astman = $freepbx->astman;
     if (is_object($astman) && $astman->Connected()) {
         $astman->send_request('Command', array('Command' => 'core abort shutdown'));
     }
 }