コード例 #1
1
function createEmailFromTemplate($templateName, $user, $data = null)
{
    global $APP_DIR;
    $email_config = getConfig("_email");
    if (!$email_config || !$templateName || !$user) {
        return null;
    }
    $templateDir = $email_config["templates"];
    $template = readTextFile("{$APP_DIR}/{$templateDir}/{$templateName}.html");
    if (!$template) {
        return null;
    }
    $name = is_string($user) ? substringBefore($user, "@") : $user["first_name"] . " " . $user["last_name"];
    $to_email = is_string($user) ? $user : $user["email"];
    if (isset($email_config["to"])) {
        $to_email = $email_config["to"];
    }
    $logo = combine($email_config["baseUrl"], getConfig("app.logo"));
    $cfg = array("site" => getConfig("defaultTitle"), "baseUrl" => $email_config["baseUrl"], "logo" => $logo, "name" => $name, "to" => $to_email);
    $template = replaceVariables($template, $cfg);
    $template = replaceVariables($template, $user);
    $template = replaceVariables($template, $data);
    $subject = substringBefore($template, "\n");
    $body = substringAfter($template, "\n");
    //replace classes with inlineStyles
    $styles = readConfigFile("{$APP_DIR}/{$templateDir}/inline.css");
    if ($styles) {
        $body = "<div class=\"fp-email\">{$body}</div>";
        $body = inlineStyles($body, $styles);
    }
    debug("createEmail subject", $subject);
    debug("createEmail body", $body);
    return createEmail($to_email, $subject, $body, true);
}
コード例 #2
1
 function get_all_taxa()
 {
     require_library('connectors/INBioAPI');
     $func = new INBioAPI();
     $paths = $func->extract_archive_file($this->dwca_file, "meta.xml");
     $archive_path = $paths['archive_path'];
     $temp_dir = $paths['temp_dir'];
     $harvester = new ContentArchiveReader(NULL, $archive_path);
     $tables = $harvester->tables;
     if (!($this->fields["taxa"] = $tables["http://rs.tdwg.org/dwc/terms/taxon"][0]->fields)) {
         debug("Invalid archive file. Program will terminate.");
         return false;
     }
     self::build_taxa_rank_array($harvester->process_row_type('http://rs.tdwg.org/dwc/terms/Taxon'));
     self::create_instances_from_taxon_object($harvester->process_row_type('http://rs.tdwg.org/dwc/terms/Taxon'));
     self::get_objects($harvester->process_row_type('http://eol.org/schema/media/Document'));
     self::get_references($harvester->process_row_type('http://rs.gbif.org/terms/1.0/Reference'));
     self::get_agents($harvester->process_row_type('http://eol.org/schema/agent/Agent'));
     self::get_vernaculars($harvester->process_row_type('http://rs.gbif.org/terms/1.0/VernacularName'));
     $this->archive_builder->finalize(TRUE);
     // remove temp dir
     recursive_rmdir($temp_dir);
     echo "\n temporary directory removed: " . $temp_dir;
     print_r($this->debug);
 }
コード例 #3
0
ファイル: date.class.php プロジェクト: Esleelkartea/arotz
 function parse()
 {
     setlocale(LC_TIME, $this->locale);
     if ($this->day && $this->month && $this->year) {
         $this->timestamp = mktime($this->hour, $this->minutes, $this->seconds, $this->month, $this->day, $this->year);
     }
     for ($i = 0; $i < 7; $i++) {
         $this->__weekdays[$i] = ucfirst(strftime("%a", $i * 86400 + 3 * 86400));
     }
     for ($i = 1; $i < 13; $i++) {
         $this->__months[$i] = ucfirst(strftime("%B", mktime(0, 0, 0, $i, 1, $this->year)));
     }
     list($this->weekday, $this->day, $this->month, $this->year, $this->hour, $this->minutes, $this->seconds) = explode(" ", date("w j n Y G i s", $this->timestamp));
     $this->strmonth = $this->__months[$this->month];
     $this->strweekday = $this->__weekdays[$this->weekday];
     //$this->string = $this->__weekdays[$this->weekday]." ".$this->day." ".$this->__months[$this->month]." ".$this->year." ".$this->hour.":".$this->minutes;
     $this->string = $this->day . "/" . $this->month . "/" . $this->year . " " . $this->hour . ":" . $this->minutes;
     $this->short_string = substr($this->__weekdays[$this->weekday], 0, 4) . " " . $this->day . " " . substr($this->__months[$this->month], 0, 3) . " " . $this->year;
     debug($this, "<font color=\"magenta\"> Parsed Date, timestamp = " . $this->timestamp . " , string = " . $this->string);
     if ($this->timestamp == 0 || $this->timestamp == -1) {
         $this->timestamp = 0;
         $this->day = 0;
         $this->month = 0;
         $this->year = 0;
         $this->hour = 0;
         $this->minutes = 0;
         $this->seconds = 0;
         $this->string = " N/A ";
         $this->short_string = " N/A ";
     }
 }
