Пример #1
0
 public function getFriendLists($arguments = false)
 {
     $defaults = array('uid' => false, 'type' => 'all', 'limit' => 0, 'offset' => 0);
     $options = parseArguments($defaults, $arguments);
     // add -1 to the user_id array. -1 is everybody
     $conditions = array('user_id' => array($options['uid'], '-1'));
     // return the info requested
     $this->recursive = -1;
     return $this->find($options['type'], array('limit' => $options['limit'], 'offset' => $options['offset'], 'conditions' => $conditions, 'order' => 'lower(title) ASC'));
 }
Пример #2
0
 public function getWallPosts($currentUserId, $arguments = false)
 {
     $this->currentUserId = $currentUserId;
     $conditions = array();
     //set the default options
     $defaults = array('all_friends' => false, 'id' => false, 'limit' => Configure::read('WallPost.Limit'), 'offset' => 0, 'uid' => false);
     //parse the options
     $options = parseArguments($defaults, $arguments, true);
     // create conditions
     if ($options['id']) {
         $conditions['WallPost.id'] = $options['id'];
         $postType = 'first';
     }
     // UID is for only showing posts on a certain wall
     if ($options['uid']) {
         $conditions['WallPost.user_id'] = $options['uid'];
         $conditions['reply_parent_id'] = null;
     }
     // mainly used for news feed.  make sure the author and user are both your friends
     if ($options['all_friends']) {
         $conditions['AND']['OR']['WallPost.author_id'] = $options['all_friends'];
         $conditions['AND']['WallPost.user_id'] = $options['all_friends'];
         $conditions['reply_parent_id'] = null;
         $this->friends = $options['all_friends'];
     }
     //create the contain rules
     $contain[] = 'User';
     // Owner - who's wall this is posted on
     $contain[] = 'PostAuthor';
     // Who made the post
     $contain[] = 'Replies.PostAuthor';
     // The author of any replies
     $contain[] = 'WallPostLike.User';
     // The user(s) of who liked/disliked this post
     // grab as much as you can, it will however be contained
     $this->recursive = 2;
     // check if we have set $postType, if it is set, use it, otherwise just use 'all'
     $wallPosts = $this->find(isset($postType) ? $postType : 'all', array('conditions' => $conditions, 'contain' => $contain, 'limit' => $options['limit'], 'offset' => $options['offset'], 'order' => 'WallPost.posted DESC'));
     // this transforms the data array.  the data structure of a find all vs find first is different
     if ($options['id']) {
         foreach ($wallPosts['WallPost'] as $key => $val) {
             $wallPosts[$key] = $val;
         }
     }
     return $wallPosts;
 }
Пример #3
0
 public function getFriends($arguments = false)
 {
     $defaults = array('friendList' => false, 'gid' => false, 'limit' => 10, 'offset' => 0, 'random' => false, 'uid' => false, 'order' => array('Friend.first_name', 'Friend.last_name'));
     $options = parseArguments($defaults, $arguments);
     if ($options['uid']) {
         $conditions['user_id'] = $options['uid'];
     }
     if ($options['gid']) {
         $conditions['group_id'] = $options['gid'];
     }
     if ($options['friendList']) {
         $conditions['list_id'] = $options['friendList'];
     }
     if ($options['random']) {
         $options['order'] = 'RANDOM()';
     }
     $this->recursive = 2;
     $friends = $this->find('all', array('conditions' => $conditions, 'contain' => array('Friend.Profile'), 'limit' => $options['limit'], 'offset' => $options['offset'], 'order' => $options['order']));
     return $friends;
 }
