Example #1
0
 /**
  * Loads all the static strings from either the cache or the ini files. Note that ini files in modules are not verified for outdatedness, so if they were updated, just clear all the caches or hard reload a page
  * This method should not be called directly from outsite TranslationPeer except for testing and debugging purposes
  */
 public static function getStaticStrings($sLanguageId)
 {
     if (!isset(self::$STATIC_STRINGS[$sLanguageId])) {
         $oCache = new Cache($sLanguageId, DIRNAME_LANG);
         $aLanguageFiles = ResourceFinder::create()->addPath(DIRNAME_LANG, "{$sLanguageId}.ini")->all()->baseFirst()->find();
         if ($oCache->entryExists() && !$oCache->isOutdated($aLanguageFiles)) {
             self::$STATIC_STRINGS[$sLanguageId] = $oCache->getContentsAsVariable();
         } else {
             self::$STATIC_STRINGS[$sLanguageId] = array();
             //Get default strings
             foreach ($aLanguageFiles as $sLanguageFile) {
                 self::$STATIC_STRINGS[$sLanguageId] = array_merge(self::$STATIC_STRINGS[$sLanguageId], parse_ini_file($sLanguageFile));
             }
             //Get strings for modules
             foreach (ResourceFinder::create()->addExpression(DIRNAME_MODULES, ResourceFinder::ANY_NAME_OR_TYPE_PATTERN, ResourceFinder::ANY_NAME_OR_TYPE_PATTERN, DIRNAME_LANG, "{$sLanguageId}.ini")->all()->baseFirst()->find() as $sLanguageFile) {
                 self::$STATIC_STRINGS[$sLanguageId] = array_merge(self::$STATIC_STRINGS[$sLanguageId], parse_ini_file($sLanguageFile));
             }
             //Fix string encoding
             foreach (self::$STATIC_STRINGS[$sLanguageId] as $sStringKey => $sValue) {
                 self::$STATIC_STRINGS[$sLanguageId][$sStringKey] = StringUtil::encodeForDbFromFile($sValue);
             }
             $oCache->setContents(self::$STATIC_STRINGS[$sLanguageId]);
         }
     }
     return self::$STATIC_STRINGS[$sLanguageId];
 }
 /**
  * Returns the image sizes for the given user suitable for widgets.
  *
  * @param BackendUser $user
  *
  * @return array
  */
 public function getOptionsForUser(BackendUser $user)
 {
     $this->loadOptions();
     $event = new ImageSizesEvent($user->isAdmin ? $this->options : $this->filterOptions(\StringUtil::deserialize($user->imageSizes, true)), $user);
     $this->eventDispatcher->dispatch(ContaoCoreEvents::IMAGE_SIZES_USER, $event);
     return $event->getImageSizes();
 }
 /**
  * @see Page::readParameters()
  */
 public function readParameters()
 {
     parent::readParameters();
     if (isset($_REQUEST['q'])) {
         $this->input = StringUtil::trim($_REQUEST['q']);
     }
 }
 /**
  * Elimina acento y reemplaza espacio con '-'
  *
  * @param String word
  */
 public static function sanitize($word)
 {
     $word = StringUtil::eliminateUnwantedChars($word);
     $word = str_replace(" ", "-", $word);
     $word = strtolower($word);
     return $word;
 }
Example #5
0
 public function actionIndex()
 {
     if (isset($_GET["pagesize"])) {
         $this->setListPageSize($_GET["pagesize"]);
     }
     $key = StringUtil::filterCleanHtml(EnvUtil::getRequest("keyword"));
     $fields = array("frp.runid", "frp.processid", "frp.flowprocess", "frp.flag", "frp.opflag", "frp.processtime", "ft.freeother", "ft.flowid", "ft.name as typeName", "ft.type", "ft.listfieldstr", "fr.name as runName", "fr.beginuser", "fr.begintime", "fr.endtime", "fr.focususer");
     $sort = "frp.processtime";
     $group = "frp.runid";
     $condition = array("and", "fr.delflag = 0", "frp.childrun = 0", sprintf("frp.uid = %d", $this->uid), sprintf("FIND_IN_SET(fr.focususer,'%s')", $this->uid));
     if ($key) {
         $condition[] = array("like", "fr.runid", "%{$key}%");
         $condition[] = array("or like", "fr.name", "%{$key}%");
     }
     $count = Ibos::app()->db->createCommand()->select("count(*) as count")->from("{{flow_run_process}} frp")->leftJoin("{{flow_run}} fr", "frp.runid = fr.runid")->leftJoin("{{flow_type}} ft", "fr.flowid = ft.flowid")->where($condition)->group($group)->queryScalar();
     $pages = PageUtil::create($count, $this->getListPageSize());
     if ($key && $count) {
         $pages->params = array("keyword" => $key);
     }
     $offset = $pages->getOffset();
     $limit = $pages->getLimit();
     $list = Ibos::app()->db->createCommand()->select($fields)->from("{{flow_run_process}} frp")->leftJoin("{{flow_run}} fr", "frp.runid = fr.runid")->leftJoin("{{flow_type}} ft", "fr.flowid = ft.flowid")->where($condition)->order($sort)->group($group)->offset($offset)->limit($limit)->queryAll();
     $data = array_merge(array("pages" => $pages), $this->handleList($list));
     $this->setPageTitle(Ibos::lang("My focus"));
     $this->setPageState("breadCrumbs", array(array("name" => Ibos::lang("Workflow")), array("name" => Ibos::lang(Ibos::lang("My focus")), "url" => $this->createUrl("focus/index")), array("name" => Ibos::lang("List"))));
     $this->render("index", $data);
 }