コード例 #4
0
 function get_all_taxa($resource_id)
 {
     self::get_associations();
     if ($this->debug_info) {
         echo "\n\n total: " . count($GLOBALS['taxon']) . "\n";
     }
     $all_taxa = array();
     $i = 0;
     $total = count(array_keys($GLOBALS['taxon']));
     foreach ($GLOBALS['taxon'] as $taxon_name => $record) {
         $i++;
         if ($this->debug_info) {
             echo "\n{$i} of {$total} " . $taxon_name;
         }
         $record["taxon_name"] = $taxon_name;
         $arr = self::get_plant_feeding_taxa($record);
         $page_taxa = $arr[0];
         if ($page_taxa) {
             $all_taxa = array_merge($all_taxa, $page_taxa);
         }
         unset($page_taxa);
     }
     $xml = \SchemaDocument::get_taxon_xml($all_taxa);
     $resource_path = CONTENT_RESOURCE_LOCAL_PATH . $resource_id . ".xml";
     if (!($OUT = fopen($resource_path, "w"))) {
         debug(__CLASS__ . ":" . __LINE__ . ": Couldn't open file: " . $resource_path);
         return;
     }
     fwrite($OUT, $xml);
     fclose($OUT);
     return $all_taxa;
     //used for testing
 }
コード例 #5
0
ファイル: Luhn.php プロジェクト: ristorantino/barcodes
 /**
  * Calculate check digit according to Luhn's algorithm
  * This is an old method, tests show that this is little bit slower than new one
  * 
  * @param string $number
  * @return integer
  */
 public function calculateOld($number)
 {
     $length = strlen($number);
     $sum = 0;
     $p = $length % 2;
     // Sum digits, where every second digit from right is doubled (last one is check digit, which is not in parameter)
     for ($i = $length - 1; $i >= 0; --$i) {
         $digit = $number[$i];
         // Every second digit is doubled
         if ($i % 2 != $p) {
             $digit *= 2;
             // If doubled value is 10 or more (for example 13), then add to sum each digit (i.e. 1 and 3)
             if ($digit > 9) {
                 $sum += $digit[0];
                 $sum += $digit[1];
             } else {
                 $sum += $digit;
             }
         } else {
             $sum += $digit;
         }
     }
     // Multiply by 9
     $sum *= 9;
     // Last one is check digit
     $ret = (double) substr($sum, -1, 1);
     debug($ret);
     return $ret;
 }
コード例 #6
0
 /**
  * index method
  *
  * @return void
  */
 public function index()
 {
     $this->Measurement->recursive = -0;
     $measurements = $this->Paginator->paginate();
     $this->set('measurements', $measurements);
     debug($measurements);
 }