Пример #4
0
 function getWallPosts($args = false)
 {
     $this->controller->loadModel('WallPost');
     $defaults = array('all_friends' => false, 'rss_hash' => false, 'rss_uid' => false, 'selectedFriendList' => false, 'uid' => false);
     $options = parseArguments($defaults, $args);
     // if checkRss returns false, get current user id, otherwise set uid = return of checkrss
     if ($user_id = !$this->checkRss($options['rss_uid'], $options['rss_hash'])) {
         $user_id = $this->controller->currentUser['User']['id'];
     }
     if ($options['all_friends']) {
         $friends = $this->getFriends($user_id, $options['selectedFriendList']);
     }
     // If the Aacl behavior is not attached
     if (!$this->controller->WallPost->Behaviors->attached('Aacl')) {
         // Get the list of all behaviors the model has attached
         $this->controller->WallPost->Behaviors->attach('Aacl');
     }
     // get all the posts of all your friends
     $wallPosts = $this->controller->WallPost->getWallPosts($this->controller->currentUser['User']['id'], array('all_friends' => $options['all_friends'] ? $friends : false, 'uid' => $options['uid'] ? $options['uid'] : false));
     $this->controller->set(compact('wallPosts'));
 }
Пример #5
0
function parseArguments($defaults, $arguments, $keep_unset = false)
{
    if (!is_array($defaults) || !is_array($arguments)) {
        return $defaults;
    }
    //just return the defaults (something goofed)
    //copy the defaults
    $results = $defaults;
    foreach ($arguments as $key => $argument) {
        //if the agrument is invalid contine the loop
        if (!$keep_unset && !isset($defaults[$key])) {
            continue;
        }
        //the option is invalid
        //if the agrument is acually an array of aguments
        if (is_array($argument)) {
            //if keep_unset is true and the default is not an array add the array
            if ($keep_unset && !is_array($defaults[$key])) {
                $results[$key] = $argument;
                continue;
                //advance the loop
            }
            //if the agument is an array then make sure it is valid
            if (!is_array($defaults[$key])) {
                continue;
            }
            //the option is not an array
            //set the suboptions
            $subdefaults = $defaults[$key];
            $results[$key] = parseArguments($subdefaults, $argument, $keep_unset);
        } else {
            //just set it
            $results[$key] = $argument;
        }
    }
    return $results;
}
define("LOG__NONE", 0);
define("LOG__ERROR", 1);
define("LOG__VERBOSE", 2);
define("LOG__DEBUG", 3);
// initialise some variables
$status = STATUS_OK;
$log_level = LOG__NONE;
// possible output strings
$criticals = "";
$warnings = "";
$unknowns = "";
$normals = "";
// set default values for command line arguments
$cmdargs = ['port' => '161', 'log_level' => LOG__NONE, 'memwarn' => 80, 'memcrit' => 90, 'reboot' => 3600, 'thres-cpu-1sec' => '95,98', 'thres-cpu-5sec' => '85,95', 'thres-cpu-1min' => '70,90'];
// parse the command line arguments
parseArguments();
//print_r( $cmdargs ); die();
require 'OSS_SNMP/OSS_SNMP/SNMP.php';
$snmp = new \OSS_SNMP\SNMP($cmdargs['host'], $cmdargs['community']);
checkCPU();
checkReboot();
checkPower();
checkFans();
checkTemperature();
checkMemory();
checkOthers();
if ($status == STATUS_OK) {
    $msg = "OK -{$normals}\n";
} else {
    $msg = "{$criticals}{$warnings}{$unknowns}\n";
}
Пример #7
0
DEFINE('ST_GERUND', 6);
DEFINE('ST_PARTICIPLE_MODEL', 7);
DEFINE('ST_TENSE_NAMES', 8);
DEFINE('ST_5_TENSES', 9);
// A few models (93.) list four of the tenses first and the past perfect next.
DEFINE('ST_4_TENSES', 10);
DEFINE('ST_FINAL', 11);
DEFINE('REG_MODEL_NUMBER', '/<td class="xl(31|50)" style="height: 12pt;" height="16">([0-9\']+)\\.<\\/td>/');
DEFINE('REG_INFINITIVE', '/<td [^>]*>([^<]+)<\\/td>/');
DEFINE('REG_LONG_INFINITIVE', '/<td[^>]*>infinitiv lung :<\\/td>[^<]*<td[^>]*>([^<]*)<\\/td>/');
DEFINE('REG_IMPERATIVE', '/<td[^>]*>imperativ pers\\. 2 :<\\/td>[^<]*<td[^>]*>([^<]*)<\\/td>/');
DEFINE('REG_SLAVE_MODELS', '/<tr[^>]*>[^<]*<td[^>]*>([^<]*)<\\/td>/');
DEFINE('REG_PARTICIPLE', '/<td[^>]*>participiu :<\\/td>[^<]*<td[^>]*>([^<]*)<\\/td>/');
DEFINE('REG_GERUND', '/<td[^>]*>gerunziu :<\\/td>[^<]*<td[^>]*>([^<]*)<\\/td>/');
DEFINE('REG_PARTICIPLE_MODEL', '/<td[^>]*>tip de declinare: a (\\d+)<\\/td>/');
list($verbose, $fileName) = parseArguments();
$data = readAndFormatFile($fileName);
$pos = 0;
$state = ST_MODEL_NUMBER;
$matches = array();
$done = false;
$numModels = 0;
$modelMap = array();
$modelNumber = 0;
$infinitive = '';
$longInfinitive = '';
$imperative = '';
$slaveModels = false;
$participle = '';
$gerund = '';
$participleModel = '';
Пример #8
0
<?php