Example #6
0
 public function actionEdit()
 {
     if (EnvUtil::submitCheck("emailSubmit")) {
         $setting = array();
         foreach ($this->_fields as $field) {
             if (array_key_exists($field, $_POST)) {
                 $setting[$field] = intval($_POST[$field]);
             } else {
                 $setting[$field] = 0;
             }
         }
         $roles = array();
         if (isset($_POST["role"])) {
             foreach ($_POST["role"] as $role) {
                 if (!empty($role["positionid"]) && !empty($role["size"])) {
                     $positionId = StringUtil::getId($role["positionid"]);
                     $roles[implode(",", $positionId)] = intval($role["size"]);
                 }
             }
         }
         $setting["emailroleallocation"] = serialize($roles);
         foreach ($setting as $key => $value) {
             Setting::model()->updateSettingValueByKey($key, $value);
         }
         CacheUtil::update("setting");
         $this->success(Ibos::lang("Update succeed", "message"), $this->createUrl("dashboard/index"));
     }
 }
Example #7
0
 /**
  * Generate the module
  */
 protected function compile()
 {
     $this->Template->src = $this->singleSRC;
     $this->Template->href = $this->source == 'external' ? $this->url : $this->singleSRC;
     $this->Template->alt = $this->altContent;
     $this->Template->var = 'swf' . $this->id;
     $this->Template->transparent = $this->transparent ? true : false;
     $this->Template->interactive = $this->interactive ? true : false;
     $this->Template->flashId = $this->flashID ?: 'swf_' . $this->id;
     $this->Template->fsCommand = '  ' . preg_replace('/[\\n\\r]/', "\n  ", \StringUtil::decodeEntities($this->flashJS));
     $this->Template->flashvars = 'URL=' . \Environment::get('base');
     $this->Template->version = $this->version ?: '6.0.0';
     $size = \StringUtil::deserialize($this->size);
     $this->Template->width = $size[0];
     $this->Template->height = $size[1];
     $intMaxWidth = TL_MODE == 'BE' ? 320 : \Config::get('maxImageWidth');
     // Adjust movie size
     if ($intMaxWidth > 0 && $size[0] > $intMaxWidth) {
         $this->Template->width = $intMaxWidth;
         $this->Template->height = floor($intMaxWidth * $size[1] / $size[0]);
     }
     if (strlen($this->flashvars)) {
         $this->Template->flashvars .= '&' . \StringUtil::decodeEntities($this->flashvars);
     }
 }
 /**
  * @depends testGetByContentTypeReturnsNullWithNoneSetAndNoDefault
  */
 public function testGetByContentTypeReturnsDefaultWithNoneSet()
 {
     $isHtmlContent = false;
     $unsubscribeUrlPlaceHolder = static::resolveUnsubscribeMergeTagContent($isHtmlContent);
     $manageSubscriptionsUrlPlaceHolder = static::resolveManageSubscriptionMergeTagContent($isHtmlContent);
     $recipientMention = 'This email was sent to [[PRIMARY^EMAIL]].';
     StringUtil::prependNewLine($unsubscribeUrlPlaceHolder, $isHtmlContent);
     StringUtil::prependNewLine($manageSubscriptionsUrlPlaceHolder, $isHtmlContent);
     StringUtil::prependNewLine($recipientMention, $isHtmlContent);
     $defaultFooter = $unsubscribeUrlPlaceHolder . $manageSubscriptionsUrlPlaceHolder . $recipientMention;
     $plainTextFooter = GlobalMarketingFooterUtil::getContentByType($isHtmlContent);
     $this->assertNotNull($plainTextFooter);
     $this->assertEquals($defaultFooter, $plainTextFooter);
     $isHtmlContent = true;
     $unsubscribeUrlPlaceHolder = static::resolveUnsubscribeMergeTagContent($isHtmlContent);
     $manageSubscriptionsUrlPlaceHolder = static::resolveManageSubscriptionMergeTagContent($isHtmlContent);
     $recipientMention = 'This email was sent to [[PRIMARY^EMAIL]].';
     StringUtil::prependNewLine($unsubscribeUrlPlaceHolder, $isHtmlContent);
     StringUtil::prependNewLine($manageSubscriptionsUrlPlaceHolder, $isHtmlContent);
     StringUtil::prependNewLine($recipientMention, $isHtmlContent);
     $defaultFooter = $unsubscribeUrlPlaceHolder . $manageSubscriptionsUrlPlaceHolder . $recipientMention;
     $richTextFooter = GlobalMarketingFooterUtil::getContentByType($isHtmlContent);
     $this->assertNotNull($richTextFooter);
     $this->assertEquals($defaultFooter, $richTextFooter);
 }
 /**
  * @see Form::save()
  */
 public function save()
 {
     parent::save();
     // send content type
     header('Content-Type: text/' . $this->fileType . '; charset=' . CHARSET);
     header('Content-Disposition: attachment; filename="export.' . $this->fileType . '"');
     if ($this->fileType == 'xml') {
         echo "<?xml version=\"1.0\" encoding=\"" . CHARSET . "\"?>\n<addresses>\n";
     }
     // get users
     $sql = "SELECT\t\temail\n\t\t\tFROM\t\twcf" . WCF_N . "_user\n\t\t\tWHERE\t\tuserID IN (" . $this->userIDs . ")\n\t\t\tORDER BY\temail";
     $result = WCF::getDB()->sendQuery($sql);
     $i = 0;
     $j = WCF::getDB()->countRows($result) - 1;
     while ($row = WCF::getDB()->fetchArray($result)) {
         if ($this->fileType == 'xml') {
             echo "<address><![CDATA[" . StringUtil::escapeCDATA($row['email']) . "]]></address>\n";
         } else {
             echo $this->textSeparator . $row['email'] . $this->textSeparator . ($i < $j ? $this->separator : '');
         }
         $i++;
     }
     if ($this->fileType == 'xml') {
         echo "</addresses>";
     }
     UserEditor::unmarkAll();
     $this->saved();
     exit;
 }
