public function getFilteredEntries($lastNames) { $entries = Entry::with('restorationType')->with('folders')->whereIn('last_name', $lastNames)->get(); //Transform $resource = createCollection($entries, new EntryTransformer()); return transform($resource)['data']; }
/** * Change to a static constructor or not, up to you * @param null $budgets */ public function __construct($budgets = NULL) { $this->type = Budget::TYPE_FIXED; $this->budgets = $budgets ?: Budget::forCurrentUser()->whereType(Budget::TYPE_FIXED)->get(); $this->amount = $this->calculate('amount'); $this->remaining = $this->calculate('remaining'); $this->cumulative = $this->calculate('cumulative'); $this->spentBeforeStartingDate = $this->calculate('spentBeforeStartingDate'); $this->spentOnOrAfterStartingDate = $this->calculate('spentOnOrAfterStartingDate'); $this->receivedOnOrAfterStartingDate = $this->calculate('receivedOnOrAfterStartingDate'); //Transform budgets $resource = createCollection($this->budgets, new BudgetTransformer()); $this->budgets = transform($resource); }
function gb2312_to_latin($string) { $output = ""; for ($i = 0; $i < strlen($string); $i++) { $letter = ord(substr($string, $i, 1)); if ($letter > 160) { $tmp = ord(substr($string, ++$i, 1)); $letter = $letter * 256 + $tmp - 65536; // echo "%$letter%"; } $output .= transform($letter); } return $output; }
function reverse_recurse($string, $step = 0) { global $reverse, $min; if ($string == 'e') { if ($step < $min) { $min = $step; print "min: {$min}\n"; } } else { foreach (transform($reverse, $string) as $reversed) { reverse_recurse($reversed, $step + 1); } } }
/** * Insert an exercise entry. * It can be an exercise set. * @param Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { $exercise = Exercise::find($request->get('exercise_id')); if ($request->get('exerciseSet')) { // We are inserting an exercise set $quantity = $exercise->default_quantity; $unit = Unit::find($exercise->default_unit_id); } else { $quantity = $request->get('quantity'); $unit = Unit::find($request->get('unit_id')); } $entry = new Entry(['date' => $request->get('date'), 'quantity' => $quantity]); $entry->user()->associate(Auth::user()); $entry->exercise()->associate($exercise); $entry->unit()->associate($unit); $entry->save(); //Return the entries for the day $entries = transform(createCollection($this->exerciseEntriesRepository->getEntriesForTheDay($request->get('date')), new ExerciseEntryTransformer()))['data']; return response($entries, Response::HTTP_CREATED); }
/** * Return response created code with transformed resource * @param $resource * @return mixed */ public function responseCreatedWithTransformer($resource, $transformer) { //Transform $resource = createItem($resource, $transformer); return response(transform($resource), Response::HTTP_CREATED); /** * @VP: * Why do all this stuff when I could just do this: * return response(transform($resource), Response::HTTP_CREATED); */ // $manager = new Manager(); // $manager->setSerializer(new DataArraySerializer); // // $manager->parseIncludes(request()->get('includes', [])); // // return response()->json( // $manager->createData($resource)->toArray(), // Response::HTTP_CREATED // ); }
/** * Main functions. Just decides what mode we are in and calls the * appropriate methods. */ function main() { global $info, $config; $args = Console_Getopt::readPHPArgv(); if (count($args) < 2) { print_usage_info(); } if (substr($args[1], 0, 1) == "-" || substr($args[1], 0, 1) == "/") { print "invalid parameter " . $args[2] . "\n"; print_usage_info(); } if (substr($args[1], -4) == ".php") { // mode 2: create zombie app if (!file_exists($args[1])) { die("config file " . $args[1] . " does not exist\n"); } read_config_file($args[1]); $outdir = ZOMBIE_BASE . '/../' . Horde_String::lower($config['app']); if (is_dir($outdir) && $args[2] != "-f") { print "Directory {$outdir} already exists.\nUse -f flag to force overwrite\n"; exit; } $n = $config['app']; print "Creating Horde Application {$n} in directory " . Horde_String::lower($n) . "\n"; transform($outdir); print "\nHorde Application '{$n}' successfully written. Where to go from here:\n" . "1) Paste content of {$n}/registry.stub to horde/config/registry.php.\n" . " After that, the {$n} should be working!\n" . "2) Replace {$n}.gif with proper application icon\n" . "3) Ensure conf.php is not world-readable as it may contain password data.\n" . "4) Start playing around and enhancing your new horde application. Enjoy!\n"; } else { // mode 1: create config file parse_options($args); print "creating config file for table " . $config['table'] . "\n"; create_table_info(); enhance_info(); print "writing config file to " . $config['file'] . "\n"; dump_config_file(); } }
function runit($title, $tx, $ty) { $text = explode("\n", read_from_url($title)); $ret = array(); foreach ($text as $t) { if (trim(strtolower(substr($t, 0, 6))) == ";data:") { $r = array(); $t = explode(";", substr($t, 6)); foreach ($t as $s) { $set = array(); $s = explode(" ", trim($s)); foreach ($s as $part) { $part = explode(",", $part); $set[] = transform($part, $tx, $ty); } $r[] = implode(" ", $set); } $ret[] = ";data:" . implode(";", $r); } else { $ret[] = $t; } } return $ret; }
/** * Get recipe contents and steps. * Contents should include the foods that belong to the recipe, * along with the description, quantity, and unit * for the food when used in the recipe (from food_recipe table), * and with the tags for the recipe. * Redoing after refactor. Still need description, quantity, unit. * @param $recipe * @return array */ public function getRecipeInfo($recipe) { $recipe = transform(createItem($recipe, new RecipeWithIngredientsTransformer()))['data']; //For some reason the units for each food aren't being added to the food //from my IngredientTransformer, so add them here foreach ($recipe['ingredients']['data'] as $index => $ingredient) { $units = Food::find($ingredient['food']['data']['id'])->units; $units = transform(createCollection($units, new UnitTransformer())); $recipe['ingredients']['data'][$index]['food']['data']['units'] = $units; } return $recipe; }
<?php function transform($num) { if ($num % 3 == 0 and $num % 5 == 0) { $num = "MaxGood"; } else { if ($num % 3 == 0) { $num = "Max"; } else { if ($num % 5 == 0) { $num = "Good"; } } } return $num; } for ($i = 1; $i <= 100; $i++) { echo transform($i) . ', '; }
/** * Get all exercises for the current user, * along with their tags, default unit name * and the name of the series each exercise belongs to. * Order first by series name, then by step number. * @return mixed */ public function getExercises() { $exercises = Exercise::forCurrentUser('exercises')->with('defaultUnit')->orderBy('step_number')->with('series')->with('tags')->get(); return transform(createCollection($exercises, new ExerciseTransformer()))['data']; }
return 4; case 'five': return 5; case 'six': return 6; case 'seven': return 7; case 'eight': return 8; case 'nine': return 9; case 'zero': return 0; } } $fh = fopen($argv[1], "r"); while (!feof($fh)) { $numbers = fgets($fh); $numbers = trim($numbers); $numbers_array = explode(';', $numbers); if (count($numbers_array) > 20) { echo "Only 20 numbers are allowed per line"; } else { foreach ($numbers_array as $number) { $number = strtolower($number); $digit = transform($number); echo $digit; } } echo "\n"; }
} //comprobamos la gente a la que se le ha pasado la fecha de inscripcion $resultado = ejecutaConsulta("select fechaadmision,correo from usuario where estado=1"); $filas = pg_numrows($resultado); if ($filas != 0) { $i = 0; for ($cont = 0; $cont < $filas; $cont++) { $correo = pg_result($resultado, $cont, 'correo'); $fechaadmision = pg_result($resultado, $cont, 'fechaadmision'); $date = date("Y-m-d G:i:s"); $admitido = transform($fechaadmision); $hoy = transform($date); $dias = ($hoy - $admitido) / 86400; if ($dias > 3) { $elementosBorrar[$i] = $correo; $i = $i + 1; } } $numelem = count($elementosBorrar); for ($j = 0; $j < $numelem; $j++) { $correo = $elementosBorrar[$j]; $resultado = ejecutaConsulta("Delete from usuario where correo='{$correo}';"); } } $hoy = date("Y-m-d G:i:s"); $ayer = transform(date("Y-m-d G:i:s")); $ayer = $ayer - 86400; $ayer = date("Y-m-d G:i:s", $ayer); $resultado = ejecutaConsulta("Select count(*) from usuario where fechabaja BETWEEN '{$ayer}' and '{$hoy}' and estado=4;"); $contador = pg_result($resultado, 0, 0); mandarCorreoContadorBaja($contador, $ayer, $hoy);
exit; } $status = ''; if (isset($_FILES['templateFile']) && $_FILES['templateFile']['error'] == 0 && ($_FILES['templateFile']['type'] = 'text/xml')) { $result = $template->ImportTemplate($_FILES['templateFile']['tmp_name']); $status = $result["status"] == "" ? __("Template File Imported") : $result["status"] . '<a id="import_err" style="margin-left: 1em;" title="' . __("View errors") . '" href="#"><img src="images/info.png"></a>'; } if (isset($_REQUEST['TemplateID']) && $_REQUEST['TemplateID'] > 0) { //get template $template->TemplateID = $_REQUEST['TemplateID']; $template->GetTemplateByID(); $deviceList = Device::GetDevicesByTemplate($template->TemplateID); } if (isset($_POST['action'])) { $template->ManufacturerID = $_POST['ManufacturerID']; $template->Model = transform($_POST['Model']); $template->Height = $_POST['Height']; $template->Weight = $_POST['Weight']; $template->Wattage = isset($_POST['Wattage']) ? $_POST['Wattage'] : 0; $template->DeviceType = $_POST['DeviceType']; $template->PSCount = $_POST['PSCount']; $template->NumPorts = $_POST['NumPorts']; $template->ShareToRepo = isset($_POST['ShareToRepo']) ? 1 : 0; $template->KeepLocal = isset($_POST['KeepLocal']) ? 1 : 0; $template->Notes = trim($_POST['Notes']); $template->Notes = $template->Notes == "<br>" ? "" : $template->Notes; $template->FrontPictureFile = $_POST['FrontPictureFile']; $template->RearPictureFile = $_POST['RearPictureFile']; $template->ChassisSlots = $template->DeviceType == "Chassis" ? $_POST['ChassisSlots'] : 0; $template->RearChassisSlots = $template->DeviceType == "Chassis" ? $_POST['RearChassisSlots'] : 0; $template->SNMPVersion = $_POST['SNMPVersion'];
/** * Get all foods, along with their default unit, default calories, * and all their units. * Also, add the calories for each food's units. Todo? * @return mixed */ public function getFoods() { $foods = Food::forCurrentUser()->with('defaultUnit')->orderBy('foods.name', 'asc')->get(); $foods = transform(createCollection($foods, new FoodTransformer())); return $foods['data']; }
* and/or modify it under the terms of the Do What the F**k You Want * to Public License, Version 2, as published by Sam Hocevar. See * http://www.wtfpl.net/ for more details. */ function transform($tbl, $tx, $ty, $sx, $sy) { $result = array(); foreach ($tbl as $pt) { $result[] = array($pt[0] * $sx + $tx, $pt[1] * $sy + $ty); } return $result; } if (php_sapi_name() != "cli") { die("You have to run this program with php-cli!\n"); } $canvas = caca_create_canvas(0, 0); $display = caca_create_display($canvas); if (!$display) { die("Error while attaching canvas to display\n"); } $tbl = array(array(5, 2), array(15, 2), array(20, 4), array(25, 2), array(34, 2), array(37, 4), array(36, 9), array(20, 16), array(3, 9), array(2, 4), array(5, 2)); for ($i = 0; $i < 10; $i++) { caca_set_color_ansi($canvas, 1 + ($color += 4) % 15, CACA_TRANSPARENT); $scale = caca_rand(4, 10) / 10; $translate = array(caca_rand(-5, 55), caca_rand(-2, 25)); $pts = transform($tbl, $translate[0], $translate[1], $scale, $scale); caca_draw_thin_polyline($canvas, $pts); } caca_put_str($canvas, 1, 1, "Caca forever..."); caca_refresh_display($display); caca_get_event($display, CACA_EVENT_KEY_PRESS, 5000000);
/** * Respond with data * Data parameter: Eloquent/Model, Eloquent/Collection, LengthAwarePaginator, Array, Assoc Array, StndObj * TransformerClass parameter can be: * STRING: transformer class in app/transformers * ARRAY: for field filtering in the form of: * ['only'=>'field1, field2, field3] OR ['except'=>'field1, field2, field3] * @param $data * @param null $transformerClass * @param null $key * @return $this */ public function withData($data, $transform = null, $key = null) { $transformerObj = transform($data); if (isset($transform) && is_array($transform)) { foreach ($transform as $k => $v) { $transformerObj = $transformerObj->{$k}($v); } } $data = $transformerObj->get(); if (isset($data['data'])) { $meta = array_except($data, 'data'); $data = $data['data']; } if (isset($key)) { $this->data[$key] = $data; if (isset($meta)) { $this->meta[$key] = $meta; } } else { $this->data = $data; if (isset($meta)) { $this->meta = $meta; } } // if( isset($data['data']) ) // { // $this->data = $data['data']; // $this->meta = $data['meta']; // } else // $this->data = $data; return $this; }
/** * Fix elements that should accumulate/increment values. */ public function fixRepeatingArguments() { $either = array(); foreach (transform($this)->children as $child) { $either[] = $child->children; } foreach ($either as $case) { $counts = array(); foreach ($case as $child) { $ser = serialize($child); if (!isset($counts[$ser])) { $counts[$ser] = array('cnt' => 0, 'items' => array()); } $counts[$ser]['cnt']++; $counts[$ser]['items'][] = $child; } $repeatedCases = array(); foreach ($counts as $child) { if ($child['cnt'] > 1) { $repeatedCases = array_merge($repeatedCases, $child['items']); } } foreach ($repeatedCases as $e) { if ($e instanceof Argument || $e instanceof Option && $e->argcount) { if (!$e->value) { $e->value = array(); } elseif (!is_array($e->value) && !$e->value instanceof \Traversable) { $e->value = preg_split('/\\s+/', $e->value); } } if ($e instanceof Command || $e instanceof Option && $e->argcount == 0) { $e->value = 0; } } } return $this; }
public function doSql($strSql, $fetchType = Bd_DB::FETCH_ASSOC, $bolUseResult = false) { // check the env before do sql query; //is in transaction is set outer; if ($this->_bolIsInTransaction) { if ($this->_intUseConnectionNum > 1) { return false; } $this->_intAffectedRows = 0; $this->_arrQueryError = array(); $this->_bolIsSqlTransformError = false; } else { //clear the last query; $this->reset(); } $this->_timer->start(); $arrSql = transform($this->_strDBName, $strSql, $this->_strConfPath, $this->_strConfFilename); $this->_transTime += $this->_timer->stop(); if (NULL === $arrSql || $arrSql['err_no'] !== 0) { $this->_bolIsSqlTransformError = true; Bd_Db_RALLog::warning(RAL_LOG_SUM_FAIL, "SplitDB", $this->_strDBName, 'transform', '', $this->_timer->getTotalTime(Bd_Timer::PRECISION_MS), 0, 0, 0, $this->_transTime, '', $strSql, self::$TRANSFORM_ERRNO, self::$TRANSFORM_ERROR); return false; } //some check before conneciton; if (BD_DB_SplitDB::SPLITDB_SQL_SELECT === $arrSql['sql_type'] && $bolUseResult === true) { Bd_Db_RALLog::warning(RAL_LOG_SUM_FAIL, "SplitDB", $this->_strDBName, 'check', '', $this->_timer->getTotalTime(Bd_Timer::PRECISION_MS), 0, 0, 0, 0, '', $strSql, self::$COMMON_ERRNO, "select should be store result"); return false; } $arrSplitIndex = $this->analyseSqlTransResult($arrSql, BD_DB_SplitDB::MAX_SQL_SPLIT_COUNT); if (!$arrSplitIndex || count($arrSplitIndex) <= 0) { Bd_Db_RALLog::warning(RAL_LOG_SUM_FAIL, "SplitDB", $this->_strDBName, 'check', '', $this->_timer->getTotalTime(Bd_Timer::PRECISION_MS), 0, 0, 0, 0, '', $strSql, self::$COMMON_ERRNO, "splitindex count error"); return false; } //open the connection; if ($this->_bolIsInTransaction) { // in transaction, only 1 split is ok; if (count($arrSplitIndex) !== 1) { Bd_Db_RALLog::warning(RAL_LOG_SUM_FAIL, "SplitDB", $this->_strDBName, 'check', '', $this->_timer->getTotalTime(Bd_Timer::PRECISION_MS), 0, 0, 0, 0, '', $strSql, self::$COMMON_ERRNO, "in transaction split count should be 1"); return false; } //in transaction , the new sql split index should be the same as the last one; if ($this->_intUseConnectionNum === 1) { if ($arrSplitIndex[0] !== $this->_intLastDBNum) { Bd_Db_RALLog::warning(RAL_LOG_SUM_FAIL, "SplitDB", $this->_strDBName, 'check', '', $this->_timer->getTotalTime(Bd_Timer::PRECISION_MS), 0, 0, 0, 0, '', $strSql, self::$COMMON_ERRNO, "in transaction connect should be the same"); return false; } } else { if ($arrSplitIndex[0] === -1) { $strDBInstanceName = $this->_strDBName; } else { $strDBInstanceName = $this->_strDBName . $arrSplitIndex[0]; } if (is_null($this->_arrMysql[$strDBInstanceName])) { $ret = $this->connect($strDBInstanceName); if (!$ret) { $this->_arrQueryError[$strDBInstanceName] = ''; return false; } } else { //echo "connection exist!\n"; } $this->_arrMysql[$strDBInstanceName]->query('START TRANSACTION'); $this->_intLastDBNum = $arrSql['sqls'][0]['splitdb_index']; $this->_intUseConnectionNum = 1; } } else { foreach ($arrSplitIndex as $intSplitIndex) { if ($intSplitIndex === -1) { $strDBInstanceName = $this->_strDBName; } else { $strDBInstanceName = $this->_strDBName . $intSplitIndex; } if (is_null($this->_arrMysql[$strDBInstanceName])) { $ret = $this->connect($strDBInstanceName); if (!$ret) { $this->_arrQueryError[$strDBInstanceName] = ''; break; } } else { //echo "connection exist!\n"; } $this->_intUseConnectionNum++; } if ($this->_intUseConnectionNum !== count($arrSplitIndex)) { $this->_intUseConnectionNum = 0; return false; } if ($this->_intUseConnectionNum === 1) { $this->_intLastDBNum = $arrSplitIndex[0]; } } //build result switch ($fetchType) { case Bd_DB::FETCH_OBJ: $ret = new Bd_Db_SplitDBResult(); break; case Bd_DB::FETCH_ASSOC: $ret = array(); break; case Bd_DB::FETCH_ROW: $ret = array(); break; default: Bd_Db_RALLog::warning(RAL_LOG_SUM_FAIL, "SplitDB", $this->_strDBName, 'check', '', $this->_timer->getTotalTime(Bd_Timer::PRECISION_MS), 0, 0, 0, 0, '', $strSql, self::$COMMON_ERRNO, "fetch type error"); return false; } // execute hooks before query foreach ($this->hkBeforeQ as $arrCallback) { $func = $arrCallback[0]; $extArgs = $arrCallback[1]; if (call_user_func_array($func, array($this, &$sql, $extArgs)) === false) { Bd_Db_RALLog::warning(RAL_LOG_SUM_FAIL, "SplitDB", $this->_strDBName, 'query', '', $this->_timer->getTotalTime(Bd_Timer::PRECISION_MS), 0, 0, 0, 0, '', $strSql, self::$COMMON_ERRNO, "execute hooks before query fail"); return false; } } //do sql query //at least one success $bolAtLeastOneSuccess = false; foreach ($arrSql['sqls'] as $oneSql) { if ($oneSql['splitdb_index'] === -1) { $strDBInstanceName = $this->_strDBName; } else { $strDBInstanceName = $this->_strDBName . $oneSql['splitdb_index']; } $this->_timer->start(); $res = $this->_arrMysql[$strDBInstanceName]->query($oneSql['sql'], $bolUseResult ? MYSQLI_USE_RESULT : MYSQLI_STORE_RESULT); $time = $this->_timer->stop(); $this->_queryTime += $time; if (is_bool($res) || $res === NULL) { $ok = $res == true; // call fail handler if (!$ok) { //echo "query fail {$oneSql['sql']}\n"; if ($arrSql['sql_type'] === BD_DB_SplitDB::SPLITDB_SQL_SELECT) { if (is_null($this->_arrQueryError[$strDBInstanceName])) { $this->_arrQueryError[$strDBInstanceName] = $oneSql['sql']; } continue; } else { if (($arrSql['sql_type'] === BD_DB_SplitDB::SPLITDB_SQL_UPDATE || $arrSql['sql_type'] === BD_DB_SplitDB::SPLITDB_SQL_DELETE) && $this->_arrMysql[$strDBInstanceName]->errno === BD_DB_SplitDB::MYSQL_ERR_TABLE_NOT_EXIST && $arrSql['table_split_type'] === BD_DB_SplitDB::SPLITDB_SPLIT_TYPE_RANGE) { //echo "delete or update fail!\n"; continue; } else { if (is_null($this->_arrQueryError[$strDBInstanceName])) { $this->_arrQueryError[$strDBInstanceName] = $oneSql['sql']; } Bd_Db_RALLog::warning(RAL_LOG_SUM_FAIL, "SplitDB", $this->_strDBName, 'query', '', $this->_timer->getTotalTime(Bd_Timer::PRECISION_MS), 0, round($time / 1000), 0, 0, $strDBInstanceName, $oneSql['sql'], self::$QUERY_ERRNO, self::$QUERY_ERROR); if ($this->onfail !== NULL) { call_user_func_array($this->onfail, array($this, &$ok)); } return false; } } } else { //commit query success if ($this->_arrMysql[$strDBInstanceName]->affected_rows >= 0) { $this->_intAffectedRows += $this->_arrMysql[$strDBInstanceName]->affected_rows; } } } else { //mysqli_result object returned if ($arrSql['sql_type'] === BD_DB_SplitDB::SPLITDB_SQL_SELECT) { //add to result switch ($fetchType) { case Bd_DB::FETCH_OBJ: $ret->addresult($res); break; case Bd_DB::FETCH_ASSOC: while ($row = $res->fetch_assoc()) { $ret[] = $row; } $res->free(); break; case Bd_DB::FETCH_ROW: while ($row = $res->fetch_row()) { $ret[] = $row; } $res->free(); break; default: return false; } //echo "query success ".$oneSql['sql']."\n"; $bolAtLeastOneSuccess = true; $this->_intAffectedRows = count($ret); } } } if ($arrSql['sql_type'] === BD_DB_SplitDB::SPLITDB_SQL_SELECT && !$bolAtLeastOneSuccess) { Bd_Db_RALLog::warning(RAL_LOG_SUM_FAIL, "SplitDB", $this->_strDBName, 'query', '', $this->_timer->getTotalTime(Bd_Timer::PRECISION_MS), 0, round($this->_queryTime / 1000), 0, 0, '', $strSql, self::$QUERY_ERRNO, self::$QUERY_ERROR); if ($this->onfail !== NULL) { call_user_func_array($this->onfail, array($this, &$ret)); } return false; } // execute hooks after query foreach ($this->hkAfterQ as $arrCallback) { $func = $arrCallback[0]; $extArgs = $arrCallback[1]; call_user_func_array($func, array($this, &$ret, $extArgs)); } if ($arrSql['sql_type'] !== BD_DB_SplitDB::SPLITDB_SQL_SELECT) { $ret = true; } return $ret; }
/** * * @param Request $request * @return mixed */ public function index(Request $request) { $typing = '%' . $request->get('typing') . '%'; $matches = Journal::where('user_id', Auth::user()->id)->where('text', 'LIKE', $typing)->orderBy('date', 'desc')->get(); return transform(createCollection($matches, new JournalTransformer())); }
$url = null; if (isset($_REQUEST['url_metadata'])) { $url = $_REQUEST['url_metadata']; } else { if (isset($_REQUEST['id'])) { $url = "http://" . $GLOBALS['apps_config']['geonetwork']['host'] . "/geonetwork/srv/eng/csw?SERVICE=CSW&VERSION=2.0.2&REQUEST=GetRecordById&outputSchema=csw:IsoRecord&ID={$_REQUEST['id']}&elementSetName=full"; } } if (isset($url)) { $parseUrl = parse_url($_SERVER['REQUEST_URI']); $base = dirname($parseUrl['path']); $xml = curl_file_get_contents($url); if (isset($_REQUEST['full'])) { $GLOBALS['data'] = transform($xml, fopen_file_get_contents("./xsl/bs_full.xsl")); } else { $GLOBALS['data'] = transform($xml, fopen_file_get_contents("./xsl/bs_full.xsl")); } $GLOBALS['data'] = str_replace("{base}", $base, $GLOBALS['data']); //IncrementPopularity($_REQUEST['id']); } ?> <!DOCTYPE HTML> <html xmlns:fb="http://ogp.me/ns/fb#" xmlns:og="http://ogp.me/ns#"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" href="<?php echo $base; ?> /inc/css/reset.css" type="text/css">
function extract_me($product_id, $log_content, $transform, $load) { $log_content .= "Rozpoczęto proces extrakcji... " . PHP_EOL; // echo $product_id; $url = 'http://www.ceneo.pl/' . $product_id . '#tab=spec'; $title = ''; $dom = new DOMDocument(); $doc = new DOMDocument(); if (@$dom->loadHTMLFile($url)) { //remove body tag $doc = preg_replace('~<(?:!DOCTYPE|/?(?:html|body))[^>]*>\\s*~i', '', $dom->saveHTML()); //creating a crawler for subpages number $first_crawler = new Crawler($doc); $subpage_num = $first_crawler->filter('div.pagination > ul > li')->last()->previousAll()->text(); if ($first_crawler->filter('.product-offer')->selectLink('morele.net')->count()) { $morele_link = $first_crawler->filter('.product-offer')->selectLink('morele.net')->attr('href'); $morele_link = 'http://ceneo.pl/' . $morele_link; } //create and write to log $log_content .= "ilosc podstron " . $subpage_num . PHP_EOL; //add each subpage to our doc for ($i = 2; $i <= $subpage_num; $i++) { ${'url_' . $i} = 'http://www.ceneo.pl/' . $product_id . '/opinie-' . $i; ${'dom_' . $i} = new DOMDocument(); if (@${'dom_' . $i}->loadHTMLFile(${'url_' . $i})) { //remove the body tags and add the code to doc $doc .= preg_replace('~<(?:!DOCTYPE|/?(?:html|body))[^>]*>\\s*~i', '', ${'dom_' . $i}->saveHTML()); } print_r(${'url_' . $i}); } $crawler = new Crawler($doc); $opinions = $crawler->filter('.product-review')->each(function (Crawler $node, $i) { $op_author = $node->filter('.product-reviewer')->text(); $op_text = $node->filter('.product-review-body')->text(); $op_summary = $node->filter('.product-review-summary > em')->text(); $op_score = $node->filter('.review-score-count')->text(); $op_time = $node->filter('.review-time > time')->attr('datetime'); $op_useful = $node->filter('.product-review-usefulness-stats span')->first()->text(); $op_useful_votes = $node->filter('.product-review-usefulness-stats span')->last()->text(); //check if pros exist if ($node->filter('.pros-cell ul li')->count()) { //add each pro to array $pros = $node->filter('.pros-cell ul li')->each(function (Crawler $pro, $i) { return $pro->text(); }); $op_pros = $pros; } else { $op_pros[] = "brak"; } //check if cons exist if ($node->filter('.cons-cell ul li')->count()) { //add each con to array $cons = $node->filter('.cons-cell ul li')->each(function (Crawler $con, $i) { return $con->text(); }); $op_cons = $cons; } else { $op_cons[] = "brak"; } return array('author' => $op_author, 'text' => $op_text, 'summary' => $op_summary, 'score' => $op_score, 'date' => $op_time, 'useful' => $op_useful, 'votes' => $op_useful_votes, 'pros' => $op_pros, 'cons' => $op_cons); }); print_r($opinions); //get device info $spec_category = $crawler->filter('nav.breadcrumbs dd span')->last('a')->text(); if ($crawler->filter('.full-specs tbody > tr ul > li > a')->count()) { $spec_producer = $crawler->filter('.full-specs tbody > tr ul > li > a')->text(); } else { $spec_producer = "Nie podano"; } $spec_name = $crawler->filter('h1.product-name')->text(); $spec_desc = $crawler->filter('.full-description')->html(); $specs['producer'] = $spec_producer; $specs['name'] = $spec_name; $specs['category'] = $spec_category; $spec_desc = strip_tags($spec_desc); $spec_desc = substr($spec_desc, 0, 100) . '...'; $specs['desc'] = $spec_desc; print_r($specs); $log_content .= "nazwa produktu: " . $spec_name . PHP_EOL; $log_content .= "Ilość pobranych opinii: " . sizeof($opinions) . PHP_EOL; //write to log file $log_file = "log_file.txt"; $bytesWritten = File::append($log_file, $log_content); if ($bytesWritten === false) { die("Couldn't write to the file."); } //MORELE if (!isset($morele_link)) { $skapiec_url = 'http://www.ceneo.pl/' . $product_id . 'clr'; $skapiec_dom = new DOMDocument(); $skapiec_doc = new DOMDocument(); if (@$skapiec_dom->loadHTMLFile($skapiec_url)) { //remove body tag $skapiec_doc = preg_replace('~<(?:!DOCTYPE|/?(?:html|body))[^>]*>\\s*~i', '', $skapiec_dom->saveHTML()); //creating a crawler for subpages number $skapiec_crawler = new Crawler($skapiec_doc); if ($skapiec_crawler->filter('.product-offer')->selectLink('morele.net')->count()) { $morele_link = $skapiec_crawler->filter('.product-offer')->selectLink('morele.net')->attr('href'); $morele_link = 'http://ceneo.pl/' . $morele_link; } else { $morele_link = "brak"; } } } $morele_dom = new DOMDocument(); if (@$morele_dom->loadHTMLFile($morele_link)) { $morelec_dom = preg_replace('~<(?:!DOCTYPE|/?(?:html|body))[^>]*>\\s*~i', '', $morele_dom->saveHTML()); $crawler = new Crawler($morelec_dom); $m_array = array(); $opinions2 = $crawler->filter('#reviews ul.review')->each(function (Crawler $node, $i) { //check if node not empty because there are two types of review blocks, left and right if ($node->filter('li.author strong')->count()) { $m_array['author'] = $node->filter('li.author strong')->text(); $m_array['date'] = $node->filter('li.date')->text(); $m_array['score'] = "brak danych"; //$node->filter('li.rate img')->attr('src'); $m_array['summary'] = "brak danych"; //$m_score = preg_replace('/[^0-9.]+/', '', $m_score); //echo "mscore: " . $m_score; $m_array['useful'] = $node->filter('li.rate-review strong')->text(); $m_array['useful_votes'] = $node->filter('li.rate-count strong')->first()->text(); //$m_array['author'] = $m_author; ('author'=>$m_author, 'summary'=>$m_summary, 'score'=>$m_score, 'date'=>$m_time, 'useful'=>$m_useful, 'votes'=>$m_useful_votes); } if ($node->filter('li.rcomment')->count()) { $m_array['text'] = $node->filter('li.rcomment')->text(); $m_array['pros'] = $node->filter('li.good p')->text(); $m_array['cons'] = $node->filter('li.bad p')->text(); } return $m_array; }); //print_r($opinions2); } else { echo "link do morele.net nie istnieje lub jest nieprawidłowy"; $opinions2 = array(); } //call transform function if ($transform == true) { transform($opinions, $opinions2, $specs, $log_content, $product_id, $load); } } //end loadfile }
function MakeSafe() { //Keep weird values out of DeviceType $validdevicetypes = array('Server', 'Appliance', 'Storage Array', 'Switch', 'Chassis', 'Patch Panel', 'Physical Infrastructure', 'CDU'); $this->RequestID = intval($this->RequestID); $this->RequestorID = intval($this->RequestorID); $this->RequestTime = sanitize($this->RequestTime); //datetime $this->CompleteTime = sanitize($this->CompleteTime); //datetime $this->Label = sanitize(transform($this->Label)); $this->SerialNo = sanitize(transform($this->SerialNo)); $this->AssetTag = sanitize($this->AssetTag); $this->ESX = intval($this->ESX); $this->Owner = intval($this->Owner); $this->DeviceHeight = intval($this->DeviceHeight); $this->EthernetCount = intval($this->EthernetCount); $this->VLANList = sanitize($this->VLANList); $this->SANCount = intval($this->SANCount); $this->SANList = sanitize($this->SANList); $this->DeviceClass = sanitize($this->DeviceClass); $this->DeviceType = in_array($this->DeviceType, $validdevicetypes) ? $this->DeviceType : 'Server'; $this->LabelColor = sanitize($this->LabelColor); $this->CurrentLocation = sanitize(transform($this->CurrentLocation)); $this->SpecialInstructions = sanitize($this->SpecialInstructions); $this->MfgDate = date("Y-m-d", strtotime($this->MfgDate)); //date }
$response = null; $oldEPSG = preg_replace("/EPSG:/", "", $fromSrs); $newEPSG = preg_replace("/EPSG:/", "", $toSrs); if (!is_null($bbox) && is_array($bbox) && count($bbox) === 4) { $response = array("newSrs" => $toSrs, "points" => array()); for ($i = 0; $i < count($bbox); $i += 2) { $pt = transform(floatval($bbox[$i]), floatval($bbox[$i + 1]), $oldEPSG, $newEPSG); if (!is_null($pt)) { $response["points"][] = array("x" => $pt["x"], "y" => $pt["y"]); } else { $response = null; break; } } } else { $pt = transform($x, $y, $oldEPSG, $newEPSG); if (!is_null($pt)) { $response = array("newSrs" => $toSrs, "points" => array(array("x" => $pt["x"], "y" => $pt["y"]))); } } if (is_null($response)) { $ajaxResponse->setSuccess(false); $ajaxResponse->setMessage(_mb("An unknown error occured.")); $ajaxResponse->send(); } else { $ajaxResponse->setSuccess(true); $ajaxResponse->setResult($response); } break; default: $ajaxResponse->setSuccess(false);
function CreateDevice() { global $dbh; $this->MakeSafe(); $this->Label = transform($this->Label); $this->SerialNo = transform($this->SerialNo); $this->AssetTag = transform($this->AssetTag); $sql = "INSERT INTO fac_Device SET Label=\"{$this->Label}\", SerialNo=\"{$this->SerialNo}\", AssetTag=\"{$this->AssetTag}\", \n\t\t\t\t\tPrimaryIP=\"{$this->PrimaryIP}\", SNMPCommunity=\"{$this->SNMPCommunity}\", ESX={$this->ESX}, Owner={$this->Owner}, \n\t\t\t\t\tEscalationTimeID={$this->EscalationTimeID}, EscalationID={$this->EscalationID}, PrimaryContact={$this->PrimaryContact}, \n\t\t\t\t\tCabinet={$this->Cabinet}, Position={$this->Position}, Height={$this->Height}, Ports={$this->Ports}, \n\t\t\t\t\tFirstPortNum={$this->FirstPortNum}, TemplateID={$this->TemplateID}, NominalWatts={$this->NominalWatts}, \n\t\t\t\t\tPowerSupplyCount={$this->PowerSupplyCount}, DeviceType=\"{$this->DeviceType}\", ChassisSlots={$this->ChassisSlots}, \n\t\t\t\t\tRearChassisSlots={$this->RearChassisSlots},ParentDevice={$this->ParentDevice}, \n\t\t\t\t\tMfgDate=\"" . date("Y-m-d", strtotime($this->MfgDate)) . "\", \n\t\t\t\t\tInstallDate=\"" . date("Y-m-d", strtotime($this->InstallDate)) . "\", WarrantyCo=\"{$this->WarrantyCo}\", \n\t\t\t\t\tWarrantyExpire=\"" . date("Y-m-d", strtotime($this->WarrantyExpire)) . "\", Notes=\"{$this->Notes}\", \n\t\t\t\t\tReservation={$this->Reservation}, HalfDepth={$this->HalfDepth}, BackSide={$this->BackSide};"; if (!$dbh->exec($sql)) { $info = $dbh->errorInfo(); error_log("PDO Error: {$info[2]} SQL={$sql}"); return false; } $this->DeviceID = $dbh->lastInsertId(); class_exists('LogActions') ? LogActions::LogThis($this) : ''; return $this->DeviceID; }
<?php $input = str_split('1113122113'); echo 'Part one: ' . count(transform(40, $input)) . ' '; echo 'Part two: ' . count(transform(50, $input)) . ' '; function transform($times, $input) { for ($i = 0; $i < $times; $i++) { $lastNumber = null; $currentCount = 0; $newInput = []; foreach ($input as $number) { if (null !== $lastNumber && $number != $lastNumber) { $newInput[] = $currentCount; $newInput[] = $lastNumber; $currentCount = 0; } $currentCount++; $lastNumber = $number; } $newInput[] = $currentCount; $newInput[] = $lastNumber; $input = $newInput; } return $input; }
<textarea name="text" style="width: 100%; box-sizing: border-box;"><?php echo htmlspecialchars($obj->text); ?> </textarea> <div style="text-align: right; padding-top: 5px;"> <button name="edit" type="submit" value="update" style="height: 2em;">Update Post</button> </div> </form> <?php } } if ($f2) { ?> <div style="min-height: 100px;"> <?php echo transform($text); ?> </div> <?php if ($delete) { ?> <form method="POST" action="?page=<?php echo $page; ?> &post=<?php echo $id; ?> &action=delete" style="text-align: right; padding-top: 5px;"> <button name="delete" type="submit" value="confirm" style="height: 2em;">Confirm Delete</button> </form> <?php
public function parseBox($domNode) { list($x1, $y1, $x2, $y2) = explode(' ', $domNode->nodeValue); if ($this->targetEPSG != '4326') { $tCoords = transform($x1, $y1, '4326', $this->targetEPSG); $x1 = $tCoords["x"]; $y1 = $tCoords["y"]; $tCoords = transform($x2, $y2, '4326', $this->targetEPSG); $x2 = $tCoords["x"]; $y2 = $tCoords["y"]; } $this->addPoint($x1, $y1); $this->addPoint($x1, $y2); $this->addPoint($x2, $y2); $this->addPoint($x2, $y1); $this->addPoint($x1, $y1); }
function reader($img, $filename = '', $readerdir = '') { global $showimage; $image = imagecreatefromjpeg($img); $GLOBALS['transform'] = 0; $GLOBALS['rotated'] = 0; $cetvel = array(array(30, 300), array(30, 1320), array(250, 50), array(850, 50), array(250, 1550), array(850, 1550), array(1140, 300), array(1140, 1320)); //setpixelfull($image,$cetvel); $radian = checkalign($image, $cetvel, false); $degree = $radian * (180 / 3.141592654); $bgc = imagecolorallocate($image, 255, 255, 255); $image = imagerotate($image, -$degree, $bgc); $fgcolor = imagecolorallocate($image, 00, 00, 255); imagestring($image, 2, 100, 100, $GLOBALS['ver_line'], $fgcolor); //setpixelfull($image,$cetvel); $GLOBALS['rotated'] = 1; getcorner($image, $cetvel); $GLOBALS['transform'] = 1; $ax = 693; // 59 $ay = 597; // 123 $point = transform($ax, $ay); imagestring($image, 2, 200, 45, $point[0] . "x" . $point[1], $fgcolor); $ismark = ismarkcircle($image, $point[0], $point[1], 13); imagestring($image, 2, 300, 45, $ismark[0] . " - " . $ismark[1] . " - " . $ismark[2], $fgcolor); imagefilledcircle($image, $point[0], $point[1], 13, $ismark[0]); $Form = array(); //kitap�ik t�r� $kitapcikTuru['A'] = array(742, 213); $kitapcikTuru['B'] = array(820, 213); $kitapcik = ""; foreach ($kitapcikTuru as $key => $val) { $point = transform($val[0], $val[1]); $ismark = ismarkcircle($image, $point[0], $point[1], 13); $Form['kitapcikturu'][$key] = $ismark[0] . " - " . $ismark[1] . " - " . $ismark[2]; if ($ismark[0] == 1) { $kitapcik = $key; } imagefilledcircle($image, $point[0], $point[1], 13, $ismark[0]); } // numara basla $leftspace = 915; $topspace = 280; $horizontal = $topspace; $horizontal += 5; $Numara[0][1] = array($leftspace, $horizontal); $horizontal += 35; $Numara[0][2] = array($leftspace, $horizontal); $horizontal += 34; $Numara[0][3] = array($leftspace, $horizontal); $horizontal += 35; $Numara[0][4] = array($leftspace, $horizontal); $horizontal += 34; $Numara[0][5] = array($leftspace, $horizontal); $horizontal += 35; $Numara[0][6] = array($leftspace, $horizontal); $horizontal += 33; $Numara[0][7] = array($leftspace, $horizontal); $horizontal += 34; $Numara[0][8] = array($leftspace, $horizontal); $horizontal += 33; $Numara[0][9] = array($leftspace, $horizontal); $horizontal += 33; $Numara[0][0] = array($leftspace, $horizontal); $leftspace = 950; $topspace = 280; $horizontal = $topspace; $horizontal += 5; $Numara[1][1] = array($leftspace, $horizontal); $horizontal += 35; $Numara[1][2] = array($leftspace, $horizontal); $horizontal += 34; $Numara[1][3] = array($leftspace, $horizontal); $horizontal += 35; $Numara[1][4] = array($leftspace, $horizontal); $horizontal += 34; $Numara[1][5] = array($leftspace, $horizontal); $horizontal += 35; $Numara[1][6] = array($leftspace, $horizontal); $horizontal += 33; $Numara[1][7] = array($leftspace, $horizontal); $horizontal += 34; $Numara[1][8] = array($leftspace, $horizontal); $horizontal += 33; $Numara[1][9] = array($leftspace, $horizontal); $horizontal += 33; $Numara[1][0] = array($leftspace, $horizontal); $leftspace = 984; $topspace = 280; $horizontal = $topspace; $horizontal += 5; $Numara[2][1] = array($leftspace, $horizontal); $horizontal += 35; $Numara[2][2] = array($leftspace, $horizontal); $horizontal += 34; $Numara[2][3] = array($leftspace, $horizontal); $horizontal += 35; $Numara[2][4] = array($leftspace, $horizontal); $horizontal += 34; $Numara[2][5] = array($leftspace, $horizontal); $horizontal += 35; $Numara[2][6] = array($leftspace, $horizontal); $horizontal += 33; $Numara[2][7] = array($leftspace, $horizontal); $horizontal += 34; $Numara[2][8] = array($leftspace, $horizontal); $horizontal += 33; $Numara[2][9] = array($leftspace, $horizontal); $horizontal += 33; $Numara[2][0] = array($leftspace, $horizontal); $leftspace = 1018; $topspace = 280; $horizontal = $topspace; $horizontal += 5; $Numara[3][1] = array($leftspace, $horizontal); $horizontal += 35; $Numara[3][2] = array($leftspace, $horizontal); $horizontal += 34; $Numara[3][3] = array($leftspace, $horizontal); $horizontal += 35; $Numara[3][4] = array($leftspace, $horizontal); $horizontal += 34; $Numara[3][5] = array($leftspace, $horizontal); $horizontal += 35; $Numara[3][6] = array($leftspace, $horizontal); $horizontal += 33; $Numara[3][7] = array($leftspace, $horizontal); $horizontal += 34; $Numara[3][8] = array($leftspace, $horizontal); $horizontal += 33; $Numara[3][9] = array($leftspace, $horizontal); $horizontal += 33; $Numara[3][0] = array($leftspace, $horizontal); $ogrnumstr = ""; $ogrnum = 0; for ($i = 0; $i < count($Numara); $i++) { $selectnum = 0; for ($j = 0; $j < count($Numara[$i]); $j++) { $point = transform($Numara[$i][$j][0], $Numara[$i][$j][1]); $ismark = ismarkcircle($image, $point[0], $point[1], 13); $Form['numara'][$i][$j] = $ismark[0] . " - " . $ismark[1] . " - " . $ismark[2]; if ($ismark[0] == 1) { $selectnum = $j; } imagefilledcircle($image, $point[0], $point[1], 13, $ismark[0]); } $ogrnumstr = $ogrnumstr . $selectnum; } $ogrnum = (int) $ogrnumstr; $sql = "INSERT INTO `d_reader` (`num`, `file`, `puan`, `utime`) VALUES ('" . $ogrnum . "', '" . $filename . "', 0, " . $GLOBALS['utime'] . ");"; mysql_query($sql) or die(mysql_error()); // T�RK�E $leftspace = 108; $topspace = 700; $extraAspace = 0; $extraBspace = 0; $extraCspace = 0; $extraDspace = 0; $horizontal = $topspace; $horizontal += 25; $Cevaplar[0]['A'] = array($extraAspace + $leftspace + 20, $horizontal); $Cevaplar[0]['B'] = array($extraBspace + $leftspace + 53, $horizontal); $Cevaplar[0]['C'] = array($extraCspace + $leftspace + 88, $horizontal); $Cevaplar[0]['D'] = array($extraDspace + $leftspace + 123, $horizontal); $horizontal += 35; $Cevaplar[1]['A'] = array($extraAspace + $leftspace + 20, $horizontal); $Cevaplar[1]['B'] = array($extraBspace + $leftspace + 53, $horizontal); $Cevaplar[1]['C'] = array($extraCspace + $leftspace + 88, $horizontal); $Cevaplar[1]['D'] = array($extraDspace + $leftspace + 123, $horizontal); $horizontal += 35; $Cevaplar[2]['A'] = array($extraAspace + $leftspace + 20, $horizontal); $Cevaplar[2]['B'] = array($extraBspace + $leftspace + 53, $horizontal); $Cevaplar[2]['C'] = array($extraCspace + $leftspace + 88, $horizontal); $Cevaplar[2]['D'] = array($extraDspace + $leftspace + 123, $horizontal); $horizontal += 35; $Cevaplar[3]['A'] = array($extraAspace + $leftspace + 20, $horizontal); $Cevaplar[3]['B'] = array($extraBspace + $leftspace + 53, $horizontal); $Cevaplar[3]['C'] = array($extraCspace + $leftspace + 88, $horizontal); $Cevaplar[3]['D'] = array($extraDspace + $leftspace + 123, $horizontal); $horizontal += 35; $Cevaplar[4]['A'] = array($extraAspace + $leftspace + 20, $horizontal); $Cevaplar[4]['B'] = array($extraBspace + $leftspace + 53, $horizontal); $Cevaplar[4]['C'] = array($extraCspace + $leftspace + 88, $horizontal); $Cevaplar[4]['D'] = array($extraDspace + $leftspace + 123, $horizontal); $horizontal += 34; $Cevaplar[5]['A'] = array($extraAspace + $leftspace + 20, $horizontal); $Cevaplar[5]['B'] = array($extraBspace + $leftspace + 53, $horizontal); $Cevaplar[5]['C'] = array($extraCspace + $leftspace + 88, $horizontal); $Cevaplar[5]['D'] = array($extraDspace + $leftspace + 123, $horizontal); $horizontal += 34; $Cevaplar[6]['A'] = array($extraAspace + $leftspace + 20, $horizontal); $Cevaplar[6]['B'] = array($extraBspace + $leftspace + 53, $horizontal); $Cevaplar[6]['C'] = array($extraCspace + $leftspace + 88, $horizontal); $Cevaplar[6]['D'] = array($extraDspace + $leftspace + 123, $horizontal); $horizontal += 34; $Cevaplar[7]['A'] = array($extraAspace + $leftspace + 20, $horizontal); $Cevaplar[7]['B'] = array($extraBspace + $leftspace + 53, $horizontal); $Cevaplar[7]['C'] = array($extraCspace + $leftspace + 88, $horizontal); $Cevaplar[7]['D'] = array($extraDspace + $leftspace + 123, $horizontal); $horizontal += 34; $Cevaplar[8]['A'] = array($extraAspace + $leftspace + 20, $horizontal); $Cevaplar[8]['B'] = array($extraBspace + $leftspace + 53, $horizontal); $Cevaplar[8]['C'] = array($extraCspace + $leftspace + 88, $horizontal); $Cevaplar[8]['D'] = array($extraDspace + $leftspace + 123, $horizontal); $horizontal += 33; $Cevaplar[9]['A'] = array($extraAspace + $leftspace + 20, $horizontal); $Cevaplar[9]['B'] = array($extraBspace + $leftspace + 53, $horizontal); $Cevaplar[9]['C'] = array($extraCspace + $leftspace + 88, $horizontal); $Cevaplar[9]['D'] = array($extraDspace + $leftspace + 123, $horizontal); $horizontal += 34; $Cevaplar[10]['A'] = array($extraAspace + $leftspace + 20, $horizontal); $Cevaplar[10]['B'] = array($extraBspace + $leftspace + 53, $horizontal); $Cevaplar[10]['C'] = array($extraCspace + $leftspace + 88, $horizontal); $Cevaplar[10]['D'] = array($extraDspace + $leftspace + 123, $horizontal); $horizontal += 35; $Cevaplar[11]['A'] = array($extraAspace + $leftspace + 20, $horizontal); $Cevaplar[11]['B'] = array($extraBspace + $leftspace + 53, $horizontal); $Cevaplar[11]['C'] = array($extraCspace + $leftspace + 88, $horizontal); $Cevaplar[11]['D'] = array($extraDspace + $leftspace + 123, $horizontal); $horizontal += 36; $Cevaplar[12]['A'] = array($extraAspace + $leftspace + 20, $horizontal); $Cevaplar[12]['B'] = array($extraBspace + $leftspace + 53, $horizontal); $Cevaplar[12]['C'] = array($extraCspace + $leftspace + 88, $horizontal); $Cevaplar[12]['D'] = array($extraDspace + $leftspace + 123, $horizontal); $horizontal += 35; $Cevaplar[13]['A'] = array($extraAspace + $leftspace + 20, $horizontal); $Cevaplar[13]['B'] = array($extraBspace + $leftspace + 54, $horizontal); $Cevaplar[13]['C'] = array($extraCspace + $leftspace + 89, $horizontal); $Cevaplar[13]['D'] = array($extraDspace + $leftspace + 123, $horizontal); $horizontal += 35; $Cevaplar[14]['A'] = array($extraAspace + $leftspace + 20, $horizontal); $Cevaplar[14]['B'] = array($extraBspace + $leftspace + 54, $horizontal); $Cevaplar[14]['C'] = array($extraCspace + $leftspace + 89, $horizontal); $Cevaplar[14]['D'] = array($extraDspace + $leftspace + 123, $horizontal); $horizontal += 35; $Cevaplar[15]['A'] = array($extraAspace + $leftspace + 20, $horizontal); $Cevaplar[15]['B'] = array($extraBspace + $leftspace + 54, $horizontal); $Cevaplar[15]['C'] = array($extraCspace + $leftspace + 89, $horizontal); $Cevaplar[15]['D'] = array($extraDspace + $leftspace + 123, $horizontal); $horizontal += 34; $Cevaplar[16]['A'] = array($extraAspace + $leftspace + 20, $horizontal); $Cevaplar[16]['B'] = array($extraBspace + $leftspace + 54, $horizontal); $Cevaplar[16]['C'] = array($extraCspace + $leftspace + 89, $horizontal); $Cevaplar[16]['D'] = array($extraDspace + $leftspace + 123, $horizontal); $horizontal += 35; $Cevaplar[17]['A'] = array($extraAspace + $leftspace + 20, $horizontal); $Cevaplar[17]['B'] = array($extraBspace + $leftspace + 54, $horizontal); $Cevaplar[17]['C'] = array($extraCspace + $leftspace + 89, $horizontal); $Cevaplar[17]['D'] = array($extraDspace + $leftspace + 123, $horizontal); $horizontal += 34; $Cevaplar[18]['A'] = array($extraAspace + $leftspace + 20, $horizontal); $Cevaplar[18]['B'] = array($extraBspace + $leftspace + 54, $horizontal); $Cevaplar[18]['C'] = array($extraCspace + $leftspace + 89, $horizontal); $Cevaplar[18]['D'] = array($extraDspace + $leftspace + 123, $horizontal); $horizontal += 34; $Cevaplar[19]['A'] = array($extraAspace + $leftspace + 20, $horizontal); $Cevaplar[19]['B'] = array($extraBspace + $leftspace + 54, $horizontal); $Cevaplar[19]['C'] = array($extraCspace + $leftspace + 89, $horizontal); $Cevaplar[19]['D'] = array($extraDspace + $leftspace + 123, $horizontal); for ($i = 0; $i < count($Cevaplar); $i++) { $dersadi = $GLOBALS["ders"]; //$utime=$GLOBALS["utime"]; $cevap = array(); foreach ($Cevaplar[$i] as $key => $val) { $point = transform($val[0], $val[1]); $ismark = ismarkcircle($image, $point[0], $point[1], 13); //$Form['turkce'][$i][$key] = $ismark[0]." - ".$ismark[1]." - ".$ismark[2]; $cevap[$key] = $ismark[0]; imagefilledcircle($image, $point[0], $point[1], 13, $ismark[0]); } $sql = "INSERT INTO `d_cevaplar` (`id`, `ogrnum`, `ders`, `kitap`, `cevapnum`, `A`, `B`, `C`, `D`, `utime`) VALUES (NULL, '" . $ogrnum . "', '" . $dersadi . "', '" . $kitapcik . "', '" . ($i + 1) . "', '" . $cevap['A'] . "', '" . $cevap['B'] . "', '" . $cevap['C'] . "', '" . $cevap['D'] . "', " . $GLOBALS['utime'] . ");"; mysql_query($sql) or die(mysql_error()); } // MATEMATIK if ($showimage) { if ($filename != '') { ob_start(); imagejpeg($image); $i = ob_get_clean(); $fp = fopen($readerdir . $filename, 'w'); fwrite($fp, $i); fclose($fp); } else { header('Content-type: image/jpeg'); imagejpeg($image); } } return $Form; }
<div> <div>', __("Default U1 Position"), '</div> <div><select id="U1Position" name="U1Position" defaultvalue="', $config->defaults["U1Position"], '" data="', $config->ParameterArray["U1Position"], '"> <option value="Bottom">', __("Bottom"), '</option> <option value="Top">', __("Top"), '</option> </select></div> </div> </div> <!-- end table --> <h3>', __("Devices"), '</h3> <div class="table"> <div> <div><label for="LabelCase">', __("Device Labels"), '</label></div> <div><select id="LabelCase" name="LabelCase" defaultvalue="', $config->defaults["LabelCase"], '" data="', $config->ParameterArray["LabelCase"], '"> <option value="upper">', transform(__("Uppercase"), 'upper'), '</option> <option value="lower">', transform(__("Lowercase"), 'lower'), '</option> <option value="initial">', transform(__("Initial caps"), 'initial'), '</option> <option value="none">', __("Don't touch my labels"), '</option> </select> </div> </div> <div> <div><label for="AppendCabDC">', __("Device Lists"), '</label></div> <div><select id="AppendCabDC" name="AppendCabDC" defaultvalue="', $config->defaults["AppendCabDC"], '" data="', $config->ParameterArray["AppendCabDC"], '"> <option value="disabled">', __("Just Devices"), '</option> <option value="enabled">', __("Show Datacenter and Cabinet"), '</option> </select> </div> </div> </div> <!-- end table --> <h3>', __("Site"), '</h3> <div class="table">