function parseArguments($argv)
{
    $file = null;
    for ($x = 0; $x < count($argv); $x++) {
        if ($argv[$x] == "-h" || $argv[$x] == "--help") {
            print "phast help menu\n";
            print "-f --file \tStart analysis with this file\n";
            print "-v --variables \tPrint all tainted variables\n";
            return;
        }
        if ($argv[$x] == "-f" || $argv[$x] == "--file") {
            $file = $argv[$x + 1];
            print $file;
        }
    }
}
parseArguments($argv);
Пример #9
0
 * 
 */
//////////////// DEFAULT CONFIGURATION ///////////////////
// some, but not all options for tidy
// found on http://www.php.net/manual/en/tidy.examples.basic.php
$default_options = array('show-body-only' => false, 'clean' => true, 'char-encoding' => 'utf8', 'add-xml-decl' => true, 'add-xml-space' => false, 'output-html' => true, 'output-xml' => false, 'output-xhtml' => false, 'numeric-entities' => false, 'ascii-chars' => false, 'doctype' => 'strict', 'bare' => true, 'fix-uri' => true, 'indent' => true, 'indent-spaces' => 4, 'tab-size' => 4, 'wrap-attributes' => true, 'wrap' => 0, 'indent-attributes' => true, 'join-classes' => false, 'join-styles' => false, 'enclose-block-text' => true, 'fix-bad-comments' => true, 'fix-backslash' => true, 'replace-color' => false, 'wrap-asp' => false, 'wrap-jste' => false, 'wrap-php' => false, 'write-back' => true, 'drop-proprietary-attributes' => false, 'hide-comments' => false, 'hide-endtags' => false, 'literal-attributes' => false, 'drop-empty-paras' => true, 'enclose-text' => true, 'quote-ampersand' => true, 'quote-marks' => false, 'quote-nbsp' => true, 'vertical-space' => true, 'wrap-script-literals' => false, 'tidy-mark' => true, 'merge-divs' => false, 'repeated-attributes' => 'keep-last', 'break-before-br' => true, 'new-blocklevel-tags' => '', 'new-pre-tags' => '', 'new-inline-tags' => '');
///////////// END OF DEFAULT CONFIGURATION ////////////////
error_reporting(E_ALL);
if (!version_compare(phpversion(), "5.0", ">=")) {
    echo "Error: tidy.php requires PHP 5 or newer.\n";
    exit(1);
}
$tidy = new Tidy();
$tmpfile = '';
// merge default options with command line arguments
$config = parseArguments($default_options);
// check if input file exists
if (!file_exists($tmpfile)) {
    echo "Error: tidy.php cannot find tmpfile at: {$tmpfile} \n";
    exit(1);
}
// let tidy do the work
$tidy->parseFile($tmpfile, $config, 'utf8');
// other things you can do with php's Tidy():
// $tidy->parseString($html, $options);
// $tidy->cleanRepair();
// echo $tidy;
// write buffer back to tmpfile
if (!file_put_contents($tmpfile, (string) $tidy)) {
    echo "Error: The file '" . $tmpfile . "' could not be written.\n";
    exit(1);