function array_searchRecursive($needle, $haystack, $strict = false, $path = array())
{
    if (!is_array($haystack)) {
        return false;
    }
    foreach ($haystack as $key => $val) {
        if (is_array($val) && ($subPath = array_searchRecursive($needle, $val, $strict, $path))) {
            $path = array_merge($path, array($key), $subPath);
            return $path;
        } elseif (!$strict && $val == $needle || $strict && $val === $needle) {
            $path[] = $key;
            return $path;
        }
    }
    return false;
}
Example #2
0
 /**
  * Builds the multidimensional array
  *
  * @version 1.0
  * @since   1.0.0
  * @author  xLink
  *
  * @param   array    $paths
  * @param   int     $id
  *
  * @return  string
  */
 public function buildJumpBoxArray($blank = array())
 {
     //grab a copy of the entire cat table, grabbing the data we need
     $cats = $this->getForumInfo('*');
     //rearrange the query
     $newQuery = array();
     if (is_array($blank) && count($blank)) {
         $newQuery[0] = $blank;
     }
     //first pass for master cats
     foreach ($cats as $cat) {
         if ($cat['parent_id'] != 0) {
             continue;
         }
         $newQuery[$cat['id']] = $cat;
     }
     $this->catTitles = $newQuery;
     //second pass for the rest
     foreach ($cats as $cat) {
         if ($cat['parent_id'] == 0) {
             continue;
         }
         $newQuery[$cat['id']] = $cat;
     }
     $this->catQuery = $newQuery;
     $auth = $this->auth;
     if (is_array($blank) && count($blank)) {
         $auth[0]['auth_view'] = true;
     }
     $a = array();
     $cats = $this->catQuery;
     //for each parent cat
     foreach ($cats as $cat) {
         if (!$auth[$cat['id']]['auth_view']) {
             continue;
         }
         if ($cat['parent_id'] > 0 && !$auth[$cat['parent_id']]['auth_view']) {
             continue;
         }
         //this is a parent cat so just add it to the array
         if ($cat['parent_id'] == 0) {
             $a[$cat['id']] = array();
             continue;
         }
         //this isnt a parent cat so do some upgrades...
         if ($cat['parent_id'] != 0) {
             $id = array_searchRecursive((int) $cat['parent_id'], $a);
             $id = $this->buildArrayPath($id, $cat['id']);
             if (!$id) {
                 $id = '$a[' . $cat['id'] . ']';
             }
             eval("{$id} = array(\$cat['title']);");
         }
     }
     return $a;
 }