Example #10
0
 private function loadTodo($num = 4)
 {
     $uid = Ibos::app()->user->uid;
     $fields = array("frp.runid", "frp.processid", "frp.flowprocess", "ft.type", "frp.flag", "ft.flowid", "fr.name as runName", "fr.beginuser", "fr.focususer");
     $condition = array("and", "fr.delflag = 0", "frp.childrun = 0", sprintf("frp.uid = %d", $uid));
     $condition[] = array("in", "frp.flag", array(1, 2));
     $sort = "frp.createtime DESC";
     $group = "frp.id";
     $runProcess = Ibos::app()->db->createCommand()->select($fields)->from("{{flow_run_process}} frp")->leftJoin("{{flow_run}} fr", "frp.runid = fr.runid")->leftJoin("{{flow_type}} ft", "fr.flowid = ft.flowid")->where($condition)->order($sort)->group($group)->offset(0)->limit($num)->queryAll();
     $allProcess = FlowProcess::model()->fetchAllProcessSortByFlowId();
     foreach ($runProcess as &$run) {
         $run["user"] = User::model()->fetchByUid($run["beginuser"]);
         if ($run["type"] == 1) {
             if (isset($allProcess[$run["flowid"]][$run["flowprocess"]]["name"])) {
                 $run["stepname"] = $allProcess[$run["flowid"]][$run["flowprocess"]]["name"];
             } else {
                 $run["stepname"] = Ibos::lang("Process steps already deleted", "workflow.default");
             }
         } else {
             $run["stepname"] = Ibos::lang("Step", "", array("{step}" => $run["processid"]));
         }
         $run["focus"] = StringUtil::findIn($uid, $run["focususer"]);
         $param = array("runid" => $run["runid"], "flowid" => $run["flowid"], "processid" => $run["processid"], "flowprocess" => $run["flowprocess"]);
         $run["key"] = WfCommonUtil::param($param);
     }
     return $runProcess;
 }
