コード例 #1
0
ファイル: iterTest.php プロジェクト: nikic/iter
 public function testReindex()
 {
     $iter = reindex('strtoupper', ['a', 'b', 'c', 'd', 'e']);
     $this->assertSame(['A' => 'a', 'B' => 'b', 'C' => 'c', 'D' => 'd', 'E' => 'e'], toArrayWithKeys($iter));
     $iter = reindex(fn\operator('*', 2), [1, 2, 3, 4]);
     $this->assertSame([2 => 1, 4 => 2, 6 => 3, 8 => 4], toArrayWithKeys($iter));
 }
コード例 #2
0
ファイル: query_host_cpu.php プロジェクト: songchin/Cacti
function get_indexes($hostname, $snmp_community, $snmp_version, $snmp_auth_username, $snmp_auth_password, $snmp_auth_protocol, $snmp_priv_passphrase, $snmp_priv_protocol, $snmp_context, $snmp_port, $snmp_timeout, $ping_retries, $max_oids)
{
    $arr = reindex(cacti_snmp_walk($hostname, $snmp_community, ".1.3.6.1.2.1.25.3.3.1", $snmp_version, $snmp_auth_username, $snmp_auth_password, $snmp_auth_protocol, $snmp_priv_passphrase, $snmp_priv_protocol, $snmp_context, $snmp_port, $snmp_timeout, $ping_retries, $max_oids, SNMP_POLLER));
    $return_arr = array();
    $j = 0;
    for ($i = 0; $i < sizeof($arr); $i++) {
        if (ereg("^[0-9]+\$", $arr[$i])) {
            $return_arr[$j] = $j;
            $j++;
        }
    }
    return $return_arr;
}
コード例 #3
0
function get_indexes($hostname, $snmp_community, $snmp_version)
{
    $arr = reindex(cacti_snmp_walk($hostname, $snmp_community, ".1.3.6.1.2.1.25.3.3.1", $snmp_version, "", "", 161, 1000));
    $return_arr = array();
    $j = 0;
    for ($i = 0; $i < sizeof($arr); $i++) {
        if (ereg("^[0-9]+\$", $arr[$i])) {
            $return_arr[$j] = $j;
            $j++;
        }
    }
    return $return_arr;
}
コード例 #4
0
ファイル: query_host_cpu.php プロジェクト: songchin/Cacti
function get_indexes($hostname, $snmp_community, $snmp_version, $snmpv3_auth_username, $snmpv3_auth_password, $snmpv3_auth_protocol, $snmpv3_priv_passphrase, $snmpv3_priv_protocol) {
	$arr = reindex(cacti_snmp_walk($hostname, $snmp_community, ".1.3.6.1.2.1.25.3.3.1", $snmp_version, $snmpv3_auth_username, $snmpv3_auth_password, $snmpv3_auth_protocol, $snmpv3_priv_passphrase, $snmpv3_priv_protocol, 161, 1000));
	$return_arr = array();

	$j = 0;

	for ($i=0;($i<sizeof($arr));$i++) {
		if (is_numeric($arr[$i])) {
			$return_arr[$j] = $j;
			$j++;
		}
	}

	return $return_arr;
}
コード例 #5
0
    function _submit(&$sync)
    {
        global $config, $db, $auth, $user;
        if ($sync === false) {
            //submit() was called directly so we need to sync after it
            $sync = new syncer();
            $exec_sync = true;
        } else {
            //submit() was called by topic->submit(), sync there when everything is done
            $exec_sync = false;
        }
        if (!$this->post_id) {
            //new post, set some default values if not set yet
            if (!$this->poster_id) {
                $this->poster_id = $user->data['user_id'];
            }
            if (!$this->poster_ip) {
                $this->poster_ip = $user->ip;
            }
            if (!$this->post_time) {
                $this->post_time = time();
            }
        }
        $this->post_subject = truncate_string($this->post_subject);
        $sql_data = array('poster_id' => $this->poster_id, 'poster_ip' => $this->poster_ip, 'topic_id' => $this->topic_id, 'forum_id' => $this->forum_id, 'post_username' => $this->post_username, 'icon_id' => $this->icon_id, 'post_time' => $this->post_time, 'post_postcount' => $this->post_postcount ? 1 : 0, 'post_visibility' => $this->post_visibility, 'post_reported' => $this->post_reported ? 1 : 0, 'enable_bbcode' => $this->enable_bbcode ? 1 : 0, 'enable_smilies' => $this->enable_smilies ? 1 : 0, 'enable_magic_url' => $this->enable_magic_url ? 1 : 0, 'enable_sig' => $this->enable_sig ? 1 : 0, 'post_subject' => $this->post_subject, 'bbcode_bitfield' => 0, 'bbcode_uid' => '', 'post_text' => $this->post_text, 'post_checksum' => md5($this->post_text), 'post_edit_time' => $this->post_edit_time, 'post_edit_reason' => $this->post_edit_reason, 'post_edit_user' => $this->post_edit_user, 'post_edit_count' => $this->post_edit_count, 'post_edit_locked' => $this->post_edit_locked, 'post_delete_time' => $this->post_delete_time, 'post_delete_reason' => $this->post_delete_reason, 'post_delete_user' => $this->post_delete_user);
        $flags = '';
        generate_text_for_storage($sql_data['post_text'], $sql_data['bbcode_uid'], $sql_data['bbcode_bitfield'], $flags, $this->enable_bbcode, $this->enable_magic_url, $this->enable_smilies);
        if ($this->post_id && $this->topic_id) {
            //edit
            $sql = "SELECT p.*, t.topic_first_post_id, t.topic_last_post_id, t.topic_approved, t.topic_replies\n\t\t\t\t\tFROM " . POSTS_TABLE . " p\n\t\t\t\t\tLEFT JOIN " . TOPICS_TABLE . " t ON (t.topic_id = p.topic_id)\n\t\t\t\t\tWHERE p.post_id=" . intval($this->post_id);
            //$sql = "SELECT * FROM " . POSTS_TABLE . " WHERE post_id=" . intval($this->post_id);
            $result = $db->sql_query($sql);
            $post_data = $db->sql_fetchrow($result);
            $db->sql_freeresult($result);
            if (!$post_data) {
                trigger_error("post_id={$this->post_id}, but that post does not exist", E_USER_ERROR);
            }
            //check first/last post
            $is_first_post = $post_data['post_id'] == $post_data['topic_first_post_id'];
            $is_last_post = $post_data['post_id'] == $post_data['topic_last_post_id'];
            $db->sql_transaction('begin');
            $sql = "UPDATE " . POSTS_TABLE . " SET " . $db->sql_build_array('UPDATE', $sql_data) . " WHERE post_id=" . $this->post_id;
            $db->sql_query($sql);
            if ($this->topic_id != $post_data['topic_id']) {
                //merge into new topic
                //get new topic's forum id and first/last post time
                $sql = "SELECT forum_id, topic_time, topic_last_post_time\n\t\t\t\t\t\tFROM " . TOPICS_TABLE . "\n\t\t\t\t\t\tWHERE topic_id = {$this->topic_id}";
                $result = $db->sql_query($sql);
                $new_topic_data = $db->sql_fetchrow($result);
                if (!$new_topic_data) {
                    trigger_error("attempted to merge post {$this->post_id} into topic {$this->topic_id}, but that topic does not exist", E_USER_ERROR);
                }
                //sync forum_posts
                //TODO
                if ($new_topic_data['forum_id'] != $post_data['forum_id']) {
                    $sync->add('forum', $post_data['forum_id'], 'forum_posts', $this->post_approved ? -1 : 0);
                    $sync->add('forum', $new_topic_data['forum_id'], 'forum_posts', $this->post_approved ? 1 : 0);
                    if ($this->forum_id != $new_topic_data['forum_id']) {
                        //user changed topic_id but not forum_id, so we saved the wrong one above. correct it via sync
                        $this->forum_id = $new_topic_data['forum_id'];
                        $sync->set('post', $this->post_id, 'forum_id', $this->forum_id);
                    }
                }
                //sync old topic
                $sync->add('topic', $post_data['topic_id'], 'topic_replies', $this->post_approved ? -1 : 0);
                $sync->add('topic', $post_data['topic_id'], 'topic_replies_real', -1);
                $sync->check_topic_empty($post_data['topic_id']);
                //sync new topic
                $sync->add('topic', $this->topic_id, 'topic_replies', $this->post_approved ? 1 : 0);
                $sync->add('topic', $this->topic_id, 'topic_replies_real', 1);
                //sync topic_reported and topic_attachment if applicable
                if ($post_data['post_reported']) {
                    $sync->topic_reported($post_data['topic_id']);
                }
                if ($post_data['post_attachment']) {
                    $sync->topic_attachment($post_data['topic_id']);
                }
                if ($this->post_reported) {
                    $sync->topic_reported($this->topic_id);
                }
                if ($this->post_attachment) {
                    $sync->topic_attachment($this->topic_id);
                }
                if ($is_first_post) {
                    //this was the first post in the old topic, sync it
                    $sync->topic_first_post($post_data['topic_id']);
                    $is_first_post = false;
                    //unset since we dont know status for new topic yet
                }
                if ($is_last_post) {
                    //this was the last post in the old topic, sync it
                    $sync->topic_last_post($post_data['topic_id']);
                    $sync->forum_last_post($post_data['forum_id']);
                    $is_last_post = false;
                    //unset since we dont know status for new topic yet
                }
                if ($this->post_time <= $new_topic_data['topic_time']) {
                    //this will be the first post in the new topic, sync it
                    $sync->topic_first_post($this->topic_id);
                    $is_first_post = true;
                }
                if ($this->post_time >= $new_topic_data['topic_last_post_time']) {
                    //this will be the last post in the new topic, sync it
                    $sync->topic_last_post($this->topic_id);
                    $sync->forum_last_post($this->topic_id);
                    $is_last_post = true;
                }
            } elseif ($is_first_post) {
                $sync->set('topic', $this->topic_id, array('icon_id' => $this->icon_id, 'topic_approved' => $this->post_approved, 'topic_title' => $this->post_subject, 'topic_poster' => $this->poster_id, 'topic_time' => $this->post_time));
            }
            //check if some statistics relevant flags have been changed
            if ($this->post_approved != $post_data['post_approved']) {
                //if topic_id was changed, we've already updated it above.
                if ($this->topic_id == $post_data['topic_id']) {
                    if ($is_first_post) {
                        //first post -> approve/disapprove whole topic if not yet done (should only happen when directly storing the post)
                        if ($this->post_approved != $post_data['topic_approved']) {
                            $sync->add('forum', $this->forum_id, 'forum_topics', $this->post_approved ? 1 : -1);
                            $sync->add('forum', $this->forum_id, 'forum_posts', $this->post_approved ? 1 + $post_data['topic_replies'] : -(1 + $post_data['topic_replies']));
                            $sync->forum_last_post($this->forum_id);
                            //and the total topics+posts
                            set_config('num_topics', $this->post_approved ? $config['num_topics'] + 1 : $config['num_topics'] - 1, true);
                            set_config('num_posts', $this->post_approved ? $config['num_posts'] + (1 + $post_data['topic_replies']) : $config['num_posts'] - (1 + $post_data['topic_replies']), true);
                        }
                    } else {
                        //reply
                        $sync->add('topic', $this->topic_id, 'topic_replies', $this->post_approved ? 1 : -1);
                        $sync->add('forum', $this->forum_id, 'forum_posts', $this->post_approved ? 1 : -1);
                    }
                }
                //update total posts
                if (!$is_first_post) {
                    set_config('num_posts', $this->post_approved ? $config['num_posts'] + 1 : $config['num_posts'] - 1, true);
                }
            }
            /*if($this->post_postcount != $post_data['post_postcount'] && $this->poster_id != ANONYMOUS)
            		{
            			//increase or decrease user_posts
            			$sync->add('user', $this->poster_id, 'user_posts', $this->post_approved ? 1 : -1);
            		}*/
            if ($this->poster_id != $post_data['poster_id'] || $this->post_postcount != $post_data['post_postcount']) {
                if ($post_data['post_postcount'] && $post_data['poster_id'] != ANONYMOUS) {
                    $sync->add('user', $post_data['poster_id'], 'user_posts', -1);
                }
                if ($this->post_postcount && $this->poster_id != ANONYMOUS) {
                    $sync->add('user', $this->poster_id, 'user_posts', 1);
                }
            }
            if ($is_first_post) {
                $sync->topic_first_post($this->topic_id);
            }
            if ($is_last_post) {
                $sync->topic_last_post($this->topic_id);
                $sync->forum_last_post($this->forum_id);
            }
            reindex('edit', $this->post_id, $sql_data['post_text'], $this->post_subject, $this->poster_id, $this->forum_id);
            $db->sql_transaction('commit');
        } elseif ($this->topic_id) {
            //reply
            $sql = "SELECT t.*, f.forum_name\n\t\t\t\t\tFROM " . TOPICS_TABLE . " t\n\t\t\t\t\tLEFT JOIN " . FORUMS_TABLE . " f ON (f.forum_id = t.forum_id)\n\t\t\t\t\tWHERE t.topic_id=" . intval($this->topic_id);
            $result = $db->sql_query($sql);
            $topic_data = $db->sql_fetchrow($result);
            $db->sql_freeresult($result);
            if (!$topic_data) {
                trigger_error("topic_id={$this->topic_id}, but that topic does not exist", E_USER_ERROR);
            }
            //we need topic_id and forum_id
            $this->forum_id = $topic_data['forum_id'];
            $sql_data['forum_id'] = $this->forum_id;
            $sql_data['topic_id'] = $this->topic_id;
            //make sure we have a post_subject (empty subjects are bad for e.g. approving)
            if ($this->post_subject == '') {
                $this->post_subject = 'Re: ' . $topic_data['topic_title'];
            }
            $db->sql_transaction('begin');
            //insert post
            $sql = "INSERT INTO " . POSTS_TABLE . " " . $db->sql_build_array('INSERT', $sql_data);
            $db->sql_query($sql);
            $this->post_id = $db->sql_nextid();
            //update topic
            if (!$sync->new_topic_flag) {
                $sync->add('topic', $this->topic_id, 'topic_replies', $this->post_approved ? 1 : 0);
                $sync->add('topic', $this->topic_id, 'topic_replies_real', 1);
                $sync->set('topic', $this->topic_id, 'topic_bumped', 0);
                $sync->set('topic', $this->topic_id, 'topic_bumper', 0);
            } else {
                $sync->topic_first_post($this->topic_id);
                $sync->new_topic_flag = false;
            }
            $sync->topic_last_post($this->topic_id);
            //update forum
            if ($this->forum_id != 0) {
                $sync->add('forum', $this->forum_id, 'forum_posts', $this->post_approved ? 1 : 0);
                $sync->forum_last_post($this->forum_id);
            }
            if ($this->post_postcount) {
                //increase user_posts...
                $sync->add('user', $this->poster_id, 'user_posts', 1);
            }
            if ($this->post_approved) {
                //...and total posts
                set_config('num_posts', $config['num_posts'] + 1, true);
            }
            reindex('reply', $this->post_id, $sql_data['post_text'], $this->post_subject, $this->poster_id, $this->forum_id);
            $db->sql_transaction('commit');
            // Mark this topic as posted to
            markread('post', $this->forum_id, $this->topic_id, $this->post_time, $this->poster_id);
            // Mark this topic as read
            // We do not use post_time here, this is intended (post_time can have a date in the past if editing a message)
            markread('topic', $this->forum_id, $this->topic_id, time());
            //
            if ($config['load_db_lastread'] && $user->data['is_registered']) {
                $sql = 'SELECT mark_time
					FROM ' . FORUMS_TRACK_TABLE . '
					WHERE user_id = ' . $user->data['user_id'] . '
						AND forum_id = ' . $this->forum_id;
                $result = $db->sql_query($sql);
                $f_mark_time = (int) $db->sql_fetchfield('mark_time');
                $db->sql_freeresult($result);
            } else {
                if ($config['load_anon_lastread'] || $user->data['is_registered']) {
                    $f_mark_time = false;
                }
            }
            if ($config['load_db_lastread'] && $user->data['is_registered'] || $config['load_anon_lastread'] || $user->data['is_registered']) {
                // Update forum info
                $sql = 'SELECT forum_last_post_time
					FROM ' . FORUMS_TABLE . '
					WHERE forum_id = ' . $this->forum_id;
                $result = $db->sql_query($sql);
                $forum_last_post_time = (int) $db->sql_fetchfield('forum_last_post_time');
                $db->sql_freeresult($result);
                update_forum_tracking_info($this->forum_id, $forum_last_post_time, $f_mark_time, false);
            }
            // Send Notifications
            user_notification('reply', $this->post_subject, $topic_data['topic_title'], $topic_data['forum_name'], $this->forum_id, $this->topic_id, $this->post_id);
        } else {
            //new topic
            $this->_topic = topic::from_post($this);
            $this->_topic->submit(true);
            //PHP4 Compatibility:
            if (version_compare(PHP_VERSION, '5.0.0', '<')) {
                $this->topic_id = $this->_topic->topic_id;
                $this->post_id = $this->_topic->topic_first_post_id;
            }
            $exec_sync = false;
        }
        foreach ($this->attachments as $attachment) {
            $attachment->post_msg_id = $this->post_id;
            $attachment->topic_id = $this->topic_id;
            $attachment->poster_id = $this->poster_id;
            $attachment->in_message = 0;
            $attachment->is_orphan = 0;
            $attachment->submit();
        }
        if ($exec_sync) {
            $sync->execute();
        }
        /*if($sync_topic)
        		{
        			if($this->_topic)
        			{
        				$this->_topic->sync();
        			}
        			else
        			{
        				sync('topic', 'topic_id', $this->topic_id);
        			}
        		}*/
    }
