public function verifyPurchase($userId, $itemId, $transactions) { $transactionId = null; $transactions = json_decode(stripslashes($transactions)); for ($i = 0; $i < count($transactions); $i++) { if ($transactions[$i]->itemId == $itemId) { $transactionId = $transactions[$i]->transactionId; } } if ($transactionId) { $postDetails = array(USER => UID, PWD => PASSWORD, SIGNATURE => SIG, METHOD => "GetTransactionDetails", VERSION => VER, TRANSACTIONID => $transactionId); $arrPostVals = array_map(create_function('$key, $value', 'return $key."=".$value."&";'), array_keys($postDetails), array_values($postDetails)); $postVals = rtrim(implode($arrPostVals), "&"); $response = parseString(runCurl(URLBASE, $postVals)); $custom = explode("%2c", $response["CUSTOM"]); if (getUserId() == $custom[0] && $itemId == $custom[1]) { // ADDED LINE TO GET KS SESSION $ks = getSession($itemId, $userId); // ADD KS to ARRAY $returnObj = array(success => true, error => "", transactionId => $response["TRANSACTIONID"], orderTime => $response["ORDERTIME"], paymentStatus => $response["PAYMENTSTATUS"], itemId => $itemId, userId => $userId, ks => $ks); } } else { $returnObj = array(success => false, error => "Item not found in transaction history"); } echo json_encode($returnObj); }
public function saveTextRevision($moduleId, $moduleContentTypeId, $moduleContentId, $oldText, $newText, $textfieldIndex = 0, $revision = 0) { global $dbi, $login, $settings; if (!$settings->enableRevisioning) { return; } // Get latest revision number and increment $maxRevision = 0; if (empty($revision)) { $result = $dbi->query("SELECT MAX(revision) FROM " . revisionTableName . " WHERE moduleId=" . $dbi->quote($moduleId) . " AND moduleContentTypeId=" . $dbi->quote($moduleContentTypeId) . " AND moduleContentId=" . $dbi->quote($moduleContentId)); if ($result->rows()) { list($maxRevision) = $result->fetchrow_array(); $maxRevision++; } } else { $maxRevision = $revision; } // Parse text strings $newText = parseString($newText); $oldText = parseString($oldText); // Calculate diff $diff = new Diff(); $result = $diff->stringDiff($newText, $oldText, " "); $changes = $diff->sequentialChanges($result); if (sizeof($changes) > 0) { $serializedChanges = serialize($changes); // Insert diff $dbi->query("INSERT INTO " . revisionTableName . "(moduleId,moduleContentTypeId,moduleContentId,textfieldIndex,diff,revision,userId,timestamp) VALUES(" . $dbi->quote($moduleId) . "," . $dbi->quote($moduleContentTypeId) . "," . $dbi->quote($moduleContentId) . "," . $dbi->quote($textfieldIndex) . "," . $dbi->quote($serializedChanges) . "," . $dbi->quote($maxRevision) . "," . $dbi->quote($login->id) . ",NOW())"); } return $maxRevision; }
function parse_file() { if (file_exists('japancar_krasnoyarsk.xml')) { $data = implode("", file('japancar_krasnoyarsk.xml')); $parser = xml_parser_create(); xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0); xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1); xml_parse_into_struct($parser, $data, $values, $tags); xml_parser_free($parser); // проход через структуры foreach ($tags as $key => $val) { if ($key == "data") { $molranges = $val; // каждая смежная пара значений массивов является верхней и // нижней границей определения for ($i = 0; $i < count($molranges); $i += 2) { $offset = $molranges[$i] + 1; $len = $molranges[$i + 1] - $offset; $tdb[] = parseString(array_slice($values, $offset, $len)); } } else { continue; } } return $tdb; } else { exit('Не удалось открыть файл japancar_krasnoyarsk.xml.'); } }
/** Settings constructor */ function Settings() { global $dbi; // Fetch settings from database $result = $dbi->query("SELECT " . "activateWithEmail," . "adminMail," . "allowUserRegistration," . "cacheSize," . "commentBlacklist," . "commentsRequireValidation," . "defaultPage," . "defaultUploadFolder," . "description," . "enableCaching," . "enableRevisioning," . "iconTheme," . "keywords," . "language," . "linkType," . "maxNoOfLinksInComments," . "requireValidation," . "showDirectLink," . "showPrinterLink," . "showRecommendLink," . "subtheme," . "theme," . "themeHeaderUrl," . "themeWidth," . "title" . " FROM " . settingsTableName . " WHERE id=1"); if ($result->rows()) { list($this->activateWithEmail, $this->adminMail, $this->allowUserRegistration, $this->cacheSize, $this->commentBlacklist, $this->commentsRequireValidation, $this->defaultPage, $this->defaultUploadFolder, $this->description, $this->enableCaching, $this->enableRevisioning, $this->iconTheme, $this->keywords, $this->language, $this->linkType, $this->maxNoOfLinksInComments, $this->requireValidation, $this->showDirectLink, $this->showPrinterLink, $this->showRecommendLink, $this->subtheme, $this->theme, $this->themeHeaderUrl, $this->themeWidth, $this->title) = $result->fetchrow_array(); // Parse strings $this->description = parseString($this->description); $this->keywords = parseString($this->keywords); $this->title = parseString($this->title); // Set initialized to true $this->initialized = true; } }
$high = $sortedArray[0]; $low = $sortedArray[sizeof($sortedArray) - 2]; // Get the images $images = parseString($value, "<pictures>", "</pictures>"); $imagesList = str_replace('<picture type="1" label="" url="', '', $images); $outside_img = substr($imagesList, 0, strpos($imagesList, "/>")); $outside_img = str_replace('"', "", $outside_img); $imagesList = str_replace('<picture type="2" label="" url="', '', $imagesList); $imagesList = str_replace('" />', ',', $imagesList); // remove the first entry as it will be a duplicate # $imagesList = substr($imagesList,strpos($imagesList,',')+1); $CimagesList = str_replace(trim($outside_img), "", $imagesList); $CimagesList = str_replace(', ', '', $CimagesList); $imagesList = $outside_img . $CimagesList; echo $imagesList; $record = array('PICTURES' => $CimagesList, 'PRICE_HIGH' => $high, 'PRICE_LOW' => $low, 'NAME' => parseString($value, "<title>", "</title>"), 'COTTAGE_REF' => $ref, "CLICKTHROUGH" => "http://www.mackays-self-catering.co.uk/s/process.php?r=" . $ref, "LAT" => parseString($value, "<latitude>", "</latitude>"), "LONG" => parseString($value, "<longitude>", "</longitude>"), "SLEEPS" => parseString($value, "<beds>", "</beds>"), "BEDS" => parseString($value, "<rooms>", "</rooms>"), "BATHS" => parseString($value, "<bathroom>", "</bathroom>"), "DESC" => parseString($value, '<description language="EN">', '</description>'), "PETS" => parseString($value, "<pets>", "</pets>"), "CHANGEOVER" => "Saturday"); // check for any unwanted data in the cottage reference and skip if any is found if (strpos($ref, 'encoding="utf-8') === false) { scraperwiki::save(array('COTTAGE_REF'), $record); } } function parseString($passage, $startStr, $endStr) { $start = strpos($passage, $startStr) + strlen($startStr); $end = strpos($passage, $endStr); $length = $end - $start; $txt = substr($passage, $start, $length); return clean_text($txt); } function clean_text($txt) {
function parseFetch(&$sRead, &$i, $iUid) { /* first we do a failsafe action to be sure we look at the correct arguments */ if (!$this->fetchMapping) { $this->fetchMapping = array('BODY' => 'BODYSTRUCTURE', 'BODYSTRUCTURE' => 'BODYSTRUCTURE', 'ENVELOPE' => 'ENVELOPE', 'UID' => 'UID', 'FLAGS' => 'FLAGS', 'INTERNALDATE' => 'INTERNALDATE', 'RFC822.SIZE' => 'RFC822.SIZE', 'RFC822' => 'RFC822', 'RFC822.TEXT' => 'RFC822.TEXT', 'BODY[TEXT]' => 'RFC822.TEXT', 'BODY[0]' => 'HEADER', 'BODY[HEADER]' => 'HEADER'); } $sArg = $aVal = ''; $aFetchResult = array(); while (isset($sRead[$i]) && $sRead[$i] != ')') { $cChar = strtoupper($sRead[$i]); // echo "<BR> $cChar, $i<BR>"; switch ($cChar) { case $cChar == ')': break 2; /* end of fetch */ /* end of fetch */ case ' ': ++$i; break; default: $sArg = strtoupper(parseString($sRead, array(' ', '['), $i)); //switch ($sArg) //{ //case 'BODY': // if ($sRead{$i} == '[') { // /* retrieve the section */ // $sSection = $this->parseEnclosed($sRead,$i,'[', switch (true) { case preg_match('/^BODY\\[([0-9.]+)\\.HEADER\\]$/', $sArg, $reg): $sArg = 'HEADER'; $aResult[$reg[1]][$sArg] = $this->parseHookedResult('FETCH', $sArg, $sRead, $i, $iCnt); break; case preg_match('/^BODY\\[([0-9.]+)\\.MIME\\]$/', $sArg, $reg): $sArg = 'MIME'; $aResult[$reg[1]][$sArg] = $this->parseHookedResult('FETCH', $sArg, $sRead, $i, $iCnt); break; case preg_match('/^BODY\\[HEADER.FIELDS$/', $sArg, $reg): $sArg = 'HEADER'; $aResult[$sArg] = $this->parseHookedResult('FETCH', $sArg, $sRead, $i, $iCnt); break; case preg_match('/^(BODY\\[([0-9.]+)\\])$/', $sArg, $reg): $sArg = 'BODYPART'; $aResult[$reg[1]][$sArg] = $this->parseHookedResult('FETCH', $sArg, $sRead, $i, $iCnt); break; default: if (isset($this->fetchMapping[$sArg])) { $sArg = $this->fetchMapping[$sArg]; $aResult[$sArg] = $this->parseHookedResult('FETCH', $sArg, $sRead, $i, $iCnt); } break; } $this->processFetchArguments($sRead, $i, $iCnt, $sArg, $aFetchResult); break; } } $this->streamShift($sRead, $i, $iCnt); $iUid = $aFetchResult['UID']; return $aFetchResult; }
/** * Work in process * @private * @author Marc Groot Koerkamp */ function sqimap_parse_address($read, &$i) { $arg_a = array(); for (; $read[$i] != ')'; ++$i) { $char = strtoupper($read[$i]); switch ($char) { case '{': case '"': $arg_a[] = parseString($read, $i); break; case 'n': case 'N': if (strtoupper(substr($read, $i, 3)) == 'NIL') { $arg_a[] = ''; $i += 2; } break; default: break; } } if (count($arg_a) == 4) { return $arg_a; // $adr = new AddressStructure(); // $adr->personal = $arg_a[0]; // $adr->adl = $arg_a[1]; // $adr->mailbox = $arg_a[2]; // $adr->host = $arg_a[3]; } else { $adr = ''; } return $adr; }
} // Sort categories sort($categories); // Get meta body for ($i = 0; $i < sizeof($categories); $i++) { // Get number of posts in category $numberOfPosts = 0; if (empty($categories[$i]["id"])) { $result2 = $dbi->query("SELECT COUNT(*) FROM " . newsTableName . " WHERE id NOT IN(SELECT moduleContentId FROM " . categoryContentRefTableName . " WHERE moduleId=" . $dbi->quote(newsModuleId) . " AND moduleContentTypeId=" . $dbi->quote(newsContentId) . ")"); } else { $result2 = $dbi->query("SELECT COUNT(*) FROM " . newsTableName . " WHERE id IN(SELECT moduleContentId FROM " . categoryContentRefTableName . " WHERE moduleId=" . $dbi->quote(newsModuleId) . " AND moduleContentTypeId=" . $dbi->quote(newsContentId) . " AND categoryId=" . $dbi->quote($categories[$i]["id"]) . ")"); } if ($result2->rows()) { list($numberOfPosts) = $result2->fetchrow_array(); } if ($numberOfPosts != 0) { $metaTitle = parseString($categories[$i]["title"]); $metaLink = $news->getNewsCategoryLink($categories[$i]["id"], $categories[$i]["title"]); $metaCount = $numberOfPosts; // Include meta body template include layoutPath . "/template/metaBody.template.php"; $content .= $metaBody; } } // Include meta footer template include layoutPath . "/template/metaFooter.template.php"; $content .= $metaFooter; // Cache file $cache->cacheFile("news", "newsCategories", $content); } echo $content;
/** * Retrieves a list with headers, flags, size or internaldate from the imap server */ function sqimap_get_small_header_list($imap_stream, $msg_list, $show_num = false) { global $squirrelmail_language, $color, $data_dir, $username, $imap_server_type; global $uid_support, $allow_server_sort; /* Get the small headers for each message in $msg_list */ $maxmsg = sizeof($msg_list); if ($show_num != '999999') { $msgs_str = sqimap_message_list_squisher($msg_list); } else { $msgs_str = '1:*'; } $messages = array(); $read_list = array(); /* * We need to return the data in the same order as the caller supplied * in $msg_list, but IMAP servers are free to return responses in * whatever order they wish... So we need to re-sort manually */ for ($i = 0; $i < sizeof($msg_list); $i++) { $messages["{$msg_list[$i]}"] = array(); } $internaldate = getPref($data_dir, $username, 'internal_date_sort', SMPREF_ON); if ($internaldate) { $query = "FETCH {$msgs_str} (FLAGS UID RFC822.SIZE INTERNALDATE BODY.PEEK[HEADER.FIELDS (Date To Cc From Subject X-Priority Importance Priority Content-Type)])"; } else { $query = "FETCH {$msgs_str} (FLAGS UID RFC822.SIZE BODY.PEEK[HEADER.FIELDS (Date To Cc From Subject X-Priority Importance Priority Content-Type)])"; } $read_list = sqimap_run_command_list($imap_stream, $query, true, $response, $message, $uid_support); $i = 0; foreach ($read_list as $r) { /* initialize/reset vars */ $subject = _("(no subject)"); $from = _("Unknown Sender"); $priority = 0; $messageid = '<>'; $type = array('', ''); $cc = $to = $inrepto = ''; $size = 0; // use unset because we do isset below unset($date); $flag_seen = $flag_answered = $flag_deleted = $flag_flagged = false; $read = implode('', $r); /* * #id<space>FETCH<space>( */ /* extract the message id */ $i_space = strpos($read, ' ', 2); $id = substr($read, 2, $i_space - 2); $fetch = substr($read, $i_space + 1, 5); if (!is_numeric($id) && $fetch !== 'FETCH') { set_up_language($squirrelmail_language); echo '<br /><b><font color="' . $color[2] . '">' . _("ERROR: Could not complete request.") . '</b><br />' . _("Unknown response from IMAP server:") . ' 1.' . htmlspecialchars($read) . "</font><br />\n"; break; } $i = strpos($read, '(', $i_space + 5); $read = substr($read, $i + 1); $i_len = strlen($read); $i = 0; while ($i < $i_len && $i !== false) { /* get argument */ $read = trim(substr($read, $i)); $i_len = strlen($read); $i = strpos($read, ' '); $arg = substr($read, 0, $i); ++$i; switch ($arg) { case 'UID': $i_pos = strpos($read, ' ', $i); if (!$i_pos) { $i_pos = strpos($read, ')', $i); } if ($i_pos) { $unique_id = substr($read, $i, $i_pos - $i); $i = $i_pos + 1; } else { break 3; } break; case 'FLAGS': $flags = parseArray($read, $i); if (!$flags) { break 3; } foreach ($flags as $flag) { $flag = strtolower($flag); switch ($flag) { case '\\seen': $flag_seen = true; break; case '\\answered': $flag_answered = true; break; case '\\deleted': $flag_deleted = true; break; case '\\flagged': $flag_flagged = true; break; default: break; } } break; case 'RFC822.SIZE': $i_pos = strpos($read, ' ', $i); if (!$i_pos) { $i_pos = strpos($read, ')', $i); } if ($i_pos) { $size = substr($read, $i, $i_pos - $i); $i = $i_pos + 1; } else { break 3; } break; case 'INTERNALDATE': $date = parseString($read, $i); //if ($tmpdate === false) break 3; //$tmpdate = str_replace(' ',' ',$tmpdate); //$tmpdate = explode(' ',$tmpdate); //$date = str_replace('-',' ',$tmpdate[0]) . " " . // $tmpdate[1] . ' ' . $tmpdate[2]; break; case 'BODY.PEEK[HEADER.FIELDS': case 'BODY[HEADER.FIELDS': $i = strpos($read, '{', $i); $header = parseString($read, $i); if ($header === false) { break 2; } /* First we replace all \r\n by \n, and unfold the header */ $hdr = trim(str_replace(array("\r\n", "\n\t", "\n "), array("\n", ' ', ' '), $header)); /* Now we can make a new header array with */ /* each element representing a headerline */ $hdr = explode("\n", $hdr); foreach ($hdr as $line) { $pos = strpos($line, ':'); if ($pos > 0) { $field = strtolower(substr($line, 0, $pos)); if (!strstr($field, ' ')) { /* valid field */ $value = trim(substr($line, $pos + 1)); switch ($field) { case 'to': $to = $value; break; case 'cc': $cc = $value; break; case 'from': $from = $value; break; case 'date': $date = $value; break; case 'x-priority': case 'importance': case 'priority': $priority = parsePriority($value); break; case 'subject': $subject = $value; if ($subject == "") { $subject = _("(no subject)"); } break; case 'content-type': $type = strtolower($value); if ($pos = strpos($type, ";")) { $type = substr($type, 0, $pos); } $type = explode("/", $type); if (empty($type[0])) { $type[0] = 'text'; // I had this added, but not committed to CVS.... did it help fix something? // $type[1] = 'plain'; } if (empty($type[1])) { $type[1] = 'plain'; } break; default: break; } } } } break; default: ++$i; break; } } if (isset($date)) { $date = str_replace(' ', ' ', $date); $tmpdate = explode(' ', trim($date)); } else { $tmpdate = $date = array(); } if ($uid_support) { $msgi = "{$unique_id}"; $messages[$msgi]['ID'] = $unique_id; } else { $msgi = "{$id}"; $messages[$msgi]['ID'] = $id; } $messages[$msgi]['TIME_STAMP'] = getTimeStamp($tmpdate); $messages[$msgi]['DATE_STRING'] = getDateString($messages[$msgi]['TIME_STAMP']); $messages[$msgi]['FROM'] = $from; //parseAddress($from); $messages[$msgi]['SUBJECT'] = $subject; // if (handleAsSent($mailbox)) { $messages[$msgi]['TO'] = $to; //parseAddress($to); // } $messages[$msgi]['PRIORITY'] = $priority; $messages[$msgi]['CC'] = $cc; //parseAddress($cc); $messages[$msgi]['SIZE'] = $size; $messages[$msgi]['TYPE0'] = $type[0]; $messages[$msgi]['TYPE1'] = $type[1]; $messages[$msgi]['FLAG_DELETED'] = $flag_deleted; $messages[$msgi]['FLAG_ANSWERED'] = $flag_answered; $messages[$msgi]['FLAG_SEEN'] = $flag_seen; $messages[$msgi]['FLAG_FLAGGED'] = $flag_flagged; /* non server sort stuff */ if (!$allow_server_sort) { $from = parseAddress($from); if ($from[0][1]) { $from = decodeHeader($from[0][1], true, false); } else { $from = $from[0][0]; } $messages[$msgi]['FROM-SORT'] = $from; $subject_sort = strtolower(decodeHeader($subject, true, false)); if (preg_match("/^(?:(?:vedr|sv|re|aw|fw|fwd|\\[\\w\\]):\\s*)*\\s*(.*)\$/si", $subject_sort, $matches)) { $messages[$msgi]['SUBJECT-SORT'] = $matches[1]; } else { $messages[$msgi]['SUBJECT-SORT'] = $subject_sort; } } ++$msgi; } array_reverse($messages); $new_messages = array(); foreach ($messages as $i => $message) { $new_messages[] = $message; } return $new_messages; }
$index++; } setPost('upload', addProfile($profile)); // TODO: Detect if there are collision of ID numbers if (getPost('upload') == 'success') { $addedProfiles++; } } setPost('upload', 'success'); } } } else { if (issetPost('add')) { $profileString = array('id', 'course', 'surname', 'firstname', 'mi', 'mobile', 'email'); $profileNull = array('birthday'); $profileNum = array('yr', 'gender', 'scholar', 'dormer', 'currentStatus', 'loawRecord', 'y1s1', 'y1s2', 'y2s0', 'y2s1', 'y2s2', 'y3s0', 'y3s1', 'y3s2', 'y4s0', 'y4s1', 'y4s2', 'y5s0', 'y5s1', 'y5s2', 'familyLivingSituation', 'atmosphereAtHome', 'parentsMaritalStatus', 'relFather', 'relMother', 'spiritualSubscale', 'godSubscale', 'problemSolving', 'seekingSocialSupport', 'avoidance', 'lvlDepression', 'lvlAnxiety', 'suicideBehavior', 'suicidalThoughts', 'hypochondriasis', 'depression', 'denial', 'interProblems', 'alienation', 'perseIdeas', 'anxiety', 'thinkingDisorder', 'impulseExp', 'socialIntroversion', 'selfDepreciation', 'deviation', 'mentalDisorder', 'alcoholUse', 'drugUse', 'hopelessness', 'traumaAbuse', 'physicalIllness', 'pastSuicidalActs', 'familyHistorySuicide', 'familyHistoryMental', 'stressfulLifeEvents', 'relationalSocialLoss', 'accessLethalMeans', 'disciplinaryCases', 'sexualOrientation'); $profile = array(); for ($i = 0; count($profileString) > $i; $i++) { $profile[$profileString[$i]] = getPost($profileString[$i]); } for ($i = 0; count($profileNull) > $i; $i++) { $profile[$profileNull[$i]] = parseString(getPost($profileNull[$i])); } for ($i = 0; count($profileNum) > $i; $i++) { $profile[$profileNum[$i]] = parseNumber(getPost($profileNum[$i])); } $addedProfile = addProfile($profile); } } } include 'add-profiles.html.php';
function protectFile($file, $key = "", $line = null) { if (strpos($_SERVER['PHP_SELF'], $file)) { if (!empty($key)) { if (isset($_GET['accesskey'])) { if ($_GET['accesskey'] == $key) { return; } } } $error = parseString(loadString("direct_access_forbidden") . "[dotted]protectFile(\"{$file}\")[/dotted]"); if ($line) { $error .= parseString(" on line {$line}"); } $error .= parseString(" in {$file}."); if (empty($key)) { $error .= parseString("<br />" . loadString("file_no_accesskey")); } echo writeError(9099, $error); die; } }
function getCustomerDetails1() { //Fetch Failure and Complaint List for that Employee $complaintNumber = $_GET["complaintNumber"]; $fields = "cust_name, cust_address, cust_email, cust_mobile"; $table = "complaint"; $rows = singlerec($fields, $table, "complaint_no=" . $complaintNumber); $row = mysql_fetch_row($rows); $str = '{"cust_name" : "' . $row[0] . '", "cust_address" : "' . parseString($row[1]) . '", "cust_email" : "' . $row[2] . '", "cust_mobile" : "' . $row[3] . '"}'; echo $str; }
/** * Save blog post. * @param $readPost Read values from post. * @return ErrorLog object if there were errors. */ function savePost($readPost = true) { global $category, $dbi, $log, $login; // Check if data is submitted from the form if ($readPost) { checkSubmitter(); } // Create ErrorLog object $errorLog = new ErrorLog(); // Get blog id and create blog object $this->blog = new Blog(getValue("blogId")); // Check if blog exists if (!empty($this->blog->id)) { if ($this->hasEditPermission()) { // Include language include scriptPath . "/" . folderBlog . "/include/language/" . $this->blog->language . "/general.php"; // Save if post was draft before $draftBefore = $this->draft; // Save blog post values if ($readPost) { $this->categories = explode(",", getPostValue("categories")); $this->disableComments = getPostValue("disableComments"); $this->draft = getPostValue("draft"); $this->showComments = getPostValue("showComments"); $this->subject = parseHtml(getPostValue("subject"), 1); $this->summary = parseThumbnailImages(parseHtml(getPostValue("summary"), 4)); $this->text = parseThumbnailImages(parseHtml(getPostValue("text"), 4)); $userId = getPostValue("userId"); // Get publication time $day = getPostValue("day"); $month = getPostValue("month"); $year = getPostValue("year"); $hour = getPostValue("hour"); $minute = getPostValue("minute"); // Process input if (!empty($day) && !empty($month) && !empty($year)) { $this->posted = mktime($hour, $minute, 0, $month, $day, $year); } if (!empty($userId)) { $this->user = new User($userId); } } // Validate post data if (empty($this->posted)) { $this->posted = mktime(); } if (empty($userId)) { $this->user = new User($login->id); } if (empty($this->subject)) { $errorLog->addError("subject", $lBlogEditPost["MissingSubject"]); } // Check if post has been modified $lastUpdated = getValue("lastUpdated"); if ($lastUpdated != $this->getLastUpdated()) { $errorLog->addError("postModified", $lBlogEditPost["PostModified"]); } // Prepare values for notification $subject = "[" . $this->blog->title . "] " . $this->subject; $message = "<p>" . $lBlogEditPost["NotifyInsert"] . " '" . $this->blog->title . "'.</p>" . "<p><b>" . $lBlogEditPost["Name"] . "</b></p><p>" . $login->name . "</p>" . "<p><b>" . $lBlogEditPost["Subject"] . "</b></p><p>" . $this->subject . "</p>" . "<p><b>" . $lBlogEditPost["Summary"] . "</b></p>" . parseString(!empty($this->summary) ? $this->summary : (!empty($this->text) ? $this->text : "")) . "<p>--<br />" . $lBlogEditPost["ReadPost"] . ": " . $this->getPostLink() . "<br />" . $lBlogEditPost["VisitBlog"] . ": " . $this->blog->getBlogLink() . "</p>"; $sender = $login->name; // If no errors proceed, otherwise return errors if (!$errorLog->hasErrors()) { if (empty($this->id)) { // Insert into database $dbi->query("INSERT INTO " . blogPostTableName . "(blogId,userId,subject,summary,text,posted,lastUpdated,showComments,disableComments,draft) VALUES(" . $dbi->quote($this->blog->id) . "," . $dbi->quote($this->user->id) . "," . $dbi->quote($this->subject) . "," . $dbi->quote($this->summary) . "," . $dbi->quote($this->text) . ",FROM_UNIXTIME(" . $dbi->quote($this->posted) . "),NOW()," . $dbi->quote($this->showComments) . "," . $dbi->quote($this->disableComments) . "," . $dbi->quote($this->draft) . ")"); // Get new post id $this->id = $dbi->getInsertId(); // Notify subscribers about the new post if (!$this->draft) { $this->notifySubscribers($sender, $subject, $message); } } else { // Update values in database $dbi->query("UPDATE " . blogPostTableName . " SET blogId=" . $dbi->quote($this->blog->id) . ",userId=" . $dbi->quote($this->user->id) . ",subject=" . $dbi->quote($this->subject) . ",summary=" . $dbi->quote($this->summary) . ",text=" . $dbi->quote($this->text) . ",posted=FROM_UNIXTIME(" . $dbi->quote($this->posted) . "),lastUpdated=lastUpdated,showComments=" . $dbi->quote($this->showComments) . ",disableComments=" . $dbi->quote($this->disableComments) . ",draft=" . $dbi->quote($this->draft) . " WHERE id=" . $dbi->quote($this->id)); // Notify subscribers if the post was a draft previously if (!$this->draft && $draftBefore) { $this->notifySubscribers($sender, $subject, $message); } } // Associate categories with this post $category->addCategoryReferences(blogModuleId, blogPostContentId, $this->id, $this->categories); // Log transaction $log->logTransaction(blogPostContentId, $this->id); // Delete cached files if (!empty($this->blog)) { $this->blog->deleteCache(); } } } } return $errorLog; }
echo "<a href=\"" . scriptUrl . "/" . folderCategory . "/" . fileCategoryIndex . "?sortby=count" . ($sortby == "count" ? " desc" : "") . (!empty($searchString) ? "&searchString=" . $searchString : "") . "\" class=\"columnHeader1\">" . $lCategoryIndex["References"] . "</a>" . ($sortby == "count" || $sortby == "count desc" ? ' <img src="' . iconUrl . '/sort' . ($sortby == "references desc" ? "up" : "down") . '.gif" />' : ''); echo "</td>"; echo "</tr>"; for ($i = 0; $i < sizeof($categories); $i++) { echo "<tr>"; echo "<td height=\"30\" class=\"item" . ($i % 2 == 0 ? "Alt" : "") . "\">"; echo "<input type=\"checkbox\" name=\"categories[]\" value=\"" . $categories[$i][1] . "\" />"; echo "</td>"; echo "<td height=\"30\" width=\"16\" class=\"item" . ($i % 2 == 0 ? "Alt" : "") . "\">"; echo "<a href=\"" . scriptUrl . "/" . folderCategory . "/" . fileCategoryEdit . "?categoryId=" . $categories[$i][1] . "&return=1\"><img src=\"" . iconUrl . "/edit.gif\" border=\"0\" title=\"" . $lCategoryEdit["EditCategoryText"] . "\" alt=\"" . $lCategoryEdit["EditCategoryText"] . "\" /></a>"; echo "</td>"; echo "<td width=\"40%\" class=\"item" . ($i % 2 == 0 ? "Alt" : "") . "\">"; echo "<a href=\"" . scriptUrl . "/" . folderCategory . "/" . fileCategory . "?categoryId=" . $categories[$i][1] . "\">" . parseString($categories[$i][0]) . "</a>"; echo "</td>"; echo "<td width=\"40%\" class=\"small1 item" . ($i % 2 == 0 ? "Alt" : "") . "\">"; echo !empty($categories[$i][2]) ? parseString($categories[$i][2]) : $lCategoryIndex["NoDescription"]; echo "</td>"; echo "<td width=\"20%\" align=\"center\" class=\"small1 item" . ($i % 2 == 0 ? "Alt" : "") . "\">"; echo $categories[$i][3]; echo " "; echo "</td>"; echo "</tr>"; } echo "</table>"; echo "<table width=\"100%\"><tr><td><input type=\"submit\" name=\"delete\" value=\"" . $lButtons["Delete"] . "\" class=\"button\" onclick=\"var agree=confirm('" . $lCategoryIndex["ConfirmDelete"] . "');if(agree) {return true;}else {return false;}\" /> </td><td align=\"right\"><input type=\"button\" name=\"selectNoneButton\" value=\"" . $lButtons["SelectNone"] . "\" class=\"button\" onclick=\"selectAll(document.categoriesForm, this, false)\" /> <input type=\"button\" name=\"selectAllButton\" value=\"" . $lButtons["SelectAll"] . "\" class=\"button\" onclick=\"selectAll(document.categoriesForm, this, true)\" /></td></tr></table>"; echo "</form>"; // Print page index echo "<p align=\"center\">"; echo $site->generatePageLinks(folderCategory . "/" . fileCategoryIndex . "?", $pageNumber, $count, 30); echo "</p>"; } else {
$curKey = $key; } } $curDoc = $docs[$curKey]; $next = $docs[$curKey + 1]; $prev = $docs[$curKey - 1]; if (!isset($next) && $letsCycle) { $next = $docs[0]; } if (!isset($prev) && $letsCycle) { $prev = $docs[count($docs) - 1]; } if ($useBuildInTpl) { $rNext = parseString($nextTpl, array('id' => $next['id'], 'pagetitle' => $next['pagetitle'])); $rPrev = parseString($prevTpl, array('id' => $prev['id'], 'pagetitle' => $prev['pagetitle'])); } else { $rNext = $modx->parseChunk($nextTpl, array('id' => $next['id'], 'pagetitle' => $next['pagetitle']), '[+', '+]'); $rPrev = $modx->parseChunk($prevTpl, array('id' => $prev['id'], 'pagetitle' => $prev['pagetitle']), '[+', '+]'); } if ($curDoc['parent'] == $folderId) { if ($directOutput) { echo parseString($directOutputTpl, array('next' => $rNext, 'prev' => $rPrev)); } else { if (isset($next)) { $modx->setPlaceholder($id . 'next', $rNext); } if (isset($prev)) { $modx->setPlaceholder($id . 'prev', $rPrev); } } }
<?php if (isset($_GET['component'])) { $component = parseString($_GET['component'], 4, 1); } if (isset($_GET['section'])) { $section = parseString($_GET['section'], 4, 1); }
<?php // Get cache content global $cache, $dbi, $site; $content = $cache->getCacheFileContent("", "latestPosts", 3600 * 4); if (empty($content)) { $postLimit = !empty($postLimit) ? $postLimit : 10; $result = $dbi->query("SELECT id FROM " . blogPostTableName . " ORDER BY posted DESC LIMIT " . $postLimit); if ($result->rows()) { // Include meta header template $metaTitle = !empty($metaTitle) ? $metaTitle : "Seneste indlæg"; include layoutPath . "/template/metaHeader.template.php"; $content = $metaHeader; for ($i = 0; list($id) = $result->fetchrow_array(); $i++) { $post = new Post($id); $metaTitle = parseString($post->subject); $metaLink = $post->getPostLink(); $metaInfo = $site->generateTimestamp($post->posted, true); $metaCount = -1; // Include meta body template include layoutPath . "/template/metaBody.template.php"; $content .= $metaBody; } // Include meta footer template include layoutPath . "/template/metaFooter.template.php"; $content .= $metaFooter; } // Save output in cache $cache->cacheFile("", "latestPosts", $content); } echo $content;
<?php // Include common functions and declarations require_once "include/common.php"; // Get get values $down = getGetValue("down"); $id = getGetValue("id"); $pageNumber = getGetValue("page"); $position = getGetValue("position"); $up = getGetValue("up"); $visible = getGetValue("visible"); // Get search string values $searchString = parseString(getValue("searchString"), true); $searchType = parseString(getValue("searchType"), true); // Set limits for search results based on search type $viewAll = !empty($searchType) ? true : false; $limit = $viewAll ? 15 : 5; // Count page number down by 1 if (!empty($pageNumber)) { $pageNumber = $pageNumber - 1; } // Move search section up or down if ($login->isWebmaster()) { if (!empty($id) && !empty($position)) { if (!empty($up)) { $result = $dbi->query("SELECT id,position FROM " . searchTypeTableName . " WHERE position<" . $dbi->quote($position) . " ORDER BY position DESC LIMIT 1"); if ($result->rows()) { list($swapId, $swapPos) = $result->fetchrow_array(); $dbi->query("UPDATE " . searchTypeTableName . " SET position=" . $dbi->quote($swapPos) . " WHERE id=" . $dbi->quote($id)); $dbi->query("UPDATE " . searchTypeTableName . " SET position=" . $dbi->quote($position) . " WHERE id=" . $dbi->quote($swapId)); }
} else { $name = !empty($comment->mail) ? "<a href=\"mailto:" . $comment->mail . "\">" . (!empty($comment->name) ? $comment->name : "-") . "</a>" : (!empty($comment->name) ? $comment->name : "-"); } echo $name; echo "</td>"; echo "<td width=\"20%\" nowrap=\"nowrap\" class=\"small1 item" . ($i % 2 == 0 ? "Alt" : "") . "\">"; echo $site->generateTimestamp($comment->posted, true); echo "</td>"; echo "<td class=\"small1 item" . ($i % 2 == 0 ? "Alt" : "") . "\" align=\"center\">"; echo !$comment->spam ? "<a href=\"" . scriptUrl . "/" . folderComment . "/" . fileCommentIndex . "?commentId=" . $comment->id . "&spam=1\"><img src=\"" . iconUrl . "/spam.gif\" border=\"0\" alt=\"" . $lButtons["MarkSpam"] . "\" title=\"" . $lButtons["MarkSpam"] . "\" /></a>" : "<a href=\"" . scriptUrl . "/" . folderComment . "/" . fileCommentIndex . "?commentId=" . $comment->id . "&spam=0\"><img src=\"" . iconUrl . "/notspam.gif\" border=\"0\" alt=\"" . $lButtons["MarkNotSpam"] . "\" title=\"" . $lButtons["MarkNotSpam"] . "\" /></a>"; echo "</td>"; echo "</tr>"; echo "<tr>"; echo "<td colspan=\"2\" class=\"small1 item" . ($i % 2 == 0 ? "Alt" : "") . "\"> </td>"; echo "<td colspan=\"4\" class=\"small1 item" . ($i % 2 == 0 ? "Alt" : "") . "\">"; echo parseString($comment->message); echo "</td>"; echo "</tr>"; } echo "</table>"; echo "<table width=\"100%\"><tr><td><input type=\"submit\" name=\"deleteComments\" value=\"" . $lButtons["Delete"] . "\" class=\"button\" onclick=\"var agree=confirm('" . $lCommentIndex["ConfirmDelete"] . "');if(agree) {return true;}else {return false;}\" />" . ($commentType == 2 ? " <input type=\"submit\" name=\"deleteSpamComments\" value=\"" . $lButtons["DeleteAll"] . "\" class=\"button\" onclick=\"var agree=confirm('" . $lCommentIndex["ConfirmDeleteSpam"] . "');if(agree) {return true;}else {return false;}\" />" : "") . ($commentType == 1 ? " <input type=\"submit\" name=\"deleteTrashComments\" value=\"" . $lButtons["DeleteAll"] . "\" class=\"button\" onclick=\"var agree=confirm('" . $lCommentIndex["ConfirmDeleteTrash"] . "');if(agree) {return true;}else {return false;}\" />" : "") . " <input type=\"submit\" name=\"" . ($commentType == 2 ? "spam" : "notSpam") . "\" value=\"" . ($commentType == 2 ? $lButtons["Spam"] : $lButtons["NotSpam"]) . "\" class=\"button\" /></td><td align=\"right\"><input type=\"button\" name=\"selectNoneButton\" value=\"" . $lButtons["SelectNone"] . "\" class=\"button\" onclick=\"selectAll(document.commentsForm, this, false)\" /> <input type=\"button\" name=\"selectAllButton\" value=\"" . $lButtons["SelectAll"] . "\" class=\"button\" onclick=\"selectAll(document.commentsForm, this, true)\" /></td></tr></table>"; echo "</form>"; // Print page index echo "<br /><center>"; echo $site->generatePageLinks(folderComment . "/" . fileCommentIndex . (!empty($request) ? $request . "&" : ""), $pageNumber, $commentType == 1 ? $comment->getNumberOfTrashComments(0, $moduleContentTypeId, $moduleContentId, $searchQuery) : ($commentType == 2 ? $comment->getNumberOfSpamComments(0, $moduleContentTypeId, $moduleContentId, $searchQuery) : $comment->getNumberOfComments(0, $moduleContentTypeId, $moduleContentId, $searchQuery)), 30); echo "</center>"; } else { echo "<p><i>" . $lCommentIndex["NoComments"] . "</i></p>"; } // Print common footer $site->printFooter();
<?php include "../API.php"; if (file_exists($API['root'] . "xml/config.xml")) { writeJARDMessage("Welcome to JArD", "This pages shows you have sucessfully installed JArD onto your personal webserver."); } else { writeError(9095, parseString(loadString("new_install_welcome"))); }
/** * Initialize object. * @param $id Blog identifier. * @param $title Blog title. */ function init($id = 0, $title = "") { if (!empty($id) || !empty($title)) { global $dbi; // Get blog data $result = $dbi->query("SELECT id,title,category,description,subscribers,language,postLimit,commentLimit,showRSSLink,showRSSCommentsLink,position FROM " . blogTableName . " WHERE " . (!empty($id) ? "id=" . $dbi->quote($id) : "") . (!empty($title) ? (!empty($id) ? " OR " : "") . "title=" . $dbi->quote(addslashes($title)) : "")); if ($result->rows()) { list($this->id, $this->title, $this->category, $this->description, $this->subscribers, $this->language, $this->postLimit, $this->commentLimit, $this->showRSSLink, $this->showRSSCommentsLink, $this->position) = $result->fetchrow_array(); // Parse text $this->title = parseString($this->title); $this->description = parseString($this->description); } $result->finish(); } }
/** * Initialize User object. * @param $id User identifier. * @param $username Username of user. * @param $email Email of user. */ function init($id = 0, $username = "", $email = "") { global $dbi; // Fetch user data if (!empty($id) || !empty($username)) { $result = $dbi->query("SELECT id,username,groupId,UNIX_TIMESTAMP(registered),UNIX_TIMESTAMP(lastUpdated),UNIX_TIMESTAMP(lastLogged),administrator,webmaster,activated " . "FROM " . userTableName . " " . "WHERE " . (!empty($id) ? "id=" . $dbi->quote($id) : (!empty($username) ? "username="******""))); if ($result->rows()) { list($this->id, $this->username, $this->groupId, $this->registered, $this->lastUpdated, $this->lastLogged, $this->administrator, $this->webmaster, $this->activated) = $result->fetchrow_array(); // Fetch user information $result = $dbi->query("SELECT categoryId,name,email,phone,mobile,linkurl,linkname,facebook,twitter,location,department,position,profileText,signature,hideEmail,hideTelephone,hideInUserlist,hideOnlineStatus,notifyAboutChanges " . "FROM " . userDataTableName . " " . "WHERE id=" . $dbi->quote($this->id)); if ($result->rows()) { list($this->categoryId, $this->name, $this->email, $this->phone, $this->mobile, $this->linkurl, $this->linkname, $this->facebook, $this->twitter, $this->location, $this->department, $this->position, $this->profileText, $this->signature, $this->hideEmail, $this->hideTelephone, $this->hideInUserlist, $this->hideOnlineStatus, $this->notifyAboutChanges) = $result->fetchrow_array(); $this->name = parseString($this->name); $this->linkname = parseString($this->linkname); $this->linkurl = parseString($this->linkurl); $this->location = parseString($this->location); $this->position = parseString($this->position); $this->profileText = parseString($this->profileText); $this->signature = parseString($this->signature); $this->department = parseString($this->department); } } } }
/** * Save comment in database * @param $moduleId Module id to add comment to. * @param $moduleContentTypeId Identifier of content type. * @param $moduleContentId Identifier of content. * @return List of errors if any. */ function saveComment($moduleId, $moduleContentTypeId, $moduleContentId) { global $dbi, $errors, $login, $referer, $settings, $spamFilter; global $lComment, $lEditComment; // Check if data is submitted from the form checkSubmitter(); // Get user ip $ip = getenv("REMOTE_ADDR"); // Get values $this->moduleId = $moduleId; $this->moduleContentTypeId = $moduleContentTypeId; $this->moduleContentId = $moduleContentId; $this->name = parseString(stripHtml(getValue("name"))); $this->mail = parseString(stripHtml(getValue("mail"))); $this->link = parseString(stripHtml(getValue("link"))); $this->subject = parseString(stripHtml(getValue("subject"))); $this->message = parseString(stripHtml(getValue("message"))); $this->spam = getValue("spam"); $this->userId = getValue("userId"); // Get default name $defaultName = parseString(getPostValue("defaultName")); // Validate comment data if (empty($this->id)) { if (!$this->hasCommentPermission()) { $errors->addError("permissions", $lEditComment["InsufficientPermissions"]); } if (!$login->isLoggedIn()) { if ($settings->commentsRequireValidation) { if (!audit()) { $errors->addError("validation", $lComment["WrongValidation"]); } } if (empty($this->name) || $this->name == $defaultName) { $errors->addError("name", $lEditComment["MissingName"]); } } } else { if (!$this->hasEditPermission()) { $errors->addError("permissions", $lEditComment["InsufficientPermissions"]); } else { if (empty($this->name) && empty($this->userId)) { $errors->addError("name", $lEditComment["MissingName"]); } } } if (empty($this->subject)) { $errors->addError("subject", $lEditComment["MissingSubject"]); } if (empty($this->message)) { $errors->addError("message", $lEditComment["MissingText"]); } // Check if message could be classified as spam $spam = $spamFilter->isSpam($this->name, $this->mail, $this->subject, $this->message); // Check if this ip has been spam before if (!$spam) { $result = $dbi->query("SELECT COUNT(*) FROM " . commentTableName . " WHERE spam=1 AND ip=" . $dbi->quote($ip)); if ($result->rows()) { list($count) = $result->fetchrow_array(); if ($count != 0) { $spam = true; } } } // If there were no errors insert or update comment if (!$errors->hasErrors()) { if (empty($this->id)) { // Insert into comment database $dbi->query("INSERT INTO " . commentTableName . "(moduleId,moduleContentTypeId,moduleContentId,userId,name,mail,link,subject,message,ip,posted,spam,trash) VALUES(" . $dbi->quote($moduleId) . "," . $dbi->quote($moduleContentTypeId) . "," . $dbi->quote($moduleContentId) . "," . ($login->isLoggedIn() ? $login->id : 0) . "," . $dbi->quote($this->name) . "," . $dbi->quote($this->mail) . "," . $dbi->quote($this->link) . "," . $dbi->quote($this->subject) . "," . $dbi->quote($this->message) . "," . $dbi->quote($ip) . ",NOW()," . $dbi->quote($spam) . ",0)"); // Get new comment id $this->id = $dbi->getInsertId(); } else { // Update values in database $dbi->query("UPDATE " . commentTableName . " SET name=" . $dbi->quote($this->name) . ",mail=" . $dbi->quote($this->mail) . ",link=" . $dbi->quote($this->link) . ",subject=" . $dbi->quote($this->subject) . ",message=" . $dbi->quote($this->message) . ",posted=posted,spam=" . $dbi->quote($spam) . " WHERE (id=" . $dbi->quote($this->id) . ")"); } // Remember poster $remember = getValue("remember"); if (!empty($remember)) { $poster["name"] = stripslashes($this->name); $poster["mail"] = stripslashes($this->mail); $poster["link"] = stripslashes($this->link); $poster["remember"] = stripslashes($remember); setcookie("commentPoster", addslashes(serialize($poster)), time() + 31536000); } } // Return errors if any return $errors; }
echo "<option value=\"{$file}\"" . (pageLanguage == $file ? " selected=\"selected\"" : "") . ">{$language}</option>"; } } } ?> </select> <p><?php echo $lSettings["DefaultPage"]; ?> <br /> <select name="defaultPage" class="longInput"> <?php $result = $dbi->query("SELECT id,title FROM " . pageTableName . " WHERE showInMenu=1 AND parentId=0 ORDER BY position"); for ($i = 0; list($pageId, $pageTitle) = $result->fetchrow_array(); $i++) { echo "<option value=\"{$pageId}\"" . ($pageId == $settings->defaultPage ? "selected=\"selected\"" : "") . "\">" . parseString($pageTitle) . "</option>"; } ?> </select></p> <p><?php echo $lSettings["DefaultUploadFolder"]; ?> <br /> <select name="defaultUploadFolder" class="longInput"> <option value="0"<?php echo pageUploadFolder == 0 ? " selected=\"selected\"" : ""; ?> >/</option> <?php function printFolderOptions($id = 0, $level = 1)
unset($imageArr[0]); foreach ($imageArr as $item) { $pic .= str_replace("</image>", "", $item . ","); } $features = parseString($value, "<features>", "</features>"); $cottfeatures = ""; $featuresArr = explode("label", $features); unset($featuresArr[0]); foreach ($featuresArr as $item) { $length = strpos($item, "id="); $cottfeatures .= substr($item, 2, $length) . ","; $cottfeatures = str_replace('" id', "", $cottfeatures); } $town = str_replace("<![CDATA[", "", $town); $town = substr($town, 0, strpos($town, "(")); if (strlen($town) < 1) { $town = parseString($value, "<postal_town>", "</postal_town>"); } $record = array('COTTAGE_LINK' => trim(clean_text($cottage_link)), 'PRICE_HIGH' => trim(clean_text($pricemax)), 'PRICE_LOW' => trim(clean_text($pricemin)), 'CHANGEOVERDAY' => trim(clean_text($changeover_day)), 'SLEEPS' => trim(clean_text($sleeps)), 'BEDROOMS' => trim(clean_text($bedrooms)), 'BATHROOMS' => trim(clean_text($bathrooms)), 'PETS' => trim(clean_text($pets)), 'COTTAGE_REFERENCE' => trim(clean_text($cottageID)), 'FEATURES' => trim(clean_text($cottfeatures)), 'DESCRIPTION' => trim(clean_text($description)), 'LOCATION_DESCRIPTON' => "N/A", 'LONGITUDE' => trim($long), 'LATITUDE' => trim($lat), 'IMAGES' => trim($pic), 'Town' => trim(clean_text($town)), 'Agent' => "holidaycottages.co.uk"); if (!strpos($cottage_link, 'version="1.0"')) { scraperwiki::save(array('COTTAGE_LINK'), $record); } } function parseString($passage, $startStr, $endStr) { $start = strpos($passage, $startStr) + strlen($startStr); $end = strpos($passage, $endStr); $length = $end - $start; $txt = substr($passage, $start, $length); return clean_text($txt); }
function setMetaKeywords($metaKeywords) { $metaKeywords = stripHtml(validateTextLength(parseString($metaKeywords), 300)); $this->metaKeywords = $metaKeywords; }
function intersectionList($input) { $values = parseString($input); if ($values["has-error"]) { return "input error"; } else { $result = traverseIntersection($values["left-border"], $values["right-border"], $values["is-open-left"], $values["is-open-right"]); return toString($result["left-border"], $result["right-border"], $result["is-open-left"], $result["is-open-right"], $values["index"]); } }
/** * Initialize page. * @param $id Page identifier. * @param $title Page title. */ function init($id, $title = "") { // Reset to default values $this->disableComments = 0; $this->fullLink = ""; $this->leftTemplate = 0; $this->leftText = ""; $this->link = ""; $this->navbarTitle = ""; $this->parent = null; $this->position = 0; $this->rightTemplate = 0; $this->rightText = ""; $this->separator = 0; $this->showComments = 0; $this->showInMenu = 1; $this->showLastModified = 0; $this->text = ""; $this->title = ""; // Attempt to read values from database if (!empty($id) && is_numeric($id) || !empty($title)) { global $dbi; // Fetch page data from database $result = $dbi->query("SELECT id,parentId,title,text,leftTemplate,leftText,rightTemplate,rightText,link,position,showComments,disableComments,showInMenu,showLastModified,navbarTitle,`separator` FROM " . pageTableName . " WHERE " . (!empty($id) ? "id=" . $dbi->quote($id) : (!empty($title) ? "title=" . $dbi->quote($title) . " OR navbarTitle=" . $dbi->quote($title) : ""))); if ($result->rows()) { list($this->id, $parentId, $this->title, $this->text, $this->leftTemplate, $this->leftText, $this->rightTemplate, $this->rightText, $this->link, $this->position, $this->showComments, $this->disableComments, $this->showInMenu, $this->showLastModified, $this->navbarTitle, $this->separator) = $result->fetchrow_array(); // Parse strings $this->title = parseString($this->title); $this->text = parseString($this->text); $this->leftText = parseString($this->leftText); $this->rightText = parseString($this->rightText); $this->parent = new Page($parentId); // If link does not contain http:// or https:// prepend scriptUrl if (!empty($this->link)) { $this->link = parseString($this->link); if (substr($this->link, 0, 7) != "http://" && substr($this->link, 0, 8) != "https://") { $this->fullLink = scriptUrl . "/" . $this->link; } else { $this->fullLink = $this->link; } } } } }
/** * Initialize Category object. * @param $id Category identifier. * @param $title Category title. */ function init($id, $title = "") { if (!empty($id) || !empty($title)) { global $dbi; // Get category data $result = $dbi->query("SELECT id,title,description FROM " . categoryTableName . " WHERE " . (!empty($id) ? "id=" . $dbi->quote($id) : "") . (!empty($title) ? "title=" . $dbi->quote(addslashes($title)) : "")); if ($result->rows()) { list($this->id, $this->title, $this->description) = $result->fetchrow_array(); // Parse strings $this->title = parseString($this->title); $this->description = parseString($this->description); } // Free result $result->finish(); } else { $this->id = -1; } }
$content = $cache->getCacheFileContent("", "latestComments", 3600 * 4); if (empty($content) || true) { $result = $dbi->query("SELECT id FROM " . commentTableName . " ORDER BY posted DESC LIMIT 10"); if ($result->rows()) { // Include meta header template $metaTitle = "Seneste kommentarer"; include layoutPath . "/template/metaHeader.template.php"; $content = $metaHeader; for ($i = 0; list($id) = $result->fetchrow_array(); $i++) { $comment = new Comment($id); $name = $comment->name; if (!empty($comment->userId)) { $user = new User($comment->userId); $name = $user->name; } $metaTitle = parseString($comment->subject); $metaLink = $comment->getCommentLink(); $metaInfo = $site->generateTimestamp($comment->posted, true) . " af " . $name; $metaCount = -1; // Include meta body template include layoutPath . "/template/metaBody.template.php"; $content .= $metaBody; } // Include meta footer template include layoutPath . "/template/metaFooter.template.php"; $content .= $metaFooter; } // Save output in cache $cache->cacheFile("", "latestComments", $content); } echo $content;