コード例 #7
0
 /**
  * Calls procesItemStates() so that the common configuration for the menu items are resolved into individual configuration per item.
  * Calls makeGifs() for all "normal" items and if configured for, also the "rollover" items.
  *
  * @return void
  * @see AbstractMenuContentObject::procesItemStates(), makeGifs()
  * @todo Define visibility
  */
 public function generate()
 {
     $splitCount = count($this->menuArr);
     if ($splitCount) {
         list($NOconf, $ROconf) = $this->procesItemStates($splitCount);
         //store initial count value
         $temp_HMENU_MENUOBJ = $GLOBALS['TSFE']->register['count_HMENU_MENUOBJ'];
         $temp_MENUOBJ = $GLOBALS['TSFE']->register['count_MENUOBJ'];
         // Now we generate the giffiles:
         $this->makeGifs($NOconf, 'NO');
         // store count from NO obj
         $tempcnt_HMENU_MENUOBJ = $GLOBALS['TSFE']->register['count_HMENU_MENUOBJ'];
         $tempcnt_MENUOBJ = $GLOBALS['TSFE']->register['count_MENUOBJ'];
         if ($this->mconf['debugItemConf']) {
             echo '<h3>$NOconf:</h3>';
             debug($NOconf);
         }
         // RollOver
         if ($ROconf) {
             // Start recount for rollover with initial values
             $GLOBALS['TSFE']->register['count_HMENU_MENUOBJ'] = $temp_HMENU_MENUOBJ;
             $GLOBALS['TSFE']->register['count_MENUOBJ'] = $temp_MENUOBJ;
             $this->makeGifs($ROconf, 'RO');
             if ($this->mconf['debugItemConf']) {
                 echo '<h3>$ROconf:</h3>';
                 debug($ROconf);
             }
         }
         // Use count from NO obj
         $GLOBALS['TSFE']->register['count_HMENU_MENUOBJ'] = $tempcnt_HMENU_MENUOBJ;
         $GLOBALS['TSFE']->register['count_MENUOBJ'] = $tempcnt_MENUOBJ;
     }
 }
コード例 #8
0
 public function testAsText()
 {
     echo "<h2>Display as text</h2>";
     $result = $this->display->asText(array('test' => 'data', 'test two' => 'data2'));
     debug($result);
     //$this->assertEquals(true,$result);
 }
コード例 #9
0
 /**
  * Import a set of valid URLS from a sitemap
  *
  * @param string path to sitemap we want to parse
  * @param boolean clear the set first, then import.
  * @param boolean verbose
  * @param int count of imported urls
  */
 function import($sitemap = null, $clear_all = true, $verbose = false)
 {
     $count = 0;
     if ($this->settings['active']) {
         if ($sitemap) {
             $this->settings['source'] = $sitemap;
         }
         if ($clear_all) {
             $this->deleteAll(1);
         }
         $xml = simplexml_load_file($this->getPathToSiteMap());
         foreach ($xml->url as $url) {
             $this->clear();
             $save_data = array('url' => parse_url((string) $url->loc, PHP_URL_PATH), 'priority' => (string) $url->priority);
             if ($this->save($save_data)) {
                 if ($verbose) {
                     echo ".";
                 }
                 $count++;
             } elseif ($verbose) {
                 echo "f";
                 debug($this->validationErrors);
             }
         }
     }
     return $count;
 }
コード例 #10
0
 /**
  * Internal callback, after Outlook Connect's request
  */
 public function oauth2callback()
 {
     $callbackTime = time();
     if (array_key_exists('code', $_GET) && !empty($_GET['code'])) {
         $url = 'https://login.microsoftonline.com/common/oauth2/v2.0/token';
         $params = array('client_id' => $this->strategy['client_id'], 'client_secret' => $this->strategy['client_secret'], 'redirect_uri' => $this->strategy['redirect_uri'], 'grant_type' => 'authorization_code', 'code' => trim($_GET['code']));
         if (!empty($this->strategy['state'])) {
             $params['state'] = $this->strategy['state'];
         }
         $response = $this->serverPost($url, $params, null, $headers);
         $results = json_decode($response);
         debug($results);
         if (!empty($results) && !empty($results->access_token)) {
             $me = $this->me($results->access_token);
             $this->auth = array('uid' => $me['Id'], 'info' => array('email' => $me['EmailAddress'], 'name' => $me['DisplayName'], 'nickname' => $me['Alias']), 'credentials' => array('token' => $results->access_token), 'raw' => $me);
             $this->callback();
         } else {
             $error = array('code' => 'access_token_error', 'message' => 'Failed when attempting to obtain access token', 'raw' => array('response' => $response, 'headers' => $headers));
             $this->errorCallback($error);
         }
     } else {
         $error = array('code' => 'oauth2callback_error', 'raw' => $_GET);
         $this->errorCallback($error);
     }
 }
