function merge_arrays($names, $compare)
{
    foreach ($names as $name) {
        if (!is_in_array($name, $compare)) {
            array_push($compare, $name);
        }
    }
    return $compare;
}
Пример #2
0
function scan_dir($dir)
{
    $BANNED_FILES = array("dev", ".", "..", "Thumbs.db", "desktop.ini");
    $directory = scandir($dir);
    foreach ($directory as $file) {
        if (!is_in_array($file, $BANNED_FILES)) {
            if (is_dir($dir . "/" . $file)) {
                echo "<optgroup label='" . $file . "'>";
                scan_dir($dir . "/" . $file);
                echo "</optgroup>\n";
            } else {
                echo "<option label='" . basename($file, ".png") . "' value='" . $dir . "/" . $file . "'";
                if ($file == "nes-8x8.png") {
                    echo " selected";
                }
                echo ">" . $file . "</option>\n";
            }
        }
    }
}
Пример #3
0
function is_in_array($array, $key, $key_value)
{
    $within_array = false;
    foreach ($array as $k => $v) {
        ## array in_array
        if (is_array($v) == !false) {
            $within_array = is_in_array($v, $key, $key_value);
            if ($within_array == false) {
                break;
            }
        } else {
            if ($v == $key_value && $k == $key) {
                $within_array = true;
                break;
            }
        }
        ## END ## in_array
    }
    ## END forearch
    return $within_array;
}
Пример #4
0
function summ_map($map, $numbers)
{
    global $config;
    $c = count($numbers);
    $i = 0;
    foreach ($numbers as $number) {
        if (is_in_array($map, $number)) {
            $i++;
        }
    }
    if (isset($config['wins'][$c][$i])) {
        return $config['wins'][$c][$i];
    } else {
        return null;
    }
}
Пример #5
0
/**
 *
 **/
