/** * {@inheritdoc} */ public function buildForm(array $form, FormStateInterface $form_state, $config_name = '') { $config = $this->config($config_name); if ($config === FALSE || $config->isNew()) { drupal_set_message(t('Config @name does not exist in the system.', array('@name' => $config_name)), 'error'); return; } $data = $config->get(); if (empty($data)) { drupal_set_message(t('Config @name exists but has no data.', array('@name' => $config_name)), 'warning'); return; } try { $output = Yaml::encode($data); } catch (InvalidDataTypeException $e) { drupal_set_message(t('Invalid data detected for @name : %error', array('@name' => $config_name, '%error' => $e->getMessage())), 'error'); return; } $form['current'] = array('#type' => 'details', '#title' => $this->t('Current value for %variable', array('%variable' => $config_name)), '#attributes' => array('class' => array('container-inline'))); $form['current']['value'] = array('#type' => 'item', '#markup' => dpr($output, TRUE)); $form['name'] = array('#type' => 'value', '#value' => $config_name); $form['new'] = array('#type' => 'textarea', '#title' => $this->t('New value'), '#default_value' => $output, '#rows' => 24, '#required' => TRUE); $form['actions'] = array('#type' => 'actions'); $form['actions']['submit'] = array('#type' => 'submit', '#value' => $this->t('Save')); $form['actions']['cancel'] = array('#type' => 'link', '#title' => $this->t('Cancel'), '#url' => $this->buildCancelLinkUrl()); return $form; }
function process_input($input) { switch ($input) { case 'd' : $GLOBALS[CLOCKWORDS_DEBUG] = TRUE; exec(":>".CLOCKWORDS_ROOT."debug.txt"); $return[] = 'debug on'; case 'y' : $cw = new clockwords; $return[] = $cw; break; case 'n' : $return[] = false; print("\nok, exiting\n"); break; case 'scr' : $ocr = new cw_ocr; sleep(2); $tmp = $ocr->screenGrab(); $ocr->setCoords($tmp); $ocr->trimImage($tmp); dpr($tmp); exec("eog $tmp &"); sleep(3); unlink($tmp); break; default : throw new Exception("unknown input, exiting"); } return $return; }
function getWords($desired) { dpr("asking for words with: $desired"); $db = $this->db(); $query = $this->makeQuery($desired); $result = $db->query($query); return $result->fetchAll(); }
/** * {@inheritdoc} */ public function buildForm(array $form, FormStateInterface $form_state, $config_name = '') { $data = $this->config($config_name)->get(); if ($data === FALSE) { drupal_set_message(t('Config !name does not exist in the system.', array('!name' => $config_name)), 'error'); return; } if (empty($data)) { drupal_set_message(t('Config !name exists but has no data.', array('!name' => $config_name)), 'warning'); return; } $dumper = new Dumper(); // Set Yaml\Dumper's default indentation for nested nodes/collections to // 2 spaces for consistency with Drupal coding standards. $dumper->setIndentation(2); // The level where you switch to inline YAML is set to PHP_INT_MAX to // ensure this does not occur. $output = $dumper->dump($data, PHP_INT_MAX); $form['name'] = array('#type' => 'value', '#value' => $config_name); $form['value'] = array('#type' => 'item', '#title' => t('Old value for %variable', array('%variable' => $config_name)), '#markup' => dpr($output, TRUE)); $form['new'] = array('#type' => 'textarea', '#title' => t('New value'), '#default_value' => $output); $form['actions'] = array('#type' => 'actions'); $form['actions']['submit'] = array('#type' => 'submit', '#value' => t('Save')); $form['actions']['cancel'] = array('#type' => 'link', '#title' => t('Cancel'), '#href' => 'devel/config'); return $form; }
public function testGetPoints() { $total=0; foreach (str_split("fictionalizing") as $letter) { $p = $this->cw_words->getPoints($letter); $total= ($p !=1) ? $total + $p : $total - 1; } dpr($total); //die(); }
function query($iteratorClass = 'GoogleMiniResultIterator') { if (!db_table_exists('cache_google_appliance')) { $this->cache = FALSE; } if (!$this->cache) { return parent::query($iteratorClass); } else { $cached_result_obj = NULL; $cache_key = md5($this->buildQuery()); $_cached_result_xml = cache_get($cache_key, 'cache_google_appliance'); $cached_result_xml = $_cached_result_xml->data; $google_debug = variable_get('google_appliance_debug', 0); if ($cached_result_xml) { try { $google_results = GoogleMini::resultFactory($cached_result_xml, $iteratorClass); } catch (Exception $e) { drupal_set_message($e->getMessage(), 'error'); watchdog('google_appliance', $e->getMessage()); return FALSE; } if ($google_debug >= 2 ){ if (function_exists('dpr')) { dpr("got cache for $cache_key"); } } elseif ($google_debug == 1) { watchdog('google_appliance', "got cache for !cache_key at !url", array('!cache_key' => $cache_key, '!url' => $_GET['q'])); } } else { try { $google_results = parent::query($iteratorClass); } catch (Exception $e) { drupal_set_message($e->getMessage(), 'error'); watchdog('google_appliance', $e->getMessage()); return FALSE; } $timeout = variable_get('google_appliance_cache_timeout', 600); // 10 minutes by default cache_set($cache_key, $google_results->payload->asXML(), 'cache_google_appliance', time() + $timeout); $google_debug = variable_get('google_debug', 0); if ($google_debug >= 2 ){ if (function_exists('dpr')) { dpr("setting cache for $cache_key"); } } elseif ($google_debug == 1) { watchdog('google_appliance', "setting cache for !cache_key at !url", array('!cache_key' => $cache_key, '!url' => $_GET['q'])); } } return $google_results; } }
/** * get a screenshot using scrot * @return string PNG filename */ function screenGrab() { while (empty($imgname)) { $uid = uniqid('', TRUE); $imgname = CLOCKWORDS_ROOT."temp/".$uid.".png"; if (file_exists($imgname)) { unset($imgname,$uid); dpr("file: $imgname already exists"); } } $cmd = "scrot ".$imgname; exec($cmd); return $imgname; }
public function testConstants() { $cs = array("_WIDTH","_HEIGHT"); $test = true; foreach ($cs as $c) { if (!defined("CLOCKWORDS_CROP$c")) { $test = false; dpr("d CLOCKWORDS_CROP$c"); } elseif (!is_numeric(constant("CLOCKWORDS_CROP$c"))) { $test = false; dpr("n CLOCKWORDS_CROP$c"); } } $this->assertTrue($test, "something is wrong with our constants"); if (!$test) { $this->fail("something is wrong with our constants"); } }
public function guardarNotaAsignatura($rut, $ramo_ID, $nota, $field) { $criteria = new Criteria(); $ramo = new EntityRamos(); $notas = new EntityNotas(); $ramo->ramo_ID = $ramo_ID; $criteria->find($ramo); $notas = new EntityNotas(); $notas->rut = $rut; $notas->ramo = $ramo->nombre; $criteria->find($notas); $prop = new ReflectionProperty("EntityNotas", $field); $prop->setValue($notas, $nota); dpr($notas); $criteria->merge($notas); }
/** * Handle an incoming request. * * @param Request $request * @param \Closure $next * @return mixed */ public function handle(Request $request, Closure $next) { $tableName = $request->route()->parameter('table_name'); if (!empty($tableName)) { try { /** @var CmfDbModel $model */ $model = call_user_func([CmfConfig::getInstance()->base_db_model_class(), 'getModelByTableName'], $tableName); CmfScaffoldApiController::setModel($model); } catch (DbUtilsException $exc) { dpr($exc->getMessage()); } } // if the model doesn't exist at all, redirect to 404 if (empty($model)) { abort(404, 'Page not found'); } return $next($request); }
function bestWord($words, $keys, $desired) { static $wordsout; foreach ($keys as $key) { $word=$words[$key]; $return[$word]=0; foreach (str_split($word) as $letter) { $p = $this->getPoints($letter); $return[$word]= ($p !=1) ? $return[$word] + $p : $return[$word] - 1; } } $wordsout++; asort($return); reset($return); if ($wordsout > 30) { for($i = rand(1,count($return)); $i >= 1; $i--) { next($return); } } dpr($return); return key($return); }
function putItAllTogether() { $ocr = new cw_ocr; $w = new cw_words; $sql = new cw_sqlite; $starttime = time(); $word=''; $exceptions=0; $notready=true; while ($notready) { print "\n Waiting for game screen. ".((time()) - ($starttime))." Seconds elapsed."; try { $filename = $ocr->screenGrab(); $ocr->patternTest($filename, CLOCKWORDS_ROOT."match_image.pat"); $notready = false; @unlink($filename); print "\n Game screen found, let's play!"; } catch (Exception $e) { $notready = true; @unlink($filename); } usleep(500000); } $stillplaying=0; while ($stillplaying < 10) { $filename = $ocr->screenGrab(); try { if (empty($GLOBALS[CLOCKWORDS_CROP_X])) { $result = $ocr->setCoords($filename); } try { dpr(array('$stillplaying'=>$stillplaying,'$filename'=>$filename)); $result = $ocr->patternTest($filename, CLOCKWORDS_ROOT."match3.pat"); //$stillplaying = ($stillplaying > 0) ? $stillplaying-1 : 0; } catch (Exception $e) { dpr($e->getMessage()); //$stillplaying++; usleep(500000); try { $result = $ocr->patternTest($filename, CLOCKWORDS_ROOT."level.pat"); $stillplaying = 100; } catch (Exception $e) { //game has not ended... } } try { $desired = $ocr->doOCR($filename); dpr(array('$desired',$desired)); try { //$word = $w->getWord($desired); $word = $sql->getAWord($desired); dpr(array('$word',$word)); try { $this->type($word); $exceptions = ($exceptions > 0) ? $exceptions-1 : $exceptions; } catch (Exception $e) { throw $e; } } catch (Exception $e) { throw $e; } } catch (Exception $e) { throw $e; } } catch (Exception $e) { dpr(array($e->getMessage(),$e->getFile(),$e->getLine()));$exceptions++; } if ($exceptions > 10) { print("\n too many exceptions!\n");break; } $sql->removeWord($word); $len = strlen($word); if ($len > 5) { usleep($len . "00000"); }//the longer the word, the longer we need to wait to reload letters } //die("\n ".CLOCKWORDS_RUN_TIME." seconds are up\n"); $this->cleanup(); }
echo $link; ?> </li> <?php } ?> </ul> <?php } ?> <?php if ($debug) { ?> <?php dpr($partner); ?> <?php } ?> <?php if ($debug && $edit) { ?> <?php echo l('edit', 'node/' . $partner->nid . '/edit', array('query' => array('destination' => 'admin/config/workflow/partner-widget'))); ?> <?php } ?>
<?php session_start(); include "main_Lib.php"; include "class/class_notas.php"; validarAcceso(); //$conn = mysqli_select_db ('dorcl_dor2009', $link); $SQL = "CALL p_obtenerRutAlumno('GODOY', 'QUIROZ', 'CAMILA CONSTANZA', '10C')"; $row = mysqliQuery($SQL, $mysqli); dpr($row); //$query2 = "SELECT @X"; //$result2 = $mysqli->query($query2); //$row2 = $result2->fetch_array(); //dpr($row2); ////Este sirve tambien para MYSQL ///* //$result = mysql_query('CALL sp_InsertarPersona(1,"Yoshiro Juan Víctor","Carbajal Cerín")'); //*/ // // ////Este sirve para SQL SERVER 2000 ///* //$result = mysql_query('exec sp_InsertarPersona(1,"Yoshiro Juan Víctor","Carbajal Cerín")'); //*/ // //if (!$result) { //die('Invalid query: ' . mysql_error()); //}
public function getRawObject($oid, $roid) { $interface = "Bimsie1LowLevelInterface"; $method = "getDataObjectByOid"; $parameters["roid"] = $roid; $parameters['oid'] = $oid; //$parameters = '"roid": "'.$roid.'", "oid": "'.$oid.'"';//,array("".$roid,"".$oid)); //$parameters = '"roid": "' . $roid .', "oid": "' . $oid ; $ret = $this->doPost($interface, $method, $parameters); $dump['interface'] = $interface; $dump['method'] = $method; $dump['parameters'] = $parameters; global $DEBUG; if ($DEBUG) { dpr($dump); } return $ret; }
function readJSON($file) { if ($_GET['b']) { $file = "b-data/" . $file; } if (is_readable($file) && !$_GET['clean']) { dpr('Data cached'); return json_decode(file_get_contents($file)); } else { return false; } }
/** * Prints backtrace and stops the script execution. */ function dprt() { $trace_result = array(); foreach (debug_backtrace(false) as $trace_call) { $trace_result[] = str_replace($_SERVER['DOCUMENT_ROOT'], '', $trace_call['file']) . ':' . $trace_call['line']; } dpr($trace_result); }
function _th_draw_event_field($field) { switch ($field['type_name']) { case 'eventTime': case 'photo': case 'description': case 'eventTitle': break; case 'name': // имя ребёнка if ($field['value_varchar']) { echo "\n"; ?> <div class="ft"><span><?php echo $field['event_field_title']; ?> </span><div class="add t_<?php echo $field['type_name']; ?> "><?php echo $field['value_varchar']; ?> </div></div><?php } break; case 'weight': // вес if ($field['value_int']) { echo "\n"; ?> <div class="ft"><span><?php echo $field['event_field_title']; ?> </span><div class="add t_<?php echo $field['type_name']; ?> "><?php echo sprintf('%2.2f', $field['value_int']); ?> килограммов</div></div><?php } break; case 'height': // рост if ($field['value_int']) { echo "\n"; ?> <div class="ft"><span><?php echo $field['event_field_title']; ?> </span><div class="add t_<?php echo $field['type_name']; ?> "><?php echo (int) $field['value_int']; ?> сантиметров</div></div><?php } break; case 'eyecolor': // рост if ($field['value_int']) { echo "\n"; ?> <div class="ft"><span><?php echo $field['event_field_title']; ?> </span><div class="add t_<?php echo $field['type_name']; ?> "><?php echo Config::$eyecolors[(int) $field['value_int']]; ?> </div></div><?php } break; default: dpr($field); break; } }
// dpr($tablesRut); foreach ($tablesRut as $key => $table) { $datos_set = array($table["field"] => $rut_nuevo); $datos_where = array($table["field"] => $rut_viejo); $class_siga->cambiarRut($datos_set, $datos_where, $table["name"]); } /** *CAMBIO DE RUT EN BD COLEGIO */ $tablesRut = $class_siga->getTableWithRut($baseSelected); foreach ($tablesRut as $key => $table) { $datos_set = array($table["field"] => $rut_nuevo); $datos_where = array($table["field"] => $rut_viejo); $class_alumno->cambiarRut($datos_set, $datos_where, $table["name"]); } dpr("El rut se ha cambiado de forma exitosa"); } } break; case "salir": session_destroy(); moveLocation("index-1.html", 0); break; case "guardarTheme": $datosStyle = $class_style->obtenerStyle($_GET['colegio_ID']); $datosStyle["style_path"] = $_GET['style_path']; $style_ID = $class_style->guardarStyle($datosStyle); $_SESSION['style']->style_ID = $style_ID; $_SESSION['style']->style_path = $_GET['style_path']; moveLocationFast("super_usuario.php"); break;
public function oldCrapForTesting(&$node) { $node->content['rdfnodeproxy_uri'] = array('#value' => "<h3>Node URI = '" . $node->rdfnodeproxy_uri . "'</h3>", '#weight' => -2); // $client = new SimpleSparqlClient("http://localhost:8080/openrdf-sesame/repositories/scfnat/"); $client = new SimpleSparqlClient("http://sparql.neurocommons.org:8890/sparql/"); /* $qs = "PREFIX sc: <http://purl.org/science/owl/sciencecommons/>\n"; $qs .= "SELECT ?s ?p ?o\n"; $qs .= "FROM <http://purl.org/commons/hcls/gene>\n"; $qs .= "WHERE { ?s rdf:type sc:gene_record . ?s ?p ?o }\n"; $qs .= "LIMIT 10"; */ $qs = "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>\n"; $qs .= "PREFIX sc: <http://purl.org/science/owl/sciencecommons/>\n"; $qs .= "PREFIX dc: <http://purl.org/dc/elements/1.1/>\n"; $qs .= "CONSTRUCT {\n"; $qs .= " ?s ?pl ?lit .\n"; // $qs .= " ?s ?pr ?res .\n"; $qs .= "}\n"; $qs .= "FROM <http://purl.org/commons/hcls/gene>\n"; $qs .= "WHERE {\n"; $qs .= " ?s ?pl ?lit .\n"; $qs .= " ?s a sc:gene_record .\n"; $qs .= " ?s dc:identifier ?id .\n"; $qs .= " filter(isLiteral(?lit)) .\n"; $qs .= " filter(xsd:integer(?id) > 11286 && xsd:integer(?id) < 11299) .\n"; /* $qs .= " optional {\n"; $qs .= " ?s ?pr ?res .\n"; $qs .= " ?res ?p2 ?o2 .\n"; $qs .= " }\n"; */ $qs .= "}\n"; $qs .= "LIMIT 1"; $result = $client->query($qs); dvm($result); // arc2_include(); // $parser = arc2_parse_sparql_results($result); $parser = ARC2::getTurtleParser(); $parser->parse('', $result); $triples = $parser->getTriples(); /* $structure = $parser->getStructure(); */ $node->content['rdfnodeproxy_results'] = array('#value' => dpr($triples, TRUE), '#weight' => -1); /* $cols = $client->cols($result); $rows = $client->rows($result, TRUE); // $tree = $client->tree($result); $node->content['rdfnodeproxy_results'] = array( '#value' => theme('table', $cols, $rows), '#weight' => -1 ); */ }
<?php // $Id: views-view-field.tpl.php,v 1.1 2008/05/16 22:22:32 merlinofchaos Exp $ /** * This template is used to print a single field in a view. It is not * actually used in default Views, as this is registered as a theme * function which has better performance. For single overrides, the * template is perfectly okay. * * Variables available: * - $view: The view object * - $field: The field handler object that can process the input * - $row: The raw SQL result that can be used * - $output: The processed output that will normally be used. * * When fetching output from the $row, this construct should be used: * $data = $row->{$field->field_alias} * * The above will guarantee that you'll always get the correct data, * regardless of any changes in the aliasing that might happen if * the view is modified. */ // print $output; dpr($view); // dpr($row);
private function writeJSON($file, $data) { if ($_GET['b']) { $file = "b-data/" . $file; } file_put_contents($file, json_encode($data)); dpr('Data written to ' . $file); }
<? print dpr($fields['']);?> <div class="teammate" id="<?php print $fields['title']->content; ?> "> <div class="image_container"> <img title="" alt="" src="<?php print file_create_url(); ?> "> <div class="helper"></div> </div> <div class="description_container"> <div class="description"> <div class="description_title"> <span class="name"><?php print t($fields['title']->content); ?> </span> <span class="exp">Experience: <span><?php print t($fields['field_employee_experience']->content); ?> </span></span> <span class="pro"><?php print t($fields['field_employee_position']->content); ?> </span> </div> <div class="text">
include_once 'bean/EntityAlumnos.php'; include_once 'bean/EntityMensualidades.php'; include_once 'PHPCriteria/Criteria.php'; include_once 'class/class_alumno.php'; include_once 'class/class_arancel.php'; include_once 'class/class_mensualidad.php'; $class_alumno = new alumno(); $criteria = new Criteria(); $class_arancel = new arancel(); $class_mensualidad = new mensualidad(); $alumnos = $class_alumno->obtenerAlumnos(); $count = 0; foreach ($alumnos as $rut => $alumno) { $beca = $class_arancel->obtenerBeca($_SESSION['colegio']->colegio_ID, $rut, $_SESSION['base_datos']->anio); if ($rut && $beca['beca_ID']) { $count++; $datos_mensualidad['mensualidad'] = $class_mensualidad->obtenerArancelAlumno($alumno['curso']); $datos_mensualidad['descuentos'] = $beca["beca_porcentaje"]; $mensualidad = $class_mensualidad->obtenerMensualidad($rut); if (!$mensualidad['mens_ID']) { $mensualidad["rut"] = $rut; $mensualidad["mensualidad"] = $datos_mensualidad['mensualidad']; $mensualidad["descuentos"] = $datos_mensualidad['descuentos']; $class_mensualidad->insertarMensualidad($mensualidad); } else { $class_mensualidad->actualizarMensualidad($datos_mensualidad, $rut); } } } dpr("Se han actualizado " . $count . " registros");
<section class="<?php print $class; ?> "> <div> <p>Let's try to add a field</p> </div> <?php require_once drupal_get_path('module', 'commerce_product') . '/includes/commerce_product.forms.inc'; require_once drupal_get_path('module', 'commerce_product') . '/includes/commerce_product_ui.products.inc'; $form = commerce_product_ui_product_form_wrapper(commerce_product_new('product')); dpr($form); print render($form); ?> </section>
function mysqliQuery($SQL, $db = null) { $mysqli = mysqliConnect($db); $result = $mysqli->query($SQL); if (!$result) { $error_db['TIPO ERROR'] = "ERROR EN LA QUERY DE STORED PROCEDURE"; $error_db['MYSQLI ERROR'] = mysqli_error($mysqli); $error_db['MYSQLI QUERY'] = $SQL; dpr($error_db); exit; } return $result->fetch_array(MYSQL_ASSOC); }