Example #3
0
function getXmlFields($searchString, $level = false)
{
    global $fields;
    global $xmlDrugFile;
    global $errors;
    $searchString = str_replace("_", " ", $searchString);
    $searchpath = array_searchRecursive($searchString, $xmlDrugFile->data[0]);
    if ($searchpath !== false) {
        $subarray = $xmlDrugFile->data[0];
        if ($level == "-1") {
            $searchDepth = sizeof($searchpath) - 3;
        } else {
            $searchDepth = sizeof($searchpath) - 2;
        }
        for ($i = 0; $i < $searchDepth; $i = $i + 1) {
            $subarray = $subarray[$searchpath[$i]];
        }
        $i = $searchpath[$i] + 1;
        for ($k = $i; $k < sizeof($subarray); $k = $k + 1) {
            if ($subarray[$k]["name"] == "TITLE") {
                getXmlContent($subarray[$k]["content"], ":");
            } else {
                if ($subarray[$k]["name"] == "TEXT") {
                    $subsubarray = $subarray[$k]["child"];
                    for ($j = 0; $j < sizeof($subsubarray); $j = $j + 1) {
                        if ($subsubarray[$j]["name"] == "PARAGRAPH") {
                            getXmlContent($subsubarray[$j]["content"]);
                        } else {
                            $errors[$file] .= " {$searchString}";
                        }
                    }
                } else {
                    if ($subarray[$k]["name"] == "COMPONENT") {
                        $subsubarray = $subarray[$k]["child"];
                        for ($j = 0; $j < sizeof($subsubarray); $j = $j + 1) {
                            if ($subsubarray[$j]["name"] == "SECTION") {
                                for ($l = 0; $l < sizeof($subsubarray[$j]["child"]); $l = $l + 1) {
                                    $temp = $subsubarray[$j]["child"][$l];
                                    if ($temp["name"] == "TITLE") {
                                        getXmlContent($temp["content"], ":");
                                    } else {
                                        if ($temp["name"] == "TEXT") {
                                            for ($m = 0; $m < sizeof($temp["child"]); $m = $m + 1) {
                                                if ($temp["child"][$m]["name"] == "PARAGRAPH") {
                                                    getXmlContent($temp["child"][$m]["content"]);
                                                }
                                            }
                                        } else {
                                            if ($temp["name"] == "COMPONENT") {
                                                for ($n = 0; $n < sizeof($temp["child"]); $n = $n + 1) {
                                                    $temp1 = $temp["child"][$n];
                                                    if ($temp1["name"] == "SECTION") {
                                                        for ($o = 0; $o < sizeof($temp1["child"]); $o = $o + 1) {
                                                            $temp2 = $temp1["child"][$o];
                                                            if ($temp2["name"] == "TITLE") {
                                                                getXmlContent($temp2["content"], ":");
                                                            } else {
                                                                if ($temp2["name"] == "TEXT") {
                                                                    for ($m = 0; $m < sizeof($temp2["child"]); $m = $m + 1) {
                                                                        if ($temp2["child"][$m]["name"] == "PARAGRAPH") {
                                                                            getXmlContent($temp2["child"][$m]["content"]);
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    } else {
                                                        $errors[$file] .= " {$searchString}";
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            } else {
                                $errors[$file] .= " {$searchString}";
                            }
                        }
                    }
                }
            }
        }
    }
}
Example #4
0
/**
* updateAllGames - Update all games in the database, using info from Games List.csv
*/
function updateAllGames()
{
    global $sql;
    // Output a 'waiting message'
    if (ob_get_level() == 0) {
        ob_start();
    }
    echo str_pad('Please wait while this task completes... ', 4096) . "<br />\n";
    $games_info = array();
    $index = 0;
    if ($file_handle = fopen(e_PLUGIN . "ebattles/images/games_icons/Games List.csv", "r")) {
        $line_of_text = fgetcsv($file_handle, 1024);
        // header
        while (!feof($file_handle)) {
            $line_of_text = fgetcsv($file_handle, 1024);
            $games_info[$index] = array('shortname' => addslashes($line_of_text[0]), 'longname' => addslashes($line_of_text[1]), 'icon' => addslashes($line_of_text[2]));
            $index++;
        }
        fclose($file_handle);
    } else {
        echo "Error loading game file.";
        exit;
    }
    // Get info from database the game is already in database
    $query = "SELECT " . TBL_GAMES . ".*" . " FROM " . TBL_GAMES;
    $result = $sql->db_Query($query);
    $num_rows = mysql_numrows($result);
    for ($i = 0; $i < $num_rows; $i++) {
        set_time_limit(10);
        $gname = mysql_result($result, $i, TBL_GAMES . ".Name");
        $gid = mysql_result($result, $i, TBL_GAMES . ".GameID");
        $search_game = array_searchRecursive($gname, $games_info, true);
        if ($search_game) {
            $q_2 = "UPDATE " . TBL_GAMES . " SET ShortName='" . $games_info[$search_game[0]]['shortname'] . "', Icon='" . $games_info[$search_game[0]]['icon'] . "'" . " WHERE (" . TBL_GAMES . ".GameID = '{$gid}')";
            $result_2 = $sql->db_Query($q_2);
            //usleep(100);
        }
        echo '<div class="percents">' . number_format(100 * $i / $num_rows, 0, '.', '') . '%&nbsp;complete</div>';
        echo str_pad('', 4096) . "\n";
        ob_flush();
    }
    echo "<br>Done.";
    ob_end_flush();
}
Example #5
0
/* Teams Standings */
// Is the user a player?
$q = "SELECT " . TBL_PLAYERS . ".*" . " FROM " . TBL_PLAYERS . ", " . TBL_GAMERS . " WHERE (" . TBL_PLAYERS . ".Event = '{$event_id}')" . "   AND (" . TBL_PLAYERS . ".Gamer = " . TBL_GAMERS . ".GamerID)" . "   AND (" . TBL_GAMERS . ".User = "******")";
$result = $sql->db_Query($q);
$pbanned = 0;
if (mysql_numrows($result) == 1) {
    $row = mysql_fetch_array($result);
    $prank = $row['Rank'];
    $pbanned = $row['Banned'];
    /* My Position */
    if ($prank == 0) {
        $prank_txt = EB_EVENT_L54;
    } else {
        $prank_txt = "#{$prank}";
    }
    $search_user = array_searchRecursive('user='******'"', $stats, false);
    $search_user ? $link_page = ceil($search_user[0] / $pages->items_per_page) : ($link_page = 1);
    $myPosition_txt = '<p>';
    $myPosition_txt .= '<a href="' . e_PLUGIN . 'ebattles/eventinfo.php?eventid=' . $event_id . '&amp;page=' . $link_page . '&amp;ipp=' . $pages->items_per_page . $pages->querystring . '">' . EB_EVENT_L55 . ': ' . $prank_txt . '</a><br />';
    $myPosition_txt .= '</p>';
}
//fm: Need userclass for match scheduling
if ($event->getField('Type') == "Team Ladder" || $event->getField('Type') == "Clan Ladder") {
    $text .= '<div id="tabs-2">';
    if ($can_challenge != 0 && $event->getField('Type') == "Clan Ladder") {
        $list_challenge_teams = array();
        $text .= '<form action="' . e_PLUGIN . 'ebattles/challengerequest.php?eventid=' . $event_id . '" method="post">';
        $text .= '<table>';
        $text .= '<tr>';
        // "Challenge team" form
        $q = "SELECT " . TBL_PLAYERS . ".*" . " FROM " . TBL_PLAYERS . ", " . TBL_GAMERS . " WHERE (" . TBL_PLAYERS . ".Event = '{$event_id}')" . "   AND (" . TBL_PLAYERS . ".Gamer = " . TBL_GAMERS . ".GamerID)" . "   AND (" . TBL_GAMERS . ".User = '******')";