function edit_droplet_perms($id)
{
    global $parser, $val, $backend, $users;
    // look if user can set permissions
    $this_user_groups = CAT_Users::get_groups_id();
    if (!CAT_Helper_Droplet::is_allowed('manage_perms', $this_user_groups)) {
        $backend->print_error($backend->lang()->translate("You don't have the permission to do this"));
    }
    $info = NULL;
    // get available groups
    $groups = $users->getGroups();
    // save perms
    if ($val->get('_REQUEST', 'save') || $val->get('_REQUEST', 'save_and_back')) {
        $edit = $val->get('_REQUEST', 'edit_groups') ? is_array($val->get('_REQUEST', 'edit_groups')) ? implode('|', $val->get('_REQUEST', 'edit_groups')) : $val->get('_REQUEST', 'edit_groups') : NULL;
        $view = $val->get('_REQUEST', 'view_groups') ? is_array($val->get('_REQUEST', 'view_groups')) ? implode('|', $val->get('_REQUEST', 'view_groups')) : $val->get('_REQUEST', 'view_groups') : NULL;
        CAT_Helper_Droplet::updateDropletPerms(array('id' => $id, 'edit' => $edit, 'view' => $view));
        $info = $backend->lang()->translate('The Droplet was saved');
        if ($val->get('_REQUEST', 'save_and_back')) {
            return list_droplets($info);
        }
    }
    $data = CAT_Helper_Droplet::getDropletData($id);
    foreach (array('edit_groups', 'view_groups') as $key) {
        $allowed_groups = isset($data[$key]) ? explode('|', $data[$key]) : array();
        $line = array();
        foreach ($groups as $gid => $name) {
            $line[] = '<input type="checkbox" name="' . $key . '[]" id="' . $key . '_' . $gid . '" value="' . $gid . '"' . (is_in_array($allowed_groups, $gid) || !count($allowed_groups) ? ' checked="checked"' : NULL) . '>' . '<label for="' . $key . '_' . $gid . '">' . $name . '</label>' . "\n";
        }
        $rows[] = array('groups' => implode('', $line), 'name' => $backend->lang()->translate($key));
    }
    $parser->output('droplet_permissions.tpl', array('rows' => $rows, 'info' => $info, 'id' => $id));
}
Пример #6
0
    if ($cfgLogin[$i] != '' && $cfgLogin[$i] == $login) {
        // user found --> check password
        if ($cfgPassword[$i] == '' || $cfgPassword[$i] != $password) {
            // password is wrong
            $phpSP_message = $strPwFalse;
            include $cfgProgDir . "objects/logout.php";
            include $cfgProgDir . "interface.php";
            exit;
        }
        $userFound = true;
        $userNr = $i;
    }
}
if ($userFound == false) {
    // user is wrong
    $phpSP_message = $strUserNotExist;
    include $cfgProgDir . "objects/logout.php";
    include $cfgProgDir . "interface.php";
    exit;
}
$userLevel = $cfgUserLevel[$userNr];
if (isset($requiredUserLevel) && !empty($requiredUserLevel[0]) || isset($minUserLevel)) {
    // check for required user level and minimum user level
    if (!is_in_array($userLevel, @$requiredUserLevel) && (!isset($minUserLevel) || empty($minUserLevel) || $userLevel < $minUserLevel)) {
        // this user does not have the required user level
        $phpSP_message = $strUserNotAllowed;
        include $cfgProgDir . "interface.php";
        exit;
    }
}
$ID = $cfgUserID[$userNr];
Пример #7
0
function rec($item, $forumMapper, $obj, $readAccess)
{
    $subItems = $forumMapper->getForumItemsByParent('1', $item->getId());
    $topics = $forumMapper->getCountTopicsById($item->getId());
    $lastPost = $forumMapper->getLastPostByTopicId($item->getId());
    $posts = $forumMapper->getCountPostsById($item->getId());
    $adminAccess = null;
    if ($obj->getUser()) {
        $adminAccess = $obj->getUser()->isAdmin();
    }
    ?>
    <?php 
    if ($item->getType() === 0) {
        ?>
        <ul class="topiclist">
            <li class="header">
                <dl class="icon">
                    <dt><a href="<?php 
        echo $obj->getUrl(array('controller' => 'showcat', 'action' => 'index', 'id' => $item->getId()));
        ?>
"><?php 
        echo $item->getTitle();
        ?>
</a></dt>
                    <dd class="topics"><?php 
        echo $obj->getTrans('topics');
        ?>
</dd>
                    <dd class="posts"><?php 
        echo $obj->getTrans('posts');
        ?>
</dd>
                    <dd class="lastpost"><span><?php 
        echo $obj->getTrans('lastPost');
        ?>
</span></dd>
                </dl>
            </li>
        </ul>
    <?php 
    }
    ?>

    <?php 
    if (is_in_array($readAccess, explode(',', $item->getReadAccess())) || $adminAccess == true) {
        ?>
        <?php 
        if ($item->getType() != 0) {
            ?>
            <ul class="topiclist forums">
                <li class="row">
                    <dl class="icon" style="
                        <?php 
            if ($obj->getUser() && $lastPost) {
                ?>
                            <?php 
                if (in_array($obj->getUser()->getId(), explode(',', $lastPost->getRead()))) {
                    ?>
                                background-image: url(<?php 
                    echo $obj->getModuleUrl('static/img/forum_read.png');
                    ?>
);
                            <?php 
                } else {
                    ?>
                                background-image: url(<?php 
                    echo $obj->getModuleUrl('static/img/topic_unread.png');
                    ?>
);
                            <?php 
                }
                ?>
                        <?php 
            } else {
                ?>
                            background-image: url(<?php 
                echo $obj->getModuleUrl('static/img/forum_read.png');
                ?>
);
                        <?php 
            }
            ?>
                            background-repeat: no-repeat;">
                        <dt>
                            <a href="<?php 
            echo $obj->getUrl(array('controller' => 'showtopics', 'action' => 'index', 'forumid' => $item->getId()));
            ?>
" class="forumtitle"><?php 
            echo $item->getTitle();
            ?>
</a><br>
                            <?php 
            echo $item->getDesc();
            ?>
                        </dt>
                        <dd class="topics"><?php 
            echo $topics;
            ?>
 <dfn><?php 
            echo $obj->getTrans('topics');
            ?>
</dfn></dd>
                        <dd class="posts"><?php 
            echo $posts;
            ?>
 <dfn><?php 
            echo $obj->getTrans('posts');
            ?>
</dfn></dd>
                        <dd class="lastpost">
                            <?php 
            if ($lastPost) {
                ?>
                                <span>
                                    <img style="width:30px; padding-right: 5px;" src="<?php 
                echo $obj->getBaseUrl($lastPost->getAutor()->getAvatar());
                ?>
"> <?php 
                echo $obj->getTrans('by');
                ?>
                                    <a href="<?php 
                echo $obj->getUrl(array('module' => 'user', 'controller' => 'profil', 'action' => 'index', 'user' => $lastPost->getAutor()->getId()));
                ?>
"><?php 
                echo $lastPost->getAutor()->getName();
                ?>
</a>
                                    <a href="<?php 
                echo $obj->getUrl(array('controller' => 'showposts', 'action' => 'index', 'topicid' => $lastPost->getTopicId(), 'page' => $lastPost->getPage()));
                ?>
#<?php 
                echo $lastPost->getId();
                ?>
">
                                        <img src="<?php 
                echo $obj->getModuleUrl('static/img/icon_topic_latest.png');
                ?>
" alt="<?php 
                echo $obj->getTrans('viewLastPost');
                ?>
" title="<?php 
                echo $obj->getTrans('viewLastPost');
                ?>
" height="10" width="12">
                                    </a>
                                    <br><?php 
                echo $lastPost->getDateCreated();
                ?>
                                </span>
                            <?php 
            }
            ?>
                        </dd>
                    </dl>
                </li>
            </ul>
        <?php 
        }
        ?>
    <?php 
    }
    ?>
    <?php 
    if (!empty($subItems)) {
        foreach ($subItems as $subItem) {
            rec($subItem, $forumMapper, $obj, $readAccess);
        }
    }
}
Пример #8
0
    $phpSP_message = $strPwNotFound;
    include $cfgProgDir . "interface.php";
    exit;
}
if (stripslashes($userArray["{$cfgDbPasswordfield}"]) != $password) {
    // password is wrong
    $phpSP_message = $strPwFalse;
    include $cfgProgDir . "interface.php";
    exit;
}
if (isset($userArray["{$cfgDbUserLevelfield}"]) && !empty($cfgDbUserLevelfield)) {
    $userLevel = stripslashes($userArray["{$cfgDbUserLevelfield}"]);
}
if (isset($requiredUserLevel) && !empty($requiredUserLevel[0]) || isset($minUserLevel)) {
    // check for required user level and minimum user level
    if (!isset($userArray["{$cfgDbUserLevelfield}"])) {
        // check if column (as entered in the configuration file) exist in database
        $phpSP_message = $strNoUserLevelColumn;
        include $cfgProgDir . "interface.php";
        exit;
    }
    if (empty($cfgDbUserLevelfield) || !is_in_array($userLevel, @$requiredUserLevel) && (!isset($minUserLevel) || empty($minUserLevel) || $userLevel < $minUserLevel)) {
        // this user does not have the required user level
        $phpSP_message = $strUserNotAllowed;
        include $cfgProgDir . "interface.php";
        exit;
    }
}
if (isset($userArray["{$cfgDbUserIDfield}"]) && !empty($cfgDbUserIDfield)) {
    $ID = stripslashes($userArray["{$cfgDbUserIDfield}"]);
}
Пример #9
0
<?php