コード例 #11
0
function delete()
{
    debug("Info: Calling Extended delete");
    if ($this->type == "archive") {
        $par = new Ente($this->name);
        $fi = newObject("fileh", $this->fileh);
        if (!$fi->delete()) {
            $this->WARNING = $fi->ERROR;
        }
        $par = typecast($this, "Ente");
        return $par->delete();
    } else {
        /* Ohohohoho we've a dir here */
        $confirmation = newObject("data_object");
        $n = $confirmation->select("inode=" . $this->ID);
        if ($confirmation->nRes < 1) {
            /* Lets detelete */
            $par = new Ente($this->name);
            $par = typecast($this, "Ente");
            return $par->delete();
        } else {
            $this->ERROR = _("Folder not empty");
            return False;
        }
    }
}
コード例 #12
0
ファイル: BioPortal.php プロジェクト: hubgit/libapi
 function annotate($text, $ontologies = array(), $params = array())
 {
     $this->annotations = array();
     if (!$text) {
         return false;
     }
     $default = array('format' => 'xml', 'filterNumber' => 'true', 'isVirtualOntologyId' => 'false', 'levelMax' => '0', 'longestOnly' => 'true', 'wholeWordOnly' => 'true', 'minTermSize' => 3, 'scored' => 'true', 'withDefaultStopWords' => 'true', 'isStopWordsCaseSensitive' => 'false', 'withSynonyms' => 'true', 'ontologiesToExpand' => implode(',', $ontologies), 'ontologiesToKeepInResult' => implode(',', $ontologies), 'textToAnnotate' => $text);
     $params = array_merge($default, $params);
     $http = array('method' => 'POST', 'ignore_errors' => false, 'header' => 'Accept: */*;q=0.2', 'timeout' => 300);
     // 5 minute timeout
     $this->get_data('http://rest.bioontology.org/obs/annotator', $params, 'dom', $http);
     debug('response');
     debug($this->data);
     if (!is_object($this->data)) {
         return FALSE;
     }
     file_put_contents(sys_get_temp_dir() . '/bioportal.xml', $this->data->saveXML());
     $nodes = $this->xpath->query('data/annotatorResultBean/annotations/annotationBean');
     if (!$nodes->length) {
         return FALSE;
     }
     foreach ($nodes as $node) {
         $context = $this->xpath->query('context', $node)->item(0);
         $concept = $this->xpath->query('concept', $node)->item(0);
         $synonyms = array();
         foreach ($this->xpath->query('synonyms/string', $concept) as $synonym) {
             $synonyms = $synonym->textContent;
         }
         $conceptId = $this->xpath->query('localConceptId', $concept)->item(0)->nodeValue;
         list($ontology, $id) = explode('/', $conceptId);
         $this->annotations[] = array('score' => $this->xpath->query('score', $node)->item(0)->nodeValue, 'start' => $this->xpath->query('from', $context)->item(0)->nodeValue - 1, 'end' => $this->xpath->query('to', $context)->item(0)->nodeValue, 'text' => $this->xpath->query('term/name', $context)->item(0)->nodeValue, 'title' => $this->xpath->query('preferredName', $concept)->item(0)->nodeValue, 'uri' => $this->xpath->query('fullId', $concept)->item(0)->nodeValue, 'ontology' => $ontology, 'id' => $id, 'type' => $this->xpath->query('semanticTypes[1]/semanticTypeBean/semanticType', $concept)->item(0)->nodeValue);
     }
 }
コード例 #13
0
ファイル: whlocationsSearch.php プロジェクト: uzerpllp/uzerp
 public function toConstraintChain()
 {
     $cc = new ConstraintChain();
     if ($this->cleared) {
         return $cc;
     }
     debug('BaseSearch::toConstraintChain Fields: ' . print_r($this->fields, true));
     foreach ($this->fields as $group) {
         foreach ($group as $field => $searchField) {
             if ($field == 'balance') {
                 $cc1 = new ConstraintChain();
                 if ($searchField->getValue() == '') {
                     $cc1->add(new Constraint('balance', '>', '0'));
                 }
                 $cc->add($cc1);
             } elseif ($field != 'parent_id' && $field != 'search_id') {
                 $c = $searchField->toConstraint();
                 if ($c !== false) {
                     $cc->add($c);
                 }
             }
         }
     }
     debug('BaseSearch::toConstraintChain Constraints: ' . print_r($cc, true));
     return $cc;
 }