Example #11
0
 /**
  * Cuts the given text to a specific lenght and adds ... at the and
  *
  * @param string $_text
  * @param int $_lenght
  * @param bool $_isFoldable 		(for unfolding / folding longer texts)
  * @return string
  */
 public static function cutText($_text, $_length, $_isFoldable = false)
 {
     $_text = strip_tags($_text);
     if (function_exists("mb_strlen")) {
         $length = mb_strlen($_text, "utf-8");
     } else {
         $length = strlen($_text);
     }
     if ($length > $_length) {
         $cutLength = max(1, $_length - 3);
         if (function_exists("mb_substr")) {
             $text = mb_substr($_text, 0, $cutLength, "utf-8");
             $textRest = mb_substr($_text, $cutLength, mb_strlen($_text, "utf-8"), "utf-8");
         } else {
             $text = substr($_text, 0, $cutLength);
             $textRest = substr($_text, $cutLength);
         }
         if (!$_isFoldable) {
             $text .= "...";
         } else {
             $id = "more_" . StringUtil::getRandom(5);
             $text .= " " . "<a style=\"text-decoration: none; font-size: 0.8em;\" id=\"show_" . $id . "\" href=" . CURRENT_PAGE_QS . "/# onclick=\"getById('" . $id . "').style.display = 'inline'; showHide('show_" . $id . "'); showHide('hide_" . $id . "'); return false;\">(" . Lang::get("global.w.more") . ")</a>" . "<b style=\"margin: 0px; font-weight: normal; display: none;\" id=\"" . $id . "\">" . $textRest . "</b>" . "<a style=\"text-decoration: none; font-size: 0.8em; float: left; display: none;\" id=\"hide_" . $id . "\" href=" . CURRENT_PAGE_QS . "/# onclick=\"getById('" . $id . "').style.display = 'none'; showHide('hide_" . $id . "'); showHide('show_" . $id . "'); return false;\">(" . Lang::get("global.w.less") . ")</a>";
         }
         return $text;
     } else {
         return $_text;
     }
 }
Example #12
0
 /**
  * Generate the content element
  */
 protected function compile()
 {
     /** @var \PageModel $objPage */
     global $objPage;
     // Clean RTE output
     if ($objPage->outputFormat == 'xhtml') {
         $this->text = \StringUtil::toXhtml($this->text);
     } else {
         $this->text = \StringUtil::toHtml5($this->text);
     }
     $this->Template->text = \StringUtil::encodeEmail($this->text);
     $this->Template->addImage = false;
     // Add an image
     if ($this->addImage && $this->singleSRC != '') {
         $objModel = \FilesModel::findByUuid($this->singleSRC);
         if ($objModel === null) {
             if (!\Validator::isUuid($this->singleSRC)) {
                 $this->Template->text = '<p class="error">' . $GLOBALS['TL_LANG']['ERR']['version2format'] . '</p>';
             }
         } elseif (is_file(TL_ROOT . '/' . $objModel->path)) {
             $this->singleSRC = $objModel->path;
             $this->addImageToTemplate($this->Template, $this->arrData);
         }
     }
     $classes = deserialize($this->mooClasses);
     $this->Template->toggler = $classes[0] ?: 'toggler';
     $this->Template->accordion = $classes[1] ?: 'accordion';
     $this->Template->headlineStyle = $this->mooStyle;
     $this->Template->headline = $this->mooHeadline;
 }
 /**
  * @see UserOptionOutput::getOutput()
  */
 public function getOutput(User $user, $optionData, $value)
 {
     if (empty($value) || $value == '0') {
         $value = 0.0;
     }
     return StringUtil::formatDouble($value, 2);
 }
Example #14
0
function geturl()
{
    $phpself = getscripturl();
    $isHTTPS = isset($_SERVER["HTTPS"]) && strtolower($_SERVER["HTTPS"]) != "off" ? true : false;
    $url = StringUtil::ihtmlSpecialChars("http" . ($isHTTPS ? "s" : "") . "://" . $_SERVER["HTTP_HOST"] . $phpself);
    return $url;
}
 /**
  * @see Action::readParameters()
  */
 public function readParameters()
 {
     parent::readParameters();
     if (!MODULE_MODERATED_USER_GROUP || !MODULE_PM) {
         throw new IllegalLinkException();
     }
     if (isset($_POST['groupID'])) {
         $this->groupID = intval($_POST['groupID']);
     }
     $this->group = new Group($this->groupID);
     if (!$this->group->groupID) {
         throw new IllegalLinkException();
     }
     // check permission
     if (!GroupApplicationEditor::isGroupLeader(WCF::getUser(), $this->groupID)) {
         throw new PermissionDeniedException();
     }
     if (isset($_POST['subject'])) {
         $this->subject = StringUtil::trim($_POST['subject']);
     }
     if (isset($_POST['text'])) {
         $this->text = StringUtil::trim($_POST['text']);
     }
     if (empty($this->subject) || empty($this->text)) {
         throw new IllegalLinkException();
     }
 }
 /**
  * @see CacheBuilder::getData()
  */
 public function getData($cacheResource)
 {
     list($cache, $packageID) = explode('-', $cacheResource['cache']);
     $data = array('actions' => array('user' => array(), 'admin' => array()), 'inheritedActions' => array('user' => array(), 'admin' => array()));
     // get all listeners and filter options with low priority
     $sql = "SELECT\t\tlistener.*, package.packageDir\n\t\t\tFROM\t\twcf" . WCF_N . "_package_dependency package_dependency,\n\t\t\t\t\twcf" . WCF_N . "_event_listener listener\n\t\t\tLEFT JOIN\twcf" . WCF_N . "_package package\n\t\t\tON\t\t(package.packageID = listener.packageID)\n\t\t\tWHERE \t\tlistener.packageID = package_dependency.dependency\n\t\t\t\t\tAND package_dependency.packageID = " . $packageID . "\n\t\t\tORDER BY\tpackage_dependency.priority";
     $result = WCF::getDB()->sendQuery($sql);
     while ($row = WCF::getDB()->fetchArray($result)) {
         $row['listenerClassName'] = StringUtil::getClassName($row['listenerClassFile']);
         // distinguish between inherited actions and non-inherited actions
         if (!$row['inherit']) {
             $data['actions'][$row['environment']][EventHandler::generateKey($row['eventClassName'], $row['eventName'])][] = $row;
         } else {
             if (!isset($data['inheritedActions'][$row['environment']][$row['eventClassName']])) {
                 $data['inheritedActions'][$row['eventClassName']] = array();
             }
             $data['inheritedActions'][$row['environment']][$row['eventClassName']][$row['eventName']][] = $row;
         }
     }
     // sort data by class name
     foreach ($data['actions'] as $environment => $listenerMap) {
         foreach ($listenerMap as $key => $listeners) {
             uasort($data['actions'][$environment][$key], array('CacheBuilderEventListener', 'sortListeners'));
         }
     }
     foreach ($data['inheritedActions'] as $environment => $listenerMap) {
         foreach ($listenerMap as $class => $listeners) {
             foreach ($listeners as $key => $val) {
                 uasort($data['inheritedActions'][$environment][$class][$key], array('CacheBuilderEventListener', 'sortListeners'));
             }
         }
     }
     return $data;
 }