$forum = $this->get('forum');
$readAccess = $this->get('readAccess');
$adminAccess = null;
if ($this->getUser()) {
    $adminAccess = $this->getUser()->isAdmin();
}
if (is_in_array($readAccess, explode(',', $forum->getCreateAccess())) || $adminAccess == true) {
    ?>
<link href="<?php 
    echo $this->getModuleUrl('static/css/forum-style.css');
    ?>
" rel="stylesheet">
<form class="form-horizontal" method="POST" action="">
        <div id="">
            <div class="row">
                <div class="col-md-12">
                    <?php 
    echo $this->getTokenField();
    ?>
                    <div class="form-group">
                        <label for="topicTitleInput" class="col-lg-2 control-label">
                            <?php 
    echo $this->getTrans('topicTitle');
    ?>
:
                        </label>
                        <div class="col-lg-8">
                            <input class="form-control"
                                   type="text"
 /**
  * @return array
  */
 private function doPassOne()
 {
     echo "doPassOne()\n";
     $LOCCTR = 0;
     ## LOCCTR..
     $lineCount = 0;
     ## for counting first foreach
     //$startingAdd = 0;	## starting address	## define in class now..
     $errorFlag = false;
     ## initial errorFlag as false -> no error found
     // user defined symbol use a another function to do it
     $OPTB_SKIP = array(".", "BASE", "END", "EXTDEF", "EXTREF");
     ## skip line with these label..
     $errorMsg = "";
     ## store error message....
     $literalsArr = array();
     //$_OPTB_WOC['BLOCK'] = 0;
     $block = 0;
     $SECTION = 0;
     $blockLocArr = array(0 => 0);
     $blockArr = array('' => 0);
     // then array_push new block...
     foreach ($this->OPTB_WOC as $_OPTB_WOC) {
         $lineCount++;
         ## have given a start position...
         $_OPTB_WOC['BLOCK'] = $block;
         $_OPTB_WOC['SECTION'] = $SECTION;
         if ($_OPTB_WOC['LINE'] == 5) {
             $_OPTB_WOC['BLOCK'] = $blockArr[''];
             //  BLOCK key to 0 // mean using BLOCK 0
             if ($_OPTB_WOC['OPCODE'] == 'START') {
                 //$LOCCTR += $this->toHex($_OPTB_WOC['OPERAND']);
                 $blockLocArr[$_OPTB_WOC['BLOCK']] += $this->toHex($_OPTB_WOC['OPERAND']);
                 //$LOCCTR = $blockLocArr[$_OPTB_WOC['BLOCK']];
                 // $this->formatNumber($blockLocArr[$_OPTB_WOC['BLOCK']]);
                 $_OPTB_WOC['LOC'] = $this->formatNumber($blockLocArr[$_OPTB_WOC['BLOCK']]);
                 $_OPTB_WOC['ELOC'] = $this->formatNumber($blockLocArr[$_OPTB_WOC['BLOCK']]);
             } else {
                 $blockLocArr[$_OPTB_WOC['BLOCK']] = $blockLocArr[''];
                 $_OPTB_WOC['LOC'] = $this->formatNumber(0x0);
                 $_OPTB_WOC['ELOC'] = $this->formatNumber(0x0);
             }
             $block = $_OPTB_WOC['BLOCK'];
             array_push($this->OPTB_WOC_afterPassOne, $_OPTB_WOC);
             continue;
             ## read next line
         } else {
             if (empty($_OPTB_WOC['LABEL']) && empty($_OPTB_WOC['OPCODE']) && empty($_OPTB_WOC['OPERAND'])) {
                 array_push($this->OPTB_WOC_afterPassOne, $_OPTB_WOC);
                 continue;
                 // read next line
             }
         }
         if ($_OPTB_WOC['OPCODE'] == 'CSECT') {
             //$blockLocArr[$_OPTB_WOC['BLOCK']] = 0;
             $blockLocArr[$_OPTB_WOC['BLOCK']] = hexdec(array_search_value($this->OPTB_WOC, 'OPCODE', 'START', 'OPERAND'));
             $_OPTB_WOC['LOC'] = $this->formatNumber($blockLocArr[$_OPTB_WOC['BLOCK']]);
             ++$SECTION;
             $_OPTB_WOC['SECTION'] = $SECTION;
             array_push($this->OPTB_WOC_afterPassOne, $_OPTB_WOC);
             continue;
             ## read next line
         }
         // new block declared
         if ($_OPTB_WOC['OPCODE'] == 'USE' && !empty($_OPTB_WOC['OPERAND']) && !array_key_exists($_OPTB_WOC['OPERAND'], $blockArr)) {
             $_OPTB_WOC['BLOCK'] = max($blockArr) + 1;
             $blockArr[$_OPTB_WOC['OPERAND']] = $_OPTB_WOC['BLOCK'];
             array_push($blockArr, $blockArr[$_OPTB_WOC['OPERAND']]);
             $blockLocArr[$_OPTB_WOC['BLOCK']] = 0x0;
             array_push($blockLocArr, $blockLocArr[$_OPTB_WOC['BLOCK']]);
         } else {
             if ($_OPTB_WOC['OPCODE'] == 'USE' && array_key_exists($_OPTB_WOC['OPERAND'], $blockArr)) {
                 $_OPTB_WOC['BLOCK'] = $blockArr[$_OPTB_WOC['OPERAND']];
             }
         }
         if ($_OPTB_WOC['OPCODE'] == 'USE') {
             $block = $_OPTB_WOC['BLOCK'];
             $_OPTB_WOC['LOC'] = $this->formatNumber($blockLocArr[$_OPTB_WOC['BLOCK']]);
             $_OPTB_WOC['ELOC'] = $this->formatNumber($blockLocArr[$_OPTB_WOC['BLOCK']]);
             array_push($this->OPTB_WOC_afterPassOne, $_OPTB_WOC);
             continue;
         }
         if ($_OPTB_WOC['OPCODE'] == 'LTORG') {
             array_push($this->OPTB_WOC_afterPassOne, $_OPTB_WOC);
             if (count($literalsArr >= 1)) {
                 $literalsArrTmp = $literalsArr;
                 foreach ($literalsArrTmp as $literals) {
                     var_dump($literals);
                     $_OPTB_WOC['LINE'] = '';
                     $_OPTB_WOC['LOC'] = $this->formatNumber($blockLocArr[$_OPTB_WOC['BLOCK']]);
                     $_OPTB_WOC['LABEL'] = $literals['LABEL'];
                     $_OPTB_WOC['OPCODE'] = $literals['OPCODE'];
                     if ($literals['OPCODE'][1] == 'X') {
                         $_OPTB_WOC['SIZE'] = strlen(get_string_between($_OPTB_WOC['OPCODE'], "'", "'")) / 2;
                     } else {
                         if ($literals['OPCODE'][1] == 'C') {
                             $_OPTB_WOC['SIZE'] = strlen(get_string_between($_OPTB_WOC['OPCODE'], "'", "'"));
                         }
                     }
                     $_OPTB_WOC['ELOC'] = $blockLocArr[$_OPTB_WOC['BLOCK']] + $_OPTB_WOC['SIZE'];
                     array_push($this->OPTB_WOC_afterPassOne, $_OPTB_WOC);
                     array_push($this->SYMTAB, array('LABEL' => $_OPTB_WOC['OPCODE'], 'LOC' => $_OPTB_WOC['LOC'], $_OPTB_WOC['SECTION']));
                     array_shift($literalsArr);
                     $blockLocArr[$_OPTB_WOC['BLOCK']] += $_OPTB_WOC['SIZE'];
                     // new LOCCTR
                 }
             }
             continue;
         }
         /*
         // something do with LTORG - -.... need a loop inside
         else if($_OPTB_WOC['OPCODE'] == 'LTORG') {
         	array_push($this->OPTB_WOC_afterPassOne,$_OPTB_WOC);
         	if(count($literalsArr) >= 1)
         		foreach($literalsArr as $literals) {
         			echo "on99999999999999999999999999999";
         			print_r($literals);
         			$_OPTB_WOC['LINE'] = '';
         			$_OPTB_WOC['LOC'] =  $this->formatNumber($blockLocArr[$_OPTB_WOC['BLOCK']]);
         			$_OPTB_WOC['LABEL'] = $literals['LABEL'];
         			$_OPTB_WOC['OPCODE'] = $literals['OPCODE'];
         			array_push($this->OPTB_WOC_afterPassOne, $_OPTB_WOC);
         			// add literals to SMYTAB too- -.. also added at the end
         			array_push($this->SYMTAB,  array('LABEL' => $_OPTB_WOC['OPCODE'], 'LOC' => $_OPTB_WOC['LOC']));
         			//array_push($this->OPTB_WOC_afterPassOne, array("LOC" => $this->formatNumber($LOCCTR),
         			//		"LABEL"	 => 	 $literals['LABEL'] ,
         			//		"OPCODE" =>		$literals['OPCODE']));
         			array_shift($literalsArr);
         			//reset($literalsArr);
         			//$key = key($literalsArr);
         			//unset($literalsArr[$key]);
         			$blockLocArr[$_OPTB_WOC['BLOCK']] += 3;
         			$_OPTB_WOC['ELOC'] = $this->formatNumber($blockLocArr[$_OPTB_WOC['BLOCK']]);
         		}
         	continue;
         }
         */
         if ($_OPTB_WOC['OPCODE'] == 'EQU') {
             if ($_OPTB_WOC['OPERAND'] == "*") {
                 $_OPTB_WOC['LOC'] = $this->formatNumber($blockLocArr[$_OPTB_WOC['BLOCK']]);
             } else {
                 //$operand = preg_split('/[^A-Z]/', $_OPTB_WOC['OPERAND']);
                 //$operation = preg_replace("([^+-/*])", '', $_OPTB_WOC['OPERAND']);
                 $operation = preg_replace("/[^+\\/*-]/", '', $_OPTB_WOC['OPERAND']);
                 $operand = explode($operation, $_OPTB_WOC['OPERAND']);
                 //$operation =  $_OPTB_WOC['OPERAND']{strlen($operand[0])};
                 //print_r($operand);
                 $locOne = array_search_value($this->OPTB_WOC_afterPassOne, 'LABEL', $operand[0], 'LOC');
                 $locTwo = array_search_value($this->OPTB_WOC_afterPassOne, 'LABEL', $operand[1], 'LOC');
                 //echo $locOne . " | " . $locTwo . "\n";
                 $locOne = hexdec($locOne);
                 $locTwo = hexdec($locTwo);
                 switch ($operation) {
                     case '+':
                         $loc = $locOne + $locTwo;
                         break;
                     case '-':
                         $loc = $locOne - $locTwo;
                         break;
                     case '*':
                         $loc = $locOne * $locTwo;
                         break;
                     case '/':
                         $loc = $locOne / $locTwo;
                         break;
                     default:
                         $loc = "0000";
                         echo "Wrong operation symbol in Symbol-Definint Statements\n";
                         break;
                 }
                 //echo "locccccccccccccccc  operation : " .  $this->formatNumber($loc)  . " | " . $operation ."\n";
                 //exit;
                 $_OPTB_WOC['LOC'] = $this->formatNumber($loc);
                 $_OPTB_WOC['BLOCK'] = '';
             }
             // don't ask why.. fix unkonwn bug
             $tmpArr = array('LOC' => $_OPTB_WOC['LOC'], 'LABEL' => $_OPTB_WOC['LABEL'], 'OPERAND' => $_OPTB_WOC['OPERAND'], 'OPCODE' => "", "OBJECTCODE" => "", 'SECTION' => $_OPTB_WOC['SECTION'], 'LINE' => '', 'COMMENT' => '');
             array_push($this->SYMTAB, $tmpArr);
             if (!isset($_OPTB_WOC['LINE'])) {
                 $_OPTB_WOC['LINE'] = '';
             }
             if (!isset($_OPTB_WOC['LOC'])) {
                 $_OPTB_WOC['LOC'] = '';
             }
             array_push($this->SYMTAB, $tmpArr);
             array_push($this->OPTB_WOC_afterPassOne, $_OPTB_WOC);
             //array_push($this->OPTB_WOC_afterPassOne, $tmpArr);
             //array_push($this->SYMTAB, $_OPTB_WOC);
             //array_push($this->OPTB_WOC_afterPAssOne, $_OPTB_WOC);
             continue;
         }
         // end EQU
         if ($_OPTB_WOC['OPCODE'] != 'END') {
             //echo "while(_OPTB_WOC['OPCODE'] != 'END')\n";
             ## if this is not a comment line then
             ## Fig 2.5 have BASE....
             if (in_array($_OPTB_WOC['OPCODE'], $OPTB_SKIP)) {
                 array_push($this->OPTB_WOC_afterPassOne, $_OPTB_WOC);
                 continue;
                 ## read next line
             }
             if ($_OPTB_WOC['LABEL'] != '.') {
                 //echo "if(_OPTB_WOC['LABEL'] != '.')\n";
                 ## if there is a symbol in the LABEL field then
                 if (empty($_OPTB_WOC['LABEL']) == false) {
                     //echo "f(empty(_OPTB_WOC['LABEL']) == false)\n";
                     ## serch SYMTAB for LABEL
                     if (is_in_array($this->SYMTAB, "LABEL", $_OPTB_WOC['LABEL'])) {
                         //echo "if(is_in_array( this->SYMTAB, \"LABEL\",  OPTB_WOC['LABEL']))\n";
                         ## set error flag(duplicate symbol)
                         $errorMsg = str_pad("Error at line ", 15) . $_OPTB_WOC['LINE'] . " : " . $_OPTB_WOC['LABEL'] . " duplicate symbol\n";
                         echo $errorMsg;
                         $this->errorLogPassOne .= $errorMsg;
                         $this->errorFlag = true;
                         // return false;	## return false to stop the program...
                     } else {
                         //echo "if(is_in_array( this->SYMTAB, \"LABEL\",  OPTB_WOC['LABEL'])) else\n";
                         ## IDK--> insert (LABEL, LOCCTR) into SYMTAB
                         $_OPTB_WOC['LOC'] = $this->formatNumber($blockLocArr[$_OPTB_WOC['BLOCK']]);
                         array_push($this->SYMTAB, array("LABEL" => $_OPTB_WOC['LABEL'], "LOC" => $_OPTB_WOC['LOC'], 'SECTION' => $_OPTB_WOC['SECTION']));
                     }
                     ## not found END
                 } else {
                     ## no label found
                     //echo "	## no label found\n";
                     $_OPTB_WOC['LOC'] = $this->formatNumber($blockLocArr[$_OPTB_WOC['BLOCK']]);
                 }
                 $errorFlag == true;
                 ## search OPTAB for OPCODE
                 foreach ($this->OPTAB_ as $value) {
                     //echo "foreach(this->OPTAB_ as value)\n";
                     ## WORD , RESW , RESB, BYTE case
                     if ($_OPTB_WOC['OPCODE'] == 'WORD') {
                         //$_OPTB_WOC['LOC'] = $this->formatNumber($LOCCTR);
                         $blockLocArr[$_OPTB_WOC['BLOCK']] += 3;
                         $_OPTB_WOC['SIZE'] = 3;
                         $_OPTB_WOC['ELOC'] = $this->formatNumber($blockLocArr[$_OPTB_WOC['BLOCK']]);
                         $errorFlag = false;
                         break;
                         ## break foreach;
                     } else {
                         if ($_OPTB_WOC['OPCODE'] == 'RESW') {
                             if ($_OPTB_WOC['OPERAND'] == 0) {
                                 $_OPTB_WOC_fix['OPERAND'] = 1;
                             } else {
                                 $_OPTB_WOC_fix['OPERAND'] = $_OPTB_WOC['OPERAND'];
                             }
                             $blockLocArr[$_OPTB_WOC['BLOCK']] += 3 * $_OPTB_WOC_fix['OPERAND'];
                             $_OPTB_WOC['SIZE'] = 3 * $_OPTB_WOC_fix['OPERAND'];
                             $_OPTB_WOC['ELOC'] = $this->formatNumber($blockLocArr[$_OPTB_WOC['BLOCK']]);
                             $errorFlag = false;
                             break;
                             ## break foreach;
                         } else {
                             if ($_OPTB_WOC['OPCODE'] == 'RESB') {
                                 if ($_OPTB_WOC['OPERAND'] == 0) {
                                     $_OPTB_WOC['OPERAND'] = 1;
                                 }
                                 $blockLocArr[$_OPTB_WOC['BLOCK']] += $_OPTB_WOC['OPERAND'];
                                 $_OPTB_WOC['SIZE'] = $_OPTB_WOC['OPERAND'];
                                 $_OPTB_WOC['ELOC'] = $this->formatNumber($blockLocArr[$_OPTB_WOC['BLOCK']]);
                                 $errorFlag = false;
                                 break;
                                 ## break foreach;
                             } else {
                                 if ($_OPTB_WOC['OPCODE'] == 'BYTE') {
                                     ## find length of constant in byes and length to LOCCTR... no idea
                                     //$_OPTB_WOC['LOC'] = $this->formatNumber($LOCCTR);
                                     if (substr($_OPTB_WOC['OPERAND'], 0, 1) == 'X') {
                                         $blockLocArr[$_OPTB_WOC['BLOCK']] += strlen(get_string_between($_OPTB_WOC['OPERAND'], "'", "'")) / 2;
                                         $_OPTB_WOC['SIZE'] = strlen(get_string_between($_OPTB_WOC['OPERAND'], "'", "'")) / 2;
                                         $_OPTB_WOC['ELOC'] = $this->formatNumber($blockLocArr[$_OPTB_WOC['BLOCK']]);
                                         $errorFlag = false;
                                         break;
                                         ## break foreach;
                                     }
                                     if (substr($_OPTB_WOC['OPERAND'], 0, 1) == 'C') {
                                         $blockLocArr[$_OPTB_WOC['BLOCK']] += strlen(get_string_between($_OPTB_WOC['OPERAND'], "'", "'"));
                                         $_OPTB_WOC['SIZE'] = strlen(get_string_between($_OPTB_WOC['OPERAND'], "'", "'"));
                                         $_OPTB_WOC['ELOC'] = $this->formatNumber($blockLocArr[$_OPTB_WOC['BLOCK']]);
                                         $errorFlag = false;
                                         break;
                                         ## break foreach;
                                     } else {
                                         $mask = "Error at line %s : %s wrong syntax\n";
                                         #$errorMsg = str_pad("Error at line ",15). $_OPTB_WOC['LINE'] . " : " . $_OPTB_WOC['OPERAND'] . " wrong syntax\n";
                                         #echo $errorMsg;
                                         echo "sprintf \n";
                                         $error = sprintf($mask, $_OPTB_WOC['LINE'], $_OPTB_WOC['OPERAND']);
                                         echo $error;
                                         $this->errorLogPassOne .= $errorMsg;
                                         //$errorFlag = true;
                                         //return false;
                                         break;
                                         ## break foreach;
                                     }
                                 } else {
                                     if (substr($_OPTB_WOC['OPCODE'], 0, 1) == '+' && substr($_OPTB_WOC['OPCODE'], 1) == $value['OPCODE'] && $value['FORMAT'] == "3/4") {
                                         $blockLocArr[$_OPTB_WOC['BLOCK']] += 4;
                                         $_OPTB_WOC['SIZE'] = 4;
                                         $_OPTB_WOC['ELOC'] = $this->formatNumber($blockLocArr[$_OPTB_WOC['BLOCK']]);
                                         $errorFlag = false;
                                         break;
                                         ## break foreach;
                                     } else {
                                         if ($_OPTB_WOC['OPCODE'] == $value['OPCODE'] && $value['FORMAT'] == "3/4") {
                                             if (substr($_OPTB_WOC['OPERAND'], 0, 1) == '=') {
                                                 //$literalLength =  strlen(get_string_between($_OPTB_WOC['OPERAND'], "'", "'"));
                                                 $literalTmp = array('SIZE' => '3', 'LABEL' => '*', 'OPCODE' => $_OPTB_WOC['OPERAND']);
                                                 if (!in_array($literalTmp, $literalsArr)) {
                                                     array_push($literalsArr, $literalTmp);
                                                     array_push($this->literalsArr, $literalTmp);
                                                 }
                                                 //print_r($literalsArr);
                                             }
                                             $blockLocArr[$_OPTB_WOC['BLOCK']] += 3;
                                             $_OPTB_WOC['SIZE'] = 3;
                                             $_OPTB_WOC['ELOC'] = $this->formatNumber($blockLocArr[$_OPTB_WOC['BLOCK']]);
                                             $errorFlag = false;
                                             break;
                                             ## break foreach;
                                         } else {
                                             if ($_OPTB_WOC['OPCODE'] == $value['OPCODE'] && $value['FORMAT'] == "2") {
                                                 $_OPTB_WOC['SIZE'] = 2;
                                                 $blockLocArr[$_OPTB_WOC['BLOCK']] += 2;
                                                 $_OPTB_WOC['ELOC'] = $this->formatNumber($blockLocArr[$_OPTB_WOC['BLOCK']]);
                                                 $errorFlag = false;
                                                 break;
                                                 ## break foreach;
                                             } else {
                                                 if ($_OPTB_WOC['OPCODE'] == $value['OPCODE'] && $value['FORMAT'] == "1") {
                                                     $_OPTB_WOC['SIZE'] = 1;
                                                     $blockLocArr[$_OPTB_WOC['BLOCK']] += 1;
                                                     $_OPTB_WOC['ELOC'] = $this->formatNumber($blockLocArr[$_OPTB_WOC['BLOCK']]);
                                                     $errorFlag = false;
                                                     break;
                                                     ## break foreach;
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
                 ## END ## search OPTAB for OPCODE
                 if ($errorFlag == !false) {
                     //echo 	"if(errorFlag == !false)";
                     $errorMsg = str_pad("Error at line ", 15) . $_OPTB_WOC['LINE'] . " : " . $_OPTB_WOC['OPCODE'] . " invalid operation code\n";
                     echo $errorMsg;
                     $this->errorLogPassOne .= $errorMsg;
                     $this->errorFlag = true;
                     //return false;	## return false to stop the program...
                 }
             }
             ## if this is not a comment line END
             ## write line to intermediate file
             ## read next input line
         } else {
             ## if OPCODE == END
             array_push($this->OPTB_WOC_afterPassOne, $_OPTB_WOC);
             ## if(LABEL != 'END') also do array_push..
             break;
             ## read next line
         }
         //$LOCCTR -= 3;	## subtract the precondition from last run..
         ## write last line to intermediate file
         ## save( LOCCTR - starting address) as program length
         //
         array_push($this->OPTB_WOC_afterPassOne, $_OPTB_WOC);
         ## array_push result..
         //print_r($this->OPTB_WOC);
     }
     if (count($literalsArr) >= 1) {
         foreach ($literalsArr as $literals) {
             //print_r($literals);
             array_push($this->SYMTAB, array('LABEL' => $literals['OPCODE'], 'LOC' => $this->formatNumber($blockLocArr[$_OPTB_WOC['BLOCK']], $_OPTB_WOC['SECTION'])));
             array_push($this->OPTB_WOC_afterPassOne, array("LOC" => $this->formatNumber($blockLocArr[$_OPTB_WOC['BLOCK']]), 'SECTION' => $_OPTB_WOC['SECTION'], "LABEL" => $literals['LABEL'], "OPCODE" => $literals['OPCODE'], 'OPERAND' => '', "OBJECTCODE" => "", 'LINE' => '', 'COMMENT' => ''));
             array_pop($literalsArr);
             $blockLocArr[$_OPTB_WOC['BLOCK']] += 3;
             $_OPTB_WOC['ELOC'] = $this->formatNumber($blockLocArr[$_OPTB_WOC['BLOCK']]);
         }
     }
     print_r($blockLocArr);
     print_r($blockArr);
     $this->OPTB_WOC = $this->OPTB_WOC_afterPassOne;
     ## update OPTB_WOC with LOC info
     $this->programLength = 9999 - $this->startingAdd;
     // 999 = $blockLocArr[$_OPTB_WOC['BLOCK']]
     echo "Program length : " . $this->formatNumber($this->programLength) . "\n";
     return $this->doPassTwo();
 }
Пример #11
0
/**
 *
 **/
function is_allowed($perm, $gid)
{
    global $admin, $settings;
    // admin is always allowed to do all
    if ($admin->get_user_id() == 1) {
        return true;
    }
    if (!array_key_exists($perm, $settings)) {
        return false;
    } else {
        $value = $settings[$perm];
        if (!is_array($value)) {
            $value = array($value);
        }
        return is_in_array($value, $gid);
    }
    return false;
}
Пример #12
0
" rel="stylesheet">
<?php 
$forum = $this->get('forum');
$forumEdit = $this->get('forumEdit');
$topics = $this->get('topics');
$topicMapper = $this->get('topicMapper');
$forumMapper = $this->get('forumMapper');
$groupIdsArray = $this->get('groupIdsArray');
$adminAccess = null;
if ($this->getUser()) {
    $adminAccess = $this->getUser()->isAdmin();
}
?>

<?php 
if (is_in_array($groupIdsArray, explode(',', $forum->getReadAccess())) || $adminAccess == true) {
    ?>
    <div id="forum">
        <h3><?php 
    echo $forum->getTitle();
    ?>
</h3>
        <div class="topic-actions">
            <?php 
    if ($this->getUser()) {
        ?>
                <div class="buttons">
                    <a href="<?php 
        echo $this->getUrl(array('controller' => 'newtopic', 'action' => 'index', 'id' => $forum->getId()));
        ?>
" class="btn btn-labeled bgblue">
Пример #13
0
 /**
  *
  **/
 public static function is_allowed($perm, $gid)
 {
     global $settings;
     // admin is always allowed to do all
     if (CAT_Users::is_root()) {
         return true;
     }
     if (!array_key_exists($perm, $settings)) {
         return false;
     } else {
         $value = $settings[$perm];
         if (!is_array($value)) {
             $value = array($value);
         }
         return is_in_array($value, $gid);
     }
     return false;
 }
Пример #14
0
function checkView($categoryID)
{
    $allow = array(112, 113);
    global $cats;
    $cat_path = dizGetPath($cats, $categoryID);
    $check = false;
    if (count($cat_path) > 1) {
        $check = is_in_array($allow, $cat_path);
    }
    return $check;
}
Пример #15
0
 public function demo_post()
 {
     // povlacimo id iz URI-a
     $id = $this->uri->segment(3, NULL);
     // prvo prikazujemo model
     $demo = $this->Api_model->get($id);
     // ako ima upisa
     if (is_numeric($id) && count($demo)) {
         $this->load->library('form_validation');
         $this->load->helper('api_data');
         // povlacenje podatak iz put metode
         // provera da li postoji takvo polje u tabeli
         $data = is_in_array($this->post(), $this->Api_model->arr_table_fields());
         // validiranje podataka sa set_data() ako ne poticu iz POST metode
         $this->form_validation->set_data($data);
         // ako je uspesno validiranje
         if ($this->form_validation->run($this->_valrule_post) != FALSE) {
             // ako je uspesan upis, model vraca zadnji id
             if (is_numeric($this->Api_model->save($data, $id))) {
                 // ako je upis u bazu uspeo vraca id upisa
                 $this->response(array('status' => 'success', 'message' => $this->lang->line('success_data_save')), 200);
             } else {
                 //ako upis nije uspeo
                 $this->response(array('status' => 'failure', 'message' => $this->lang->line('error_data_save')), 500);
             }
         } else {
             // ako nije prosla validacija prikazuje greske
             $this->response(array('status' => 'failure', 'message' => $this->form_validation->error_array()), 400);
         }
     } else {
         // ako ne postoji salje se greska sa obavestenjem
         $this->response(array('status' => 'failure', 'message' => $this->lang->line('error_find_records')), 404);
     }
 }