コード例 #14
0
 /**
  * Renders the current node
  *
  * @param LiquidContext $context
  * @return string
  */
 public function render(&$context)
 {
     $collection = $context->get($this->collection_name);
     if (!is_array($collection)) {
         die(debug('not array', $collection));
     }
     // discard keys
     $collection = array_values($collection);
     if (isset($this->attributes['limit']) || isset($this->attributes['offset'])) {
         $limit = $context->get($this->attributes['limit']);
         $offset = $context->get($this->attributes['offset']);
         $collection = array_slice($collection, $offset, $limit);
     }
     $length = count($collection);
     $cols = $context->get($this->attributes['cols']);
     $row = 1;
     $col = 0;
     $result = "<tr class=\"row1\">\n";
     $context->push();
     foreach ($collection as $index => $item) {
         $context->set($this->variable_name, $item);
         $context->set('tablerowloop', array('length' => $length, 'index' => $index + 1, 'index0' => $index, 'rindex' => $length - $index, 'rindex0' => $length - $index - 1, 'first' => (int) ($index == 0), 'last' => (int) ($index == $length - 1)));
         $result .= "<td class=\"col" . ++$col . "\">" . $this->render_all($this->_nodelist, $context) . "</td>";
         if ($col == $cols && !($index == $length - 1)) {
             $col = 0;
             $result .= "</tr>\n<tr class=\"row" . ++$row . "\">";
         }
     }
     $context->pop();
     $result .= "</tr>\n";
     return $result;
 }
コード例 #15
0
ファイル: SeoUrl.php プロジェクト: stonelasley/seo
 /**
  * Import a set of valid URLS from a sitemap
  *
  * @param string $sitemapPath path to sitemap we want to parse defaults to webroot/site-map.xml
  * @param bool $clearAll
  * @param bool $verbose
  * @throws NotFoundException
  * @internal param \clear $boolean the set first, then import.
  * @internal param \verbose $boolean
  * @internal param \count $int of imported urls
  * @return int
  */
 public function import($sitemapPath = null, $clearAll = true, $verbose = false)
 {
     $count = 0;
     if ($this->settings['active']) {
         if (!file_exists($this->__getPathToSiteMap($sitemapPath))) {
             throw new NotFoundException("File not found.");
         }
         if ($clearAll) {
             $this->deleteAll(1);
         }
         $xml = simplexml_load_file($this->__getPathToSiteMap($sitemapPath));
         foreach ($xml->url as $url) {
             $this->create();
             $saveData = array('url' => parse_url((string) $url->loc, PHP_URL_PATH), 'priority' => (string) $url->priority);
             if ($this->save($saveData)) {
                 if ($verbose) {
                     echo ".";
                 }
                 $count++;
             } elseif ($verbose) {
                 echo "f";
                 debug($this->validationErrors);
             }
         }
     }
     return $count;
 }
コード例 #16
0
ファイル: AdminController.php プロジェクト: besimhu/legacy
 public function setup()
 {
     $m = ClassRegistry::init('News.Metadatum');
     if ($this->request->is('post')) {
         if (!empty($this->request->data['latest_news_items'])) {
             //vomit($this->request->data['latest_news_items']);
             $m->deleteAll(array('Metadatum.key' => 'latest_news'), false);
             $s = array('Metadatum' => array('key' => 'latest_news', 'value' => $this->request->data['latest_news_items']));
             if ($m->save($s)) {
                 $this->Session->setFlash('Latest news items saved!');
             } else {
                 debug($m->validationErrors);
             }
         }
     }
     $m = $m->findByKey('latest_news');
     $s = $m['Metadatum']['value'];
     $a = explode(",", $s);
     //debug($s);
     $this->set('init', $m);
     if ($m) {
         $order = "FIND_IN_SET(Item.id, '" . $s . "')";
         $conditions['Item.id'] = $a;
         $m = ClassRegistry::init('News.Item')->find('all', array('conditions' => $conditions, 'order' => $order));
         $this->set(compact('m'));
     }
 }