Example #17
0
 public function __construct($data, $boxname = "")
 {
     $this->TopData['templatename'] = "topthreads";
     $this->getBoxStatus($data);
     $this->TopData['boxID'] = $data['boxID'];
     if (!defined('TOPTHREADS_COUNT')) {
         define('TOPTHREADS_COUNT', 10);
     }
     if (!defined('TOPTHREADS_TITLELENGTH')) {
         define('TOPTHREADS_TITLELENGTH', 25);
     }
     if (!defined('TOPTHREADS_SBCOLOR_ACP')) {
         define('TOPTHREADS_SBCOLOR_ACP', 2);
     }
     require_once WBB_DIR . 'lib/data/board/Board.class.php';
     $boardIDs = Board::getAccessibleBoards();
     if (!empty($boardIDs)) {
         $sql = "SELECT thread.*" . "\n  FROM wbb" . WBB_N . "_thread thread" . "\n WHERE thread.boardID IN (0" . $boardIDs . ")" . "\n ORDER BY thread.replies DESC" . "\n LIMIT 0, " . TOPTHREADS_COUNT;
         $result = WBBCore::getDB()->sendQuery($sql);
         while ($row = WBBCore::getDB()->fetchArray($result)) {
             $row['replies'] = StringUtil::formatInteger($row['replies']);
             $row['title'] = StringUtil::encodeHTML($row['topic']) . ' - ' . $row['replies'];
             if (TOPTHREADS_TITLELENGTH != 0 && strlen($row['topic']) > TOPTHREADS_TITLELENGTH) {
                 $row['topic'] = StringUtil::substring($row['topic'], 0, TOPTHREADS_TITLELENGTH - 3) . '...';
             }
             $row['topic'] = StringUtil::encodeHTML($row['topic']);
             $this->TopData['threads'][] = $row;
         }
     }
 }
 /**
  * @see CacheBuilder::getData()
  */
 public function getData($cacheResource)
 {
     $sql = "SELECT *\r\n\t\t\t\tFROM ugml_stat_type\r\n\t\t\t\tGROUP BY ugml_stat_type.statTypeID";
     $result = WCF::getDB()->sendQuery($sql);
     while ($row = WCF::getDB()->fetchArray($result)) {
         $sql = "SELECT DISTINCT `time`\r\n\t\t\t\t\tFROM ugml_stat_entry_archive\r\n\t\t\t\t\tWHERE statTypeID = " . $row['statTypeID'];
         $result2 = WCF::getDB()->sendQuery($sql);
         while ($row2 = WCF::getDB()->fetchArray($result2)) {
             $row['times'][] = $row2['time'];
         }
         // range
         $sql = "SELECT MAX(rank)\r\n\t\t\t\t\t\tAS max\r\n\t\t\t\t\tFROM ugml_stat_entry\r\n\t\t\t\t\tWHERE statTypeID = " . $row['statTypeID'];
         $row += WCF::getDB()->getFirstRow($sql);
         $this->data[$row['statTypeID']] = $row;
     }
     $this->data = array('byStatTypeID' => $this->data, 'byTypeName' => array());
     foreach ($this->data['byStatTypeID'] as $statTypeID => $row) {
         $name = StringUtil::firstCharToUpperCase($row['type']) . StringUtil::firstCharToUpperCase($row['name']);
         $this->data['byTypeName'][$name] = $row;
     }
     // get the names and the types
     $sql = "SELECT GROUP_CONCAT(DISTINCT type)\r\n\t\t\t\t\t\t\tAS types,\r\n\t\t\t\t\t\tGROUP_CONCAT(DISTINCT name)\r\n\t\t\t\t\t\t\tAS names\r\n\t\t\t\tFROM ugml_stat_type\r\n\t\t\t\tGROUP BY NULL";
     $row = WCF::getDB()->getFirstRow($sql);
     $this->data['types'] = explode(',', $row['types']);
     $this->data['names'] = explode(',', $row['names']);
     return $this->data;
 }
        private function parseQ ()
        {
            if (empty ($this->q) || $this->q == '*')
            {
                $this->displaySearchStr = CLUtil::getLabelForType ($this->type);
                $this->clVars['query'] = null;                
            }
            else
            {
                $tokens = StringUtil::tokenize ($this->q);
                $qParts = array ();
                
                foreach ($tokens as $token)
                {
                    if (preg_match ('/^(srchType|minAsk|maxAsk|hasPic|addTwo):(.*)/i', $token, $matches))
                    {
                        $this->clVars[strtolower ($matches[1])] = $matches[2];
                    }
                    else
                    {
                        $qParts[] = $token;
                    }
                }

                $this->displaySearchStr = implode (' ' , $qParts);
                $this->clVars['query'] = trim (preg_replace ('/ {2,}/', ' ', strtolower (implode (' ' , $qParts))));
            }
        }
