function set_language($code) { global $path_to_root, $installed_languages, $GetText; $lang = array_search_value($code, $installed_languages, 'code'); $changed = $this->code != $code || $this->version != @$lang['version']; if ($lang && $changed) { // flush cache as we can use several languages in one account flush_dir(company_path() . '/js_cache'); $this->name = $lang['name']; $this->code = $lang['code']; $this->encoding = $lang['encoding']; $this->version = @$lang['version']; $this->dir = isset($lang['rtl']) && $lang['rtl'] === true ? 'rtl' : 'ltr'; $locale = $path_to_root . "/lang/" . $this->code . "/locale.inc"; $this->is_locale_file = file_exists($locale); } $GetText->set_language($this->code, $this->encoding); $GetText->add_domain($this->code, $path_to_root . "/lang", $this->version); // Necessary for ajax calls. Due to bug in php 4.3.10 for this // version set globally in php.ini ini_set('default_charset', $this->encoding); if (isset($_SESSION['App']) && $changed) { $_SESSION['App']->init(); } // refresh menu }
/** * Recursive generate the menu for all the children of given $nav * * @param $parent * @return string */ private function generateNavigationChildren($parent) { $html = '<ul class="treeview-menu">'; $navigation = NavigationAdmin::whereParentIdORM($parent->id); foreach ($navigation as $key => $nav) { $active = array_search_value($nav->id, $this->urlParentNavs) ? 'active open' : ''; $children = $this->generateNavigationChildren($nav); $link = strlen($children) < 2 ? url($this->baseUrl . $nav->url) : '#'; $childrenClass = strlen($children) < 2 ? '' : ' treeview '; $html .= '<li class="' . $active . $childrenClass . '"><a href="' . $link . '">'; $html .= strlen($nav->icon) > 2 ? '<i class="fa fa-fw fa-' . $nav->icon . '"></i> ' : ''; $html .= '<span>' . $nav->title . '</span>'; if (strlen($children) > 2) { $html .= '<i class="fa fa-angle-left pull-right"></i>'; } $html .= '</a>' . $children; $html .= '</li>'; } $html .= '</ul>'; return count($navigation) >= 1 ? $html : ''; }
private function generateObjectProgram() { global $OUTPUT_LOG_PREFIX; $OPTB_WOC_OP = array(); $headerContent = ''; $defineContent = ''; $referContent = ''; $textContent = ''; $modificationContent = ''; $endContent = ''; $textRecordMaxLen = hexdec('1E'); $textRecord = ''; $TstartinggAdd = ''; $Tlength = 0; // max = 1E $Ttemp = ''; $perviouBlock = 0; if (max(array_column($this->OPTB_WOC, 'SECTION')) == 0) { if (max(array_column($this->OPTB_WOC, 'BLOCK')) > 0) { $moreThanOneBlock = true; $loc = array(); $block = array(); foreach ($this->OPTB_WOC as $key => $row) { $loc[$key] = $row['LOC']; $block[$key] = $row['BLOCK']; } array_multisort(array_keys($this->OPTB_WOC), SORT_ASC, $this->OPTB_WOC); } foreach ($this->OPTB_WOC as $_OPTB_WOC) { // testing... // if(!isset($_OPTB_WOC['ELOC']) || empty($_OPTB_WOC['ELOC'])) continue; // testing state not sure.. // if(!isset($_OPTB_WOC['SIZE']) || empty($_OPTB_WOC['SIZE'])) continue; if (isset($_OPTB_WOC['realLOC']) || !empty($_OPTB_WOC['realLOC'])) { $_OPTB_WOC['LOC'] = $_OPTB_WOC['realLOC']; } if (!isset($_OPTB_WOC['BLOCK']) || empty($_OPTB_WOC['BLOCK'])) { // no change } else { $perviouBlock = $_OPTB_WOC['BLOCK']; } if (!isset($_OPTB_WOC['LOC']) || empty($_OPTB_WOC['LOC'])) { continue; } else { $perviouBlock = $_OPTB_WOC['BLOCK']; } if ($_OPTB_WOC['LINE'] == 5) { $programName = $_OPTB_WOC['LABEL']; $_OPTB_WOC['recordType'] = 'E'; $startingAddress = sprintf("%06X", hexdec($_OPTB_WOC['OPERAND'])); } else { if (!empty($_OPTB_WOC['OBJECTCODE'])) { $_OPTB_WOC['recordType'] = 'T'; if ($Tlength == 0) { $TstartinggAdd = '00' . $_OPTB_WOC['LOC']; $Tlength = $_OPTB_WOC['SIZE']; $Ttemp = $_OPTB_WOC['OBJECTCODE'] . '^'; // $Ttemp = sprintf("%06X", hexdec($_OPTB_WOC['OBJECTCODE'])) . '^' ; $writed = false; //echo $Ttemp . "\n"; } else { if (isset($_OPTB_WOC['ELOC']) && isset($_OPTB_WOC['LOC'])) { if ($Tlength + hexdec($_OPTB_WOC['ELOC']) - hexdec($_OPTB_WOC['LOC']) <= $textRecordMaxLen && $_OPTB_WOC['BLOCK'] == $perviouBlock) { $Tlength += $_OPTB_WOC['SIZE']; $Ttemp .= $_OPTB_WOC['OBJECTCODE'] . '^'; // $Ttemp .= sprintf("%06X", hexdec($_OPTB_WOC['OBJECTCODE'])) . '^' ; $writed = false; //echo $Ttemp . "\n"; } else { $textContent .= 'T' . '^' . $TstartinggAdd . '^' . sprintf("%02X", $Tlength) . '^' . substr($Ttemp, 0, -1) . "\r\n"; $Tlength = 0; $TstartinggAdd = '00' . $_OPTB_WOC['LOC']; $Tlength = $_OPTB_WOC['SIZE']; $Ttemp = $_OPTB_WOC['OBJECTCODE'] . '^'; // $Ttemp = sprintf("%06X", hexdec($_OPTB_WOC['OBJECTCODE'])) . '^' ; $writed = true; } } } } else { if (!$writed) { $textContent .= 'T' . '^' . $TstartinggAdd . '^' . sprintf("%02X", $Tlength) . '^' . substr($Ttemp, 0, -1) . "\r\n"; $Tlength = 0; $TstartinggAdd = '00' . $_OPTB_WOC['LOC']; $Ttemp = $_OPTB_WOC['OBJECTCODE']; // $Ttemp = sprintf("%06X", hexdec($_OPTB_WOC['OBJECTCODE'])) . '^' ; $writed = true; } $_OPTB_WOC['recordType'] = 'SKIP'; } } if ($_OPTB_WOC['OPCODE'][0] == '+' && in_array($_OPTB_WOC['OPERAND'], array('RDREC', 'WRREC'))) { $_OPTB_WOC['recordType'] = 'M'; $modificationContent .= 'M' . '^' . sprintf("%06X", hexdec($_OPTB_WOC['LOC']) + 1) . '^' . '05' . "\r\n"; } //var_dump($Tlength); array_push($OPTB_WOC_OP, $_OPTB_WOC); } $textContent .= 'T' . '^' . $TstartinggAdd . '^' . sprintf("%02X", $Tlength) . '^' . substr($Ttemp, 0, -1) . "\r\n"; $Tlength = 0; $TstartinggAdd = '00' . $_OPTB_WOC['LOC']; $Ttemp = $_OPTB_WOC['OBJECTCODE']; // $Ttemp = sprintf("%06X", hexdec($_OPTB_WOC['OBJECTCODE'])) . '^' ; $writed = true; // first if scope fix bug-_- . don't modify dont ask dont touch if (max(array_column($this->OPTB_WOC, 'BLOCK')) > 0) { $endingAddress1 = max(array_column($this->OPTB_WOC, 'ELOC')); $endingAddress2 = max(array_column($this->OPTB_WOC, 'realLOC')); $endingAddress = $endingAddress1 > $endingAddress2 ? $endingAddress1 : $endingAddress2; } else { $endingAddress = 0; // initial only .. just bullshit.. foreach (array_reverse(array_column($this->OPTB_WOC, 'ELOC')) as $lastELOC) { if (!empty($lastELOC)) { echo "lastELOC : " . $lastELOC . "\r\n"; $endingAddress = $lastELOC; break; } } } $programLength = hexdec($endingAddress) - hexdec($startingAddress); if (empty($programName)) { $programName = 'COPY'; } $programLength = sprintf("%06X", $programLength); $headerContent = 'H' . sprintf('%-6s', $programName) . '^' . $startingAddress . '^' . $programLength; $endContent = $startingAddress; $headerRecord = $headerContent . "\r\n"; $defineRecord = $defineContent . "\r\n"; $referRecord = $referContent . "\r\n"; $textTrecord = $textContent; // contain new line dont worry $modificationRecord = $modificationContent; // contain new line dont worry $endRecord = 'E' . '^' . $endContent . "\r\n"; if (empty($headerContent)) { $headerRecord = ''; } if (empty($defineContent)) { $defineRecord = ''; } if (empty($referContent)) { $referRecord = ''; } if (empty($textContent)) { $textTrecord = ''; } if (empty($modificationContent)) { $modificationRecord = ''; } // fix lastline T^00001D^00^ problem .. delete it $fixTextTrecord = explode("\r\n", $textTrecord); //print_r($fixTextTrecord); end($fixTextTrecord); $tRecordLastIndex = key($fixTextTrecord); if (empty($fixTextTrecord[$tRecordLastIndex])) { $tRecordLastIndex = $tRecordLastIndex - 1; } if (substr($fixTextTrecord[$tRecordLastIndex], -4) == '^00^') { unset($fixTextTrecord[$tRecordLastIndex]); } $textTrecord = implode("\r\n", $fixTextTrecord); $this->objectProgramContent = $headerRecord . $defineRecord . $referRecord . $textTrecord . $modificationRecord . $endRecord; echo $this->objectProgramContent; } else { $objectProgram = array(); $countSize = 0; $tLine = 0; $previousSection = 'no_value'; $index = 0; $modificationArr = array(); $modificationSortedArr = array(); $storageTypeArr = array('RESW', 'RESB', 'BYTE', 'WORD'); print_r_to_html(RESULT_PATH . '/' . $OUTPUT_LOG_PREFIX . 'fuckmeOPTB.html', $this->OPTB_WOC); $startLoc = sprintf("%04X", hexdec(array_search_value($this->OPTB_WOC, 'OPCODE', 'START', 'OPERAND'))); foreach ($this->OPTB_WOC as $_OPTB) { if (!isset($_OPTB['SECTION']) || empty($_OPTB['SECTION'])) { $_OPTB['SECTION'] = 0; } if ($_OPTB['LINE'] == 5 || $_OPTB['OPCODE'] == 'START' || $_OPTB['OPCODE'] == 'CSECT') { $objectProgram[$_OPTB['SECTION']]['NAME'] = $_OPTB['LABEL']; //continue; } else { if ($_OPTB['OPCODE'] == 'EXTDEF') { $extdef = explode(',', $_OPTB['OPERAND']); //array_push($objectProgram[$_OPTB['SECTION']]['EXTDEF'], $extdef); $objectProgram[$_OPTB['SECTION']]['EXTDEF'] = $extdef; //continue; } else { if ($_OPTB['OPCODE'] == 'EXTREF') { $extref = explode(',', $_OPTB['OPERAND']); //array_push($objectProgram[$_OPTB['SECTION']]['EXTREF'], $extref); $objectProgram[$_OPTB['SECTION']]['EXTREF'] = $extref; //continue; } else { if (isset($_OPTB['OBJECTCODE']) && !empty($_OPTB['OBJECTCODE'])) { if (!isset($_OPTB_WOC)) { $_OPTB['SIZE'] = strlen($_OPTB['OBJECTCODE']) / 2; } $countSize += $_OPTB['SIZE']; if ($previousSection != $_OPTB['SECTION']) { $previousSection = $_OPTB['SECTION']; $countSize = 0; $tLine = 0; } if ($countSize >= $textRecordMaxLen || $index > 0 && $this->OPTB_WOC[$index - 1]['OPCODE'] == 'LTORG') { ++$tLine; $countSize = 0; } $objectProgram[$_OPTB['SECTION']]['TEXT'][] = array('LOC' => $_OPTB['LOC'], 'OBJECTCODE' => $_OPTB['OBJECTCODE'], 'SIZE' => strlen($_OPTB['OBJECTCODE']) / 2, 'TLINE' => $tLine, 'INDEX' => $index); //continue; } } } } ++$index; } // end foreach $previousTLINE = 'no_vlaue'; $opIndex = 0; $tIndex = 0; foreach ($objectProgram as $_objectProgram) { foreach ($_objectProgram['TEXT'] as $_TEXT) { if (!isset($objectProgram[$opIndex]['TRECORD'][$_TEXT['TLINE']])) { $objectProgram[$opIndex]['TRECORD'][$_TEXT['TLINE']]['STARTLOC'] = $_TEXT['LOC']; } if (!isset($objectProgram[$opIndex]['TRECORD'][$_TEXT['TLINE']]['LENGTH'])) { $objectProgram[$opIndex]['TRECORD'][$_TEXT['TLINE']]['LENGTH'] = 0; } $objectProgram[$opIndex]['TRECORD'][$_TEXT['TLINE']]['LENGTH'] += $_TEXT['SIZE']; } ++$opIndex; $previousTLINE = 'no_vlaue'; } // end foreach // fix some unique bug literal loc missing // only for this figure only= =.. $index = 0; $lastELOC = 'no_value'; foreach ($this->OPTB_WOC as $_OPTB) { if (isset($_OPTB['LABEL'])) { if (!empty($_OPTB['ELOC'])) { $lastELOC = $_OPTB['ELOC']; } if ($_OPTB['LABEL'] == '*') { if ($_OPTB['OPCODE'][1] == 'C') { $size = strlen(get_string_between($_OPTB['OPCODE'], "'", "'")); } else { if ($_OPTB['OPCODE'][1] == 'X') { $size = strlen(get_string_between($_OPTB['OPCODE'], "'", "'")) / 2; if ($size == 0.5) { $size = 1; } } } $this->OPTB_WOC[$index]['LOC'] = $lastELOC; $this->OPTB_WOC[$index]['SIZE'] = $size; $newELOC = hexdec($lastELOC) + $size; $this->OPTB_WOC[$index]['ELOC'] = sprintf("%04X", $newELOC); $lastELOC = $this->OPTB_WOC[$index]['ELOC']; } } ++$index; } // end foreach print_r_to_html(RESULT_PATH . '/' . $OUTPUT_LOG_PREFIX . 'fixedOPTB.html', $this->OPTB_WOC); $maxSection = max(array_column($this->OPTB_WOC, 'SECTION')); for ($i = 0; $i <= $maxSection; $i++) { $tmpOPTB = $this->optb_woc_filter('SECTION', $i); $maxLoc = max(array_column($tmpOPTB, 'ELOC')); //$minLoc = min(array_column($tmpOPTB, 'LOC')); $minLoc = array_column($tmpOPTB, 'LOC')[0]; $objectProgram[$i]['LENGTH'] = hexdec($maxLoc) - hexdec($minLoc); $objectProgram[$i]['LENGTH'] = sprintf('%06X', $objectProgram[$i]['LENGTH']); $objectProgram[$i]['STARTLOC'] = $minLoc; $objectProgram[$i]['ENDLOC'] = $maxLoc; } print_r_to_html(RESULT_PATH . '/' . $OUTPUT_LOG_PREFIX . 'objectprogramArray.html', $objectProgram); $content = ''; $delimiter = '^'; $objectProgramRes = array(); for ($index = 0; $index < count($objectProgram); $index++) { // Header record : $objectProgramRes[$index] = 'H' . $delimiter . sprintf("%-6s", $objectProgram[$index]['NAME']) . $delimiter . sprintf("%06X", hexdec($objectProgram[$index]['STARTLOC'])) . $delimiter . sprintf("%06X", hexdec($objectProgram[$index]['ENDLOC'])) . "\r\n"; // Define record : $dRecord = ''; // initial as empty string if (!empty($objectProgram[$index]['EXTDEF'])) { $dRecord = 'D'; for ($e = 0; $e < count($objectProgram[$index]['EXTDEF']); $e++) { $defineLoc = $this->define_record_search_loc($objectProgram[$index]['EXTDEF'][$e], $index); $defineSymbol = sprintf("%-6s", $objectProgram[$index]['EXTDEF'][$e]); $dRecord .= $delimiter . $defineSymbol . $delimiter . sprintf("%06X", hexdec($defineLoc)); } $objectProgramRes[$index] .= $dRecord . "\r\n"; } // end if extdef !empty // Refer record : $rRecord = ''; // initial as empty string if (!empty($objectProgram[$index]['EXTREF'])) { $rRecord = 'R'; for ($e = 0; $e < count($objectProgram[$index]['EXTREF']); $e++) { $defineSymbol = sprintf("%-6s", $objectProgram[$index]['EXTREF'][$e]); $rRecord .= $delimiter . $defineSymbol; } $objectProgramRes[$index] .= $rRecord . "\r\n"; } // end if extref !empty // Text record : $tRecord = ''; // initial as empty string $tRecordLine = NULL; if (isset($objectProgram[$index]['TEXT']) && !empty($objectProgram[$index]['TEXT'])) { for ($t = 0; $t < count($objectProgram[$index]['TRECORD']); $t++) { $startLocTmp = sprintf("%06X", hexdec($objectProgram[$index]['TRECORD'][$t]['STARTLOC'])); $lengthTmp = sprintf("%02X", $objectProgram[$index]['TRECORD'][$t]['LENGTH']); $tRecordLine[$t] = 'T' . $delimiter . $startLocTmp . $delimiter . $lengthTmp; for ($t2 = 0; $t2 < count($objectProgram[$index]['TEXT']); $t2++) { if ($objectProgram[$index]['TEXT'][$t2]['TLINE'] == $t) { $tRecordLine[$t] .= $delimiter . $objectProgram[$index]['TEXT'][$t2]['OBJECTCODE']; } else { if ($objectProgram[$index]['TEXT'][$t2]['TLINE'] < $t) { continue; } else { if ($objectProgram[$index]['TEXT'][$t2]['TLINE'] > $t) { break; } } } } // end inner for } // end for print_r_to_html(RESULT_PATH . '/' . $OUTPUT_LOG_PREFIX . 'tRecordLine' . $index . '.html', $tRecordLine); $tRecord = implode("\r\n", $tRecordLine); $objectProgramRes[$index] .= $tRecord . "\r\n"; } // end if text record !empty // Modification record (revised) : $mRecord = ''; if (isset($objectProgram[$index]['EXTREF']) && !empty($objectProgram[$index]['EXTREF'])) { foreach ($objectProgram[$index]['EXTREF'] as $extref) { if (!empty($this->modification_record($extref, $index))) { $modificationArr[$index][] = $this->modification_record($extref, $index); } // end if } // end forach // originating array .. foreach ($modificationArr[$index] as $_extref) { if (is_array($_extref)) { foreach ($_extref as $__extref) { $modificationSortedArr[$index][] = $__extref; } // end inner foreach } // end is_array } // end foreach // sorting array : $decloc = array(); foreach ($modificationSortedArr[$index] as $key => $row) { $decloc[$key] = $row['DECLOC']; } array_multisort($decloc, SORT_ASC, $modificationSortedArr[$index]); $mRecord = ''; foreach ($modificationSortedArr[$index] as $_extref) { $mRecord .= 'M' . $delimiter . $_extref['LOC'] . $delimiter . $_extref['SIZE'] . $delimiter . $_extref['OPERATOR'] . $_extref['SYMBOL'] . "\r\n"; } $objectProgramRes[$index] .= $mRecord; //$objectProgramRes[$index] .= $mRecord . "\r\n"; } // end if extref record !empty // End record : $eRecord = ''; if (isset($objectProgram[$index]['STARTLOC']) && !empty($objectProgram[$index]['STARTLOC'])) { $eRecord .= 'E'; if ($index == 0) { $eRecord .= $delimiter . $objectProgram[$index]['STARTLOC']; } $objectProgramRes[$index] .= $eRecord . "\r\n"; } // combine to file content ... $content .= $objectProgramRes[$index] . "\r\n\r\n\r\n"; } // end for loop echo $content; $this->objectProgramContent = $content; print_r_to_html(RESULT_PATH . '/' . $OUTPUT_LOG_PREFIX . 'modificationSortedArr' . $index . '.html', $modificationSortedArr); print_r_to_html(RESULT_PATH . '/' . $OUTPUT_LOG_PREFIX . 'modificationArr' . $index . '.html', $modificationArr); //create_file(RESULT_PATH.'/'.$OUTPUT_LOG_PREFIX.'object-program.txt',$content); //file_put_contents(RESULT_PATH.'/'.$OUTPUT_LOG_PREFIX.'object-program.txt',$content); //print_r($objectProgram); } // end else // exit; }
/** * Generate the Main Navigation's HTML + show Active * @return string */ protected function generateNavigation() { $html = ''; $navigation = NavigationWebsite::mainNavigation(); foreach ($navigation as $key => $nav) { $extra = ''; $link = url($this->baseUrl . $nav->url); $children = $this->generateNavigationChildren($nav); $class = array_search_value($nav->id, $this->parentNavs) ? 'active' : ''; if (strlen($children) > 2) { $link = '#'; $class .= ' dropdown-toggle'; $extra = ' <i class="icon-down-open-mini"></i>'; } $html .= "<li class='{$class}'>"; $html .= '<a class="' . $class . '" href="' . $link . '">' . $nav->title . $extra . '</a>'; $html .= $children; $html .= '</li>'; } return $html; }
function pinyin($str, $split = "") { $pinyin = (include iPATH . 'include/pinyin.php'); preg_match_all(CN_PATTERN, trim($str), $match); $s = $match[0]; $c = count($s); for ($i = 0; $i < $c; $i++) { if ($v = array_search_value($s[$i], $pinyin)) { $zh && $split && ($R[] = $split); $R[] = $v; $zh = true; $az09 = false; } else { if (eregi("[a-z0-9]", $s[$i])) { $zh && $i != 0 && !$az09 && $split && ($R[] = $split); $R[] = $s[$i]; $zh = true; $az09 = true; } else { // array('+',' ','/','?','%','#','&','=')//url // array('\\','/',':','?','*','"','<','>','|')//dir $sp = true; if ($split) { if ($s[$i] == ' ') { $R[] = $sp ? '' : $split; $sp = false; } else { $R[] = $sp ? $split : ''; $sp = true; } } else { $R[] = ''; } // $R[]=$split?(($s[$i]==' ')?$split: // str_replace(array('+',' ','/','?','%','#','&','=','\\',':','*','"','<','>','|'),'',$s[$i])):''; $zh = false; $az09 = false; } } } unset($pinyin); return implode('', $R); }
function filterImport($arrayName) { if ($arrayName == '_REQUEST') { $variablesArray = $_REQUEST; } else { $variablesArray = ${$arrayName}; global $variablesArray; } global $filterOps; global $pilotsTable, $flightsTable; $this->filterArray = array(); foreach ($variablesArray as $key => $value) { if (substr($key, 0, 7) != "FILTER_") { continue; } if (substr($key, -3) == "_op") { continue; } // we take care of these in the _select counterparts of them if (preg_match("/YEAR/", $key) || preg_match("/day_text/", $key) || preg_match("/day_text/", $key)) { continue; } if ($key == "FILTER_PilotBirthdate_text") { if (!$value) { continue; } $op = 'FILTER_PilotBirthdate'; $opID = 0x22; $year1 = substr($variablesArray['FILTER_PilotBirthdate_text'], 6, 4); // 23.02.2008 $month1 = substr($variablesArray['FILTER_PilotBirthdate_text'], 3, 2); $day1 = substr($variablesArray['FILTER_PilotBirthdate_text'], 0, 2); $operand = $variablesArray['FILTER_PilotBirthdate_op']; $this->filterArray[] = array($opID, $op, $operand, $year1, $month1, $day1, 0, 0, 0); continue; } if ($key == "FILTER_dateType") { $opID = 0x20; $op = 'FILTER_DATE'; if ($value == "DATE_RANGE") { $year1 = substr($variablesArray['FILTER_from_day_text'], 6, 4); // 23.02.2008 $month1 = substr($variablesArray['FILTER_from_day_text'], 3, 2); $day1 = substr($variablesArray['FILTER_from_day_text'], 0, 2); $year2 = substr($variablesArray['FILTER_to_day_text'], 6, 4); $month2 = substr($variablesArray['FILTER_to_day_text'], 3, 2); $day2 = substr($variablesArray['FILTER_to_day_text'], 0, 2); $this->filterArray[] = array($opID, $op, 'between', $year1, $month1, $day1, $year2, $month2, $day2); } else { if ($value == "MONTH_YEAR") { $year1 = $variablesArray['FILTER_MONTH_YEAR_select_YEAR']; $month1 = $variablesArray['FILTER_MONTH_YEAR_select_MONTH']; $operand = $variablesArray['FILTER_MONTH_YEAR_select_op']; $this->filterArray[] = array($opID, $op, $operand, $year1, $month1, 0); } else { if ($value == "YEAR") { $year1 = $variablesArray['FILTER_YEAR_select']; $operand = $variablesArray['FILTER_YEAR_select_op']; $this->filterArray[] = array($opID, $op, $operand, $year1, 0, 0); } } } continue; } if (substr($key, -7) == "_select") { if (!$value) { continue; } $op = substr($key, 0, -7); $opID = array_search_value($op, $filterOps); $operand = $variablesArray[$op . '_op']; $this->filterArray[] = array($opID, $op, $operand, $value); continue; } if (substr($key, -5) == "_incl") { if (!$value) { continue; } $value = trim($value, ","); if (preg_match("/FILTER_nacclubs(\\d+)_incl/", $key, $matches)) { $key = "FILTER_nacclubs_incl"; $opID = array_search_value($key, $filterOps); $valueArray = explode(",", $value); $this->filterArray[] = array($opID, $key, $valueArray, $matches[1]); } else { $opID = array_search_value($key, $filterOps); $valueArray = explode(",", $value); $this->filterArray[] = array($opID, $key, $valueArray); } continue; } // if nothing else matches , is a simple var if (!$value) { continue; } $op = $key; $opID = array_search_value($op, $filterOps); // echo "Importing $opID,$op,$value <BR>"; $this->filterArray[] = array($opID, $op, $value); continue; } // foreach // echo "$filterArray<HR><PRE>"; print_r($this->filterArray); echo "</PRE>".$value; }
function check_data() { global $installed_languages; if (get_post('code') == '' || get_post('name') == '' || get_post('encoding') == '') { display_error(_("Language name, code nor encoding cannot be empty")); return false; } $id = array_search_value($_POST['code'], $installed_languages, 'code'); if ($id !== null && $installed_languages[$id]['package'] != null) { display_error(_('Standard package for this language is already installed. If you want to install this language manually, uninstall standard language package first.')); return false; } return true; }
/** Variable guide * $OPTAB['OPCODE'] represent the code in operation code table * $opcode represnt the code in $_OPTB_WOC['OPCODE'] fix for both format 3 and format 4 + */ private function doPassTwo() { $this->foundDefSym(); echo "doPassTwo();\n"; $errorFlag = false; ## initial errorFlag as false -> no error found $errorMsg = ""; ## store error message.... /********************************************************************* * Mnemonic |Number |Special use * * A | 0 |Accumulator; used for arithmetic operations* * X | 1 |Index register; used for addressing ( * L | 2 |Linkage regsiter; the Jump to Subroutine(JSUB) * instruction stores the return address in the register * B | 3 |Base register; used for addressing * S | 4 |General working register--no special use * T | 5 |General working register--no special use * F | 6 |Floating-point accumulator(48 bits) * PC | 8 |Program counter; contains the address of the * next instruction to be fetched for execution * SW | 9 |Status word; contains a variety of information, * including a Condition Code(CC) * *****************************************************************/ //$xReg = 0; // actualy this should do in passOne..// I don't use index. don't break my code plesae $bReg = 0; // Base register // $pcReg = 0; // invalid ...no use in here // find base register value first... if (($baseTA = array_search_value($this->OPTB_WOC, 'OPCODE', "BASE", 'OPERAND')) == !false && ($bReg = array_search_value($this->OPTB_WOC, "LABEL", $baseTA, "LOC")) == !false) { $this->bReg = $bReg; echo "BASE register value : " . $bReg . "\n"; // exit(); // end reading base address } else { $bReg = 'no_value'; $this->bReg = $bReg; // exit(); } // storage .. RESW and RESB are include in skip array $OPTB_SKIP = array(".", "*", "BASE", "END", "RESW", "RESB", "LTORG", "EXTDEF", "EXTREF"); ## skip line with these label.. $OPTB_WOC_afterPassTwo = array(); foreach ($this->OPTB_WOC as $_OPTB_WOC) { if (isset($_OPTB_WOC['OBJECTCODE']) && !empty($_OPTB_WOC['OBJECTCODE'])) { $_OPTB_WOC['OBJECTCODE'] = ''; } if ($_OPTB_WOC['LINE'] == 5 && $_OPTB_WOC['OPCODE'] == 'START') { array_push($OPTB_WOC_afterPassTwo, $_OPTB_WOC); // keep it.. no change continue; ## read next line } else { if ($_OPTB_WOC['OPCODE'] == 'EXTDEF') { $extdef = explode(",", $_OPTB_WOC['OPERAND']); array_push($this->EXTDEF, $extdef); array_push($OPTB_WOC_afterPassTwo, $_OPTB_WOC); continue; // read next line } else { if ($_OPTB_WOC['OPCODE'] == 'EXTREF') { $extref = explode(",", $_OPTB_WOC['OPERAND']); array_push($OPTB_WOC_afterPassTwo, $_OPTB_WOC); array_push($this->EXTREF, $extref); continue; // read next line } else { if (empty($_OPTB_WOC['LINE']) && empty($_OPTB_WOC['LOC']) && empty($_OPTB_WOC['LABEL']) && empty($_OPTB_WOC['OPCODE']) && empty($_OPTB_WOC['OPERAND']) && empty($_OPTB_WOC['OBJECTCODE'])) { array_push($OPTB_WOC_afterPassTwo, $_OPTB_WOC); continue; // read next line } else { if (array_search_value($this->OPTAB_, 'OPCODE', $_OPTB_WOC['OPCODE'], 'FORMAT') == '1') { $_OPTB_WOC['FORMAT'] = '1'; $_OPTB_WOC['OBJECTCODE'] = array_search_value($this->OPTAB_, 'OPCODE', $_OPTB_WOC['OPCODE'], 'OPCODEVAL'); $errorMsg .= "Line at " . $_OPTB_WOC['LINE'] . " : symbol " . $_OPTB_WOC['OPERAND'] . " is undefined symbol\n"; $this->errorLogPassTwo .= $errorMsg; $errorFlag = true; array_push($OPTB_WOC_afterPassTwo, $_OPTB_WOC); continue; // read next line } else { if (array_search_value($this->OPTAB_, 'OPCODE', $_OPTB_WOC['OPCODE'], 'FORMAT') == '2') { $_OPTB_WOC['FORMAT'] = '2'; $_OPTB_WOC['OBJECTCODE'] = array_search_value($this->OPTAB_, 'OPCODE', $_OPTB_WOC['OPCODE'], 'OPCODEVAL'); $errorMsg .= "Line at " . $_OPTB_WOC['LINE'] . " : symbol " . $_OPTB_WOC['OPERAND'] . " is undefined symbol\n"; $this->errorLogPassTwo .= $errorMsg; $errorFlag = true; $_OPTB_WOC['OBJECTCODE'] = $this->formatTwoCode($_OPTB_WOC['OBJECTCODE'], $_OPTB_WOC['OPERAND']); array_push($OPTB_WOC_afterPassTwo, $_OPTB_WOC); continue; // read next line } else { if ($_OPTB_WOC['LABEL'] == '*' || empty($_OPTB_WOC['LINE'])) { $_OPTB_WOC['OBJECTCODE'] = $this->formatOPCODEVAL_STORAGE_BYTE(substr($_OPTB_WOC['OPCODE'], 1)); array_push($OPTB_WOC_afterPassTwo, $_OPTB_WOC); continue; // read next line } else { if ($_OPTB_WOC['LABEL'] == '*' && !empty($_OTB_WOC['LINE'])) { continue; } } } } } } } } //if($_OPTB_WOC['OPCODE'] != 'END') { //else if(true){ // getting base register value if (in_array($_OPTB_WOC['OPCODE'], $OPTB_SKIP)) { array_push($OPTB_WOC_afterPassTwo, $_OPTB_WOC); continue; // read next line } else { if ($_OPTB_WOC['OPCODE'] == 'BYTE') { ## C'EOF' = 454F46 | X'F1" = F1 ... need a special function for this.. $_OPTB_WOC['OBJECTCODE'] = $this->formatOPCODEVAL_STORAGE_BYTE($_OPTB_WOC['OPERAND']); ## store 0 as operand address array_push($OPTB_WOC_afterPassTwo, $_OPTB_WOC); continue; // read next line } else { if ($_OPTB_WOC['OPCODE'] == 'WORD') { $_OPTB_WOC['OBJECTCODE'] = $this->formatOPCODEVAL_STORAGE(base_convert($_OPTB_WOC['OPERAND'], 10, 16)); ## store 0 as operand address array_push($OPTB_WOC_afterPassTwo, $_OPTB_WOC); continue; // read next line } else { // flag bit $_OPTB_WOC['N'] = $_OPTB_WOC['I'] = $_OPTB_WOC['X'] = $_OPTB_WOC['P'] = $_OPTB_WOC['B'] = $_OPTB_WOC['E'] = 0; if (substr($_OPTB_WOC['OPCODE'], 0, 1) == '+') { $_OPTB_WOC['FORMAT'] = '4'; $opcode = substr($_OPTB_WOC['OPCODE'], 1); $_OPTB_WOC['B'] = 0; $_OPTB_WOC['P'] = 0; $_OPTB_WOC['E'] = 1; } else { $_OPTB_WOC['FORMAT'] = '3'; $opcode = $_OPTB_WOC['OPCODE']; $_OPTB_WOC['E'] = 0; } // @c or @m Indirect addressing type if (substr($_OPTB_WOC['OPERAND'], 0, 1) == '@') { $_OPTB_WOC['N'] = 1; $_OPTB_WOC['I'] = 0; } // #c or #m Immediate addressing type if (substr($_OPTB_WOC['OPERAND'], 0, 1) == '#') { $_OPTB_WOC['N'] = 0; $_OPTB_WOC['I'] = 1; } else { if ($_OPTB_WOC['N'] == 0 && $_OPTB_WOC['I'] == 0) { $_OPTB_WOC['N'] = $_OPTB_WOC['I'] = 1; } } // c.X j,X use index register if (strpos($_OPTB_WOC['OPERAND'], ",")) { $_OPTB_WOC['X'] = 1; } else { $_OPTB_WOC['X'] = 0; } // to gain readability $fN = $_OPTB_WOC['N']; $fI = $_OPTB_WOC['I']; $fX = $_OPTB_WOC['X']; $fB = $_OPTB_WOC['B']; $fP = $_OPTB_WOC['P']; $fE = $_OPTB_WOC['E']; $addr = false; ## serach OPTAB for OPCODE // found that opcode in operation code table // if found if (($OPTAB['OPCODEVAL'] = array_search_value($this->OPTAB_, 'OPCODE', $opcode, 'OPCODEVAL')) == !false) { // do someting if (empty($_OPTB_WOC['OPERAND'])) { //fix unknown bug= = $targetLOC = 0; } else { if ($_OPTB_WOC['X'] == 1) { $OPERAND = explode(",", $_OPTB_WOC['OPERAND']); $addTa = $OPERAND[0]; // addressing target.. // need replace by find_LOC //$targetLOC = array_search_value($this->SYMTAB, "LABEL", $addTa, "LOC"); $targetLOC = $this->find_LOC($_OPTB_WOC, $addTa); } else { if ($_OPTB_WOC['N'] == 1 && $_OPTB_WOC['I'] == 1) { $addTa = $_OPTB_WOC['OPERAND']; // need replace by find_LOC //$targetLOC = array_search_value($this->SYMTAB, "LABEL", $addTa, "LOC"); $targetLOC = $this->find_LOC($_OPTB_WOC); // echo "errorrrr : \n"; print("Line : " . $_OPTB_WOC['LINE'] . "\n"); // debug finished=.= } else { if ($_OPTB_WOC['N'] == 1 && $_OPTB_WOC['I'] == 0) { $addTa = substr($_OPTB_WOC['OPERAND'], 1); // need replace by find_LOC //$targetLOC = array_search_value($this->SYMTAB, "LABEL", $addTa, "LOC"); $targetLOC = $this->find_LOC($_OPTB_WOC, $addTa); } else { if ($_OPTB_WOC['N'] == 0 && $_OPTB_WOC['I'] == 1) { $addTa = substr($_OPTB_WOC['OPERAND'], 1); if (is_numeric($addTa)) { $targetLOC = base_convert($addTa, 10, 16); // copy the value as loc $addr = true; } else { $addTa = substr($_OPTB_WOC['OPERAND'], 1); // need replace by find_LOC //$targetLOC = array_search_value($this->SYMTAB, "LABEL", $addTa, "LOC"); $targetLOC = $this->find_LOC($_OPTB_WOC, $addTa); } } } } } } if (substr($_OPTB_WOC['OPERAND'], 0, 1) == '=') { $targetLOC = array_search_value($this->OPTB_WOC, 'OPCODE', $_OPTB_WOC['OPERAND'], 'LOC'); } if ($addr == false) { if ($fE == 0) { if ($this->chkAddMode($_OPTB_WOC, $targetLOC, $fE) == "B") { $add = $this->chkAddMode($_OPTB_WOC, $targetLOC, $fE, true); $_OPTB_WOC['B'] = 1; $_OPTB_WOC['P'] = 0; } else { if ($this->chkAddMode($_OPTB_WOC, $targetLOC, $fE) == "PC") { $add = $this->chkAddMode($_OPTB_WOC, $targetLOC, $fE, true); $_OPTB_WOC['B'] = 0; $_OPTB_WOC['P'] = 1; } } } else { if ($fE == 1 && $this->chkAddMode($_OPTB_WOC, $targetLOC, $fE) == "EX") { // I just forget .... final add this part at 12/28/2015 night = = .. if ($_OPTB_WOC['X'] == 1) { $OPERAND = explode(",", $_OPTB_WOC['OPERAND']); $addTa = $OPERAND[0]; // addressing target.. // need replace by find_LOC //$targetLOC = array_search_value($this->SYMTAB, "LABEL", $addTa, "LOC"); $targetLOC = $this->find_LOC($this->SYMTAB, substr($_OPTB_WOC['OPERAND'], 1)); } else { if ($_OPTB_WOC['OPERAND'][0] == '#' || $_OPTB_WOC['OPERAND'][0] == '@') { // need replace by find_LOC //$targetLOC = array_search_value($this->SYMTAB, "LABEL", substr($_OPTB_WOC['OPERAND'],1), "LOC"); $targetLOC = $this->find_LOC($_OPTB_WOC, substr($_OPTB_WOC['OPERAND'], 1)); } else { // need replace by find_LOC //$targetLOC = array_search_value($this->SYMTAB, "LABEL", $_OPTB_WOC['OPERAND'], "LOC"); $targetLOC = $this->find_LOC($_OPTB_WOC); } } //echo "targetLoc : " . $targetLOC; $add = $this->chkAddMode($_OPTB_WOC, $targetLOC, $fE, true); $_OPTB_WOC['B'] = $_OPTB_WOC['P'] = 0; } else { echo "Error : chkdAddMode error found..\n"; } } $_OPTB_WOC['ADD'] = $add; } // end addr $fB = $_OPTB_WOC['B']; $fP = $_OPTB_WOC['P']; $_OPTB_WOC['TA'] = $targetLOC; $_OPTB_WOC['OPCODEVAL'] = $OPTAB['OPCODEVAL']; if ($this->computerType == 'SIC') { $add = $targetLOC; } if ($addr == true || !isset($addr)) { $_OPTB_WOC['addr'] = "true"; } else { $_OTB_WOC['addr'] = "false"; } if (empty($_OPTB_WOC['OPERAND']) == false) { if ($addr == !false) { $_OPTB_WOC['OBJECTCODE'] = $this->addModeVal($OPTAB['OPCODEVAL'], $targetLOC, $fN, $fI, $fX, $fB, $fP, $fE); } else { $_OPTB_WOC['OBJECTCODE'] = $this->addModeVal($OPTAB['OPCODEVAL'], $add, $fN, $fI, $fX, $fB, $fP, $fE); } } else { if ($this->computerType == 'SIC') { $_OPTB_WOC['OBJECTCODE'] = sprintf("%02.X", hexdec($OPTAB['OPCODEVAL'])) . "0000"; } else { if ($this->computerType == 'SIC/XE') { $_OPTB_WOC['OBJECTCODE'] = sprintf("%02.X", hexdec($OPTAB['OPCODEVAL']) + 3) . "0000"; } } } } else { // tell no found... } } } } // else end array_push($OPTB_WOC_afterPassTwo, $_OPTB_WOC); //} // end true // $_OPTB_WOC['OPCODE'] == 'END' //else { // break; // break the foreach //} } // foreach end // fix unkonwn bug= =... haha this so useful to delete duplicate literals= =... $OPTB_WOC_afterPassTwoFix = array(); $previous_label = 'no_value'; $previous_line = 'no_value'; $previous_loc = 'no_value'; $previous_operand = 'no_value'; $pervious_opcode = 'no_value'; foreach ($OPTB_WOC_afterPassTwo as $fixOPTB) { if ($fixOPTB['LINE'] == $previous_line && $fixOPTB['LOC'] == $previous_loc && $fixOPTB['OPCODE'] == $pervious_opcode && $fixOPTB['OPERAND'] == $previous_operand) { continue; } else { if ($fixOPTB['LABEL'] == $previous_label && $fixOPTB['LABEL'] == '*' && $fixOPTB['OPCODE'] == $pervious_opcode) { continue; } else { $previous_label = $fixOPTB['LABEL']; $previous_line = $fixOPTB['LINE']; $previous_loc = $fixOPTB['LOC']; $pervious_opcode = $fixOPTB['OPCODE']; $previous_operand = $fixOPTB['OPERAND']; array_push($OPTB_WOC_afterPassTwoFix, $fixOPTB); } } } $this->OPTB_WOC_afterPassTwo = $OPTB_WOC_afterPassTwoFix; $this->OPTB_WOC = $OPTB_WOC_afterPassTwoFix; //$this->OPTB_WOC = $OPTB_WOC_afterPassTwo; //print_r($this->OPTB_WOC); print_r($this->EXTDEF); print_r($this->EXTREF); return $this->doPassThree(); //return $this->OPTB_WOC; }
function coa_list_row($label, $name, $value = null) { global $path_to_root, $installed_extensions; $path = $path_to_root . '/sql/'; $coas = array(); $sqldir = opendir($path); while (false !== ($fname = readdir($sqldir))) { if (is_file($path . $fname) && substr($fname, -4) == '.sql' && @($fname[2] == '_')) { $ext = array_search_value($fname, $installed_extensions, 'sql'); if ($ext != null) { $descr = $ext['name']; } elseif ($fname == 'en_US-new.sql') { // two standard COAs $descr = _("Standard new company American COA (4 digit)"); } elseif ($fname == 'en_US-demo.sql') { $descr = _("Standard American COA (4 digit) with demo data"); } else { $descr = $fname; } $coas[$fname] = $descr; } } ksort($coas); View::get()->layoutHintRow(); $controlAsString = array_selector($name, $value, $coas); View::get()->addControl(View::controlFromRenderedString(View::CONTROL_ARRAY, $label, $controlAsString)); }