コード例 #1
0
 public function _initialize()
 {
     $this->assign('title', '正在跳转微信支付');
     $this->addJs('/js/weixin/api.js');
     $this->notifyUrl = add_host(U('Interface/index'));
     parent::_initialize();
 }
コード例 #2
0
ファイル: deven.php プロジェクト: gresakg/deven
    chgrp($server_root, $group);
    //add initial index file to test if it works
    $file = fopen($server_root . "/index.php", "w");
    fwrite($file, "<?php phpinfo(); ?>");
    fclose($file);
    chown($server_root . "/index.php", $user);
}
//write apache config file
$file = fopen($apache_config_dir . $domain . ".conf", "w");
ob_start();
include 'vhtpl.php';
$content = ob_get_clean();
fwrite($file, $content);
fclose($file);
//add entry to /etc/hosts
add_host($domain, $ip);
//enable new site
exec("a2ensite " . $domain);
//restart apache
exec("service apache2 reload");
echo "The developpement environement for " . $domain . "is successfully created!" . nl . "If you point your browser to {$domain} you should see phpinfo()." . nl . "You can start working on your project in {$server_root}" . nl . "You will find apache logs in {$logpath}." . nl . "Have fun!" . nl;
// end the script with carriage return
echo nl;
function add_host($hostname, $ip = "127.0.0.1")
{
    $file = fopen("/etc/hosts", "a");
    fwrite($file, nl . "# Line added by DevEn" . nl);
    fwrite($file, $ip . "\t" . $hostname . nl);
    fclose($file);
    echo nl . "Domain " . $hostname . " with the ip " . $ip . " added to the hosts file." . nl;
}
コード例 #3
0
ファイル: hosts.php プロジェクト: rennhak/zabbix
 }
 $result = true;
 DBstart();
 if (isset($_REQUEST['hostid'])) {
     if (isset($_REQUEST['clear_templates'])) {
         foreach ($_REQUEST['clear_templates'] as $id) {
             $result &= unlink_template($_REQUEST['hostid'], $id, false);
         }
     }
     $result = update_host($_REQUEST['hostid'], $_REQUEST['host'], $_REQUEST['port'], $_REQUEST['status'], $useip, $_REQUEST['dns'], $_REQUEST['ip'], $_REQUEST['proxy_hostid'], $templates, $useipmi, $_REQUEST['ipmi_ip'], $_REQUEST['ipmi_port'], $_REQUEST['ipmi_authtype'], $_REQUEST['ipmi_privilege'], $_REQUEST['ipmi_username'], $_REQUEST['ipmi_password'], $_REQUEST['newgroup'], $groups);
     $msg_ok = S_HOST_UPDATED;
     $msg_fail = S_CANNOT_UPDATE_HOST;
     /*			$audit_action 	= AUDIT_ACTION_UPDATE;*/
     $hostid = $_REQUEST['hostid'];
 } else {
     $hostid = $result = add_host($_REQUEST['host'], $_REQUEST['port'], $_REQUEST['status'], $useip, $_REQUEST['dns'], $_REQUEST['ip'], $_REQUEST['proxy_hostid'], $templates, $useipmi, $_REQUEST['ipmi_ip'], $_REQUEST['ipmi_port'], $_REQUEST['ipmi_authtype'], $_REQUEST['ipmi_privilege'], $_REQUEST['ipmi_username'], $_REQUEST['ipmi_password'], $_REQUEST['newgroup'], $groups);
     $msg_ok = S_HOST_ADDED;
     $msg_fail = S_CANNOT_ADD_HOST;
     /*			$audit_action 	= AUDIT_ACTION_ADD;*/
 }
 if (!zbx_empty($hostid) && $hostid && $clone_hostid && $_REQUEST['form'] == 'full_clone') {
     // Host applications
     $sql = 'SELECT * FROM applications WHERE hostid=' . $clone_hostid . ' AND templateid=0';
     $res = DBselect($sql);
     while ($db_app = DBfetch($res)) {
         add_application($db_app['name'], $hostid, 0);
     }
     // Host items
     $sql = 'SELECT DISTINCT i.itemid, i.description ' . ' FROM items i ' . ' WHERE i.hostid=' . $clone_hostid . ' AND i.templateid=0 ' . ' ORDER BY i.description';
     $res = DBselect($sql);
     while ($db_item = DBfetch($res)) {
コード例 #4
0
ファイル: import.inc.php プロジェクト: phedders/zabbix
 function StartElement($parser, $name, $attrs)
 {
     $this->element_data = '';
     if (!isset($this->root)) {
         if ($name == XML_TAG_ZABBIX_EXPORT) {
             if (isset($attrs['version'])) {
                 if ($attrs['version'] == '1.0') {
                     $this->root = true;
                     return;
                 } else {
                     error(S_UNSUPPORTED_VERSION_OF_IMPORTED_DATA);
                 }
             }
         }
         error(S_UNSUPPORTED_FILE_FORMAT);
         $this->root = false;
     } else {
         if (!$this->root) {
             return false;
         }
     }
     $data =& $this->data[$name];
     foreach ($attrs as $id => $val) {
         $attrs[$id] = html_entity_decode($val);
     }
     switch ($name) {
         case XML_TAG_HOST:
             $this->main_node = array($name);
             $this->sub_node = null;
             $data = $attrs;
             $data['groups'] = array();
             $data['skip'] = false;
             $sql = 'SELECT hostid ' . ' FROM hosts' . ' WHERE host=' . zbx_dbstr($data['name']) . ' AND status IN (' . HOST_STATUS_MONITORED . ',' . HOST_STATUS_NOT_MONITORED . ',' . HOST_STATUS_TEMPLATE . ')' . ' AND ' . DBin_node('hostid', get_current_nodeid(false));
             if ($host_data = DBfetch(DBselect($sql))) {
                 /* exist */
                 if ($this->host['exist'] == 1) {
                     $data['skip'] = true;
                     info('Host [' . $data['name'] . '] skipped - user rule');
                     break;
                     // case
                 }
                 if (!isset($this->available_hosts[$host_data['hostid']])) {
                     error('Host [' . $data['name'] . '] skipped - Access deny.');
                     break;
                     // case
                 }
                 $data['hostid'] = $host_data['hostid'];
                 $data['templates'] = get_templates_by_hostid($host_data['hostid']);
                 $data['groups'] = get_groupids_by_host($host_data['hostid']);
             } else {
                 /* missed */
                 if ($this->host['missed'] == 1) {
                     /* skip */
                     $data['skip'] = true;
                     info('Host [' . $data['name'] . '] skipped - user rule');
                     break;
                     // case
                 }
                 if (!uint_in_array(get_current_nodeid(), $this->available_nodes)) {
                     error('Host [' . $data['name'] . '] skipped - access denied.');
                     break;
                     // case
                 }
                 $data['templates'] = array();
                 $data['hostid'] = add_host($data['name'], 10050, HOST_STATUS_TEMPLATE, 0, '', '', 0, array(), 'no', '', 623, -1, 2, '', '', null, array());
             }
             break;
             // case
         // case
         case XML_TAG_GRAPH:
             $data = $attrs;
             $data['items'] = array();
             $this->sub_node = null;
             array_push($this->main_node, $name);
             break;
             // case
         // case
         case XML_TAG_DEPENDENCY:
             // checks if trigger has been skipped
             if (str_in_array($attrs['description'], $this->data[XML_TAG_DEPENDENCIES]['skip'])) {
                 info('Trigger [' . $attrs['description'] . '] dependency update skipped - user rule');
                 break;
             }
             // searches trigger by host name & trigger description
             if (!($trigger_down = get_trigger_by_description($attrs['description']))) {
                 error('Trigger [' . $attrs['description'] . '] dependency update skipped - trigger not found');
                 break;
             }
             $data['triggerid_down'] = $trigger_down['triggerid'];
             $data['triggerid_up'] = array();
             $this->sub_node = null;
             array_push($this->main_node, $name);
             break;
         case XML_TAG_HOSTPROFILE:
         case XML_TAG_HOSTPROFILE_EXT:
         case XML_TAG_TEMPLATE:
         case XML_TAG_ITEM:
         case XML_TAG_TRIGGER:
         case XML_TAG_DEPENDS:
         case XML_TAG_GRAPH_ELEMENT:
             /*case XML_TAG_SCREEN:
             		case XML_TAG_SCREEN_ELEMENT:*/
             $data = $attrs;
             $this->sub_node = null;
             array_push($this->main_node, $name);
             break;
             // case
         // case
         case XML_TAG_HOSTS:
             $this->data[XML_TAG_DEPENDENCIES]['skip'] = array();
             break;
         case XML_TAG_DEPENDENCIES:
         case XML_TAG_ZABBIX_EXPORT:
         case XML_TAG_GROUPS:
         case XML_TAG_APPLICATIONS:
         case XML_TAG_TEMPLATES:
         case XML_TAG_ITEMS:
         case XML_TAG_TRIGGERS:
         case XML_TAG_GRAPHS:
             /* case XML_TAG_SCREENS:*/
             $this->sub_node = null;
             break;
             // case
         // case
         case XML_TAG_GROUP:
         case XML_TAG_APPLICATION:
         default:
             $this->sub_node = $name;
             break;
             // case
     }
 }
コード例 #5
0
 public function responseSubscribeMsg()
 {
     //个性化二维码
     if (isset($this->postObj->EventKey)) {
         $eventKey = (string) $this->postObj->EventKey;
         $pcid = substr($eventKey, 8);
     } else {
         $pcid = 0;
     }
     //取用户的基本信息
     $openid = (string) $this->postObj->FromUserName;
     $accessToken = get_access_token();
     $data = get_weichat_user_info($openid, $accessToken);
     //用出客户基本信息
     //添加或更新用户信息
     $customerInfo = get_customer_info($openid);
     $customer = new \Customer\Model\CustomerModel();
     $data['subcribe_time'] = time();
     if ($customerInfo == FALSE) {
         //进行注册送券活动
         $this->_sentCouponForNewUser($openid, $pcid);
         //取上线用户信息
         $oldCustomerInfo = $customer->getCustomerInfoById($pcid);
         if ($oldCustomerInfo != false) {
             $oldOpendid = $oldCustomerInfo['openid'];
         } else {
             $oldOpendid = '';
         }
         //进行注册送红包活动
         $SendRedGiftController = new SendRedGiftController();
         $SendRedGiftController->sendRedGiftForCustomer($openid, $oldOpendid);
         //加上邀请码
         $code = $customer->checkCode();
         $data['parentid'] = $pcid;
         $data['customer_code'] = $code;
     } else {
         if ($customerInfo['parentid'] == 0) {
             $data['parentid'] = $pcid;
         }
     }
     $userInfo[] = $data;
     $customer->addUserInfo($userInfo);
     $reply = new ReplyModel();
     $id = 1;
     $reply->setId($id);
     $message = $reply->getInfoById();
     //获取附件信息
     $attch = new AttachmentModel();
     $key = 'picurl';
     $attch->setKey($key);
     $attch->setInfo($message);
     $message = $attch->findInfo();
     if ($message['news_type'] == 0) {
         $replyMessage = A('ReplyMessage');
         $replyMessage->setText($message['description']);
         $replyMessage->replyTextMessage();
     } elseif ($message['news_type'] == 1) {
         $replyMessage = A('ReplyMessage');
         $data['title'] = $message['title'];
         $data['description'] = $message['description'];
         $data['url'] = $message['url'];
         $data['picurl'] = add_host($message[$key]['url']);
         $news[] = $data;
         $replyMessage->setNews($news);
         $replyMessage->replyNewsMessage();
     } else {
         $replyMessage = A('ReplyMessage');
         $replyMessage->setText('系统错误');
         $replyMessage->replyTextMessage();
     }
     return;
 }
コード例 #6
0
ファイル: host.php プロジェクト: neoloc/mscadmin
    gohome();
}
// are you in the correct group?
if ($_SESSION['role_id'] < 2) {
    errormsg('Your role does not have access to this resource');
} else {
    if (isset($_POST['host_name']) && isset($_POST['host_alias'])) {
        // Setup POST data as a new variable
        $host_name = $_POST['host_name'];
        $host_alias = $_POST['host_alias'];
        $host_key = md5(uniqid(rand(), true));
        if (!check_host_name_isfree($host_name, $mysqli)) {
            errormsg("host_name is already in use");
        }
        if (!check_host_alias_isfree($host_alias, $mysqli)) {
            errormsg("host_alias is already in use");
        }
        if (!check_host_key_isfree($host_key, $mysqli)) {
            errormsg("host_key is already in use");
        }
        if (add_host($host_name, $host_alias, $host_key, $mysqli)) {
            echo "\n\t\t\t<!-- Begin Content Division -->\n\t\t\t<div id='content'>\t\t\t\t\t\n\t\t\t\t<legend>Create Host</legend>\n\t\t\t\t" . quickalert("success", "New host has been added.") . "\t\t\t\t\n\t\t\t<!-- End Content Division -->\n\t\t\t</div>\n\t\t\t";
        } else {
            errormsg("Failed to insert new record into the database");
        }
    } elseif (!$_POST) {
        echo "\n\t\t<!-- Begin Content Division -->\n\t\t<div id='content'>\n\t\t\t<form class='form-horizontal' action='" . SITE_URL . "/?do=create&object=host' method='post' name='create_host'>\n\t\t\t\t<fieldset>\n\t\t\t\t\n\t\t\t\t<legend>Create Host</legend>\n\t\t\t\t" . quickalert("info", "New host will need to be in the same layer2 network segment.") . "\n\t\t\t\t\n\t\t\t\t<div class='form-group'>\n\t\t\t\t  <label class='col-md-4 control-label' for='textinput'>Host Address</label>\n\t\t\t\t  <div class='col-md-4'>\n\t\t\t\t  <input\n\t\t\t\t  \trequired\n\t\t\t\t  \ttype='text'\n\t\t\t\t  \tname='host_name'\n\t\t\t\t  \tplaceholder='e.g msc-scanner1.yourdomain.tld'\n\t\t\t\t  \tclass='form-control input-md'\n\t\t\t\t  \tsize='50'\n\t\t\t\t  \tpattern='^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])|(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\\-]*[a-zA-Z0-9])\\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\\-]*[A-Za-z0-9])\$'\n\t\t\t\t  >\n\t\t\t\t  <span class='help-block'>FQDN or IP address of the host</span>  \n\t\t\t\t  </div>\n\t\t\t\t</div>\n\t\t\t\t\n\t\t\t\t<div class='form-group'>\n\t\t\t\t  <label class='col-md-4 control-label' for='textinput'>Host Alias</label>  \n\t\t\t\t  <div class='col-md-4'>\n\t\t\t\t  <input required name='host_alias' name='host_alias' type='text' placeholder='e.g. Scanner1' pattern='^([a-zA-Z0-9]){3,50}\$' class='form-control input-md'>\n\t\t\t\t  <span class='help-block'>Enter an Alias for the host</span>  \n\t\t\t\t  </div>\n\t\t\t\t</div>\n\t\t\t\t\n\t\t\t\t<div class='form-group'>\n\t\t\t\t  <label class='col-md-4 control-label' for='singlebutton'></label>\n\t\t\t\t  <div class='col-md-4'>\n\t\t\t\t\t<button id='singlebutton' name='singlebutton' class='btn success large' type='submit'><span class='glyphicon glyphicon-plus-sign' id='logIcon'></span> Create </button>\n\t\t\t\t  </div>\n\t\t\t\t</div>\n\t\t\t\t\n\t\t\t\t</fieldset>\n\t\t\t</form>\n\t\t<!-- End Content Division -->\n\t\t</div>\n\t\t";
    } else {
        errormsg('post error and create_transmap page');
    }
}
コード例 #7
0
ファイル: class.chost.php プロジェクト: phedders/zabbix
 /**
  * Add Host
  *
  * {@source}
  * @access public
  * @static
  * @since 1.8
  * @version 1
  *
  * @param _array $hosts multidimensional array with Hosts data
  * @param string $hosts['host'] Host name.
  * @param array $hosts['groupids'] HostGroup IDs add Host to.
  * @param int $hosts['port'] Port. OPTIONAL
  * @param int $hosts['status'] Host Status. OPTIONAL
  * @param int $hosts['useip'] Use IP. OPTIONAL
  * @param string $hosts['dns'] DNS. OPTIONAL
  * @param string $hosts['ip'] IP. OPTIONAL
  * @param int $hosts['proxy_hostid'] Proxy Host ID. OPTIONAL
  * @param int $hosts['useipmi'] Use IPMI. OPTIONAL
  * @param string $hosts['ipmi_ip'] IPMAI IP. OPTIONAL
  * @param int $hosts['ipmi_port'] IPMI port. OPTIONAL
  * @param int $hosts['ipmi_authtype'] IPMI authentication type. OPTIONAL
  * @param int $hosts['ipmi_privilege'] IPMI privilege. OPTIONAL
  * @param string $hosts['ipmi_username'] IPMI username. OPTIONAL
  * @param string $hosts['ipmi_password'] IPMI password. OPTIONAL
  * @return boolean
  */
 public static function add($hosts)
 {
     $templates = null;
     $newgroup = '';
     $error = 'Unknown ZABBIX internal error';
     $result_ids = array();
     $result = false;
     DBstart(false);
     foreach ($hosts as $host) {
         if (empty($host['groupids'])) {
             $result = false;
             $error = 'No groups for host [ ' . $host['host'] . ' ]';
             break;
         }
         $host_db_fields = array('host' => null, 'port' => 0, 'status' => 0, 'useip' => 0, 'dns' => '', 'ip' => '0.0.0.0', 'proxy_hostid' => 0, 'useipmi' => 0, 'ipmi_ip' => '', 'ipmi_port' => 623, 'ipmi_authtype' => 0, 'ipmi_privilege' => 0, 'ipmi_username' => '', 'ipmi_password' => '');
         if (!check_db_fields($host_db_fields, $host)) {
             $result = false;
             $error = 'Wrong fields for host [ ' . $host['host'] . ' ]';
             break;
         }
         $result = add_host($host['host'], $host['port'], $host['status'], $host['useip'], $host['dns'], $host['ip'], $host['proxy_hostid'], $templates, $host['useipmi'], $host['ipmi_ip'], $host['ipmi_port'], $host['ipmi_authtype'], $host['ipmi_privilege'], $host['ipmi_username'], $host['ipmi_password'], $newgroup, $host['groupids']);
         if (!$result) {
             break;
         }
         $result_ids[$result] = $result;
     }
     $result = DBend($result);
     if ($result) {
         return $result_ids;
     } else {
         self::$error = array('error' => ZBX_API_ERROR_INTERNAL, 'data' => $error);
         //'Internal zabbix error');
         return false;
     }
 }
コード例 #8
0
                # Wenn DHCP Subnet zu IP nicht existiert dann kein Eintrag DHCP
                if ($network = test_ip_dhcpsubnet($ip)) {
                    print "<b>Subnetz {$network}/24</b> nicht im DHCP eingetragen<br>Client wird nicht in DHCP eingetragen<br><br>";
                    #$ip = "";
                    $dhcp = "";
                }
            } else {
                echo "IP Adresse {$ip} nicht korrekt!<br>Client wird ohne IP Adresse eingetragen.<br><br>";
                $ip = "";
                if ($dhcp) {
                    echo "Client wird nicht in DHCP eingetragen.<br><br>";
                    $dhcp = "";
                }
            }
        }
        if (add_host($hostDN, $hostname, $hostdesc, $mac, $ip, $atts, $dhcp)) {
            $mesg .= "<br>Neuer Rechner erfolgreich angelegt<br>";
        } else {
            $automatic_back = 0;
            $mesg .= "<br>Fehler beim anlegen des Rechners!<br>";
        }
        $url = 'hostoverview.php';
    } else {
        $seconds = 4;
        $mesg = "In der Domain <b>{$assocdom}</b> existiert bereits ein Client mit Namen <b>{$hostname}</b>!<br><br>\n\t\t\t\t\tBitte w&auml;hlen Sie einen anderen HOSTNAMEN.<br><br>";
        $get_hostdesc = str_replace(" ", "_", $hostdesc);
        $get_mac = str_replace(" ", "_", $mac);
        $get_ip = str_replace(" ", "_", $ip);
        $url = "new_host.php?hostname=Hier_anderen_HOSTNAME_eingeben&hostdesc=" . $get_hostdesc . "&mac=" . $get_mac . "&ip=" . $ip;
    }
} else {
コード例 #9
0
    exit;
}
if (isset($_GET["PostFixEnableAiguilleuse-list"])) {
    routing_list();
    exit;
}
if (isset($_GET["PostFixEnableAiguilleuseAdd"])) {
    PostFixEnableAiguilleuseAdd();
    exit;
}
if (isset($_GET["PostFixAiguilleuseServerDelete"])) {
    del_host();
    exit;
}
if (isset($_GET["PostFixEnableAiguilleuse-insert"])) {
    add_host();
    exit;
}
js();
function js()
{
    $page = CurrentPageName();
    $users = new usersMenus();
    $tpl = new templates();
    $title = $tpl->_ENGINE_parse_body('{InternalRouter}');
    $html = "\n\nfunction InternalRouter_load(){\n\tYahooWin4('650','{$page}?popup=yes&ou={$_GET["ou"]}&hostname={$_GET["hostname"]}','{$title}');\n\t\n\t}\n\t\nfunction PostFixEnableAiguilleuseAdd(){\n\tYahooWin3('400','{$page}?PostFixEnableAiguilleuseAdd=yes&ou={$_GET["ou"]}&hostname={$_GET["hostname"]}','{$title}');\n}\n\t\nInternalRouter_load();\n";
    echo $html;
}
function save_enable()
{
    $ou = base64_decode($_GET["ou"]);