コード例 #6
0
ファイル: reindex.php プロジェクト: karwana/penelope
<?php

/**
 * LICENSE: This source code is subject to the license that is available
 * in the LICENSE file distributed along with this package.
 *
 * @package    Penelope
 * @author     Matthew Caruana Galizia <*****@*****.**>
 * @copyright  Karwana Ltd
 * @since      File available since Release 1.0.0
 */
use Karwana\Penelope\Schema;
use Karwana\Penelope\Scripts\Reindexer;
function reindex(Schema $schema)
{
    $reindexer = new Reindexer($schema);
    $reindexer->run();
}
if (empty($argv[1])) {
    throw new \InvalidArgumentException('Missing initialization script path.');
}
require_once __DIR__ . '/Penelope/Reindexer.php';
require_once $argv[1];
if (!isset($schema)) {
    $schema = $penelope->getSchema();
}
reindex($schema);
コード例 #7
0
$no_http_headers = true;

if (file_exists(dirname(__FILE__) . "/../include/global.php")) {
        include(dirname(__FILE__) . "/../include/global.php");
}
include(dirname(__FILE__) . "/../include/config.php");
include(dirname(__FILE__) . "/../lib/snmp.php");

$hostname = $_SERVER["argv"][1];
$snmp_community = $_SERVER["argv"][2];
$snmp_version = $_SERVER["argv"][3];


