/** * get list of users with access to the file * * @param string $path to the file * @return array */ public function getAccessList($path) { // Make sure that a share key is generated for the owner too list($owner, $ownerPath) = $this->util->getUidAndFilename($path); // always add owner to the list of users with access to the file $userIds = array($owner); if (!$this->util->isFile($ownerPath)) { return array('users' => $userIds, 'public' => false); } $ownerPath = substr($ownerPath, strlen('/files')); $ownerPath = $this->util->stripPartialFileExtension($ownerPath); // Find out who, if anyone, is sharing the file $result = \OCP\Share::getUsersSharingFile($ownerPath, $owner); $userIds = \array_merge($userIds, $result['users']); $public = $result['public'] || $result['remote']; // check if it is a group mount if (\OCP\App::isEnabled("files_external")) { $mounts = \OC_Mount_Config::getSystemMountPoints(); foreach ($mounts as $mount) { if ($mount['mountpoint'] == substr($ownerPath, 1, strlen($mount['mountpoint']))) { $mountedFor = $this->util->getUserWithAccessToMountPoint($mount['applicable']['users'], $mount['applicable']['groups']); $userIds = array_merge($userIds, $mountedFor); } } } // Remove duplicate UIDs $uniqueUserIds = array_unique($userIds); return array('users' => $uniqueUserIds, 'public' => $public); }
function createApp($appName, $orgName) { Util::throwExceptionIfNullOrBlank($appName, "App Name"); Util::throwExceptionIfNullOrBlank($orgName, "orgName"); $objUtil = new Util($this->apiKey, $this->secretKey); try { $params = array(); $params['apiKey'] = $this->apiKey; $params['version'] = $this->version; date_default_timezone_set('UTC'); $params['timeStamp'] = date("Y-m-d\\TG:i:s") . substr((string) microtime(), 1, 4) . "Z"; $params['App Name'] = $appName; $params['orgName'] = $orgName; $signature = urlencode($objUtil->sign($params)); //die(); $body = null; $body = '{"app42":{"app":}}'; $params['body'] = $body; $params['signature'] = $signature; $contentType = $this->content_type; $accept = $this->accept; $this->url = $this->url; $response = RestClient::post($this->url, $params, null, null, $contentType, $accept, $body); } catch (App42Exception $e) { throw $e; } catch (Exception $e) { throw new App42Exception($e); } return $response; }
/** * A method to check if an email exists * * @param {String} [$email] - must be valid email * * @return boolean */ public function emailExists($email) { $u = new Util(); $db = new DB($u->getDBConfig()); $stmt = $db->getDb()->prepare("SELECT * FROM users WHERE email = :email"); $stmt->bindParam(':email', $email, PDO::PARAM_STR); $stmt->execute(); if ($stmt->rowCount() > 0) { return false; } return true; }
/** * 向网站提交数据 */ public function commitFile() { $starttime = date('Y-m-d H:i:s'); $util = new \Util(); $res = $util->commitData(); // var_dump($res); $endtime = date('Y-m-d H:i:s'); $this->assign('starttime', $starttime); $this->assign('endtime', $endtime); $this->assign('list', $res); $this->assign('count', count($res)); $this->display(); }
public function cadastrarAction() { $ct = new Categoria(); $ut = new Util(); $user = My_Auth::getInstance('Painel')->getStorage()->read(); $request = $this->getRequest(); if ($request->isPost()) { $pt = new Postagem(); $erro = false; $msg = ''; $now = $ut->nowDateSql(); $pt->setTitulo($request->getPost('titulo')); $pt->setPostagem($request->getPost('postagem')); $pt->setCagegoriaId($request->getPost('categoria_id')); $pt->setUsuarioId($user->id); $pt->setPostadoem($now); $pt->setTags($request->getPost('tags')); $pt->setAlteradoem($now); $data = array('titulo' => $pt->getTitulo(), 'postagem' => $pt->getPostagem(), 'categoria_id' => $pt->getCagegoriaId(), 'usuario_id' => $pt->getUsuarioId(), 'postadoem' => $pt->getPostadoem(), 'tags' => $pt->getTags(), 'alteradoem' => $pt->getAlteradoem()); if ($postagem_id = $pt->savePostagem($data)) { if ($request->getPost('image_data')) { $imageName = time() . '_saved.jpg'; //$imagem = json_decode($request->getPost('image_data')); $base64 = base64_decode(preg_replace('#^data:image/[^;]+;base64,#', '', $request->getPost('image_data'))); //base64_decode(preg_replace('#^data:image/[^;]+;base64,#', '', $_POST['imagem'])); // create image $source = imagecreatefromstring($base64); if (!file_exists(ROOT_DIR . DS . 'site' . DS . 'images' . DS . 'blog' . DS . $postagem_id)) { mkdir(ROOT_DIR . DS . 'site' . DS . 'images' . DS . 'blog' . DS . $postagem_id, 0777, true); } $url = ROOT_DIR . DS . 'site' . DS . 'images' . DS . 'blog' . DS . $postagem_id . DS . $imageName; imagejpeg($source, $url, 100); $pt->setImagem($imageName); $data = array('imagem' => $pt->getImagem()); if (!$pt->savePostagem($data, $postagem_id)) { $erro = true; } } } else { $erro = true; } if ($erro) { $msg = 'Ocorreu um erro, tente novamente'; $this->view->msg = $msg; } else { $this->_helper->redirector('listar', 'postagens'); } } $this->view->categorias = $ct->getAllCategoria(); $this->render(); }
function HistorySpec($query) { $util = new Util(); $myDateToday = $util->dateTodaySQL(); $queryMYSQL = new QueryMYSQL(); //cherche le dernier groupe $queryMaxGroup = "select max(GROUPE) `maxGROUPE` from HISTORIQUE"; echo $queryMaxGroup . "<br/>"; $arrayMax = $queryMYSQL->select_n($queryMaxGroup); $groupe = $arrayMax[0]["maxGROUPE"]; $groupe = $groupe + 1; $queryHistory = "insert into HISTORIQUE (GROUPE,VARIABLE,login,date_modif) values ({$groupe},\"{$query}\",'" . $_SESSION['login'] . "','{$myDateToday}')"; //echo $queryHistory."<br/>"; $queryMYSQL->query($queryHistory); }
/** * @param $params * * @return string */ public static function buildHttpQuery($params) { if (!$params) { return ''; } // Urlencode both keys and values $keys = Util::urlencodeRfc3986(array_keys($params)); $values = Util::urlencodeRfc3986(array_values($params)); $params = array_combine($keys, $values); // Parameters are sorted by name, using lexicographical byte value ordering. // Ref: Spec: 9.1.1 (1) uksort($params, 'strcmp'); $pairs = array(); foreach ($params as $parameter => $value) { if (is_array($value)) { // If two or more parameters share the same name, they are sorted by their value // Ref: Spec: 9.1.1 (1) // June 12th, 2010 - changed to sort because of issue 164 by hidetaka sort($value, SORT_STRING); foreach ($value as $duplicateValue) { $pairs[] = $parameter . '=' . $duplicateValue; } } else { $pairs[] = $parameter . '=' . $value; } } // For each parameter, the name is separated from the corresponding value by an '=' character (ASCII code 61) // Each name-value pair is separated by an '&' character (ASCII code 38) return implode('&', $pairs); }
function get_unresolved_alarms($conn) { $alarms = intval(Alarm::get_count($conn, '', '', 1, TRUE)); $alarms_prev = intval($_SESSION['_unresolved_alarms']); if ($alarms != $alarms_prev && $alarms_prev > 0) { $new_alarms = $alarms - $alarms_prev; } else { $new_alarms = 0; } $_SESSION['_unresolved_alarms'] = $alarms; $data['alarms'] = $alarms; $data['new_alarms'] = $new_alarms; $data['new_alarms_desc'] = ''; if ($new_alarms > 0) { $criteria = array('src_ip' => '', 'dst_ip' => '', 'hide_closed' => 1, 'order' => 'ORDER BY a.timestamp DESC', 'inf' => 0, 'sup' => $new_alarms, 'date_from' => '', 'date_to' => '', 'query' => '', 'directive_id' => '', 'intent' => 0, 'sensor' => '', 'tag' => '', 'num_events' => '', 'num_events_op' => 0, 'plugin_id' => '', 'plugin_sid' => '', 'ctx' => '', 'host' => '', 'net' => '', 'host_group' => ''); list($alarm_list, $count) = Alarm::get_list($conn, $criteria); $alarm_string = ''; foreach ($alarm_list as $alarm) { $desc_alarm = Util::translate_alarm($conn, $alarm->get_sid_name(), $alarm); $desc_alarm = html_entity_decode(str_replace("'", "\\'", $desc_alarm)); $desc_alarm = str_replace('"', """, $desc_alarm); $desc_alarm = str_replace('—', "-", $desc_alarm); $desc_alarm = Util::js_entities($desc_alarm); if ($alarm_string != '') { $alarm_string .= '|'; } $alarm_string .= $desc_alarm; } $data['new_alarms_desc'] = $alarm_string; } $return['error'] = FALSE; $return['output'] = $data; return $return; }
public function actionBuyApi($item_id, $num) { $itemList = Util::loadConfig('items'); $item = $itemList[$item_id]; if (isset($item)) { $user = User::model()->findByPk($this->usr_id); if ($user->gold - $item['price'] * $num < 0) { throw new PException('余额不足'); } else { $transaction = Yii::app()->db->beginTransaction(); try { $user->gold -= $item['price'] * $num; $items = unserialize($user->items); if (isset($items[$item_id])) { $items[$item_id] += $num; } else { $items[$item_id] = $num; } $user->items = serialize($items); $user->saveAttributes(array('gold', 'items')); $transaction->commit(); } catch (Exception $e) { $transaction->rollback(); throw $e; } $this->echoJsonData(array('user_gold' => $user->gold)); } } else { throw new PException('商品不存在'); } }
public function getAngebote($data) { if (!$this->loggedIn) { return "TIMEOUT"; } $html = ""; $T = new HTMLTable(2); #, "Bitte wählen Sie einen Lieferschein"); $T->setTableStyle("width:100%;margin-top:10px;"); $T->setColWidth(1, 130); $T->useForSelection(false); $T->maxHeight(400); $AC = anyC::get("GRLBM", "isA", "1"); $AC->addJoinV3("Auftrag", "AuftragID", "=", "AuftragID"); $AC->addAssocV3("UserID", "=", Session::currentUser()->getID()); $AC->addAssocV3("status", "=", "open"); #$AC->addOrderV3("datum", "DESC"); $AC->addOrderV3("nummer", "DESC"); #$AC->setLimitV3(100); #$AC->addJoinV3("Adresse", "t2.AdresseID", "=", "AdresseID"); $i = 0; while ($B = $AC->n()) { $Adresse = new Adresse($B->A("AdresseID")); $T->addRow(array("<span style=\"font-size:20px;font-weight:bold;\">" . $B->A("prefix") . $B->A("nummer") . "</span><br><span style=\"color:grey;\">" . Util::CLDateParser($B->A("datum")) . "</span>", $Adresse->getHTMLFormattedAddress())); $T->addCellStyle(1, "vertical-align:top;"); $T->addRowStyle("cursor:pointer;border-bottom:1px solid #ccc;"); #if($i % 2 == 1) # $T->addRowStyle ("background-color:#eee;"); $T->addRowEvent("click", "\n\t\t\t\t\$(this).addClass('selected');\n\t\t\t\t\n\t\t\t\tCustomerPage.rme('getAuftrag', {GRLBMID: " . $B->getID() . "}, function(transport){ \n\t\t\t\t\t\tif(transport == 'TIMEOUT') { document.location.reload(); return; } \n\t\t\t\t\t\t\$('#contentLeft').html(transport); \n\t\t\t\t\t}, \n\t\t\t\t\tfunction(){},\n\t\t\t\t\t'POST');\n\t\t\t\t\t\n\t\t\t\tCustomerPage.rme('getArtikel', {GRLBMID: " . $B->getID() . ", query : '', KategorieID: ''}, function(transport){ \n\t\t\t\t\t\tif(transport == 'TIMEOUT') { document.location.reload(); return; } \n\t\t\t\t\t\t\$('#contentRight').html(transport); \n\t\t\t\t\t\t\$('.selected').removeClass('selected');\n\t\t\t\t\t\t\$('#frameSelect').hide(); \$('#frameEdit').show();\n\t\t\t\t\t}, \n\t\t\t\t\tfunction(){},\n\t\t\t\t\t'POST');"); $i++; } $html .= $T; return $html; }
/** * Método para generar un mensaje de alerta, párametros que puede recibir: "icon: icono", "title: ", "subtext: ", "name: ", "autoOpen: " * @param type $text * @param type $params * @return type */ public static function alert($text, $params = '') { //Extraigo los parametros $params = Util::getParams(func_get_args()); $icon = isset($params['icon']) ? $params['icon'] : 'icon-exclamation-sign'; $title = isset($params['title']) ? '<i class="' . $icon . '" style="padding-right:5px; margin-top:5px;"></i>' . $params['title'] : null; $subtext = isset($params['subtext']) ? "<p style='margin-top: 10px'>{$params['subtext']}</p>" : null; $name = isset($params['name']) ? trim($params['name'], '()') : "dwModal" . rand(10, 5000); $autoOpen = isset($params['autoOpen']) ? true : false; $modal = '<div class="modal hide" id="' . $name . '">'; $modal .= '<div class="modal-header">'; $modal .= '<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>'; $modal .= $title ? "<h3>{$title}</h3>" : ''; $modal .= '</div>'; $modal .= "<div class=\"modal-body\">{$text} {$subtext}</div>"; $modal .= '<div class="modal-footer">'; $modal .= '<button class="btn btn-primary" data-dismiss="modal" aria-hidden="true">Aceptar</button>'; $modal .= '</div>'; $modal .= '</div>'; $modal .= '<script type="text/javascript">'; $modal .= "function {$name}() { \$('#{$name}').modal('show'); }; "; if ($autoOpen) { $modal .= '$(function(){ ' . $name . '(); });'; } $modal .= "\$('#{$name}').on('shown', function () { \$('.btn-primary', '#{$name}').focus(); });"; $modal .= '</script>'; return $modal . PHP_EOL; }
public static function process() { global $neardConfig, $neardApps, $neardTools; $result = '[git]' . PHP_EOL; $result .= 'client = \'' . $neardTools->getGit()->getExe() . '\'' . PHP_EOL; $foundRepos = $neardTools->getGit()->findRepos(true); if (!empty($foundRepos)) { // Repositories $refactorRepos = array(); foreach ($foundRepos as $repo) { /*$repo = dirname($repo); if (!in_array($repo, $refactorRepos)) { $refactorRepos[] = $repo;*/ $result .= 'repositories[] = \'' . Util::formatUnixPath($repo) . '\'' . PHP_EOL; //} } } else { $result .= 'repositories[] = \'\'' . PHP_EOL; } // App $result .= PHP_EOL . '[app]' . PHP_EOL; $result .= 'debug = false' . PHP_EOL; $result .= 'cache = false' . PHP_EOL . PHP_EOL; // Filetypes $result .= '[filetypes]' . PHP_EOL; $result .= '; extension = type' . PHP_EOL; $result .= '; dist = xml' . PHP_EOL . PHP_EOL; // Binary filetypes $result .= '[binary_filetypes]' . PHP_EOL; $result .= '; extension = true' . PHP_EOL; $result .= '; svh = false' . PHP_EOL; $result .= '; map = true' . PHP_EOL . PHP_EOL; file_put_contents($neardApps->getGitlist()->getConf(), $result); }
/** * Make an assertion and throw {@link Hamcrest\AssertionError} if it fails. * * The first parameter may optionally be a string identifying the assertion * to be included in the failure message. * * If the third parameter is not a matcher it is passed to * {@link Hamcrest\Core\IsEqual#equalTo} to create one. * * Example: * <pre> * // With an identifier * assertThat("apple flavour", $apple->flavour(), equalTo("tasty")); * // Without an identifier * assertThat($apple->flavour(), equalTo("tasty")); * // Evaluating a boolean expression * assertThat("some error", $a > $b); * assertThat($a > $b); * </pre> */ public static function assertThat() { $args = func_get_args(); switch (count($args)) { case 1: self::$_count++; if (!$args[0]) { throw new AssertionError(); } break; case 2: self::$_count++; if ($args[1] instanceof Matcher) { self::doAssert('', $args[0], $args[1]); } elseif (!$args[1]) { throw new AssertionError($args[0]); } break; case 3: self::$_count++; self::doAssert($args[0], $args[1], Util::wrapValueWithIsEqual($args[2])); break; default: throw new \InvalidArgumentException('assertThat() requires one to three arguments'); } }
public function __construct($args) { global $neardBs, $neardConfig, $neardLang, $neardBins, $neardWinbinder; if (isset($args[0]) && !empty($args[0])) { $filePath = $neardBs->getAliasPath() . '/' . $args[0] . '.conf'; $fileContent = file_get_contents($filePath); if (preg_match('/^Alias \\/' . $args[0] . ' "(.+)"/', $fileContent, $match)) { $this->initName = $args[0]; $initDest = Util::formatWindowsPath($match[1]); $apachePortUri = $neardBins->getApache()->getPort() != 80 ? ':' . $neardBins->getApache()->getPort() : ''; $neardWinbinder->reset(); $this->wbWindow = $neardWinbinder->createAppWindow(sprintf($neardLang->getValue(Lang::EDIT_ALIAS_TITLE), $this->initName), 490, 200, WBC_NOTIFY, WBC_KEYDOWN | WBC_KEYUP); $this->wbLabelName = $neardWinbinder->createLabel($this->wbWindow, $neardLang->getValue(Lang::ALIAS_NAME_LABEL) . ' :', 15, 15, 85, null, WBC_RIGHT); $this->wbInputName = $neardWinbinder->createInputText($this->wbWindow, $this->initName, 105, 13, 150, null, 20); $this->wbLabelDest = $neardWinbinder->createLabel($this->wbWindow, $neardLang->getValue(Lang::ALIAS_DEST_LABEL) . ' :', 15, 45, 85, null, WBC_RIGHT); $this->wbInputDest = $neardWinbinder->createInputText($this->wbWindow, $initDest, 105, 43, 190, null, 20, WBC_READONLY); $this->wbBtnDest = $neardWinbinder->createButton($this->wbWindow, $neardLang->getValue(Lang::BUTTON_BROWSE), 300, 43, 110); $this->wbLabelExp = $neardWinbinder->createLabel($this->wbWindow, sprintf($neardLang->getValue(Lang::ALIAS_EXP_LABEL), $apachePortUri, $this->initName, $initDest), 15, 80, 470, 50); $this->wbProgressBar = $neardWinbinder->createProgressBar($this->wbWindow, self::GAUGE_SAVE + 1, 15, 137, 190); $this->wbBtnSave = $neardWinbinder->createButton($this->wbWindow, $neardLang->getValue(Lang::BUTTON_SAVE), 215, 132); $this->wbBtnDelete = $neardWinbinder->createButton($this->wbWindow, $neardLang->getValue(Lang::BUTTON_DELETE), 300, 132); $this->wbBtnCancel = $neardWinbinder->createButton($this->wbWindow, $neardLang->getValue(Lang::BUTTON_CANCEL), 385, 132); $neardWinbinder->setHandler($this->wbWindow, $this, 'processWindow'); $neardWinbinder->mainLoop(); $neardWinbinder->reset(); } } }
public function GetGenerator($bytearray = false) { if ($bytearray) { return Util::toByteArray($this->Generator); } return $this->Generator->toString(); }
/** * Strip markup to show plaintext * Attention the following code block is an adaption * of the Active Abstract MediaWiki Plugin * created by Brion Vibber et. al. * It is not Public Domain, but has the same license as the MediaWiki * @param string $text * @return string * @access private */ public static function stripMarkup($text, $image = 'image', $category = 'Category', $language = 'en') { $category = Util::getMediaWikiCategoryNamespace($language); $image = preg_quote($image, '#'); // $image = preg_quote( $wgContLang->getNsText( NS_IMAGE ), '#' ); $text = preg_replace('/(<ref>.+?<\\/ref>)/s', "", $text); // remove ref $text = str_replace("'''", "", $text); $text = str_replace("''", "", $text); $text = preg_replace('#<!--.*?-->#s', '', $text); // HTML-style comments $text = preg_replace('#</?[a-z0-9]+.*?>#s', '', $text); // HTML-style tags $text = preg_replace('#\\[[a-z]+:.*? (.*?)\\]#s', '$1', $text); // URL links $text = preg_replace('#\\{\\{\\{.*?\\}\\}\\}#s', '', $text); // template parameters //$text = preg_replace( '#\\{\\{.*?\\}\\}#s', '', $text ); // template calls $text = preg_replace('/\\{{2}((?>[^\\{\\}]+)|(?R))*\\}{2}/x', '', $text); // search {{....}} $text = preg_replace('#\\{\\|.*?\\|\\}#s', '', $text); // tables $text = preg_replace("#\r\n\t\t\t\\[\\[\r\n\t\t\t\t:?{$image}\\s*:\r\n\t\t\t\t\t(\r\n\t\t\t\t\t\t[^][]*\r\n\t\t\t\t\t\t\\[\\[\r\n\t\t\t\t\t\t[^][]*\r\n\t\t\t\t\t\t\\]\\]\r\n\t\t\t\t\t)*\r\n\t\t\t\t[^][]*\r\n\t\t\t\\]\\]#six", '', $text); // images $text = preg_replace('#\\[\\[(' . $category . ':.*)\\]\\]#s', '', $text); // Category Links $text = preg_replace('#\\[\\[([^|\\]]*\\|)?(.*?)\\]\\]#s', '$2', $text); // links $text = preg_replace('#^:.*$#m', '', $text); // indented lines near start are usually disambigs or notices //TODO $text = Sanitizer::decodeCharReferences( $text ); return trim($text); }
public function loadPlugin($app, $folder, $optional = false) { if (!file_exists(Util::getRootPath() . "{$app}/{$folder}/plugin.xml") and !$optional) { throw new Exception("Required plugin {$app}/{$folder} not available (1)"); } if (!file_exists(Util::getRootPath() . "{$app}/{$folder}/plugin.xml")) { return false; } $xml = new XMLPlugin(Util::getRootPath() . "{$app}/{$folder}/plugin.xml"); $allowedPlugins = Environment::getS("allowedPlugins", false); $extraPlugins = Environment::getS("pluginsExtra", false); $allow = false; if ($allowedPlugins !== false and in_array($xml->registerClassName(), $allowedPlugins)) { $allow = true; } if ($extraPlugins !== false and in_array($xml->registerClassName(), $extraPlugins)) { $allow = true; } if ($allowedPlugins !== false and !$allow) { if (!$optional) { throw new Exception("Required plugin {$app}/{$folder} not available (2)"); } return false; } require_once Util::getRootPath() . "{$app}/{$folder}/" . $xml->registerClassName() . ".class.php"; $this->addClassPath(Util::getRootPath() . "{$app}/{$folder}"); return true; }
public function getOverviewContent() { $html = "<div class=\"touchHeader\"><p>Uhr</p></div>\n\t\t\t<div style=\"padding:10px;\">"; $html .= "<div id=\"fheOverviewClock\"><span>" . Util::CLWeekdayName(date("w")) . "<br><b>" . date("d") . ". " . Util::CLMonthName(date("m")) . " " . date("Y") . "</b></span><b>" . Util::CLTimeParser(time()) . "</b></div>"; $html .= "</div>"; echo $html; }
public static function merge(array $input, $message_list, $options = array()) { $context = isset($options['context']) ? $options['context'] : null; $mixables = array(); foreach (Util::splitDelimList($message_list) as $message) { if ($result = self::call($message, $context)) { $mixables = array_merge($mixables, $result); } } while ($mixable = array_shift($mixables)) { if ($mixable instanceof Declaration) { $input[] = $mixable; } else { list($property, $value) = $mixable; if ($property === 'mixin') { $input = Mixin::merge($input, $value, $options); } elseif (!empty($options['keyed'])) { $input[$property] = $value; } else { $input[] = array($property, $value); } } } return $input; }
/** * 获取会员组价格 * @param $id int 商品或货品ID * @param $type string goods:商品; product:货品 * @return float 价格 */ public function getGroupPrice($id, $type = 'goods') { if (!$this->group_id) { return null; } //1,查询特定商品的组价格 $groupPriceDB = new IModel('group_price'); if ($type == 'goods') { $discountRow = $groupPriceDB->getObj('goods_id = ' . $id . ' and group_id = ' . $this->group_id, 'price'); } else { $discountRow = $groupPriceDB->getObj('product_id = ' . $id . ' and group_id = ' . $this->group_id, 'price'); } if ($discountRow) { return $discountRow['price']; } //2,根据会员折扣率计算商品折扣 if ($this->group_discount) { if ($type == 'goods') { $goodsDB = new IModel('goods'); $goodsRow = $goodsDB->getObj('id = ' . $id, 'sell_price'); return $goodsRow ? Util::priceFormat($goodsRow['sell_price'] * $this->group_discount) : null; } else { $productDB = new IModel('products'); $productRow = $productDB->getObj('id = ' . $id, 'sell_price'); return $productRow ? Util::priceFormat($productRow['sell_price'] * $this->group_discount) : null; } } return null; }
public function onResponseSent() { if (!$this->settings->hasSetting("debug_log") or !$this->environment->request()) { return; } $path = $this->environment->request()->path(); if (count($path) > 0 and strcasecmp($path[0], "debug") == 0) { return; } $log = $this->settings->setting("debug_log"); $handle = @fopen($log, "a"); if (!$handle) { Logging::logError("Could not write to log file: " . $log); return; } $trace = Logging::getTrace(); try { foreach ($trace as $d) { fwrite($handle, Util::toString($d)); } fclose($handle); } catch (Exception $e) { Logging::logError("Could not write to log file: " . $log); Logging::logException($e); } }
public static function cleanUp() { if (!file_exists(Util::getRootPath() . "../phynxPublic/filelink")) { return; } $delete = array(); $dir = new DirectoryIterator(Util::getRootPath() . "../phynxPublic/filelink/"); foreach ($dir as $file) { if ($file->isDot()) { continue; } if (!$file->isDir()) { continue; } if ($file->getCTime() < time() - 3600 * 24 * 14) { $delete[] = $file->getPathname(); } } foreach ($delete as $dir) { $D = new DirectoryIterator($dir); foreach ($D as $file) { if ($file->isDot()) { continue; } if ($file->isDir()) { continue; } unlink($file->getPathname()); } rmdir($dir); } }
public function requestRegModify() { //------------------------------------ // param valid check //------------------------------------- $uid = (int) $_SESSION[DBWork::sessionKey]; $co_id = (int) $_SESSION[DBWork::accountKey]; $item_cd = (int) $this->param['item_cd']; $itemgrp_cd = (int) $this->param['itemgrp_cd']; $item_nm = $this->param['item_nm']; $item_qty = $this->param['item_qty']; $item_danwi = $this->param['item_danwi']; $item_in_danga = (int) $this->param['item_in_danga']; $item_out_danga = (int) $this->param['item_out_danga']; if (!$item_nm || !Util::lengthCheck($item_nm, 1, 45)) { throw new Exception('Data length'); } //------------------------------------ // db work //------------------------------------ //itemgrp 와 외래키 설정 $sql = "INSERT INTO item (`co_id`, `item_cd`, `itemgrp_cd`, `item_nm`, `item_qty`, `item_danwi`, `item_in_danga`, \r\n\t\t\t\t\t\t\t\t\t`item_out_danga`, `reg_date`, `reg_uid`)\r\n\t\t\t\t\t\t\t\tVALUES \r\n\t\t\t\t\t\t\t\t({$co_id}, {$item_cd}, {$itemgrp_cd}, '{$item_nm}', '{$item_qty}', '{$item_danwi}',\r\n\t\t\t\t\t\t\t\t\t{$item_in_danga}, {$item_out_danga}, now(), {$uid})\r\n\t\t\t\t\t\t\t\tON DUPLICATE KEY UPDATE \r\n\t\t\t\t\t\t\t\t`item_cd` = {$item_cd}, `itemgrp_cd` = {$itemgrp_cd}, `item_nm` = '{$item_nm}',\r\n\t\t\t\t\t\t\t\t`item_qty` = '{$item_qty}', `item_danwi` = '{$item_danwi}', `item_in_danga` = {$item_in_danga}, \r\n\t\t\t\t\t\t\t\t`item_out_danga` = {$item_out_danga}, `reg_date` = now(), `reg_uid` = {$uid};"; $this->updateSql($sql); return 1; }
public static function clean_username($username) { $name = str_replace("'", "", $username); $clean_name = str_replace(" ", "_", $name); $uname = Util::mid_cut($clean_name, 20, "_"); return preg_replace('/_{2,}/', '_', $uname); }
function SIEM_trends_week($param = "") { global $tz; $tzc = Util::get_tzc($tz); $data = array(); $plugins = $plugins_sql = ""; require_once 'ossim_db.inc'; $db = new ossim_db(); $dbconn = $db->connect(); $sensor_where = make_sensor_filter($dbconn); if ($param != "") { require_once "classes/Plugin.inc"; $oss_p_id_name = Plugin::get_id_and_name($dbconn, "WHERE name LIKE '{$param}'"); $plugins = implode(",", array_flip($oss_p_id_name)); $plugins_sql = "AND acid_event.plugin_id in ({$plugins})"; } $sqlgraph = "SELECT COUNT(acid_event.sid) as num_events, day(convert_tz(timestamp,'+00:00','{$tzc}')) as intervalo, monthname(convert_tz(timestamp,'+00:00','{$tzc}')) as suf FROM snort.acid_event LEFT JOIN ossim.plugin ON acid_event.plugin_id=plugin.id WHERE timestamp BETWEEN '" . gmdate("Y-m-d 00:00:00", gmdate("U") - 604800) . "' AND '" . gmdate("Y-m-d 23:59:59") . "' {$plugins_sql} {$sensor_where} GROUP BY suf,intervalo ORDER BY suf,intervalo"; if (!($rg =& $dbconn->Execute($sqlgraph))) { print $dbconn->ErrorMsg(); } else { while (!$rg->EOF) { $hours = $rg->fields["intervalo"] . " " . substr($rg->fields["suf"], 0, 3); $data[$hours] = $rg->fields["num_events"]; $rg->MoveNext(); } } $db->close($dbconn); return $param != "" ? array($data, $oss_plugin_id) : $data; }
function titles() { $questQuery = ' SELECT qt.RewardTitleId AS ARRAY_KEY, qt.RequiredRaces, ge.holiday FROM quest_template qt LEFT JOIN game_event_seasonal_questrelation sq ON sq.questId = qt.id LEFT JOIN game_event ge ON ge.eventEntry = sq.eventEntry WHERE qt.RewardTitleId <> 0'; DB::Aowow()->query('REPLACE INTO ?_titles SELECT Id, 0, 0, 0, 0, 0, 0, 0, male_loc0, male_loc2, male_loc3, male_loc6, male_loc8, female_loc0, female_loc2, female_loc3, female_loc6, female_loc8 FROM dbc_chartitles'); // hide unused titles DB::Aowow()->query('UPDATE ?_titles SET cuFlags = ?d WHERE id BETWEEN 85 AND 123 AND id NOT IN (113, 120, 121, 122)', CUSTOM_EXCLUDE_FOR_LISTVIEW); // set expansion DB::Aowow()->query('UPDATE ?_titles SET expansion = 2 WHERE id >= 72 AND id <> 80'); DB::Aowow()->query('UPDATE ?_titles SET expansion = 1 WHERE id >= 42 AND id <> 46 AND expansion = 0'); // set category DB::Aowow()->query('UPDATE ?_titles SET category = 1 WHERE id <= 28 OR id IN (42, 43, 44, 45, 47, 48, 62, 71, 72, 80, 82, 126, 127, 128, 157, 163, 167, 169, 177)'); DB::Aowow()->query('UPDATE ?_titles SET category = 5 WHERE id BETWEEN 96 AND 109 OR id IN (83, 84)'); DB::Aowow()->query('UPDATE ?_titles SET category = 2 WHERE id BETWEEN 144 AND 156 OR id IN (63, 77, 79, 113, 123, 130, 131, 132, 176)'); DB::Aowow()->query('UPDATE ?_titles SET category = 6 WHERE id IN (46, 74, 75, 76, 124, 133, 134, 135, 137, 138, 155, 168)'); DB::Aowow()->query('UPDATE ?_titles SET category = 4 WHERE id IN (81, 125)'); DB::Aowow()->query('UPDATE ?_titles SET category = 3 WHERE id IN (53, 64, 120, 121, 122, 129, 139, 140, 141, 142) OR (id >= 158 AND category = 0)'); // update side $questInfo = DB::World()->select($questQuery); $sideUpd = DB::World()->selectCol('SELECT IF (title_A, title_A, title_H) AS ARRAY_KEY, BIT_OR(IF(title_A, 1, 2)) AS side FROM achievement_reward WHERE (title_A <> 0 AND title_H = 0) OR (title_H <> 0 AND title_A = 0) GROUP BY ARRAY_KEY HAVING side <> 3'); foreach ($questInfo as $tId => $data) { if ($data['holiday']) { DB::Aowow()->query('UPDATE ?_titles SET holidayId = ?d WHERE id = ?d', $data['holiday'], $tId); } $side = Util::sideByRaceMask($data['RequiredRaces']); if ($side == 3) { continue; } if (!isset($sideUpd[$tId])) { $sideUpd[$tId] = $side; } else { $sideUpd[$tId] |= $side; } } foreach ($sideUpd as $tId => $side) { if ($side != 3) { DB::Aowow()->query("UPDATE ?_titles SET side = ?d WHERE id = ?d", $side, $tId); } } // update side - sourceless titles (maintain query order) DB::Aowow()->query('UPDATE ?_titles SET side = 2 WHERE id <= 28 OR id IN (118, 119, 116, 117, 110, 127)'); DB::Aowow()->query('UPDATE ?_titles SET side = 1 WHERE id <= 14 OR id IN (111, 115, 112, 114, 126)'); // ! src12Ext pendant in source-script ! $doubles = DB::World()->selectCol('SELECT IF(title_A, title_A, title_H) AS ARRAY_KEY, GROUP_CONCAT(entry SEPARATOR " "), count(1) FROM achievement_reward WHERE title_A <> 0 OR title_H <> 0 GROUP BY ARRAY_KEY HAVING count(1) > 1'); foreach ($doubles as $tId => $acvIds) { DB::Aowow()->query('UPDATE ?_titles SET src12Ext = ?d WHERE id = ?d', explode(' ', $acvIds)[1], $tId); } return true; }
public function extractPage($pageID, $pageTitle, $pageSource) { $result = new ExtractionResult($pageID, $this->language, $this->getExtractorID()); $category = Util::getMediaWikiNamespace($this->language, MW_CATEGORY_NAMESPACE); if (preg_match_all("/" . $category . ":(.*)/", $pageID, $match)) { $result->addTriple($this->getPageURI(), RDFtriple::URI(SKOS_PREFLABEL, false), RDFtriple::Literal($this->decode_title($pageTitle), NULL, $this->language)); $result->addTriple($this->getPageURI(), RDFtriple::URI(RDF_TYPE, false), RDFtriple::URI(SKOS_CONCEPT, false)); if (preg_match_all("/\\[\\[" . $category . ":(.*)\\]\\]/", $pageSource, $matches, PREG_SET_ORDER)) { foreach ($matches as $match) { // split on | sign if (strpos($match[1], '|') === false) { $object = Util::getDBpediaCategoryPrefix($this->language) . URI::wikipediaEncode($match[1]); } else { $split = explode('|', $match[1]); $object = Util::getDBpediaCategoryPrefix($this->language) . URI::wikipediaEncode($split[0]); } try { $object = RDFtriple::URI($object); } catch (Exception $e) { echo 'Caught exception: ', $e->getMessage(), "\n"; continue; } $result->addTriple($this->getPageURI(), RDFtriple::URI(SKOS_BROADER, false), $object); } } } return $result; }
public function processWindow($window, $id, $ctrl, $param1, $param2) { global $neardBins, $neardLang, $neardWinbinder; $boxTitle = sprintf($neardLang->getValue(Lang::CHANGE_PORT_TITLE), $this->bin); $port = $neardWinbinder->getText($this->wbInputPort[WinBinder::CTRL_OBJ]); switch ($id) { case $this->wbInputPort[WinBinder::CTRL_ID]: $neardWinbinder->setEnabled($this->wbBtnFinish[WinBinder::CTRL_OBJ], empty($port) ? false : true); break; case $this->wbBtnFinish[WinBinder::CTRL_ID]: $neardWinbinder->incrProgressBar($this->wbProgressBar); if ($port == $this->currentPort) { $neardWinbinder->messageBoxWarning($neardLang->getValue(Lang::CHANGE_PORT_SAME_ERROR), $boxTitle); $neardWinbinder->resetProgressBar($this->wbProgressBar); break; } $changePort = $this->bin->changePort($port, true, $this->wbProgressBar); if ($changePort === true) { $neardWinbinder->messageBoxInfo(sprintf($neardLang->getValue(Lang::PORT_CHANGED), $this->bin, $port), $boxTitle); $neardWinbinder->destroyWindow($window); Util::startLoading(); $this->bin->getService()->restart(); } else { $neardWinbinder->messageBoxError(sprintf($neardLang->getValue(Lang::PORT_NOT_USED_BY), $port, $changePort), $boxTitle); $neardWinbinder->resetProgressBar($this->wbProgressBar); } break; case IDCLOSE: case $this->wbBtnCancel[WinBinder::CTRL_ID]: $neardWinbinder->destroyWindow($window); break; } }
/** * Generator source code, from which Phalcon extension can be built */ public function run() { echo 'Generating safe build... '; Util::cleanDirectory($this->outputDir); $this->generateFiles(); echo "OK\n"; }
function generate_gallery($gallery_name, $max_items, $current_item) { Util::gallery_clamp_values($max_items, $current_item); $html = "<img src=\"_img/{$gallery_name}/{$current_item}.JPG\" />"; $html .= Util::generate_gallery_nav($gallery_name, $max_items, $current_item); return $html; }