Example #20
0
 public function actionDestroy()
 {
     $id = EnvUtil::getRequest("id");
     $runId = StringUtil::filterStr(StringUtil::filterCleanHtml($id));
     WfHandleUtil::destroy($runId);
     $this->ajaxReturn(array("isSuccess" => true));
 }
 /**
  * Creates a new source file entry.
  * 
  * @param	integer		$sourceID
  * @param	string		$location
  * @param	string		$type
  * @param	integer		$fileDate
  * @return	SourceFile
  */
 public static function create($sourceID, $location, $type, $profileName = '', $fileDate = TIME_NOW)
 {
     $fileVersion = $packageName = '';
     // get filename
     $filename = basename($location);
     // set file version based upon type
     if ($type != 'wcfsetup') {
         require_once PB_DIR . 'lib/system/package/PackageReader.class.php';
         $pr = new PackageReader($sourceID, $location, true);
         $data = $pr->getPackageData();
         $fileVersion = $data['version'];
         $packageName = $data['name'];
         $type = 'package';
     }
     $sql = "INSERT INTO\tpb" . PB_N . "_source_file\n\t\t\t\t\t(sourceID, hash, filename, fileType, fileVersion, fileDate, packageName, profileName)\n\t\t\tVALUES\t\t(" . $sourceID . ",\n\t\t\t\t\t'" . escapeString(StringUtil::getRandomID()) . "',\n\t\t\t\t\t'" . escapeString($filename) . "',\n\t\t\t\t\t'" . $type . "',\n\t\t\t\t\t'" . escapeString($fileVersion) . "',\n\t\t\t\t\t" . $fileDate . ",\n\t\t\t\t\t'" . escapeString($packageName) . "',\n\t\t\t\t\t'" . escapeString($profileName) . "')";
     WCF::getDB()->sendQuery($sql);
     $fileID = WCF::getDB()->getInsertID('pb' . PB_N . '_source_file', 'fileID');
     $sourceFile = new SourceFile($fileID);
     // move file
     if (!copy($location, PB_DIR . 'packages/' . $sourceFile->fileID . '-' . $sourceFile->hash)) {
         $sql = "DELETE FROM\tpb" . PB_N . "_source_file\n\t\t\t\tWHERE\t\tfileID = " . $sourceFile->fileID;
         WCF::getDB()->sendQuery($sql);
         throw new SystemException("Could not move source file, resource missing or insufficient permissions.");
     }
     @unlink($location);
     return $sourceFile;
 }
Example #22
0
 public function run($options)
 {
     if (isset($options['bootstrap'])) {
         require_once $options['bootstrap'];
     }
     $result = null;
     $args = isset($options['optional']) ? StringUtil::parseConfig($options['optional']) : array();
     if (!isset($options['n']) || $options['n'] === 'ls') {
         $result = "<<scruit subsets>>\n";
         foreach ($this->commands as $key => $val) {
             $result .= "{$key}\n";
         }
     } elseif (isset($this->commands[$options['n']]) || class_exists($options['n'])) {
         $command = isset($this->commands[$options['n']]) ? $this->commands[$options['n']] : new $options['n']();
         if (in_array('Scruit\\Runnable', class_implements($command))) {
             if (isset($args['man'])) {
                 $command->doc();
             } else {
                 $result = $command->run($args);
             }
         } else {
             $result = $options['n'] . ' is not runner.';
         }
     } else {
         $result = $options['n'] . ' is not exists.';
     }
     return $result;
 }
