Example #1
1
function GenerateGroup($ingroup, $boys, $girls)
{
    $minboys = 2;
    $mingirls = 1;
    $output = 0;
    if ($boys < 4 || $girls < 1) {
        $output = 0;
    } else {
        $pos_combinations = BoysGirlsPossibleCombinations($ingroup, $minboys, $mingirls, $boys, $girls);
        PrintArray($pos_combinations);
        $sum = 0;
        foreach ($pos_combinations as $combination) {
            $set_combi = nCr($boys, $combination['boy']) * nCr($girls, $combination['girl']);
            $sum += $set_combi;
            //echo '$sum: '.$sum;
            //echo "nCr($boys,".$combination['boy'].")*nCr($girls,".$combination['girl'].")<br/>";
        }
        $output = $sum;
    }
    return $output;
}
Example #2
0
function PrintArrayT($array)
{
    if (is_array($array)) {
        $lineData = "";
        $lineHead = "";
        foreach ($array as $key => $value) {
            if (false && is_array($value)) {
                echo "<tr><td>" . $key . "</td><td>";
                PrintArray($value);
                echo "</td></tr>\n";
            } else {
                $lineHead .= "<th>{$key}</th>";
                $lineData .= "<td>{$value}</td>";
            }
        }
        echo "\tArray:<table border=\"1\" cellpadding=\"0\" cellspacing=\"0\" frame=\"void\"><thead>{$lineHead}</thead><tr>{$lineData}</tr></table>\n";
    } else {
        PrintArray($array);
    }
}
Example #3
0
    echo '<pre>';
    print_r($arr);
    echo '</pre>';
}
function SumPossible($val, $girlrange, $boyzrange)
{
    $combinations = array();
    if ($girlrange[1] + $boyzrange[1] < $val) {
        $combinations = 0;
    } else {
        $lowermin = min($girlrange[0], $boyzrange[0]);
        $lowermax = max($girlrange[0], $boyzrange[0]);
        $uppermin = min($girlrange[1], $boyzrange[1]);
        $genderorder = array();
        if ($lowermin == $girlrange[0]) {
            $genderorder[0] = 'girl';
            $genderorder[1] = 'boy';
        } elseif ($lowermin == $boyzrange[0]) {
            $genderorder[0] = 'boy';
            $genderorder[1] = 'girl';
        }
        for ($i = $lowermin, $j = $val - $lowermin; $i <= $uppermin, $j >= $lowermax; $i++, $j--) {
            $combinations[] = array($genderorder[0] => $i, $genderorder[1] => $j);
        }
    }
    return $combinations;
}
$girlrange = array(1, 2);
$boyzrange = array(2, 4);
PrintArray(sumpossible(4, $girlrange, $boyzrange));
Example #4
0
function PrintArray($data, $indent)
{
    foreach ($data as $key => &$value) {
        if (is_array($value)) {
            echo htmlspecialchars("{$indent}{$key}:\n");
            PrintArray($value, $indent . '  ');
        } else {
            echo htmlspecialchars("{$indent}{$key}: " . preg_replace('/[\\x00-\\x08\\x0B\\x0C\\x0E-\\x1F\\x80-\\x9F]/u', '', $value) . "\n");
        }
    }
}
Example #5
0
if (isset($_GET['c'])) {
    $_SESSION['c'] = $_GET['c'];
}
if (isset($_GET['p']) && $_GET['p'] != "login") {
    $_SESSION['q'] = $_SERVER['QUERY_STRING'];
}
if (defined('DEVELOPER_MODE')) {
    global $start;
    $time = microtime();
    $time = explode(" ", $time);
    $time = $time[1] + $time[0];
    $finish = $time;
    $totaltime = $finish - $start;
    printf("<h3>Page took %f seconds to load.</h3>", $totaltime);
    echo '<h3>User Manager Data</h3><pre>';
    PrintArray($userbank);
    echo '</pre><h3>Post Data</h3><pre>';
    print_r($_POST);
    echo '</pre><h3>Session Data</h3><pre>';
    print_r($_SESSION);
    echo '</pre> ';
    echo '</pre><h3>Cookie Data</h3><pre>';
    print_r($_COOKIE);
    echo '</pre> ';
}
?>
</div>
<script type="text/javascript">
var settab = ProcessAdminTabs();
window.addEvent('domready', function(){	
				<?php 
Example #6
0
$log['AppName'] = "SVN";
//Log_MailAccess($log);
// get host
$ip = $_SERVER["REMOTE_ADDR"];
$agent = $_SERVER["HTTP_USER_AGENT"];
$host = exec("host {$ip}");
$host = substr($host, strrpos($host, " "));
$host = trim($host);
if ($host == "3(NXDOMAIN)") {
    $host = "unknown";
} else {
    $_SERVER["REMOTE_NAME"] = "{$host}";
}
ob_start();
echo "<html>";
ksort($_SERVER);
PrintArray($_SERVER);
$dumpServer = ob_get_contents();
echo "</html>";
ob_end_clean();
$to = "*****@*****.**";
$sub = "SVN:{$lang} {$ip} {$host}";
$msg = "";
$msg = $msg . "\n\n\n" . $dumpServer;
$ahead = "";
$ahead .= "MIME-Version: 1.0\r\n";
$ahead .= "Content-type: text/html; charset=UTF-8\r\n";
$crawler = preg_match("/(crawl|msnbot|yandex\\.ru)/", $host) || preg_match("/(msnbot|spider)/", $agent);
if (!preg_match("/192\\.168\\.10\\.2|217\\.75\\.82\\.141/", $_SERVER["REMOTE_ADDR"]) && !$crawler) {
    //mail($to, $sub, $msg, $ahead);
}
Example #7
0
    if ($parent_id != 0) {
        $sql = "select * from n_categories where cat_id={$parent_id}";
        $res = mysql_query($sql);
        $res_data = mysql_fetch_assoc($res);
        $parent_id = $res_data['parent_id'];
        $cat_name = $res_data['cat_name'];
        if ($parent_id != 0) {
            BackTracking($cat_name, &$result);
        } else {
            array_unshift($result['cat_name'], $cat_name);
            array_unshift($result['parent_id'], $parent_id);
        }
    }
}
function PrintArray($arr)
{
    echo "<pre>";
    print_r($arr);
    echo "</pre>";
}
$result = array('cat_name' => array(), 'parent_id' => array());
BackTracking('Gsm', &$result);
$categories = array_combine(array_values($result['parent_id']), array_values($result['cat_name']));
//PrintArray($result);
PrintArray($categories);
echo "<br>";
$sql = 'select * from n_categories';
$res = mysql_query($sql);
while ($resdata = mysql_fetch_assoc($res)) {
    echo $resdata['cat_name'] . "<br/>";
}
 /**
  * Returns the available classes for a given slot. Can retrieve only the class
  * name or the full CSS style. This is made with the mode parameter
  *
  * @param      str  The slot's name.
  * @param      int  optional 0 retrieves only the class name [Default]
  *                           1 Retrieve the full css style
  *
  * @return     array  The found classes
  */
 public static function findStylesheetClasses($content, $mode = 0)
 {
     // This is only a paliative solution. Hope someone can fix the parse class: I don't know Call-time pass-by-reference
     ini_set('error_reporting', 'E_ERROR');
     require_once dirname(__FILE__) . '/../tools/parser/htmlparser.inc';
     require_once dirname(__FILE__) . '/../tools/parser/common.inc';
     $slotName = $content->getW3sSlot()->getSlotName();
     $page = $content->getW3sPage();
     // Opens the template and parses its structure
     $templateAttributes = self::retrieveTemplateAttributesFromPage($page);
     $templateFile = self::getTemplateFile($templateAttributes["projectName"], $templateAttributes["templateName"]);
     $p = new HtmlParser($templateFile, unserialize(Read_File("parser/htmlgrammar.cmp")), $templateFile, 1);
     $p->Parse();
     $src = "";
     GetPageSrc($p->content, $src);
     ob_start();
     PrintArray($p->content);
     $contents = ob_get_clean();
     // Finds the id of Slots
     $i = 1;
     $elements = array($slotName);
     while (1) {
         preg_match('/(.*)\\[content\\].*\\[pars\\]\\[id\\]\\[value\\]=' . $slotName . '/', $contents, $res);
         if (count($res) == 0) {
             break;
         }
         $startKey = str_replace("[", "\\[", $res[1]);
         $startKey = str_replace("]", "\\]", $startKey);
         preg_match('/' . $startKey . '\\[pars\\]\\[id\\]\\[value\\]=(.*)/', $contents, $res);
         $elements[] = $res[1];
         $slotName = $res[1];
         $i++;
         // Prevents blocks if an infinite loop occours if a non well-format template is searched
         if ($i == 100) {
             break;
         }
     }
     // Finds all the template's stylesheets
     $fp = fopen($templateFile, "r");
     $templateContents = fread($fp, filesize($templateFile));
     fclose($fp);
     $templateContents = str_replace("\r\n", "", $templateContents);
     preg_match_all('/.*?rel=["|\']stylesheet["|\'].*?href\\s*=\\s*["|\'](.*?)["|\'].*?/', $templateContents, $stylesheets);
     // Creates a single stylesheet from the stylesheets retrieved
     $contents = '';
     foreach ($stylesheets[1] as $stylesheet) {
         $stylesheet = substr($stylesheet, 1, strlen($stylesheet));
         $fp = fopen($stylesheet, "r");
         $currentContent = fread($fp, filesize($stylesheet));
         fclose($fp);
         $currentContent = str_replace("\r\n", "", $currentContent);
         $currentContent = preg_replace('/HTML>.*?}+?/', '', $currentContent);
         $contents .= $currentContent;
     }
     // Find classes from xhtml elements
     $result = $mode == 0 ? array('w3sNone' => 'None') : array();
     foreach ($elements as $element) {
         $expression = $mode == 0 ? '/#' . trim($element) . '[a-zA-Z0-9-_:\\s]*\\.(.*?)\\{+?/' : '/#' . trim($element) . '[a-zA-Z0-9-_:\\s]*(\\..*?\\{.*?\\})+?/';
         preg_match_all($expression, $contents, $classes);
         foreach ($classes[1] as $class) {
             if ($mode == 0) {
                 $result[$class] = $class;
             } else {
                 $result[] = $class;
             }
         }
     }
     // Find classes not associated to xhtml elements
     $expression = $mode == 0 ? '/(^|})\\.(.*?)\\{+?/' : '/(^|})(\\..*?\\{.*?\\})+?/';
     preg_match_all($expression, $contents, $classes);
     foreach ($classes[2] as $class) {
         if ($mode == 0) {
             $result[$class] = $class;
         } else {
             $result[] = $class;
         }
     }
     return $result;
 }