/** * Create string representation * * @return string */ public function toString() { $args = array(); if (isset($this->args)) { for ($j = 0, $a = sizeof($this->args); $j < $a; $j++) { if (is_array($this->args[$j])) { $args[] = 'array[' . sizeof($this->args[$j]) . ']'; } else { if (is_object($this->args[$j])) { $args[] = $this->qualifiedClassName(get_class($this->args[$j])) . '{}'; } else { if (is_string($this->args[$j])) { $display = str_replace('%', '%%', addcslashes(substr($this->args[$j], 0, min(FALSE === ($p = strpos($this->args[$j], "\n")) ? 0x40 : $p, 0x40)), "..")); $args[] = '(0x' . dechex(strlen($this->args[$j])) . ")'" . $display . "'"; } else { if (is_null($this->args[$j])) { $args[] = 'NULL'; } else { if (is_scalar($this->args[$j])) { $args[] = (string) $this->args[$j]; } else { if (is_resource($this->args[$j])) { $args[] = (string) $this->args[$j]; } else { $args[] = '<' . gettype($this->args[$j]) . '>'; } } } } } } } } return sprintf(" at %s::%s(%s) [line %d of %s] %s\n", isset($this->class) ? $this->qualifiedClassName($this->class) : '<main>', isset($this->method) ? $this->method : '<main>', implode(', ', $args), $this->line, basename(isset($this->file) ? $this->file : __FILE__), $this->message); }
public function search(\GoRemote\Application $app, $query) { $searchQuery = '%' . addcslashes($query, "%_") . '%'; //select * from jobs inner join companies using(companyid) inner join sources using(sourceid) where match(companies.name, sources.name, jobs.position, jobs.description) against ('php' IN NATURAL LANGUAGE MODE); $jobs = $app['db']->fetchAll("select jobs.*, unix_timestamp(jobs.dateadded) as dateadded_unixtime, companies.name as companyname, companies.url as companyurl, sources.name as sourcename, sources.url as sourceurl from jobs \n inner join companies using(companyid) \n inner join sources using(sourceid) \n where jobs.dateadded > UTC_TIMESTAMP() - INTERVAL 2 MONTH\n and jobs.datedeleted=0 \n\tand jobs.position <> '' \n and (\n companies.name like ? or \n jobs.position like ? or \n jobs.description like ?\n )\n order by jobs.dateadded desc limit 80", [$searchQuery, $searchQuery, $searchQuery]); return $jobs; }
public static function doConvert(array $data, array $parent = array()) { $output = ''; foreach ($data as $k => $v) { $index = str_replace(' ', '-', $k); if (is_array($v)) { $sec = array_merge((array) $parent, (array) $index); $output .= PHP_EOL . '[' . join('.', $sec) . ']' . PHP_EOL; $output .= self::doConvert($v, $sec); } else { $output .= "{$index}="; if (is_numeric($v) || is_float($v)) { $output .= "{$v}"; } elseif (is_bool($v)) { $output .= $v === true ? 1 : 0; } elseif (is_string($v)) { $output .= "'" . addcslashes($v, "'") . "'"; } else { $output .= "{$v}"; } $output .= PHP_EOL; } } return $output; }
public function set($config_id, $data) { if (!$data || !is_array($data)) { throw new Zend_Exception('config data type error'); } $content = "<?php\n\n"; foreach ($data as $key => $val) { if (is_array($val)) { $content .= "\$config['{$key}'] = " . var_export($val, true) . ";"; } else { if (is_bool($val)) { $content .= "\$config['{$key}'] = " . ($val ? 'true' : 'false') . ";"; } else { $content .= "\$config['{$key}'] = '" . addcslashes($val, "'") . "';"; } } $content .= "\r\n"; } $config_path = AWS_PATH . 'config/' . $config_id . '.php'; $fp = @fopen($config_path, "w"); @chmod($config_path, 0777); $fwlen = @fwrite($fp, $content); @fclose($fp); return $fwlen; }
/** * {@inheritDoc} */ public function format($string) { static $format = <<<EOF package main import "fmt" import "github.com/russross/blackfriday" func main() { input := []byte("%s") output := blackfriday.MarkdownCommon(input) fmt.Printf(string(output[:])) } EOF; $input = tempnam(sys_get_temp_dir(), 'fabricius_blackfriday'); $input .= '.go'; file_put_contents($input, sprintf($format, addcslashes($string, "\n\""))); $pb = new ProcessBuilder(array($this->goBin, 'run', $input)); $proc = $pb->getProcess(); $code = $proc->run(); unlink($input); if (0 !== $code) { $message = sprintf("An error occurred while running:\n%s", $proc->getCommandLine()); $errorOutput = $proc->getErrorOutput(); if (!empty($errorOutput)) { $message .= "\n\nError Output:\n" . str_replace("\r", '', $errorOutput); } $output = $proc->getOutput(); if (!empty($output)) { $message .= "\n\nOutput:\n" . str_replace("\r", '', $output); } throw new RuntimeException($message); } return $proc->getOutput(); }
function render_comment_json($subject, $zid, $time, $cid, $body) { global $can_moderate; global $auth_zid; $score = get_comment_score($cid); $rid = -1; if ($can_moderate) { $row = run_sql("select rid from comment_vote where cid = ? and zid = ?", array($cid, $auth_zid)); if (count($row) == 0) { $rid = 0; } else { $rid = $row[0]["rid"]; } } $s = "\$level{\n"; $s .= "\$level\t\"cid\": {$cid},\n"; $s .= "\$level\t\"zid\": \"{$zid}\",\n"; $s .= "\$level\t\"time\": {$time},\n"; $s .= "\$level\t\"score\": \"{$score}\",\n"; $s .= "\$level\t\"rid\": {$rid},\n"; $s .= "\$level\t\"subject\": \"" . addcslashes($subject, "\\\"") . "\",\n"; $s .= "\$level\t\"comment\": \"" . addcslashes($body, "\\\"") . "\",\n"; $s .= "\$level\t\"reply\": [\n"; return $s; }
/** * {@inheritdoc} */ public function find($ip, $url, $limit, $method, $start = NULL, $end = NULL) { $select = $this->database->select('webprofiler', 'wp', ['fetch' => \PDO::FETCH_ASSOC]); if (NULL === $start) { $start = 0; } if (NULL === $end) { $end = time(); } if ($ip = preg_replace('/[^\\d\\.]/', '', $ip)) { $select->condition('ip', '%' . $this->database->escapeLike($ip) . '%', 'LIKE'); } if ($url) { $select->condition('url', '%' . $this->database->escapeLike(addcslashes($url, '%_\\')) . '%', 'LIKE'); } if ($method) { $select->condition('method', $method); } if (!empty($start)) { $select->condition('time', $start, '>='); } if (!empty($end)) { $select->condition('time', $end, '<='); } $select->fields('wp', ['token', 'ip', 'method', 'url', 'time', 'parent']); $select->orderBy('time', 'DESC'); $select->range(0, $limit); return $select->execute()->fetchAllAssoc('token'); }
function usesubmit() { global $_G; $list = $uids = array(); $num = !empty($this->parameters['num']) ? intval($this->parameters['num']) : 10; $limit = $num + 20; $giftMagicID = C::t('common_magic')->fetch_by_identifier('gift'); $mid = $giftMagicID['available'] ? intval($giftMagicID['magicid']) : 0; if ($mid) { foreach (C::t('common_magiclog')->fetch_all_by_magicid_action_uid($mid, 2, $_G['uid'], 0, $limit) as $value) { $uids[] = intval($value['uid']); } } if ($uids) { $counter = 0; $members = C::t('common_member')->fetch_all($uids); foreach (C::t('common_member_field_home')->fetch_all($uids) as $uid => $value) { $value = array_merge($members[$uid], $value); $info = !empty($value['magicgift']) ? unserialize($value['magicgift']) : array(); if (!empty($info['left']) && (empty($info['receiver']) || !in_array($_G['uid'], $info['receiver']))) { $value['avatar'] = addcslashes(avatar($uid, 'small'), "'"); $list[$uid] = $value; $counter++; if ($counter >= $num) { break; } } } } usemagic($this->magic['magicid'], $this->magic['num']); updatemagiclog($this->magic['magicid'], '2', '1', '0', '0', 'uid', $_G['uid']); $op = 'show'; include template('home/magic_detector'); }
/** * init * * Establishes base settings for making recommendations. * * @param string $settings Settings from config.ini * @param \VuFind\RecordDriver\AbstractBase $driver Record driver object * * @return void */ public function init($settings, $driver) { // If we have query parts, we should try to find related records: $parts = $this->getQueryParts($driver); if (!empty($parts)) { // Limit the number of parts based on the boolean clause limit: $sm = $this->getSearchManager(); $params = $sm->setSearchClassId('Solr')->getParams(); $limit = $params->getQueryIDLimit(); if (count($parts) > $limit) { $parts = array_slice($parts, 0, $limit); } // Assemble the query parts and filter out current record if it comes // from the Solr index.: $query = '(' . implode(' OR ', $parts) . ')'; if ($driver->getResourceSource() == 'VuFind') { $query .= ' NOT id:"' . addcslashes($driver->getUniqueID(), '"') . '"'; } // Perform the search and return either results or an error: $params->setLimit(5); $params->setOverrideQuery($query); $result = $sm->setSearchClassId('Solr')->getResults($params); $this->results = $result->getResults(); } }
public static function ToSql($field, $oper, $val) { // we need here more advanced checking using the type of the field - i.e. integer, string, float switch ($field) { case 'id': return intval($val); break; case 'amount': case 'tax': case 'total': return floatval($val); break; default: //mysql_real_escape_string is better if ($oper == 'bw' || $oper == 'bn') { return "'" . addslashes($val) . "%'"; } else { if ($oper == 'ew' || $oper == 'en') { return "'%" . addcslashes($val) . "'"; } else { if ($oper == 'cn' || $oper == 'nc') { return "'%" . addslashes($val) . "%'"; } else { return "'" . addslashes($val) . "'"; } } } } }
/** * @Route("/grid", name="lc_admin_person_grid") * @Template() */ public function gridAction(Request $request) { $form = $this->createForm(new PersonFilterFormType()); $form->handleRequest($request); $result['grid'] = null; if ($form->isValid()) { $em = $this->getDoctrine()->getManager(); $sql = $em->createQueryBuilder(); $sql->select('u'); $sql->from('PROCERGSLoginCidadaoCoreBundle:Person', 'u'); $sql->where('1=1'); $parms = $form->getData(); if (isset($parms['username'][0])) { $sql->andWhere('u.cpf like ?1 or LowerUnaccent(u.username) like LowerUnaccent(?1) or LowerUnaccent(u.email) like LowerUnaccent(?1) or LowerUnaccent(u.firstName) like LowerUnaccent(?1) or LowerUnaccent(u.surname) like LowerUnaccent(?1)'); $sql->setParameter('1', '%' . addcslashes($parms['username'], '\\%_') . '%'); } $sql->addOrderBy('u.id', 'desc'); $grid = new GridHelper(); $grid->setId('person-grid'); $grid->setPerPage(5); $grid->setMaxResult(5); $grid->setQueryBuilder($sql); $grid->setInfiniteGrid(true); $grid->setRoute('lc_admin_person_grid'); $grid->setRouteParams(array($form->getName())); return array('grid' => $grid->createView($request)); } return $result; }
function searchkey($keyword, $field, $returnsrchtxt = 0) { $srchtxt = ''; if ($field && $keyword) { if (preg_match("(AND|\\+|&|\\s)", $keyword) && !preg_match("(OR|\\|)", $keyword)) { $andor = ' AND '; $keywordsrch = '1'; $keyword = preg_replace("/( AND |&| )/is", "+", $keyword); } else { $andor = ' OR '; $keywordsrch = '0'; $keyword = preg_replace("/( OR |\\|)/is", "+", $keyword); } $keyword = str_replace('*', '%', addcslashes($keyword, '%_')); $srchtxt = $returnsrchtxt ? $keyword : ''; foreach (explode('+', $keyword) as $text) { $text = trim(daddslashes($text)); if ($text) { $keywordsrch .= $andor; $keywordsrch .= str_replace('{text}', $text, $field); } } $keyword = " AND ({$keywordsrch})"; } return $returnsrchtxt ? array($srchtxt, $keyword) : $keyword; }
/** * @param resource $pipe * @since Method available since Release 3.5.12 */ protected function process($pipe, $job) { if (!($this->tempFile = tempnam(sys_get_temp_dir(), 'PHPUnit')) || file_put_contents($this->tempFile, $job) === FALSE) { throw new PHPUnit_Framework_Exception('Unable to write temporary files for process isolation.'); } fwrite($pipe, "<?php require_once '" . addcslashes($this->tempFile, "'") . "'; ?>"); }
private function toXmlValue($a_key, $a_value) { switch (gettype($a_value)) { default: return makePair($a_key, $a_value); case 'string': if (preg_match("/\\n\\r\\t/i", $a_value)) { return $this->makePair($a_key, '<![CDATA[' . $a_value . ']]>'); } return $this->makePair($a_key, addcslashes($a_value, "\n\r\t\"")); case 'array': $o = null; foreach ($a_value as $k => $v) { $o .= $this->toXmlValue($k, $v); } return $this->makePair($a_key, $o); case 'object': $o = null; foreach (get_object_vars($a_value) as $k => $v) { $o .= $this->toXmlValue($k, $v); } return $this->makePair($a_key, $o); } return null; }
/** * Converts an object into a php class string. * - NOTE: Only one depth level is supported. * * @param object $object Data Source Object * @param array $params Parameters used by the formatter * * @return string Config class formatted string * * @since 1.0 */ public function objectToString($object, $params = array()) { // Build the object variables string $vars = ''; foreach (get_object_vars($object) as $k => $v) { if (is_scalar($v)) { $vars .= "\tpublic \$" . $k . " = '" . addcslashes($v, '\\\'') . "';\n"; } elseif (is_array($v) || is_object($v)) { $vars .= "\tpublic \$" . $k . " = " . $this->getArrayString((array) $v) . ";\n"; } } $str = "<?php\n"; // If supplied, add a namespace to the class object if (isset($params['namespace']) && $params['namespace'] != '') { $str .= "namespace " . $params['namespace'] . ";\n\n"; } $str .= "class " . $params['class'] . " {\n"; $str .= $vars; $str .= "}"; // Use the closing tag if it not set to false in parameters. if (!isset($params['closingtag']) || $params['closingtag'] !== false) { $str .= "\n?>"; } return $str; }
/** * Converts an object into a php class string. * - NOTE: Only one depth level is supported. * * @param object $object Data Source Object * @param array $params Parameters used by the formatter * * @throws \InvalidArgumentException * @return string Config class formatted string */ public static function objectToString($object, $params = array()) { $header = RegistryHelper::getValue($params, 'header'); // Build the object variables string $vars = ""; foreach (get_object_vars($object) as $k => $v) { if (is_scalar($v)) { $vars .= sprintf("\t'%s' => '%s',\n", $k, addcslashes($v, '\\\'')); } elseif (is_array($v) || is_object($v)) { $vars .= sprintf("\t'%s' => %s,\n", $k, static::getArrayString((array) $v)); } } $str = "<?php\n"; if ($header) { $str .= $header . "\n"; } $str .= "\nreturn array(\n"; $str .= $vars; $str .= ");\n"; // Use the closing tag if it not set to false in parameters. if (RegistryHelper::getValue($params, 'closingtag', false)) { $str .= "\n?>"; } return $str; }
function createData() { $this->supportCached(true); $module = getModuleBySection($this->section); $idcat = (int) $this->params['idcat']; $cpath = array(); if ($this->section == SECTION && A::$MAINFRAME->idcat > 0) { $catrow = A::$DB->getRowById(A::$MAINFRAME->idcat, "{$this->section}_categories"); $this->Assign("category", $catrow); $cpath[] = $catrow['id']; while ($catrow && $catrow['idker'] > 0) { $cpath[] = $catrow['idker']; $catrow = A::$DB->getRowById($catrow['idker'], "{$this->section}_categories"); } } $categories = array(); A::$DB->query("SELECT id,idker,name FROM {$this->section}_categories ORDER BY level,sort"); while ($row = A::$DB->fetchRow()) { $row['name'] = addcslashes($row['name'], "'"); $row['link'] = call_user_func($module . "_createCategoryLink", $row['id'], $this->section); $row['selected'] = $this->section == SECTION && in_array($row['id'], $cpath); $categories[] = $row; } A::$DB->free(); $this->Assign("categories", $categories); }
/** * Creates a single quoted string that can be put into javascript variables. * @param string $string The input string * @param boolean $htmlEncode True if string shall be html encoded, first * @return string */ static function ToJavascript($string, $htmlEncode = true) { if ($htmlEncode) { $string = self::ToHtml($string); } return '\'' . addcslashes($string, "'\r\n\\") . '\''; }
public function BgForm() { $this->value = array_shift(array_reverse(array_unique($this->value))); // оставляем уникальные значения масива, переварачиваем, извлекаем первый. + экранируем от пробелов $this->value = addcslashes($this->value, ' '); return true; }
function ToSql($field, $oper, $val) { // we need here more advanced checking using the type of the field - i.e. integer, string, float switch ($field) { case 'id': return intval($val); break; case 'amount': case 'tax': case 'total': return floatval($val); break; case 'invdate': $arrDateVal = explode("/", $val); return '\'' . $arrDateVal[2] . '-' . $arrDateVal[0] . '-' . $arrDateVal[1] . '\''; // reformat date to: Y-m-d break; default: //mysql_real_escape_string is better if ($oper == 'bw' || $oper == 'bn') { return "'" . addslashes($val) . "%'"; } else { if ($oper == 'ew' || $oper == 'en') { return "'%" . addcslashes($val) . "'"; } else { if ($oper == 'cn' || $oper == 'nc') { return "'%" . addslashes($val) . "%'"; } else { return "'" . addslashes($val) . "'"; } } } } }
function go_get_campaigns($ifNotPage) { $groupId = $this->go_get_groupid(); $base = base_url(); if (!$this->commonhelper->checkIfTenant($groupId)) { $ul = ''; } else { $ul = "WHERE user_group='{$groupId}'"; } $page = !$ifNotPage ? $this->uri->segment(3) : 1; if ((is_numeric($page) || $page == 'ALL') && !is_null($this->uri->segment(4)) && strlen($this->uri->segment(4)) > 2) { $search = addcslashes(mysql_real_escape_string($this->uri->segment(4)), "%"); if (strlen($search) > 0) { $addedSQL = "(campaign_id RLIKE '{$search}' OR campaign_name RLIKE '{$search}')"; } $addedSQL = strlen($ul) < 1 ? "WHERE {$addedSQL}" : "AND {$addedSQL}"; } //$addedSQL = ''; $query = $this->db->query("SELECT count(*) AS cnt FROM vicidial_campaigns {$ul} {$addedSQL};"); $total = $query->row()->cnt; $limit = 5; $rp = $this->uri->segment(3) == 'ALL' ? $total : 25; if (is_null($page) || $page < 1 || !is_numeric($page)) { $page = 1; } $start = ($page - 1) * $rp; $return['pagelinks'] = $this->pagelinks($groupId, $page, $rp, $total, $limit); $query = $this->db->query("SELECT campaign_id,campaign_name,active,dial_method,auto_dial_level FROM vicidial_campaigns {$ul} {$addedSQL} ORDER BY campaign_id limit {$start},{$rp};"); $return['list'] = $query->result(); return $return; }
/** * var_export clone, without using output buffering. * (For calls in ob_handler) * * @param mixed $var to be exported * @param integer $maxLevel (recursion protect) * @param integer $level of current indent * @return string */ public static function varExport($var, $maxLevel = 10, $level = 0) { $escapes = "\"\r\t\$"; $tab = ' '; if (is_bool($var)) { return $var ? 'TRUE' : 'FALSE'; } elseif (is_string($var)) { return '"' . addcslashes($var, $escapes) . '"'; } elseif (is_float($var) || is_int($var)) { return $var; } elseif (is_null($var)) { return 'NULL'; } elseif (is_resource($var)) { return 'NULL /* ' . $var . ' */'; } if ($maxLevel < $level) { return 'NULL /* ' . (string) $var . ' MAX LEVEL ' . $maxLevel . " REACHED*/"; } if (is_array($var)) { $return = "array(\n"; } else { $return = get_class($var) . "::__set_state(array(\n"; } $offset = str_repeat($tab, $level + 1); foreach ((array) $var as $key => $value) { $return .= $offset; if (is_int($key)) { $return .= $key; } else { $return .= '"' . addcslashes($key, $escapes) . '"'; } $return .= ' => ' . self::varExport($value, $maxLevel, $level + 1) . ",\n"; } return $return . str_repeat($tab, $level) . (is_array($var) ? ')' : '))'); }
/** * MailInfo constructor */ function MailInfo() { global $application; $MR =& $application->getInstance('MessageResources'); //initialize form data with null values when adding a new notification $this->currentNotificationId = modApiFunc("Notifications", "getCurrentNotificationId"); if ($this->currentNotificationId == 'Add') { $this->notificationInfo = array('Id' => '', 'Name' => '', 'Subject' => '', 'Body' => '', 'JavascriptBody' => '', 'From_addr' => '', 'Email_Code' => '', 'Active' => 'checked', 'Action_id' => 1); $request = new Request(); $request->setView('NotificationInfo'); $request->setAction('AddNotification'); $formAction = $request->getURL(); $this->properties = array('SubmitButton' => $MR->getMessage('BTN_ADD'), 'FormAction' => $formAction); } else { //initialize form data with database values when editing the notification $this->notificationInfo = modApiFunc("Notifications", "getNotificationInfo", $this->currentNotificationId); if (sizeof($this->notificationInfo) == 1) { $this->notificationInfo = $this->notificationInfo[0]; $this->notificationInfo['JavascriptBody'] = addcslashes(addslashes($this->notificationInfo['Body']), ".."); $this->notificationInfo['Body'] = prepareHTMLDisplay($this->notificationInfo['Body']); } else { $this->currentNotificationId = 'Add'; $this->notificationInfo = array('Id' => '', 'Name' => '', 'Subject' => '', 'Body' => '', 'JavascriptBody' => '', 'From_addr' => '', 'Email_Code' => '', 'Active' => 'checked', 'Action_id' => 1); } $request = new Request(); $request->setView('NotificationInfo'); $request->setAction('SaveNotification'); $formAction = $request->getURL(); $this->properties = array('SubmitButton' => $MR->getMessage('BTN_SAVE'), 'FormAction' => $formAction); } $this->actionsList = modApiFunc("Notifications", "getActionsList"); $this->InfoTags = modApiFunc("Notifications", "getAvailableTagsList", $this->actionsList); }
function create_graph($a, $b) { // 2. matching $count = 0; $gml = "graph [\ncomment \"Matching\"\ndirected 1\n# First set of labels\n"; foreach ($a as $str) { $gml .= "node [ id {$count} label \"" . addcslashes($str, '"') . "\" ]\n"; $count++; } $gml .= "# Second set of labels\n"; foreach ($b as $str) { $gml .= "node [ id {$count} label \"" . addcslashes($str, '"') . "\" ]\n"; $count++; } $m = count($a); $n = count($b); for ($i = 0; $i < $m; $i++) { for ($j = 0; $j < $n; $j++) { $gml .= "edge [ source {$i} target " . ($m + $j) . " label \"" . floor(100 * compare($a[$i], $b[$j])) . "\" ]\n"; } } $gml .= "]\n"; /* echo '<pre>'; echo $gml; echo '</pre>'; */ return $gml; }
public function index($setting = false) { if (!$setting || !$this->config->get('tracking_input_status') || $setting['language_id'] != $this->config->get('config_language_id') || isset($this->session->data['tracking_input_show']) && !$this->session->data['tracking_input_show'] || $this->config->get('tracking_input_no_cookie_only') && (isset($this->request->request['tracking']) || isset($this->request->cookie['tracking'])) || $this->config->get('tracking_input_show') == 'once' && isset($this->request->cookie['__octfsh__']) && (!isset($this->session->data['tracking_input_show']) || !$this->session->data['tracking_input_show'])) { return ''; } $this->document->addScript('catalog/view/javascript/triyp.min.js'); //$this->document->addScript('catalog/view/javascript/triyp.js'); $this->session->data['tracking_input_show'] = true; if ($this->config->get('tracking_input_show') == 'once') { setcookie('__octfsh__', '1', time() + 2592000, '/'); } $data['show_close_button'] = $this->config->get('tracking_input_show_close_button'); $data['image_close'] = file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/image/close.png') ? 'catalog/view/theme/' . $this->config->get('config_template') . '/image/close.png' : 'catalog/view/theme/default/image/close.png'; $data['image_loading'] = file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/image/loading.gif') ? 'catalog/view/theme/' . $this->config->get('config_template') . '/image/loading.gif' : 'catalog/view/theme/default/image/loading.gif'; $data['send_link'] = html_entity_decode($this->url->link('module/tracking_input/send', '', isset($this->request->server['HTTPS']) && $this->request->server['HTTPS'] == 'on' ? 'SSL' : 'NONSSL'), ENT_QUOTES, 'UTF-8'); $data['close_link'] = html_entity_decode($this->url->link('module/tracking_input/close', '', isset($this->request->server['HTTPS']) && $this->request->server['HTTPS'] == 'on' ? 'SSL' : 'NONSSL'), ENT_QUOTES, 'UTF-8'); $data['text_thankyou'] = isset($setting['text_thankyou']) && utf8_strlen($setting['text_thankyou']) > 0 ? addcslashes(str_replace(array("\r\n", "\n", "\r"), array(' ', ' ', ' '), html_entity_decode($setting['text_thankyou'], ENT_QUOTES, 'UTF-8')), "'") : ''; $data['error_message'] = isset($setting['error_message']) && utf8_strlen($setting['error_message']) > 0 ? addcslashes(str_replace(array("\r\n", "\n", "\r"), array(' ', ' ', ' '), html_entity_decode($setting['error_message'], ENT_QUOTES, 'UTF-8')), "'") : ''; $data['json'] = array(); foreach (array('send_link', 'close_link', 'text_thankyou', 'error_message') as $_v) { $data['json'][$_v] = $data[$_v]; } $data['json'] = json_encode($data['json']); $data['text_message'] = html_entity_decode($setting['text'], ENT_QUOTES, 'UTF-8'); $data['text_heading'] = html_entity_decode($setting['text_heading'], ENT_QUOTES, 'UTF-8'); $data['send_button'] = $setting['button']; $this->language->load('affiliate/tracking_input'); $data['text_loading'] = $this->language->get('text_please_wait'); $_tpl = '/template/module/tracking_input_' . (isset($setting['template']) ? $setting['template'] : 'default_' . (substr($setting['position'], 0, 3) === 'col' ? 'column' : 'row')) . '.tpl'; $_tpl = (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . $_tpl) ? $this->config->get('config_template') : 'default') . $_tpl; return $this->load->view($_tpl, $data); }
function dumpData($table, $style, $query) { if ($_POST["format"] == "json") { if ($this->database) { echo ",\n"; } else { $this->database = true; echo "{\n"; register_shutdown_function(array($this, '_database')); } $connection = connection(); $result = $connection->query($query, 1); if ($result) { echo '"' . addcslashes($table, "\r\n\"\\") . "\": [\n"; $first = true; while ($row = $result->fetch_assoc()) { echo $first ? "" : ", "; $first = false; foreach ($row as $key => $val) { json_row($key, $val); } json_row(""); } echo "]"; } return true; } }
/** * {@inheritdoc} */ protected function buildCriteria($ip, $url, $start, $end, $limit, $method) { $criteria = array(); $args = array(); if ($ip = preg_replace('/[^\\d\\.]/', '', $ip)) { $criteria[] = 'ip LIKE :ip'; $args[':ip'] = '%' . $ip . '%'; } if ($url) { $criteria[] = 'url LIKE :url'; $args[':url'] = '%' . addcslashes($url, '%_\\') . '%'; } if ($method) { $criteria[] = 'method = :method'; $args[':method'] = $method; } if (!empty($start)) { $criteria[] = 'time >= :start'; $args[':start'] = $start; } if (!empty($end)) { $criteria[] = 'time <= :end'; $args[':end'] = $end; } return array($criteria, $args); }
protected function writeReal( MessageCollection $collection ) { if ( isset( $this->extra['header'] ) ) { $output = $this->extra['header']; } else { $output = "<?php\n"; } $output .= $this->doHeader( $collection ); $mangler = $this->group->getMangler(); foreach ( $collection as $item ) { $key = $mangler->unmangle( $item->key() ); $key = stripcslashes( $key ); $value = $item->translation(); if ( $value === null ) { continue; } $value = str_replace( TRANSLATE_FUZZY, '', $value ); $value = addcslashes( $value, "'" ); $output .= "\$$key = '$value';\n"; } return $output; }
function cht_message_parse($msg, $escaped = false, $author_auth = 0) { global $supernova, $config; // $user_auth_level = isset($user['authlevel']) ? $user['authlevel'] : AUTH_LEVEL_ANONYMOUS; $msg = htmlentities($msg, ENT_COMPAT, 'UTF-8'); $msg = str_replace('sn://', SN_ROOT_VIRTUAL, $msg); !empty($config->url_faq) ? $msg = str_replace('faq://', $config->url_faq, $msg) : false; foreach ($supernova->design['bbcodes'] as $auth_level => $replaces) { if ($auth_level > $author_auth) { continue; } foreach ($replaces as $key => $html) { $msg = preg_replace('' . $key . '', $html, $msg); } } foreach ($supernova->design['smiles'] as $auth_level => $replaces) { if ($auth_level > $author_auth) { continue; } foreach ($replaces as $key => $imgName) { $msg = preg_replace("#" . addcslashes($key, '()[]{}') . "#isU", "<img src=\"design/images/smileys/" . $imgName . ".gif\" align=\"absmiddle\" title=\"" . $key . "\" alt=\"" . $key . "\">", $msg); } } return str_replace($escaped ? '\\r\\n' : "\r\n", '<br />', $msg); }
/** * encode data for dataTable plugin. * @deprecated * * @param array $params * Associated array of row elements. * @param int $sEcho * Datatable needs this to make it more secure. * @param int $iTotal * Total records. * @param int $iFilteredTotal * Total records on a page. * @param array $selectorElements * Selector elements. * @return string */ public static function encodeDataTableSelector($params, $sEcho, $iTotal, $iFilteredTotal, $selectorElements) { $sOutput = '{'; $sOutput .= '"sEcho": ' . intval($sEcho) . ', '; $sOutput .= '"iTotalRecords": ' . $iTotal . ', '; $sOutput .= '"iTotalDisplayRecords": ' . $iFilteredTotal . ', '; $sOutput .= '"aaData": [ '; foreach ($params as $key => $value) { $addcomma = FALSE; $sOutput .= "["; foreach ($selectorElements as $element) { if ($addcomma) { $sOutput .= ","; } //CRM-7130 --lets addslashes to only double quotes, //since we are using it to quote the field value. //str_replace helps to provide a break for new-line $sOutput .= '"' . addcslashes(str_replace(array("\r\n", "\n", "\r"), '<br />', $value[$element]), '"\\') . '"'; //remove extra spaces and tab character that breaks dataTable CRM-12551 $sOutput = preg_replace("/\\s+/", " ", $sOutput); $addcomma = TRUE; } $sOutput .= "],"; } $sOutput = substr_replace($sOutput, "", -1); $sOutput .= '] }'; return $sOutput; }