コード例 #17
0
 public function inscription_1()
 {
     if (isset($_SESSION['user'])) {
         $this->redirectToRoute('accueil');
         // si ok envoie page 2
     }
     if (isset($_POST['suivant'])) {
         $mail = $_POST['wuser']['mail'];
         $user_manager = new userManager();
         $verif = $user_manager->emailExists($mail);
         if ($verif) {
             debug("Cet email est déjà utilisé !");
             $this->show('inscription/inscription1');
             // redirection si erreur
         } else {
             //envoi image + changement nom_image
             $uploads_dir = "C:/xampp/htdocs/projet_lotl/public/assets/img/uploads/";
             //debug($_FILES);die();
             $tmp_name = $_FILES['avatar']['tmp_name'];
             $name = time() . "_" . $_FILES['avatar']['name'];
             $result = move_uploaded_file($tmp_name, "{$uploads_dir}{$name}");
             $_POST['wuserInsc']['avatar'] = $name;
             $_SESSION['wuserInsc'] = $_POST['wuser'];
             //hashage du mdp
             $_SESSION['wuserInsc']['mot_de_passe'] = password_hash($_SESSION['wuserInsc']['mot_de_passe'], PASSWORD_DEFAULT);
             //debug($_SESSION['wuser']);die();
             $this->redirectToRoute('inscription2');
             // si ok envoie page 2
         }
     }
     $this->show('inscription/inscription1');
     // redirection si erreur
 }
コード例 #18
0
ファイル: class.calendario_xml.php プロジェクト: etlapa/uiest
 function get_listado_xml()
 {
     $this->set_columnas("cal_fecha_inicio, cal_fecha_fin, cal_titulo, cal_id, cal_gal_id");
     $sql = "SELECT          " . implode(",", $this->get_columnas()) . "\nFROM            calendario\nWHERE           cal_eliminado IS NULL";
     list($root, $dom) = $this->parent_node($sql, $pagina_posicion);
     # GENERACION DE PAGINACION
     $sql = $this->get_sql_or_array();
     if ($this->get_debug_mode()) {
         debug($sql);
     }
     if ($this->get_total_reg()) {
         foreach ($this->get_registros($sql) as $registro) {
             if ($registro) {
                 $item = $root->appendChild($dom->createElement("row"));
                 $item->setAttribute("id", $registro["cal_id"]);
                 $cell = $item->appendChild($dom->createElement("cell"));
                 $cell->appendChild($dom->createTextNode(utf8_encode($registro["cal_fecha_inicio"])));
                 $cell = $item->appendChild($dom->createElement("cell"));
                 $cell->appendChild($dom->createTextNode(utf8_encode($registro["cal_fecha_fin"])));
                 $cell = $item->appendChild($dom->createElement("cell"));
                 $cell->appendChild($dom->createTextNode(utf8_encode($registro["cal_titulo"])));
                 $cell = $item->appendChild($dom->createElement("cell"));
                 $cell->appendChild($dom->createTextNode(utf8_encode($registro["cal_gal_id"])));
             }
         }
     }
     return $dom->saveXML();
 }
コード例 #19
0
 /**
  * Adds an error log to debug bar and log file
  * @static
  * @param Integer $errno error level (E_USER_xxx)
  * @param String $errstr Error message
  * @param String $errfile[optional] name of the file where error occurred - default: unknown
  * @param Integer $errline[optional] line number where error thrown - default: unknown
  * @return Boolean should always return true
  */
 static function error($errno, $errstr, $errfile = "unknown", $errline = "unknown")
 {
     switch ($errno) {
         case E_USER_ERROR:
             $error = '';
             $error .= '<p>A <b>Fatal Error</b> has occured.</p>';
             $error .= '<dl>';
             $error .= '<dt>' . $errstr . '</dt>';
             $error .= '<dd>' . $errfile . ' (' . $errline . ')</dd>';
             $error .= '</dl>';
             fatalError($error);
             break;
         case E_USER_WARNING:
             $type = 'warning';
             self::$error[] = array('type' => 'warning', 'file' => $errfile, 'line' => $errline, 'str' => $errstr);
             break;
         case E_USER_NOTICE:
             $type = 'notice';
             self::$error[] = array('type' => 'notice', 'file' => $errfile, 'line' => $errline, 'str' => $errstr);
             break;
         default:
             $type = $errno;
             self::$error[] = array('type' => $type, 'file' => $errfile, 'line' => $errline, 'str' => $errstr);
             break;
     }
     debug("------------- Error : " . $type . "--------------", 'error');
     debug("File : " . $errfile, 'error');
     debug("Line : " . $errline, 'error');
     debug("Message : " . $errstr, 'error');
     debug("----------------------------------------", 'error');
     return true;
 }
