Esempio n. 1
0
function haku_save_options_action()
{
    /*
    	Security check
    */
    check_ajax_referer('haku_nonce', 'haku_referer');
    /*
    	Processing
    */
    $form_contents = $_POST;
    unset($form_contents['action'], $form_contents['haku_referer']);
    $current_options = get_option(get_haku_var('theme'));
    if (is_array($current_options)) {
        if (array_equal($current_options, $form_contents)) {
            $response = ':)';
        } else {
            $response = update_option(get_haku_var('theme'), $form_contents) ? ':)' : haku_error(1);
        }
    } else {
        $response = update_option(get_haku_var('theme'), $form_contents) ? ':)' : haku_error(2);
    }
    /*
    	Response
    */
    die($response);
}
Esempio n. 2
0
            <tbody>
                <?php 
$mockDataList = array(array('status' => 'Acer Team Championship Kinguin VS dignitas', 'teams' => array('teamkinguin', 'teamdignitas')), array('status' => 'FACEIT.com - Starladder XIII - EnVyUs vs Gamers2 0 - 0 (BO3)', 'teams' => array('teamenvyus', 'gamers2')), array('status' => 'FACEIT.com - Starladder XIII - Team Kinguin vs ex-Copenhagen Wolves (BO3)', 'teams' => array('teamkinguin', 'copenhagenwolves')), array('status' => 'FACEIT.com - FACEIT 2015 League Stage 1 - Day 3 - Grand Final - Ninjas in Pyjamas vs TSM.Kinguin (BO3)', 'teams' => array('ninjasinpyjamas', 'teamsolomid')), array('status' => 'Fightdat leageu - gamers2 vs TSM.Kinguin', 'teams' => array('gamers2', 'teamsolomid')), array('status' => 'Ora 22:00 Kinguin vs. undefined [SLTV StarSeries XIII]', 'teams' => array('teamkinguin', '-unknown-')), array('status' => 'EnVyUs vs. Gamers2 || StarSeries S13 || @sL4Mtv @sltvstrike', 'teams' => array('teamenvyus', 'gamers2')), array('status' => 'КУБОК МУРА, HR vs M5 by Tafa & Strike', 'teams' => array('hellraisers', 'moscowfive')), array('status' => 'Team Kinguin vs. Undefined || StarSeries S13 Group D || @sL4Mtv', 'teams' => array('teamkinguin', '-unknown-')), array('status' => 'Na`Vi vs. NiP || Gfinity Spring Masters 2 || by Kvan & Strike', 'teams' => array('natusvincere', 'ninjasinpyjamas')), array('status' => 'Liquid vs. VOX || Gfinity Spring Masters 2 || @sL4Mtv @sltvstrike', 'teams' => array('teamliquid', 'voxeminor')), array('status' => 'NiP vs. Liquid || Gfinity Spring Masters 2 || @sL4Mtv @sltvstrike', 'teams' => array('ninjasinpyjamas', 'teamliquid')), array('status' => 'nerdRage vs. AlienTech.black || FBM S4 || @sL4Mtv @sltvstrike', 'teams' => array('nerdrage', 'teamalientech')), array('status' => '[FR] - CounterPit - Team Dignitas vs Virtus Pro', 'teams' => array('teamdignitas', 'virtuspro')), array('status' => 'Patrick матч FlipSid3 vs. LDLC White', 'teams' => array('flipsid3tactics', 'teamldlccom')), array('status' => 'FlipSid3 vs. LDLC.White | StarSeries S13 | sL4M', 'teams' => array('flipsid3tactics', 'teamldlccom')), array('status' => '[ESL /w KeitaTV] (Starts 21.30) LGB eSports vs. KillerFish (Acer Predator Master)', 'teams' => array('lgbesports', 'killerfishesport')), array('status' => 'LGB vs KillerFish @ Acer Predator Masters powered by Intel', 'teams' => array('lgbesports', 'killerfishesport')), array('status' => 'ESL Spain: LGB eSports vs KillerFish - TakeTV Acer Predator Master', 'teams' => array('lgbesports', 'killerfishesport')), array('status' => 'Acer Predator Masters LIVE 21:30 LGB vs. KILLERFISH www.cmtv.eu #Giveaway‬', 'teams' => array('lgbesports', 'killerfishesport')), array('status' => 'Kibicujemy Polakom G2 vs Virtus', 'teams' => array('gamers2', 'virtuspro')), array('status' => '(RU)NAVI vs VEGA by MCS|Oldkinder', 'teams' => array('natusvincere', 'vegasquadron')), array('status' => 'ESWC Khabarovsk', 'teams' => false), array('status' => '[FR] ESL ESEA Pro League / 20:45 NiP vs. f3 / 21:45 NiP vs. f3 / 22:45 Dignitas vs. Na\'Vi', 'teams' => array('ninjasinpyjamas', 'flipsid3tactics')), array('status' => 'F3ide vs. NiP on de_inferno @  ESL ESEA by Flife', 'teams' => array('ninjasinpyjamas', 'flipsid3tactics')), array('status' => 'ESL ESEA Pro League - Method vs Tempo Storm', 'teams' => array('method', 'tempostorm')), array('status' => '[RETRANSMISSÃO] Keyd vs. CLG --Próximo jogo: Keyd Stars vs. Team Liquid às 20:00 - ESL ESEA Pro League [NA]', 'teams' => array('keydstars', 'counterlogicgaming')), array('status' => 'Virtus.PRO vs FlipSide on de_mirage @  ESL ESEA by ceh9', 'teams' => array('flipsid3tactics', 'virtuspro')), array('status' => 'Fragbite Masters S4 LIVE : 19:00 Natus Vincerevs. vs Hellraisers #GIVEAWAY www.cmtv.eu', 'teams' => array('natusvincere', 'hellraisers')), array('status' => 'CZ/SK DEV1S.com @ fragbite nEph vs. LGB o 22CET', 'teams' => array('neophyte', 'lgbesports')), array('status' => 'Headshot.bg vs. Tricked - Balkan Championship #2 - Best of 3 Visit CSGOCasino.net 18+ only!', 'teams' => array('headshotbg', 'trickedesport')), array('status' => 'Starladder 13 - Na\'Vi [0] vs [0] FlipSide (BO3)', 'teams' => array('natusvincere', 'flipsid3tactics')), array('status' => 'Druidz vs Circadian in the ESL Majors!', 'teams' => array('-unknown-', '-unknown-')), array('status' => '[FR] TEAM LEGEND vs GamersLeague eSport 21h cevo', 'teams' => array('-unknown-', '-unknown-')), array('status' => 'TSM Kinguin vs Kinguin - Alienware Area51 CS:GO Cup 2 Finals', 'teams' => array('teamsolomid', 'teamkinguin')), array('status' => 'CSGOcup.pl - FINAŁ Boys in Suits vs NEVER-LUCKY', 'teams' => array('-unknown-', '-unknown-')), array('status' => 'FACEIT 2015 League - EU Stage 2 - TSM.Kinguin vs Flipsid3 Tactics', 'teams' => array('teamsolomid', 'flipsid3tactics')), array('status' => '[PT-BR] Nihilum vs. Cloud 9 - ESL ESEA Pro League (NA)', 'teams' => array('cloud9', 'nihilum')), array('status' => 'GO:CL: VP vs dig w/ follower giveaways! [EN]', 'teams' => array('viruspro', 'teamdignitas')), array('status' => 'King of Nordic Finland vs Denmark', 'teams' => array('finland', 'denmark')), array('status' => 'TeamKinguin vs. Wyvern | DreamHack Open Summer 2015 BYOC | Giveaway at https://goo.gl/GsT6d5', 'teams' => array('teamkinguin', '-unknown-')));
$teamList = new AvailableTeams('web/');
$streamMock = new Stream();
foreach ($mockDataList as $mockData) {
    if ($mockData['teams'] == false) {
        if (!$streamMock->isCast($mockData['status'])) {
            $passed = true;
        } else {
            $passed = false;
        }
    } else {
        $teams = $teamList->getTeamsInString($mockData['status']);
        $teamIdentifiers = array($teams[0]['identifier'], $teams[1]['identifier']);
        if (array_equal($teamIdentifiers, $mockData['teams'])) {
            $passed = true;
        } else {
            $passed = false;
        }
    }
    ?>
                    <tr <?php 
    if ($passed) {
        echo 'class="success"';
    } else {
        echo 'class="danger"';
    }
    ?>
>
                        <td>
Esempio n. 3
0
function array_equal($array1, $array2)
{
    if (count($array1) != count($array2)) {
        return FALSE;
    }
    foreach ($array1 as $k1 => $v1) {
        if (!array_key_exists($k1, $array2)) {
            return FALSE;
        }
        $v2 = $array2[$k1];
        if (is_array($v1) && is_array($v2)) {
            if (!array_equal($v1, $v2)) {
                return FALSE;
            }
        } else {
            if (!is_array($v1) && !is_array($v2)) {
                if ($v1 != $v2) {
                    return FALSE;
                }
            } else {
                return FALSE;
            }
        }
    }
    return TRUE;
}
 public function run($name)
 {
     $fileName = MAGENTO . '/var/split/old/' . $name;
     echo "Reading {$fileName}.\n";
     $file = fopen($fileName, "r");
     while (!feof($file)) {
         $csv[] = fgetcsv($file, 0, ',');
     }
     $keys = array_shift($csv);
     foreach ($csv as $i => $row) {
         $csv[$i] = array_combine($keys, $row);
         $csv[$i] = $csv[$i];
         //array_filter($csv[$i],'self::checkEmpty');
     }
     $i = 0;
     $currentSet = null;
     foreach ($csv as $row) {
         $row['sku_type'] = 1;
         $row['price_type'] = 1;
         $row['weight_type'] = 1;
         $row = $this->removeInvalidData($row);
         $row = $this->convertBool($row);
         if (trim($row['sku']) != '') {
             $currentSet = $row['sku'];
             $this->_groups[$currentSet][] = $row;
             $i++;
         } else {
             $processedChild = array_filter($row, 'self::checkEmpty');
             if (!empty($processedChild)) {
                 $newExtRow = array_merge($this->_groups[$currentSet][0], $processedChild);
                 if (array_equal($this->_groups[$currentSet][0], $newExtRow)) {
                     continue;
                 }
                 $newExtRow['bundle_skus'] = '';
                 $newExtRow['bundle_options'] = '';
                 $this->_groups[$currentSet][] = $newExtRow;
             }
             unset($processedChild, $newExtRow);
         }
     }
     echo "MEMORY USED : " . convert(memory_get_usage(true)) . "\n";
     fclose($file);
     unset($csv, $keys, $file, $row);
     $finalArray = array();
     foreach ($this->_groups as $sku => $_product) {
         foreach ($_product as $__product) {
             $finalArray[] = $__product;
         }
     }
     unset($this->_groups);
     prepareCsv($finalArray, 'split/new/' . $name, ',');
     echo "MEMORY USED : " . convert(memory_get_usage(true)) . "\n";
 }
 /**
  * @param $triggers
  * @param $method
  */
 public function checkInput(array &$triggers, $method)
 {
     $create = $method == 'create';
     $update = $method == 'update';
     $delete = $method == 'delete';
     // permissions
     if ($update || $delete) {
         $triggerDbFields = array('triggerid' => null);
         $dbTriggers = $this->get(array('triggerids' => zbx_objectValues($triggers, 'triggerid'), 'output' => API_OUTPUT_EXTEND, 'editable' => true, 'preservekeys' => true, 'selectDependencies' => API_OUTPUT_REFER));
     } else {
         $triggerDbFields = array('description' => null, 'expression' => null, 'error' => 'Trigger just added. No status update so far.', 'value' => TRIGGER_VALUE_FALSE, 'value_flags' => TRIGGER_VALUE_FLAG_UNKNOWN, 'lastchange' => time());
     }
     if ($update) {
         $triggers = $this->extendObjects($this->tableName(), $triggers, array('description'));
     }
     foreach ($triggers as $tnum => &$trigger) {
         $currentTrigger = $triggers[$tnum];
         if (($update || $delete) && !isset($dbTriggers[$trigger['triggerid']])) {
             self::exception(ZBX_API_ERROR_PARAMETERS, _('No permissions to referred object or it does not exist!'));
         }
         // check for "templateid", because it is not allowed
         if (array_key_exists('templateid', $trigger)) {
             if ($update) {
                 $error = _s('Cannot update "templateid" for trigger "%1$s".', $trigger['description']);
             } else {
                 $error = _s('Cannot set "templateid" for trigger "%1$s".', $trigger['description']);
             }
             self::exception(ZBX_API_ERROR_PARAMETERS, $error);
         }
         if (!check_db_fields($triggerDbFields, $trigger)) {
             self::exception(ZBX_API_ERROR_PARAMETERS, _('Incorrect fields for trigger.'));
         }
         if ($update) {
             $dbTrigger = $dbTriggers[$trigger['triggerid']];
         } elseif ($delete) {
             if ($dbTriggers[$trigger['triggerid']]['templateid'] != 0) {
                 self::exception(ZBX_API_ERROR_PARAMETERS, _s('Cannot delete templated trigger "%1$s:%2$s".', $dbTriggers[$trigger['triggerid']]['description'], explode_exp($dbTriggers[$trigger['triggerid']]['expression'])));
             }
             continue;
         }
         $expressionChanged = true;
         if ($update) {
             if (isset($trigger['expression'])) {
                 $expressionFull = explode_exp($dbTrigger['expression']);
                 if (strcmp($trigger['expression'], $expressionFull) == 0) {
                     $expressionChanged = false;
                 }
             }
             if (isset($trigger['description']) && strcmp($trigger['description'], $dbTrigger['description']) == 0) {
                 unset($trigger['description']);
             }
             if (isset($trigger['priority']) && $trigger['priority'] == $dbTrigger['priority']) {
                 unset($trigger['priority']);
             }
             if (isset($trigger['type']) && $trigger['type'] == $dbTrigger['type']) {
                 unset($trigger['type']);
             }
             if (isset($trigger['comments']) && strcmp($trigger['comments'], $dbTrigger['comments']) == 0) {
                 unset($trigger['comments']);
             }
             if (isset($trigger['url']) && strcmp($trigger['url'], $dbTrigger['url']) == 0) {
                 unset($trigger['url']);
             }
             if (isset($trigger['status']) && $trigger['status'] == $dbTrigger['status']) {
                 unset($trigger['status']);
             }
             if (isset($trigger['dependencies'])) {
                 $dbTrigger['dependencies'] = zbx_objectValues($dbTrigger['dependencies'], 'triggerid');
                 if (array_equal($dbTrigger['dependencies'], $trigger['dependencies'])) {
                     unset($trigger['dependencies']);
                 }
             }
         }
         // if some of the properties are unchanged, no need to update them in DB
         // validating trigger expression
         if (isset($trigger['expression']) && $expressionChanged) {
             // expression permissions
             $expressionData = new CTriggerExpression();
             if (!$expressionData->parse($trigger['expression'])) {
                 self::exception(ZBX_API_ERROR_PARAMETERS, $expressionData->error);
             }
             if (!isset($expressionData->expressions[0])) {
                 self::exception(ZBX_API_ERROR_PARAMETERS, _('Trigger expression must contain at least one host:key reference.'));
             }
             $expressionHosts = $expressionData->getHosts();
             $hosts = API::Host()->get(array('filter' => array('host' => $expressionHosts), 'editable' => true, 'output' => array('hostid', 'host', 'status'), 'templated_hosts' => true, 'preservekeys' => true));
             $hosts = zbx_toHash($hosts, 'host');
             $hostsStatusFlags = 0x0;
             foreach ($expressionHosts as $host) {
                 if (!isset($hosts[$host])) {
                     self::exception(ZBX_API_ERROR_PARAMETERS, _s('Incorrect trigger expression. Host "%s" does not exist or you have no access to this host.', $host));
                 }
                 // find out if both templates and hosts are referenced in expression
                 $hostsStatusFlags |= $hosts[$host]['status'] == HOST_STATUS_TEMPLATE ? 0x1 : 0x2;
                 if ($hostsStatusFlags == 0x3) {
                     self::exception(ZBX_API_ERROR_PARAMETERS, _('Incorrect trigger expression. Trigger expression elements should not belong to a template and a host simultaneously.'));
                 }
             }
             foreach ($expressionData->expressions as $exprPart) {
                 $sql = 'SELECT i.itemid,i.value_type' . ' FROM items i,hosts h' . ' WHERE i.key_=' . zbx_dbstr($exprPart['item']) . ' AND ' . dbConditionInt('i.flags', array(ZBX_FLAG_DISCOVERY_NORMAL, ZBX_FLAG_DISCOVERY_CREATED)) . ' AND h.host=' . zbx_dbstr($exprPart['host']) . ' AND h.hostid=i.hostid' . ' AND ' . DBin_node('i.itemid');
                 if (!DBfetch(DBselect($sql))) {
                     self::exception(ZBX_API_ERROR_PARAMETERS, _s('Incorrect item key "%1$s" provided for trigger expression on "%2$s".', $exprPart['item'], $exprPart['host']));
                 }
             }
         }
         // check existing
         $this->checkIfExistsOnHost($currentTrigger);
     }
     unset($trigger);
 }