/** * @param $phoneArray * @return bool|\Exception|\SoapFault */ public function getDeviceIp($phoneArray) { try { $response = $this->client->SelectCmDevice('', ['MaxReturnedDevices' => '1000', 'Class' => 'Phone', 'Model' => '255', 'Status' => 'Any', 'NodeName' => '', 'SelectBy' => 'Name', 'SelectItems' => $phoneArray]); } catch (SoapFault $E) { // Loop if we get a RISPort error for exceeding maximum calls in 1 minute if (preg_match('/^AxisFault: Exceeded allowed rate for Reatime information/', $E->faultstring)) { sleep(30); $this->getDeviceIp($phoneArray); } return $E; } /* * No Errors * Process Results */ return $response["SelectCmDeviceResult"]; $SelectCmDeviceResult = $response["SelectCmDeviceResult"]; /* * Return results if they exist * Or return false */ if ($SelectCmDeviceResult->CmNodes) { return $SelectCmDeviceResult->CmNodes; } return false; }
function openqrm_dhcpd_appliance($cmd, $appliance_fields) { global $OPENQRM_SERVER_BASE_DIR; global $OPENQRM_EXEC_PORT; $openqrm_server = new openqrm_server(); $OPENQRM_SERVER_IP_ADDRESS = $openqrm_server->get_ip_address(); $event = new event(); $appliance_id = $appliance_fields["appliance_id"]; $appliance_name = $appliance_fields["appliance_name"]; $resource = new resource(); $resource->get_instance_by_id($appliance_fields["appliance_resources"]); $resource_mac = $resource->mac; $resource_ip = $resource->ip; $appliance = new appliance(); $appliance->get_instance_by_id($appliance_id); if ($resource->id == "-1" || $resource->id == "") { return; } $event->log("openqrm_dhcpd_appliance", $_SERVER['REQUEST_TIME'], 5, "openqrm-dhcpd-appliance-hook.php", "Handling {$cmd} event {$appliance_id}/{$appliance_name}/{$resource_ip}/{$resource_mac}", "", "", 0, 0, $resource->id); switch ($cmd) { case "start": $event->log("openqrm_dhcpd_appliance", $_SERVER['REQUEST_TIME'], 5, "openqrm-dhcpd-appliance-hook.php", "Adding hostname " . $appliance->name . " from resource " . $resource->id . ".", "", "", 0, 0, $resource->id); $dhcpd_command = $OPENQRM_SERVER_BASE_DIR . "/openqrm/plugins/dhcpd/bin/openqrm-dhcpd-appliance add_hostname -m " . $resource_mac . " -n " . $appliance->name . " -d " . $resource->id . " --openqrm-cmd-mode background"; $openqrm_server->send_command($dhcpd_command); break; case "stop": $event->log("openqrm_dhcpd_appliance", $_SERVER['REQUEST_TIME'], 5, "openqrm-dhcpd-appliance-hook.php", "Removing hostname " . $appliance->name . " from resource " . $resource->id . ".", "", "", 0, 0, $resource->id); $dhcpd_command = $OPENQRM_SERVER_BASE_DIR . "/openqrm/plugins/dhcpd/bin/openqrm-dhcpd-appliance remove_hostname -m " . $resource_mac . " -n " . $appliance->name . " -d " . $resource->id . " --openqrm-cmd-mode background"; $openqrm_server->send_command($dhcpd_command); break; } }
function get_lvm_iscsi_deployment_image_rootdevice_identifier($lvm_iscsi_storage_id) { global $OPENQRM_SERVER_BASE_DIR; global $OPENQRM_ADMIN; global $event; // place for the storage stat files $StorageDir = $_SERVER["DOCUMENT_ROOT"] . '/openqrm/base/plugins/lvm-storage/storage'; $rootdevice_identifier_array = array(); $storage = new storage(); $storage->get_instance_by_id($lvm_iscsi_storage_id); $storage_resource = new resource(); $storage_resource->get_instance_by_id($storage->resource_id); $storage_resource_id = $storage_resource->id; $ident_file = "{$StorageDir}/{$storage_resource_id}.lv.lvm-iscsi-deployment.ident"; if (file_exists($ident_file)) { unlink($ident_file); } // send command $resource_command = "{$OPENQRM_SERVER_BASE_DIR}/openqrm/plugins/lvm-storage/bin/openqrm-lvm-storage post_identifier -t lvm-iscsi-deployment -u {$OPENQRM_ADMIN->name} -p {$OPENQRM_ADMIN->password}"; $storage_resource->send_command($storage_resource->ip, $resource_command); if (!lvm_iscsi_deployment_wait_for_identfile($ident_file)) { $event->log("get_image_rootdevice_identifier", $_SERVER['REQUEST_TIME'], 2, "image.lvm-iscsi-deployment", "Timeout while requesting image identifier from storage id {$storage->id}", "", "", 0, 0, 0); return; } $fcontent = file($ident_file); foreach ($fcontent as $lun_info) { $tpos = strpos($lun_info, ","); $timage_name = trim(substr($lun_info, 0, $tpos)); $troot_device = trim(substr($lun_info, $tpos + 1)); $rootdevice_identifier_array[] = array("value" => "{$troot_device}", "label" => "{$timage_name}"); } return $rootdevice_identifier_array; }
function get_nagios3_appliance_link($appliance_id) { global $event; global $OPENQRM_SERVER_BASE_DIR; global $OPENQRM_SERVER_IP_ADDRESS; global $OPENQRM_EXEC_PORT; $p_appliance = new appliance(); $p_appliance->get_instance_by_id($appliance_id); $p_resource = new resource(); $p_resource->get_instance_by_id($p_appliance->resources); $nagios_link = "/openqrm/base/index.php?name=Nagios3&iframe=/cgi-bin/nagios3/status.cgi?host=" . $p_appliance->name; $html = new htmlobject($OPENQRM_SERVER_BASE_DIR . '/openqrm/web/base/class/htmlobjects'); $a = $html->a(); // $a->label = '<img title="Service monitoring" alt="Service monitoring" height="24" width="24" src="/openqrm/base/plugins/nagios3/img/plugin.png" border=0>'; $a->label = 'nagios'; $a->css = 'badge'; $a->href = $nagios_link; $a->handler = ''; $plugin_link = $a; if ($p_resource->id == 0) { $plugin_link = $a; } if ($p_resource->id == '') { $plugin_link = ""; } return $plugin_link; }
function get_novnc_appliance_link($appliance_id) { global $event; global $OPENQRM_SERVER_BASE_DIR; global $OPENQRM_SERVER_IP_ADDRESS; global $OPENQRM_EXEC_PORT; $p_appliance = new appliance(); $p_appliance->get_instance_by_id($appliance_id); $p_resource = new resource(); $p_resource->get_instance_by_id($p_appliance->resources); $virtualization = new virtualization(); $virtualization->get_instance_by_id($p_appliance->virtualization); $html = new htmlobject($OPENQRM_SERVER_BASE_DIR . '/openqrm/web/base/class/htmlobjects'); $a = $html->a(); $a->label = 'noVNC'; $a->css = 'badge'; $a->handler = 'onclick="wait();"'; $plugin_link = ''; if (strstr($p_appliance->state, "active")) { if (strstr($virtualization->type, '-vm-')) { $a->href = '/openqrm/base/index.php?plugin=novnc&controller=novnc&novnc_action=console&appliance_id=' . $p_appliance->id; } else { $a->href = '/openqrm/base/index.php?plugin=novnc&controller=novnc&novnc_action=login&appliance_id=' . $p_appliance->id; } $plugin_link = $a; } else { if ($p_resource->id === '0') { $a->href = '/openqrm/base/index.php?plugin=novnc&controller=novnc&novnc_action=login&appliance_id=' . $p_appliance->id; $plugin_link = $a; } } return $plugin_link; }
function get_sshterm_appliance_link($appliance_id) { global $event; global $OPENQRM_SERVER_BASE_DIR; global $OPENQRM_SERVER_IP_ADDRESS; global $OPENQRM_EXEC_PORT; $p_appliance = new appliance(); $p_appliance->get_instance_by_id($appliance_id); $p_resource = new resource(); $p_resource->get_instance_by_id($p_appliance->resources); // get the parameters from the plugin config file $OPENQRM_PLUGIN_SSHTERM_CONFIG_FILE = "{$OPENQRM_SERVER_BASE_DIR}/openqrm/plugins/sshterm/etc/openqrm-plugin-sshterm.conf"; $store = openqrm_parse_conf($OPENQRM_PLUGIN_SSHTERM_CONFIG_FILE); extract($store); $sshterm_login_ip = $p_resource->ip; $sshterm_window = 'window' . str_replace('.', '', $sshterm_login_ip); $sshterm_login_url = "https://{$sshterm_login_ip}:{$OPENQRM_PLUGIN_WEBSHELL_PORT}"; $html = new htmlobject($OPENQRM_SERVER_BASE_DIR . '/openqrm/web/base/class/htmlobjects'); $a = $html->a(); $a->label = 'SSHTerm'; $a->css = 'badge'; $a->href = '#'; $a->handler = 'onclick="sshwindow = window.open(\'' . $sshterm_login_url . '\',\'' . $sshterm_window . '\', \'location=0,status=0,scrollbars=yes,resizable=yes,width=972,height=500,left=100,top=100,screenX=400,screenY=100\'); sshwindow.focus(); return false;"'; $plugin_link = ''; if (strstr($p_appliance->state, "active")) { $plugin_link = $a; } if ($p_resource->id == 0) { $plugin_link = $a; } if ($p_resource->id == '') { $plugin_link = ""; } return $plugin_link; }
function get_lcmc_appliance_link($appliance_id) { global $event; global $OPENQRM_SERVER_BASE_DIR; global $OPENQRM_SERVER_IP_ADDRESS; global $OPENQRM_EXEC_PORT; $p_appliance = new appliance(); $p_appliance->get_instance_by_id($appliance_id); $p_resource = new resource(); $p_resource->get_instance_by_id($p_appliance->resources); $lcmc_gui = "/openqrm/base/plugins/lcmc/lcmc-gui.php"; $icon_size = "width='24' height='24'"; $icon_title = "Configure appliaction highavailability"; $html = new htmlobject($OPENQRM_SERVER_BASE_DIR . '/openqrm/web/base/class/htmlobjects'); $a = $html->a(); $a->label = 'LCMC'; //'<img title="'.$icon_title.'" alt="'.$icon_title.'" $icon_size src="/openqrm/base/plugins/lcmc/img/plugin.png" border=0>'; $a->css = 'badge'; $a->href = '#'; $a->handler = 'onclick="window.open(\'' . $lcmc_gui . '\',\'\', \'location=0,status=0,scrollbars=1,width=1150,height=800,left=50,top=50,screenX=50,screenY=50\');return false;"'; $plugin_link = ''; if (strstr($p_appliance->state, "active")) { $plugin_link = $a; } if ($p_resource->id == 0) { $plugin_link = $a; } if ($p_resource->id == '') { $plugin_link = ""; } return $plugin_link; }
public function select($sql) { $result = $this->pdo->query($sql); $result->setFetchMode(\PDO::FETCH_ASSOC); $data = $result->fetchAll(); return $data; }
/** * Construct * * @param registry $registry * @param int $currency_id Current currency_id id */ public function __construct($registry, $currency_id) { $this->_db = $registry->get('db'); try { $statement = $this->_db->prepare('SELECT * FROM `currency`'); $statement->execute(); } catch (PDOException $e) { if ($this->db->inTransaction()) { $this->db->rollBack(); } trigger_error($e->getMessage()); } if ($statement->rowCount()) { foreach ($statement->fetchAll() as $currency) { $this->_currencies[$currency->currency_id] = array('currency_id' => $currency->currency_id, 'code' => $currency->code, 'rate' => $currency->rate, 'symbol' => $currency->symbol, 'name' => $currency->name); if ($currency->currency_id == $currency_id) { $this->_currency_id = $currency->currency_id; $this->_currency_code = $currency->code; $this->_currency_rate = $currency->rate; $this->_currency_name = $currency->name; $this->_currency_symbol = $currency->symbol; } } } }
/** * Destroys the environment after each test method is run * * @return void * @access public */ public function endTest() { $this->mongodb = new MongodbSource($this->_config); $this->mongodb->connect(); $this->dropData(); unset($this->mongodb); }
function openqrm_template_deployment_resource_virtual_command($cmd, $resource_fields) { global $event; global $OPENQRM_SERVER_BASE_DIR; global $OPENQRM_SERVER_IP_ADDRESS; global $OPENQRM_EXEC_PORT; $resource_id = $resource_fields["resource_id"]; $resource = new resource(); $resource->get_instance_by_id($resource_id); $host_resource = new resource(); $host_resource->get_instance_by_id($resource->vhostid); $event->log("openqrm_template_deployment_resource_virtual_command", $_SERVER['REQUEST_TIME'], 5, "openqrm-template_deployment-resource-virtual-command-hook.php", "Handling {$cmd} command of resource {$resource->id} on host {$host_resource->id}", "", "", 0, 0, 0); switch ($cmd) { case "reboot": $event->log("openqrm_template_deployment_resource_virtual_command", $_SERVER['REQUEST_TIME'], 5, "openqrm-template_deployment-resource-virtual-command-hook.php", "Handling {$cmd} command", "", "", 0, 0, 0); $virtual_command = $OPENQRM_SERVER_BASE_DIR . "/openqrm/plugins/template_deployment/bin/openqrm-template_deployment-vm restart_by_mac -m " . $resource->mac . " -d noop --openqrm-cmd-mode background"; // reboot conflicts with appliance stop, commented out for now //$host_resource->send_command($host_resource->ip, $virtual_command); break; case "halt": $event->log("openqrm_template_deployment_resource_virtual_command", $_SERVER['REQUEST_TIME'], 5, "openqrm-template_deployment-resource-virtual-command-hook.php", "Handling {$cmd} command", "", "", 0, 0, 0); $virtual_command = $OPENQRM_SERVER_BASE_DIR . "/openqrm/plugins/template_deployment/bin/openqrm-template_deployment-vm stop_by_mac -m " . $resource->mac . " --openqrm-cmd-mode background"; $host_resource->send_command($host_resource->ip, $virtual_command); break; } }
function get_template_appliance_link($appliance_id) { global $event; global $OPENQRM_SERVER_BASE_DIR; global $OPENQRM_SERVER_IP_ADDRESS; global $OPENQRM_EXEC_PORT; $p_appliance = new appliance(); $p_appliance->get_instance_by_id($appliance_id); $p_resource = new resource(); $p_resource->get_instance_by_id($p_appliance->resources); $html = new htmlobject($OPENQRM_SERVER_BASE_DIR . '/openqrm/web/base/class/htmlobjects'); $a = $html->a(); $a->label = 'Template'; $a->css = 'badge'; $a->href = '#'; $a->handler = 'onclick="window.open(\'Template-URL\',\'\', \'location=0,status=0,scrollbars=1,width=1150,height=800,left=50,top=50,screenX=50,screenY=50\');return false;"'; $plugin_link = ''; if (strstr($p_appliance->state, "active")) { $plugin_link = $a; } if ($p_resource->id == 0) { $plugin_link = $a; } if ($p_resource->id == '') { $plugin_link = ""; } return $plugin_link; }
function openqrm_template_appliance($cmd, $appliance_fields) { global $event; global $OPENQRM_SERVER_BASE_DIR; global $OPENQRM_SERVER_IP_ADDRESS; global $OPENQRM_EXEC_PORT; $appliance_id = $appliance_fields["appliance_id"]; $appliance_name = $appliance_fields["appliance_name"]; $resource = new resource(); $resource->get_instance_by_id($appliance_fields["appliance_resources"]); $appliance_ip = $resource->ip; // check appliance values, maybe we are in update and they are incomplete if ($resource->id == "-1" || $resource->id == "") { return; } $event->log("openqrm_new_appliance", $_SERVER['REQUEST_TIME'], 5, "openqrm-template-appliance-hook.php", "Handling {$cmd} event {$appliance_id}/{$appliance_name}/{$appliance_ip}", "", "", 0, 0, $appliance_id); switch ($cmd) { case "start": $openqrm_server = new openqrm_server(); $openqrm_server->send_command($OPENQRM_SERVER_BASE_DIR . "/openqrm/plugins/template/bin/openqrm-template-manager start " . $appliance_id . " " . $appliance_name . " " . $appliance_ip . " --openqrm-cmd-mode background"); break; case "stop": $openqrm_server = new openqrm_server(); $openqrm_server->send_command($OPENQRM_SERVER_BASE_DIR . "/openqrm/plugins/template/bin/openqrm-template-manager stop " . $appliance_id . " " . $appliance_name . " " . $appliance_ip . " --openqrm-cmd-mode background"); break; } }
/** * 处理任务数据的回调方法 * @param function $callback * @param resource $vendorInstance * @param array $option * @throws MyRuntimeException */ public static function processJobData($callback, $vendorInstance, $option = array()) { $option += array('decode' => TRUE, 'delete' => TRUE, 'release' => FALSE, 'delay' => 10, 'priority' => 1024, 'timeout' => NULL); $retData = NULL; //echo 'proceed job data'.PHP_EOL; //var_dump($vendorInstance); $job = $vendorInstance->reserve($option['timeout']); //var_dump($job); if ($job) { if ($option['decode'] == TRUE) { $arg = self::decodeData($job->getData()); } else { $arg = $job->getData(); } if (!is_callable($callback)) { throw new RuntimeException('process data error'); } $retData = call_user_func($callback, $arg); if (!$retData) { if ($option['release'] == TRUE) { $vendorInstance->release($job, $option['priority'], $option['delay']); } throw new RuntimeException('process data error'); } if ($option['delete'] == TRUE) { $vendorInstance->delete($job); } } else { $arg = $job; } return $retData; }
public function getUser($login) { $this->connect(); $q = $this->bdCon->prepare("select * from " . $this->config['user_tab'] . " where " . $this->config['user_login'] . "='{$login}'"); $q->execute(); $res = $q->fetch(); return $res; }
/** * {@inheritdoc} */ public function nextRecord() { if (is_object($this->handle) && ($data = $this->handle->fetch_assoc())) { return $data; } else { return false; } }
/** * query * @param string $sql * @param resource $connResource * @return array */ public function query($sql, $connResource) { $rows = array(); $result = $connResource->query($sql); while ($row = $result->fetch_assoc()) { $rows[] = $row; } return $rows; }
/** * Creates a new OCI8Statement that uses the given connection handle and SQL statement. * * @param resource $dbh The connection handle. * @param string $statement The SQL statement. */ public function __construct($dbh, $statement, SQLite3Connection $conn) { list($statement, $paramMap) = self::convertPositionalToNamedPlaceholders($statement); $this->_sth = $dbh->prepare($statement); $this->_dbh = $dbh; $this->_ret = null; $this->_paramMap = $paramMap; $this->_conn = $conn; }
function openqrm_nagios3_appliance($cmd, $appliance_fields) { global $event; global $OPENQRM_SERVER_BASE_DIR; global $OPENQRM_SERVER_IP_ADDRESS; global $OPENQRM_EXEC_PORT; $appliance_id = $appliance_fields["appliance_id"]; $appliance = new appliance(); $appliance->get_instance_by_id($appliance_id); $appliance_name = $appliance_fields["appliance_name"]; $resource = new resource(); $resource->get_instance_by_id($appliance_fields["appliance_resources"]); $appliance_ip = $resource->ip; // check appliance values, maybe we are in update and they are incomplete if ($appliance->imageid == 1) { return; } if ($resource->id == "-1" || $resource->id == "") { return; } // get the nagios service checks $nagios_host = new nagios3_host(); $nagios_host->get_instance_by_appliance_id($appliance_id); $active_nagios_services = explode(',', $nagios_host->appliance_services); $nagios_service_list = ''; foreach ($active_nagios_services as $service_id) { $nagios_service = new nagios3_service(); $nagios_service->get_instance_by_id($service_id); $nagios_service_list = $nagios_service_list . "," . $nagios_service->port; } $nagios_service_list = substr($nagios_service_list, 1); if (!strlen($nagios_service_list)) { $event->log("openqrm_new_appliance", $_SERVER['REQUEST_TIME'], 5, "openqrm-nagios3-appliance-hook.php", "Appliance {$appliance_id} has no configured nagios services, skipping...", "", "", 0, 0, $appliance_id); return 0; } $event->log("openqrm_new_appliance", $_SERVER['REQUEST_TIME'], 5, "openqrm-nagios3-appliance-hook.php", "Handling {$cmd} event {$appliance_id}/{$appliance_name}/{$appliance_ip}", "", "", 0, 0, $appliance_id); switch ($cmd) { case "start": $nagios_appliance_start_cmd = $OPENQRM_SERVER_BASE_DIR . "/openqrm/plugins/nagios3/bin/openqrm-nagios-manager add -n " . $appliance_name . " -i " . $resource->ip . " -p " . $nagios_service_list . " --openqrm-cmd-mode background"; $openqrm_server = new openqrm_server(); $openqrm_server->send_command($nagios_appliance_start_cmd, NULL, true); break; case "stop": $nagios_appliance_stop_cmd = "{$OPENQRM_SERVER_BASE_DIR}/openqrm/plugins/nagios3/bin/openqrm-nagios-manager remove_host -n " . $appliance_name . " --openqrm-cmd-mode background"; $openqrm_server = new openqrm_server(); $openqrm_server->send_command($nagios_appliance_stop_cmd, NULL, true); break; case "remove": $nagios_appliance_stop_cmd = "{$OPENQRM_SERVER_BASE_DIR}/openqrm/plugins/nagios3/bin/openqrm-nagios-manager remove_host -n " . $appliance_name . " --openqrm-cmd-mode background"; $openqrm_server = new openqrm_server(); $openqrm_server->send_command($nagios_appliance_stop_cmd, NULL, true); // remove nagios_host from the db $nagios_host->remove_by_appliance_id($appliance_id); break; } }
/** * Connect to database * @param string $databaseName */ public function connect($databaseName = "") { $this->bdLink = @mysqli_connect($this->hostname, $this->username, $this->password, '', $this->port); $this->gestionErreur(!$this->bdLink, 'Connect - ' . self::ERROR_CONNECT . ' ' . $this->hostname); if ($databaseName != "") { $this->selectBd($databaseName); } //request with UTF-8 character set according to http://se.php.net/manual/en/function.mysqli-query.php $this->bdLink->query("SET NAMES 'utf8'"); }
/** * Méthode de connection à la base redis * * @return void */ private final function _connect() { trigger_error('start', E_USER_NOTICE); $this->redis = new Redis(); try { $this->redis->pconnect($this->getInput('host'), $this->getInput('port'), $this->getInput('timeout')); } catch (Exception $e) { trigger_error('redis connection error', E_USER_ERROR); } trigger_error('end', E_USER_NOTICE); }
/** * Constructor * * @param resource $pdooci PDOOCI connection * @param string $statement sql statement * * @return Statement $statement created */ public function __construct($pdooci, $statement) { try { $this->_pdooci = $pdooci; $this->_con = $pdooci->getConnection(); $this->_statement = Statement::insertMarks($statement); $this->_stmt = \oci_parse($this->_con, $this->_statement); $this->_fetch_sty = \PDO::FETCH_BOTH; } catch (\Exception $e) { throw new \PDOException($e->getMessage()); } }
/** * Load model * * @param string $model */ public function model($model) { $file = DIR_BASE . 'application' . DIR_SEPARATOR . 'model' . DIR_SEPARATOR . $model . '.php'; $class = 'Model' . preg_replace('/[^a-zA-Z0-9]/', '', $model); if (file_exists($file)) { include_once $file; $this->registry->set('model_' . str_replace(DIR_SEPARATOR, '_', $model), new $class($this->registry)); } else { trigger_error('Error: Could not load model ' . $file . '!'); exit; } }
/** * Get a list of recycle bin contents for the current user * @param object $userObj current user object * @param resource $db database connection * @return array of recycle bin contents */ static function get_recyclebin_contents($userObj, $db) { $recycle_bin = array(); // Query the Papers tables. $i = 0; $stmt = $db->prepare("SELECT property_id AS id, paper_type, paper_title, DATE_FORMAT(deleted,'%Y%m%d%H%i') AS deleted FROM properties WHERE paper_ownerID = ? AND deleted IS NOT NULL"); $stmt->bind_param('i', $userObj->get_user_ID()); $stmt->execute(); $stmt->bind_result($id, $paper_type, $paper_title, $deleted); while ($stmt->fetch()) { $recycle_bin[$i]['id'] = $id; $recycle_bin[$i]['type'] = 'paper'; $recycle_bin[$i]['name'] = $paper_title; $recycle_bin[$i]['deleted'] = $deleted; $recycle_bin[$i]['subtype'] = $paper_type; $i++; } $stmt->close(); // Query the Questions tables. $stmt = $db->prepare("SELECT q_id AS id, q_type, leadin_plain, DATE_FORMAT(deleted,'%Y%m%d%H%i') AS deleted FROM questions WHERE ownerID = ? AND deleted IS NOT NULL"); $stmt->bind_param('i', $userObj->get_user_ID()); $stmt->execute(); $stmt->bind_result($id, $q_type, $leadin_plain, $deleted); while ($stmt->fetch()) { $recycle_bin[$i]['id'] = $id; $recycle_bin[$i]['type'] = 'question'; if ($q_type == 'sct') { $parts = explode('~', $leadin_plain); $recycle_bin[$i]['name'] = $parts[0]; } else { $recycle_bin[$i]['name'] = $leadin_plain; } $recycle_bin[$i]['deleted'] = $deleted; $recycle_bin[$i]['subtype'] = $q_type; $i++; } $stmt->close(); // Query the Folder tables. $stmt = $db->prepare("SELECT id, name, DATE_FORMAT(deleted,'%Y%m%d%H%i') AS deleted FROM folders WHERE ownerID = ? AND deleted IS NOT NULL"); $stmt->bind_param('i', $userObj->get_user_ID()); $stmt->execute(); $stmt->bind_result($id, $name, $deleted); while ($stmt->fetch()) { $recycle_bin[$i]['id'] = $id; $recycle_bin[$i]['type'] = 'folder'; $recycle_bin[$i]['name'] = str_replace(';', '\\', $name); $recycle_bin[$i]['deleted'] = $deleted; $recycle_bin[$i]['subtype'] = ''; $i++; } $stmt->close(); return $recycle_bin; }
/** * Creates a new OCI8Statement that uses the given connection handle and SQL statement. * * @param resource $dbh The connection handle. * @param string $statement The SQL statement. */ public function __construct($dbh, $statement, SQLite3Connection $conn) { $this->_dbh = $dbh; list($statement, $paramMap) = self::convertPositionalToNamedPlaceholders($statement); $this->_sth = $dbh->prepare($statement); if (!$this->_sth) { throw SQLite3Exception::fromErrorInfo($this->errorInfo()); } $this->_ret = null; $this->_paramMap = $paramMap; $this->_conn = $conn; }
function get_nagios3_appliance_edit($appliance_id, $openqrm, $response) { $p_appliance = new appliance(); $p_appliance->get_instance_by_id($appliance_id); $p_resource = new resource(); $p_resource->get_instance_by_id($p_appliance->resources); if ($p_resource->id !== '') { $a = $response->html->a(); $a->label = '<img title="Service monitoring" alt="Service monitoring" height="24" width="24" src="' . $openqrm->get('baseurl') . '/plugins/nagios3/img/plugin.png" border=0>'; $a->href = $openqrm->get('baseurl') . '/index.php?base=appliance&appliance_action=load_edit&aplugin=nagios3&appliance_id=' . $appliance_id . '&nagios3_action=edit'; return $a; } }
/** * Return Http Response object for a given url. */ public function getResponse($url) { try { $response = $this->http_client->get($url, array('headers' => $this->getRequestHeaders())); if (empty($response)) { throw new MigrateException('No response at ' . $this->getPath() . '.'); } } catch (RequestException $e) { throw new MigrateException('Error message: ' . $e->getMessage() . ' at ' . $url . '.'); $response = NULL; } return $response; }
function __construct() { /*//Conectando ao banco de dados $this->o_db = new PDO("sqlite:./databases/db.sq3");*/ //Mudando para MySQL $st_host = 'localhost'; $st_banco = 'ufpa_pdti'; $st_usuario = 'root'; $st_senha = ''; $st_dsn = "mysql:host={$st_host};dbname={$st_banco}"; $this->o_db = new PDO($st_dsn, $st_usuario, $st_senha); $this->o_db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); }
/** * {@inheritDoc} */ public function quoteTrustedValue($value) { if ($this->resource instanceof DriverInterface) { $this->resource = $this->resource->getConnection()->getResource(); } if (is_resource($this->resource)) { return '\'' . pg_escape_string($this->resource, $value) . '\''; } if ($this->resource instanceof \PDO) { return $this->resource->quote($value); } return 'E' . parent::quoteTrustedValue($value); }
function action() { $resource = new resource(); $resource->get_instance_by_id(0); $t = $this->response->html->template($this->tpldir . '/local-server-about-usage.tpl.php'); $t->add($this->response->html->thisfile, "thisfile"); $t->add($this->lang['label'], 'label'); $t->add($this->lang['usage_integrate_title'], 'usage_integrate_title'); $t->add($this->lang['usage_remove_title'], 'usage_remove_title'); $t->add(sprintf($this->lang['usage_integrate_content'], $this->basedir, $resource->ip), 'usage_integrate_content'); $t->add(sprintf($this->lang['usage_remove_content'], $resource->ip), 'usage_remove_content'); $t->add($this->openqrm->get('baseurl'), 'baseurl'); return $t; }