コード例 #20
0
ファイル: forms.php プロジェクト: vijo/writetothem
function add_all_variables_hidden_nonQF($variables)
{
    debug("SERIALIZE", "Writing hidden vars:", $variables);
    $ser_vars = base64_encode(serialize($variables));
    $html_hidden = '<input name="mysociety_serialized_variables" type="hidden" value="' . $ser_vars . '">';
    return $html_hidden;
}
コード例 #21
0
ファイル: Tool.php プロジェクト: ClMatthey/ArenaWeb
 public function releaseItem($idFighter)
 {
     $listTool = $this->find('all', array("conditions" => array("fighter_id" => $idFighter)));
     foreach ($listTool as $key => $values) {
         debug($values[$key]);
     }
 }
コード例 #22
0
 function get_all_taxa($resource_id)
 {
     $this->observers = self::get_observers();
     $this->activities = self::get_activities();
     self::get_associations();
     self::get_general_descriptions();
     self::prepare_common_names();
     echo "\n total: " . count($GLOBALS['taxon']) . "\n";
     $all_taxa = array();
     $i = 0;
     $total = count(array_keys($GLOBALS['taxon']));
     foreach ($GLOBALS['taxon'] as $taxon_name => $record) {
         $i++;
         if ($i % 100 == 0) {
             echo "\n{$i} of {$total} " . $taxon_name;
         }
         $record["taxon_name"] = $taxon_name;
         $arr = self::get_visitors_taxa($record);
         $page_taxa = $arr[0];
         if ($page_taxa) {
             $all_taxa = array_merge($all_taxa, $page_taxa);
         }
         unset($page_taxa);
     }
     $xml = \SchemaDocument::get_taxon_xml($all_taxa);
     $resource_path = CONTENT_RESOURCE_LOCAL_PATH . $resource_id . ".xml";
     if (!($OUT = fopen($resource_path, "w"))) {
         debug(__CLASS__ . ":" . __LINE__ . ": Couldn't open file: " . $resource_path);
         return;
     }
     fwrite($OUT, $xml);
     fclose($OUT);
     return $all_taxa;
     //used for testing
 }
コード例 #23
0
ファイル: bootstrap.php プロジェクト: TehTreag/cakepackages
function diebug($variables = false, $showHtml = true, $showFrom = true, $die = true)
{
    if (Configure::read() > 0) {
        if (is_array($showHtml)) {
            $showHtml = array_merge(array('showHtml' => true, 'showFrom' => true, 'die' => true), $showHtml);
            extract($showHtml);
        }
        if ($showFrom) {
            $calledFrom = debug_backtrace();
            echo '<strong>' . substr(str_replace(ROOT, '', $calledFrom[0]['file']), 1) . '</strong>';
            echo ' (line <strong>' . $calledFrom[0]['line'] . '</strong>)<br /><br />';
        }
        if (!is_array($variables)) {
            $variables = array($variables);
        }
        if ($showHtml) {
            App::import('Vendor', 'dBug', array('file' => 'dBug.php'));
            foreach ($variables as $key => $variable) {
                new dBug($variable);
                echo '<br />';
            }
        } else {
            foreach ($variables as $variable) {
                debug($var, $showHtml, $showFrom);
                echo '<br />';
            }
        }
        if ($die) {
            die;
        }
    }
}
function dwellings_run()
{
    checkday();
    page_header("Dwellings");
    global $session;
    $op = httpget("op");
    $dwid = httpget('dwid');
    $type = httpget('type');
    debug(get_module_pref("location_saver"));
    if ($type == "" && $dwid > 0) {
        $sql = "SELECT type FROM " . db_prefix("dwellings") . " WHERE dwid={$dwid}";
        $result = db_query($sql);
        $row = db_fetch_assoc($result);
        $type = $row['type'];
    }
    $cityid = httpget('cityid');
    require_once "modules/dwellings/run/case_{$op}.php";
    if ($op != "list" && $op != "") {
        addnav("Leave");
        addnav("Return to Hamlet", "runmodule.php?module=dwellings");
    } else {
        addnav("Navigation");
        villagenav();
    }
    page_footer();
}
コード例 #25
0
 public function testSetIdUser()
 {
     $user_id = 30;
     $this->api->setIdUser($user_id);
     $result = $this->assertEquals($user_id, $this->api->getIdUser());
     debug($result);
 }