$bsnMobileEncryptionCipher = ".1.3.6.1.4.1.14179.2.1.4.1.31";

$stationcipher = reindex(cacti_snmp_walk($hostname, $snmp_community, $bsnMobileEncryptionCipher, $snmp_version, "", "", 161, 1000));

$findStationCipherType= array_count_values($stationcipher);

$stationccmpaes=0;
$stationtkipmic=0;
$stationwep40=0;
$stationwep104=0;
$stationwep128=0;
$stationciphernone=0;
$stationciphernotavailable=0;
$stationcipherunknown=0;


if (array_key_exists('0', $findStationCipherType)) {
	$stationccmpaes=$findStationCipherType[0];
コード例 #8
0
ファイル: auditd.php プロジェクト: BillTheBest/1.6.x
    exit;
}
if (isset($_GET["folder"])) {
    folders();
    exit;
}
if (isset($_GET["events"])) {
    events();
    exit;
}
if (isset($_GET["events-list"])) {
    events_list();
    exit;
}
if (isset($_GET["reindex"])) {
    reindex();
    exit;
}
if (isset($_GET["import-now"])) {
    importnow();
    exit;
}
if (isset($_GET["js-folder"])) {
    js_folder();
    exit;
}
js();
function checkrights()
{
    $users = new usersMenus();
    if ($users->AsSambaAdministrator) {
コード例 #9
0
$no_http_headers = true;

if (file_exists(dirname(__FILE__) . "/../include/global.php")) {
        include(dirname(__FILE__) . "/../include/global.php");
}
include(dirname(__FILE__) . "/../include/config.php");
include(dirname(__FILE__) . "/../lib/snmp.php");

$hostname = $_SERVER["argv"][1];
$snmp_community = $_SERVER["argv"][2];
$snmp_version = $_SERVER["argv"][3];


$bsnMobileStationPolicyType = ".1.3.6.1.4.1.14179.2.1.4.1.30";

$stationpolicy = reindex(cacti_snmp_walk($hostname, $snmp_community, $bsnMobileStationPolicyType, $snmp_version, "", "", 161, 1000));

$findStationPolicyType= array_count_values($stationpolicy);

$stationpolicydot1x=0;
$stationpolicywpa1=0;
$stationpolicywpa2=0;
$stationpolicywpav2vff=0;
$stationpolicynotavailable=0;
$stationpolicyunknown=0;


if (array_key_exists('0', $findStationPolicyType)) {
	$stationpolicydot1x=$findStationPolicyType[0];
	}
if (array_key_exists('1', $findStationPolicyType)) {
コード例 #10
0
$no_http_headers = true;

if (file_exists(dirname(__FILE__) . "/../include/global.php")) {
        include(dirname(__FILE__) . "/../include/global.php");
}
include(dirname(__FILE__) . "/../include/config.php");
include(dirname(__FILE__) . "/../lib/snmp.php");

$hostname = $_SERVER["argv"][1];
$snmp_community = $_SERVER["argv"][2];
$snmp_version = $_SERVER["argv"][3];


$bsnMobileStationStatus = ".1.3.6.1.4.1.14179.2.1.4.1.9";

$stationstatus = reindex(cacti_snmp_walk($hostname, $snmp_community, $bsnMobileStationStatus, $snmp_version, "", "", 161, 1000));

$findStationStatusType= array_count_values($stationstatus);

$stationidle=0;
$stationpending=0;
$stationauthenticated=0;
$stationassociated=0;
$stationpowersave=0;
$stationdisassociated=0;
$stationtobedeleted=0;
$stationprobing=0;
$stationblacklisted=0;


if (array_key_exists('0', $findStationStatusType)) {
コード例 #11
0
$no_http_headers = true;

if (file_exists(dirname(__FILE__) . "/../include/global.php")) {
        include(dirname(__FILE__) . "/../include/global.php");
}
include(dirname(__FILE__) . "/../include/config.php");
include(dirname(__FILE__) . "/../lib/snmp.php");

$hostname = $_SERVER["argv"][1];
$snmp_community = $_SERVER["argv"][2];
$snmp_version = $_SERVER["argv"][3];


$bsnRogueAPEntry = ".1.3.6.1.4.1.14179.2.1.7.1.24";

$rogues = reindex(cacti_snmp_walk($hostname, $snmp_community, $bsnRogueAPEntry, $snmp_version, "", "", 161, 1000));

$sorted = array_count_values($rogues);

for ($i = 0; $i <= 10; $i++) {
	if (array_key_exists($i, $sorted)) {
	}
	else {
	$sorted[$i] = 0;}

}


print "reta:" . $sorted[0] . " retb:" . $sorted[1] . " retc:" . $sorted[2] . " retd:" . $sorted[3] . " rete:" . $sorted[4] . " retf:" . $sorted[5] . " retg:" . $sorted[6] . " reth:" . $sorted[7] . " reti:" . $sorted[8] . " retj:" . $sorted[9] . " retk:" . $sorted[10];

function reindex($arr) {
コード例 #12
0
if (file_exists(dirname(__FILE__) . "/../include/global.php")) {
        include(dirname(__FILE__) . "/../include/global.php");
}
include(dirname(__FILE__) . "/../include/config.php");
include(dirname(__FILE__) . "/../lib/snmp.php");


$hostname = $_SERVER["argv"][1];
$snmp_community = $_SERVER["argv"][2];
$snmp_version = $_SERVER["argv"][3];


$bsnMobileProtocol = ".1.3.6.1.4.1.14179.2.1.4.1.25";

$stationprotocol = reindex(cacti_snmp_walk($hostname, $snmp_community, $bsnMobileProtocol, $snmp_version, "", "", 161, 1000));

$findStationProtocolType= array_count_values($stationprotocol);

$stationdot11a=0;
$stationdot11b=0;
$stationdot11g=0;
$stationunknownprotocol=0;
$stationmobile=0;


if (array_key_exists('1', $findStationProtocolType)) {
	$stationdot11a=$findStationProtocolType[1];
	}
if (array_key_exists('2', $findStationProtocolType)) {
	$stationdot11b=$findStationProtocolType[2];
コード例 #13
0
$no_http_headers = true;

if (file_exists(dirname(__FILE__) . "/../include/global.php")) {
        include(dirname(__FILE__) . "/../include/global.php");
}
include(dirname(__FILE__) . "/../include/config.php");
include(dirname(__FILE__) . "/../lib/snmp.php");

$hostname = $_SERVER["argv"][1];
$snmp_community = $_SERVER["argv"][2];
$snmp_version = $_SERVER["argv"][3];


$bsnMobileStationCcxVersion = ".1.3.6.1.4.1.14179.2.1.4.1.33";

$stationccxversion = reindex(cacti_snmp_walk($hostname, $snmp_community, $bsnMobileStationCcxVersion, $snmp_version, "", "", 161, 1000));

$findStationccxversionType= array_count_values($stationccxversion);

$stationccxunsupported=0;
$stationccxv1=0;
$stationccxv2=0;
$stationccxv3=0;
$stationccxv4=0;
$stationccxv5=0;

if (array_key_exists('0', $findStationccxversionType)) {
	$stationccxunsupported=$findStationccxversionType[0];
	}
if (array_key_exists('1', $findStationccxversionType)) {
	$stationccxv1=$findStationccxversionType[1];
コード例 #14
0
$hostname = $_SERVER["argv"][1];
$snmp_community = $_SERVER["argv"][2];
$snmp_version = $_SERVER["argv"][3];
$cmd = $_SERVER["argv"][4];

if ($cmd == "index") {
	$return_arr = reindex(cacti_snmp_walk($hostname, $snmp_community, $oids["index"], $snmp_version, "", "", "", 161, 1000));

	for ($i=0;($i<sizeof($return_arr));$i++) {
		print $return_arr[$i] . "\n";
	}
}elseif ($cmd == "query") {
	$arg = $_SERVER["argv"][5];

	$arr_index = reindex(cacti_snmp_walk($hostname, $snmp_community, $oids["index"], $snmp_version, "", "", "", 161, 1000));
	$arr = reindex(cacti_snmp_walk($hostname, $snmp_community, $oids[$arg], $snmp_version, "", "", "", 161, 1000));

	for ($i=0;($i<sizeof($arr_index));$i++) {
		print $arr_index[$i] . "!" . $arr[$i] . "\n";
	}
}elseif ($cmd == "get") {
	$arg = $_SERVER["argv"][5];
	$index = $_SERVER["argv"][6];

	if (($arg == "total") || ($arg == "used")) {
		/* get hrStorageAllocationUnits from the snmp cache since it is faster */
		$host_id = db_fetch_cell("select id from host where hostname='$hostname' and snmp_community='$snmp_community'");
		$sau = db_fetch_cell("select field_value from host_snmp_cache where host_id=$host_id and field_name='hrStorageAllocationUnits' and snmp_index='$index'");

		print (cacti_snmp_get($hostname, $snmp_community, $oids[$arg] . ".$index", $snmp_version, "", "", "", 161, 1000) * $sau);
	}else{
コード例 #15
0
$snmpv3_auth_protocol = $_SERVER["argv"][6];
$snmpv3_priv_passphrase = $_SERVER["argv"][7];
$snmpv3_priv_protocol = $_SERVER["argv"][8];
$cmd = $_SERVER["argv"][9];

if ($cmd == "index") {
	$return_arr = reindex(cacti_snmp_walk($hostname, $snmp_community, $oids["index"], $snmp_version, $snmpv3_auth_username, $snmpv3_auth_password, $snmpv3_auth_protocol, $snmpv3_priv_passphrase, $snmpv3_priv_protocol, 161, 1000));

	for ($i=0;($i<sizeof($return_arr));$i++) {
		print $return_arr[$i] . "\n";
	}
}elseif ($cmd == "query") {
	$arg = $_SERVER["argv"][10];

	$arr_index = reindex(cacti_snmp_walk($hostname, $snmp_community, $oids["index"], $snmp_version, $snmpv3_auth_username, $snmpv3_auth_password, $snmpv3_auth_protocol, $snmpv3_priv_passphrase, $snmpv3_priv_protocol, 161, 1000));
	$arr = reindex(cacti_snmp_walk($hostname, $snmp_community, $oids[$arg], $snmp_version, $snmpv3_auth_username, $snmpv3_auth_password, $snmpv3_auth_protocol, $snmpv3_priv_passphrase, $snmpv3_priv_protocol, 161, 1000));

	for ($i=0;($i<sizeof($arr_index));$i++) {
		print $arr_index[$i] . "!" . $arr[$i] . "\n";
	}
}elseif ($cmd == "get") {
	$arg = $_SERVER["argv"][10];
	$index = $_SERVER["argv"][11];

	if (($arg == "total") || ($arg == "used")) {
		/* get hrStorageAllocationUnits from the snmp cache since it is faster */
		$host_id = db_fetch_cell("select id from host where hostname='$hostname' and snmp_community='$snmp_community'");
		$sau = db_fetch_cell("select field_value from host_data_query_cache where host_id=$host_id and field_name='hrStorageAllocationUnits' and index_value='$index'");

		print (cacti_snmp_get($hostname, $snmp_community, $oids[$arg] . ".$index", $snmp_version, $snmpv3_auth_username, $snmpv3_auth_password, $snmpv3_auth_protocol, $snmpv3_priv_passphrase, $snmpv3_priv_protocol, 161, 1000) * $sau);
	}else{
コード例 #16
0
 */
if ($cmd == "index") {
	$return_arr = reindex(cacti_snmp_walk($hostname, $snmp_community, $oids["index"], $snmp_version, $snmp_auth_username, $snmp_auth_password, $snmp_auth_protocol, $snmp_priv_passphrase, $snmp_priv_protocol, $snmp_context, $snmp_port, $snmp_timeout, $ping_retries, $max_oids, SNMP_POLLER));

	for ($i=0;($i<sizeof($return_arr));$i++) {
		print $return_arr[$i] . "\n";
	}

/*
 * process QUERY requests
 */
}elseif ($cmd == "query") {
	$arg = $_SERVER["argv"][5];

	$arr_index = reindex(cacti_snmp_walk($hostname, $snmp_community, $oids["index"], $snmp_version, $snmp_auth_username, $snmp_auth_password, $snmp_auth_protocol, $snmp_priv_passphrase, $snmp_priv_protocol, $snmp_context, $snmp_port, $snmp_timeout, $ping_retries, $max_oids, SNMP_POLLER));
	$arr = reindex(cacti_snmp_walk($hostname, $snmp_community, $oids[$arg], $snmp_version, $snmp_auth_username, $snmp_auth_password, $snmp_auth_protocol, $snmp_priv_passphrase, $snmp_priv_protocol, $snmp_context, $snmp_port, $snmp_timeout, $ping_retries, $max_oids, SNMP_POLLER));

	for ($i=0;($i<sizeof($arr_index));$i++) {
		print $arr_index[$i] . "!" . $arr[$i] . "\n";
	}

/*
 * process GET requests
 */
}elseif ($cmd == "get") {
	$arg = $_SERVER["argv"][5];
	$index = $_SERVER["argv"][6];

	if (($arg == "total") || ($arg == "used")) {
		/* get hrStorageAllocationUnits from the snmp cache since it is faster */
		$sau = db_fetch_cell("select field_value from device_snmp_cache where device_id=$device_id and field_name='hrStorageAllocationUnits' and snmp_index='$index'");
コード例 #17
0
ファイル: reindex_system.php プロジェクト: nyeholt/relapse
$dbService = za()->getService('DbService');
$projectService = za()->getService('ProjectService');
$clientService = za()->getService('ClientService');
$issueService = za()->getService('IssueService');
/* @var $issueService IssueService */
/* @var $clientService ClientService */
/* @var $projectService ProjectService */
$items = $clientService->getClients();
reindex($items);
unset($items);
$items = $clientService->getContacts();
reindex($items);
unset($items);
$items = $projectService->getprojects();
reindex($items);
unset($items);
$items = $projectService->getTasks();
reindex($items);
unset($items);
$items = $issueService->getIssues();
reindex($items);
unset($items);
function reindex($items)
{
    $searchService = za()->getService('SearchService');
    foreach ($items as $item) {
        echo "Reindexing " . $item->title . "...   ";
        $searchService->index($item);
        echo "Done\r\n";
    }
}
コード例 #18
0
ファイル: solr-update.php プロジェクト: parvbhullar/test
function reindex($q, $limit = 1000, $offset = 0)
{
    $server = "178.63.79.68";
    //$server = "188.40.100.77";
    $updateServer = $server;
    //"188.40.100.77";
    //$url = "http://$server:8080/solr/collectionv2/select?q=$q&rows=$limit&start=$offset&wt=json&indent=true";
    $url = "http://{$server}:8080/solr/collectionv2/select?q={$q}&rows={$limit}&start={$offset}&wt=json&indent=true";
    $results = json_decode(file_get_contents($url), true);
    //Get total again push it
    $results = $results["response"];
    //    print_r($results);
    $numFound = $results["numFound"];
    $docs = isset($results["docs"]) ? $results["docs"] : false;
    $transaction = $docs;
    if ($transaction) {
        $dq = "update?stream.body=<delete><query>*:*</query></delete>&commit=true";
        //        $ch = curl_init();
        //        $url = 'http://178.63.79.68:8080/solr/collectionv2/update?stream.body=%3Cdelete%3E%3Cquery%3EpartnerId:' . $partnerId . '%3C/query%3E%3C/delete%3E&commit=true';
        //        curl_setopt($ch, CURLOPT_URL, $url);
        //        curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
        //        curl_setopt($ch, CURLOPT_POST, TRUE);
        //        curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: application/json'));
        //        curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($transaction));
        //        $response = curl_exec($ch);
        //        if ($response === FALSE) {
        //            die('Curl failed: ' . curl_error($ch));
        //        }
        //
        //        // Close connection
        //        curl_close($ch);
        //        $transaction = $GLOBALS['DB']->v2GetDirtySkuForSolrUpload($partnerId);
        $ch = curl_init();
        $url = "http://{$updateServer}:8080/solr/collectionv2/update?wt=json&commit=true";
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
        curl_setopt($ch, CURLOPT_POST, TRUE);
        curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: application/json'));
        curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($transaction));
        $response = curl_exec($ch);
        if ($response === FALSE) {
            print_r('Curl failed: ' . curl_error($ch));
        }
        // Close connection
        curl_close($ch);
        if ($numFound > $offset) {
            $offset = $offset + $limit;
            echo "Reindex started - " . $offset . PHP_EOL;
            reindex($q, $limit, $offset);
        }
    }
}
コード例 #19
0
if (file_exists(dirname(__FILE__) . "/../include/global.php")) {
        include(dirname(__FILE__) . "/../include/global.php");
}
include(dirname(__FILE__) . "/../include/config.php");
include(dirname(__FILE__) . "/../lib/snmp.php");


$hostname = $_SERVER["argv"][1];
$snmp_community = $_SERVER["argv"][2];
$snmp_version = $_SERVER["argv"][3];


$bsnMobileAuthenticationAlgorithm = ".1.3.6.1.4.1.14179.2.1.4.1.19";

$stationalgorithm = reindex(cacti_snmp_walk($hostname, $snmp_community, $bsnMobileAuthenticationAlgorithm, $snmp_version, "", "", 161, 1000));

$findStationAlgorithmType= array_count_values($stationalgorithm);

$stationauthopen=0;
$stationauthsharedkey=0;
$stationauthunknown=0;
$stationopenandeap=0;


if (array_key_exists('0', $findStationAlgorithmType)) {
	$stationauthopen=$findStationAlgorithmType[0];
	}
if (array_key_exists('1', $findStationAlgorithmType)) {
	$stationauthsharedkey=$findStationAlgorithmType[1];
	}