Example #23
0
 /**
  * Generate the content element
  */
 protected function compile()
 {
     /** @var \PageModel $objPage */
     global $objPage;
     // Clean the RTE output
     if ($objPage->outputFormat == 'xhtml') {
         $this->text = \StringUtil::toXhtml($this->text);
     } else {
         $this->text = \StringUtil::toHtml5($this->text);
     }
     // Add the static files URL to images
     if (TL_FILES_URL != '') {
         $path = \Config::get('uploadPath') . '/';
         $this->text = str_replace(' src="' . $path, ' src="' . TL_FILES_URL . $path, $this->text);
     }
     $this->Template->text = \StringUtil::encodeEmail($this->text);
     $this->Template->addImage = false;
     // Add an image
     if ($this->addImage && $this->singleSRC != '') {
         $objModel = \FilesModel::findByUuid($this->singleSRC);
         if ($objModel === null) {
             if (!\Validator::isUuid($this->singleSRC)) {
                 $this->Template->text = '<p class="error">' . $GLOBALS['TL_LANG']['ERR']['version2format'] . '</p>';
             }
         } elseif (is_file(TL_ROOT . '/' . $objModel->path)) {
             $this->singleSRC = $objModel->path;
             $this->addImageToTemplate($this->Template, $this->arrData);
         }
     }
 }
 protected function renderTitleContent()
 {
     $starLink = StarredUtil::getToggleStarStatusLink($this->model, null);
     $content = StringUtil::renderFluidContent($this->getTitle());
     $content .= $starLink;
     return ZurmoHtml::tag('h1', array(), $content);
 }
 /**
  * @see Form::readFormParameters()
  */
 public function readFormParameters()
 {
     parent::readFormParameters();
     if (isset($_POST['username'])) {
         $this->username = StringUtil::trim($_POST['username']);
     }
 }
 /**
  * @see	Action::readParameters()
  */
 public function readParameters()
 {
     parent::readParameters();
     if (isset($_POST['packageName'])) {
         $this->packageName = StringUtil::trim($_POST['packageName']);
     }
 }
 /**
  * Creates a new account
  *
  * @param	string	$accountname
  * @param	string	$password
  * @param	string	$email
  * @return	void
  */
 public function create($accountname, $password, $email)
 {
     $salt = StringUtil::getRandomID();
     $password = sha1($salt . sha1($salt . $password));
     $sql = "INSERT INTO authserv_users (accountname, password, email, salt, time) VALUES ('" . escapeString($accountname) . "', '" . $password . "', '" . escapeString($email) . "', '" . $salt . "', " . time() . ")";
     Services::getDB()->sendQuery($sql);
 }