コード例 #26
0
 protected function _request($path, $request = array())
 {
     // preparing request
     $request = Hash::merge($this->_request, $request);
     $request['uri']['path'] .= $path;
     if (isset($request['uri']['query'])) {
         $request['uri']['query'] = array_merge(array('access_token' => $this->_config['token']), $request['uri']['query']);
     } else {
         $request['uri']['query'] = array('access_token' => $this->_config['token']);
     }
     // createding http socket object for later use
     $HttpSocket = new HttpSocket(array('ssl_verify_host' => false));
     // issuing request
     $response = $HttpSocket->request($request);
     // olny valid response is going to be parsed
     if (substr($response->code, 0, 1) != 2) {
         if (Configure::read('debugApis')) {
             debug($request);
             debug($response->body);
             die;
         }
         return false;
     }
     // parsing response
     $results = $this->_parseResponse($response);
     if (isset($results['data'])) {
         return $results['data'];
     }
     return $results;
 }
コード例 #27
0
ファイル: module_lang.php プロジェクト: wborbajr/TecnodataApp
function lang($a = '', $b = '', $c = '')
{
    global $havelang, $Language, $CurrentLanguage;
    // see if the desired lang has the label.
    if (isset($Language[$CurrentLanguage])) {
        $label = $Language[$CurrentLanguage]->label($a, $b, $c);
    } else {
        debug("leeg lang: " . $CurrentLanguage);
    }
    //debug("label: $label (a=$a -- b=$b -- c=$c)");
    if ($label != "") {
        //return "{".$label."}";
        return $label;
    } else {
        //debug("not set: a=$a -- b=$b -- c=$c");
        // fall back on the english file
        if (isset($Language['eng'])) {
            $label = $Language['eng']->label($a, $b, $c);
        }
        if ($label != "") {
            //return "[".$label."]";
            return $label;
        } else {
            return "{$a} - {$b} - ({$c})";
        }
    }
}
コード例 #28
0
 function testRequestFile()
 {
     $data = array('hash' => 'f93b1cc0dd5b5a634ace4c662190a566', 'segments' => array(array(0, 119)), 'send' => true);
     $result = $this->testAction('/peers/request_file', array('data' => json_encode($data), 'method' => 'post'));
     Configure::write('debug', 1);
     debug(json_decode($result, true));
 }
コード例 #29
0
 public function __construct($argError, $argCode = NULL, $argPrevius = NULL)
 {
     // 書き換える前のエラーをロギングしておく
     logging($argError . PATH_SEPARATOR . var_export(debug_backtrace(), TRUE), 'exception');
     debug($argError);
     // 通常は500版のインターナルサーバエラー
     $msg = 'Internal Server Error';
     // RESTfulエラーコード&メッセージ定義
     if (400 === $argCode) {
         // バリデーションエラー等、必須パラメータの有無等の理由によるリクエスト自体の不正
         $msg = 'Bad Request';
     } elseif (401 === $argCode) {
         // ユーザー認証の失敗
         $msg = 'Unauthorized';
     } elseif (404 === $argCode) {
         // 許可されていない(もしくは未定義の)リソース(モデル)へのアクセス
         $msg = 'Not Found';
     } elseif (405 === $argCode) {
         // 許可されていない(もしくは未定義の)リソースメソッドの実行
         $msg = 'Method Not Allowed';
     } elseif (503 === $argCode) {
         // メンテナンスや制限ユーザー等の理由による一時利用の制限中
         $msg = 'Service Unavailable';
     }
     parent::__construct($msg, $argCode, $argPrevius);
 }
function game_stones_install()
{
    global $session;
    debug("Adding Hooks");
    module_addhook("darkhorsegame");
    return true;
}