Example #28
0
 public function actionIndex()
 {
     $shareInfo["sid"] = intval(EnvUtil::getRequest("sid"));
     $shareInfo["stable"] = StringUtil::filterCleanHtml(EnvUtil::getRequest("stable"));
     $shareInfo["initHTML"] = StringUtil::filterDangerTag(EnvUtil::getRequest("initHTML"));
     $shareInfo["curid"] = StringUtil::filterCleanHtml(EnvUtil::getRequest("curid"));
     $shareInfo["curtable"] = StringUtil::filterCleanHtml(EnvUtil::getRequest("curtable"));
     $shareInfo["module"] = StringUtil::filterCleanHtml(EnvUtil::getRequest("module"));
     $shareInfo["isrepost"] = intval(EnvUtil::getRequest("isrepost"));
     if (empty($shareInfo["stable"]) || empty($shareInfo["sid"])) {
         echo "类型和资源ID不能为空";
         exit;
     }
     if (!($oldInfo = Source::getSourceInfo($shareInfo["stable"], $shareInfo["sid"], false, $shareInfo["module"]))) {
         echo "此信息不可以被转发";
         exit;
     }
     empty($shareInfo["module"]) && ($shareInfo["module"] = $oldInfo["module"]);
     if (empty($shareInfo["initHTML"]) && !empty($shareInfo["curid"])) {
         if ($shareInfo["curid"] != $shareInfo["sid"] && $shareInfo["isrepost"] == 1) {
             $curInfo = Source::getSourceInfo($shareInfo["curtable"], $shareInfo["curid"], false, "weibo");
             $userInfo = $curInfo["source_user_info"];
             $shareInfo["initHTML"] = " //@" . $userInfo["realname"] . ":" . $curInfo["source_content"];
             $shareInfo["initHTML"] = str_replace(array("\n", "\r"), array("", ""), $shareInfo["initHTML"]);
         }
     }
     $shareInfo["shareHtml"] = !empty($oldInfo["shareHtml"]) ? $oldInfo["shareHtml"] : "";
     $data = array("shareInfo" => $shareInfo, "oldInfo" => $oldInfo);
     $this->renderPartial("index", $data);
 }
 /**
  * @see CacheBuilder::getData()
  */
 public function getData($cacheResource)
 {
     list($cache, $packageID, $languageIDs) = explode('-', $cacheResource['cache']);
     $data = array();
     // get all taggable types
     $sql = "SELECT\t\ttaggable.taggableID, taggable.name\n\t\t\tFROM\t\twcf" . WCF_N . "_package_dependency package_dependency,\n\t\t\t\t\twcf" . WCF_N . "_tag_taggable taggable\n\t\t\tWHERE \t\ttaggable.packageID = package_dependency.dependency\n\t\t\t\t\tAND package_dependency.packageID = " . $packageID . "\n\t\t\tORDER BY\tpackage_dependency.priority";
     $result = WCF::getDB()->sendQuery($sql);
     $itemIDs = array();
     while ($row = WCF::getDB()->fetchArray($result)) {
         $itemIDs[$row['name']] = $row['taggableID'];
     }
     if (count($itemIDs) > 0) {
         // get tag ids
         $tagIDs = array();
         $sql = "SELECT\t\tCOUNT(*) AS counter, object.tagID\n\t\t\t\tFROM \t\twcf" . WCF_N . "_tag_to_object object\n\t\t\t\tWHERE \t\tobject.taggableID IN (" . implode(',', $itemIDs) . ")\n\t\t\t\t\t\tAND object.languageID IN (" . $languageIDs . ")\n\t\t\t\tGROUP BY \tobject.tagID\n\t\t\t\tORDER BY \tcounter DESC";
         $result = WCF::getDB()->sendQuery($sql, 500);
         while ($row = WCF::getDB()->fetchArray($result)) {
             $tagIDs[$row['tagID']] = $row['counter'];
         }
         // get tags
         if (count($tagIDs)) {
             $sql = "SELECT\t\tname, tagID\n\t\t\t\t\tFROM\t\twcf" . WCF_N . "_tag\n\t\t\t\t\tWHERE\t\ttagID IN (" . implode(',', array_keys($tagIDs)) . ")";
             $result = WCF::getDB()->sendQuery($sql);
             while ($row = WCF::getDB()->fetchArray($result)) {
                 $row['counter'] = $tagIDs[$row['tagID']];
                 $this->tags[StringUtil::toLowerCase($row['name'])] = new Tag(null, $row);
             }
             // sort by counter
             uasort($this->tags, array('self', 'compareTags'));
             $data = $this->tags;
         }
     }
     return $data;
 }
 /**
  * Get a unique filename within given target folder, remove uniqid() suffix from file (optional, add $strPrefix) and append file count by name to
  * file if file with same name already exists in target folder
  *
  * @param string $strTarget The target file path
  * @param string $strPrefix A uniqid prefix from the given target file, that was added to the file before and should be removed again
  * @param        $i         integer Internal counter for recursion usage or if you want to add the number to the file
  *
  * @return string | false The filename with the target folder and unique id or false if something went wrong (e.g. target does not exist)
  */
 public static function getUniqueFileNameWithinTarget($strTarget, $strPrefix = null, $i = 0)
 {
     $objFile = new \File($strTarget, true);
     $strTarget = ltrim(str_replace(TL_ROOT, '', $strTarget), '/');
     $strPath = str_replace('.' . $objFile->extension, '', $strTarget);
     if ($strPrefix && ($pos = strpos($strPath, $strPrefix)) !== false) {
         $strPath = str_replace(substr($strPath, $pos, strlen($strPath)), '', $strPath);
         $strTarget = $strPath . '.' . $objFile->extension;
     }
     // Create the parent folder
     if (!file_exists($objFile->dirname)) {
         $objFolder = new \Folder(ltrim(str_replace(TL_ROOT, '', $objFile->dirname), '/'));
         // something went wrong with folder creation
         if ($objFolder->getModel() === null) {
             return false;
         }
     }
     if (file_exists(TL_ROOT . '/' . $strTarget)) {
         // remove suffix
         if ($i > 0 && StringUtil::endsWith($strPath, '_' . $i)) {
             $strPath = rtrim($strPath, '_' . $i);
         }
         // increment counter & add extension again
         $i++;
         // for performance reasons, add new unique id to path to make recursion come to end after 100 iterations
         if ($i > 100) {
             return static::getUniqueFileNameWithinTarget(static::addUniqIdToFilename($strPath . '.' . $objFile->extension, null, false));
         }
         return static::getUniqueFileNameWithinTarget($strPath . '_' . $i . '.' . $objFile->extension, $strPrefix, $i);
     }
     return $strTarget;
 }