function frs_process_release_form($is_update, $request, $group_id, $title, $url) { global $frspf, $frsrf, $frsff; $pm = ProjectManager::instance(); //get and filter all inputs from $request $release = array(); $res = $request->get('release'); $vName = new Valid_String(); $vPackage_id = new Valid_UInt(); $vStatus_id = new Valid_UInt(); if ($vName->validate($res['name']) && $vPackage_id->validate($res['package_id']) && $vStatus_id->validate($res['status_id'])) { $release['status_id'] = $res['status_id']; $release['name'] = $res['name']; $release['package_id'] = $res['package_id']; } else { $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('file_admin_editreleases', 'rel_update_failed')); $GLOBALS['Response']->redirect('/file/showfiles.php?group_id=' . $group_id); } $um = UserManager::instance(); $user = $um->getCurrentUser(); $vDate = new Valid_String(); if ($vDate->validate($res['date'])) { $release['date'] = $res['date']; } else { $release['date'] = ""; } $vRelease_notes = new Valid_Text(); if ($vRelease_notes->validate($res['release_notes'])) { $release['release_notes'] = $res['release_notes']; } else { $release['release_notes'] = ""; } $vChange_log = new Valid_Text(); if ($vChange_log->validate($res['change_log'])) { $release['change_log'] = $res['change_log']; } else { $release['change_log'] = ""; } if ($request->valid(new Valid_String('js'))) { $js = $request->get('js'); } else { $js = ""; } if ($request->validArray(new Valid_String('ftp_file'))) { $ftp_file = $request->get('ftp_file'); } else { $ftp_file = array(); } if ($request->validArray(new Valid_UInt('file_processor'))) { $file_processor = $request->get('file_processor'); } else { $file_processor = array(); } if ($request->validArray(new Valid_UInt('file_type'))) { $file_type = $request->get('file_type'); } else { $file_type = array(); } if ($request->validArray(new Valid_String('reference_md5'))) { $reference_md5 = $request->get('reference_md5'); } else { $reference_md5 = array(); } if ($request->validArray(new Valid_String('comment'))) { $comment = $request->get('comment'); } else { $comment = array(); } if ($request->validArray(new Valid_UInt('ftp_file_processor'))) { $ftp_file_processor = $request->get('ftp_file_processor'); } else { $ftp_file_processor = array(); } if ($request->validArray(new Valid_UInt('ftp_file_type'))) { $ftp_file_type = $request->get('ftp_file_type'); } else { $ftp_file_type = array(); } if ($request->validArray(new Valid_String('ftp_reference_md5'))) { $ftp_reference_md5 = $request->get('ftp_reference_md5'); } else { $ftp_reference_md5 = array(); } if ($request->valid(new Valid_String('release_news_subject'))) { $release_news_subject = $request->get('release_news_subject'); } else { $release_news_subject = ""; } if ($request->valid(new Valid_Text('release_news_details'))) { $release_news_details = $request->get('release_news_details'); } else { $release_news_details = ""; } if ($request->valid(new Valid_WhiteList('private_news', array(0, 1)))) { $private_news = $request->get('private_news'); } else { $private_news = 0; } if ($request->validArray(new Valid_UInt('ugroups'))) { $ugroups = $request->get('ugroups'); } else { $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('file_admin_editreleases', 'rel_update_failed')); $GLOBALS['Response']->redirect('/file/showfiles.php?group_id=' . $group_id); } if ($request->valid(new Valid_WhiteList('release_submit_news', array(0, 1)))) { $release_submit_news = (int) $request->get('release_submit_news'); } else { $release_submit_news = 0; } if ($request->valid(new Valid_WhiteList('notification', array(0, 1)))) { $notification = $request->get('notification'); } else { $notification = 0; } if ($is_update) { if ($request->validArray(new Valid_UInt('release_files_to_delete'))) { $release_files_to_delete = $request->get('release_files_to_delete'); } else { $release_files_to_delete = array(); } if ($request->validArray(new Valid_UInt('release_files'))) { $release_files = $request->get('release_files'); } else { $release_files = array(); } if ($request->validArray(new Valid_UInt('release_file_processor'))) { $release_file_processor = $request->get('release_file_processor'); } else { $release_file_processor = array(); } if ($request->validArray(new Valid_UInt('release_file_type'))) { $release_file_type = $request->get('release_file_type'); } else { $release_file_type = array(); } if ($request->validArray(new Valid_String('release_reference_md5'))) { $release_reference_md5 = $request->get('release_reference_md5'); } else { $release_reference_md5 = array(); } if ($request->validArray(new Valid_UInt('new_release_id'))) { $new_release_id = $request->get('new_release_id'); } else { $new_release_id = array(); } if ($request->validArray(new Valid_String('release_time'))) { $release_time = $request->get('release_time'); } else { $release_time = array(); } if ($request->validArray(new Valid_String('reference_md5'))) { $reference_md5 = $request->get('reference_md5'); } else { $reference_md5 = array(); } if ($request->validArray(new Valid_Text('release_comment'))) { $release_comment = $request->get('release_comment'); } else { $release_comment = array(); } if ($request->valid(new Valid_UInt('id'))) { $release['release_id'] = $request->get('id'); } else { exit; } } $validator = new frsValidator(); if ($is_update) { $valid = $validator->isValidForUpdate($release, $group_id); } else { $valid = $validator->isValidForCreation($release, $group_id); } if ($valid) { //uplaod release_notes and change_log if needed $data_uploaded = false; if (isset($_FILES['uploaded_change_log']) && !$_FILES['uploaded_change_log']['error']) { $code = addslashes(fread(fopen($_FILES['uploaded_change_log']['tmp_name'], 'r'), file_utils_get_size($_FILES['uploaded_change_log']['tmp_name']))); if (strlen($code) > 0 && strlen($code) < $GLOBALS['sys_max_size_upload']) { //size is fine $GLOBALS['Response']->addFeedback('info', $GLOBALS['Language']->getText('file_admin_editreleases', 'data_uploaded')); $data_uploaded = true; $release['change_log'] = $code; } else { //too big or small $GLOBALS['Response']->addFeedback('warning', $GLOBALS['Language']->getText('file_admin_editreleases', 'length_err', $GLOBALS['sys_max_size_upload'])); } } if (isset($_FILES['uploaded_release_notes']) && !$_FILES['uploaded_release_notes']['error']) { $code = addslashes(fread(fopen($_FILES['uploaded_release_notes']['tmp_name'], 'r'), file_utils_get_size($_FILES['uploaded_release_notes']['tmp_name']))); if (strlen($code) > 0 && strlen($code) < $GLOBALS['sys_max_size_upload']) { //size is fine if (!$data_uploaded) { $GLOBALS['Response']->addFeedback('info', $GLOBALS['Language']->getText('file_admin_editreleases', 'data_uploaded')); } $release['release_notes'] = $code; } else { //too big or small $GLOBALS['Response']->addFeedback('warning', $GLOBALS['Language']->getText('file_admin_editreleases', 'length_err', $GLOBALS['sys_max_size_upload'])); } } if ($is_update) { // make sure that we don't change the date by error because of timezone reasons. // eg: release created in India (GMT +5:30) at 2004-06-03. // MLS in Los Angeles (GMT -8) changes the release notes // the release_date that we showed MLS is 2004-06-02. // with mktime(0,0,0,2,6,2004); we will change the unix time in the database // and the people in India will discover that their release has been created on 2004-06-02 $rel =& $frsrf->getFRSReleaseFromDb($release['release_id']); if (format_date('Y-m-d', $rel->getReleaseDate()) == $release['date']) { // the date didn't change => don't update it $unix_release_time = $rel->getReleaseDate(); } else { $date_list = split("-", $release['date'], 3); $unix_release_time = mktime(0, 0, 0, $date_list[1], $date_list[2], $date_list[0]); } } else { //parse the date $date_list = split("-", $release['date'], 3); $unix_release_time = mktime(0, 0, 0, $date_list[1], $date_list[2], $date_list[0]); } //now we create or update the release $array = array('release_date' => $unix_release_time, 'name' => $release['name'], 'status_id' => $release['status_id'], 'package_id' => $release['package_id'], 'notes' => $release['release_notes'], 'changes' => $release['change_log']); if ($is_update) { $array['release_id'] = $release['release_id']; } if ($is_update) { $res = $frsrf->update($array); if (!$res) { $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('file_admin_editreleases', 'rel_update_failed')); //insert failed - go back to definition screen } else { //release added - now show the detail page for this new release $release_id = $array['release_id']; $GLOBALS['Response']->addFeedback('info', $GLOBALS['Language']->getText('file_admin_editreleases', 'rel_updated', $release['name'])); } } else { $res = $frsrf->create($array); if (!$res) { $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language'] > getText('file_admin_editreleases', 'add_rel_fail')); //insert failed - go back to definition screen } else { //release added - now show the detail page for this new release $release_id = $res; $GLOBALS['Response']->addFeedback('info', $GLOBALS['Language']->getText('file_admin_editreleases', 'rel_added')); } } if ($res) { // extract cross references $reference_manager =& ReferenceManager::instance(); $reference_manager->extractCrossRef($release['release_notes'], $release_id, ReferenceManager::REFERENCE_NATURE_RELEASE, $group_id); $reference_manager->extractCrossRef($release['change_log'], $release_id, ReferenceManager::REFERENCE_NATURE_RELEASE, $group_id); //set the release permissions list($return_code, $feedbacks) = permission_process_selection_form($group_id, 'RELEASE_READ', $release_id, $ugroups); if (!$return_code) { $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('file_admin_editpackages', 'perm_update_err')); $GLOBALS['Response']->addFeedback('error', $feedbacks); } //submit news if requested if ($release_id && user_ismember($group_id, 'A') && $release_submit_news) { news_submit($group_id, $release_news_subject, $release_news_details, $private_news, 3); } // Send notification if ($notification) { $rel = $frsrf->getFRSReleaseFromDb($release_id); $count = $frsrf->emailNotification($rel); if ($count === false) { $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('global', 'mail_failed', array($GLOBALS['sys_email_admin']))); } else { if ($count > 0) { $GLOBALS['Response']->addFeedback('info', $GLOBALS['Language']->getText('file_admin_editreleases', 'email_sent', $count)); } } } $group = $pm->getProject($group_id); $group_unix_name = $group->getUnixName(false); $project_files_dir = $GLOBALS['ftp_frs_dir_prefix'] . '/' . $group_unix_name; if ($is_update) { $files =& $rel->getFiles(); //remove files foreach ($release_files_to_delete as $rel_file) { $res =& $frsff->getFRSFileFromDb($rel_file); $fname = $res->getFileName(); $res = $frsff->delete_file($group_id, $rel_file); if ($res == 0) { $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('file_admin_editreleases', 'f_not_yours', basename($fname))); } else { $GLOBALS['Response']->addFeedback('info', $GLOBALS['Language']->getText('file_admin_editreleases', 'file_deleted', basename($fname))); } } //update files $index = 0; foreach ($release_files as $rel_file) { if (!$release_files_to_delete || !in_array($rel_file, $release_files_to_delete)) { $package_id = $release['package_id']; $fname = $files[$index]->getFileName(); $list = split('/', $fname); $fname = $list[sizeof($list) - 1]; if ($new_release_id[$index] != $release_id) { //changing to a different release for this file //see if the new release is valid for this project $res2 = $frsrf->getFRSReleaseFromDb($new_release_id[$index], $group_id); if (!$res2 || count($res2) < 1) { //release not found for this project $GLOBALS['Response']->addFeedback('warning', $GLOBALS['Language']->getText('file_admin_editreleases', 'rel_not_yours', $fname)); } else { $package_id = $res2->getPackageID(); } } if ($new_release_id[$index] == $release_id || $res2) { if (!ereg("[0-9]{4}-[0-9]{2}-[0-9]{2}", $release_time[$index])) { $GLOBALS['Response']->addFeedback('warning', $GLOBALS['Language']->getText('file_admin_editreleases', 'data_not_parsed_file', $fname)); } else { $res2 =& $frsff->getFRSFileFromDb($rel_file); if (format_date('Y-m-d', $res2->getReleaseTime()) == $release_time[$index]) { $unix_release_time = $res2->getReleaseTime(); } else { $date_list = split("-", $release_time[$index], 3); $unix_release_time = mktime(0, 0, 0, $date_list[1], $date_list[2], $date_list[0]); } $array = array('release_id' => $new_release_id[$index], 'release_time' => $unix_release_time, 'type_id' => $release_file_type[$index], 'processor_id' => $release_file_processor[$index], 'file_id' => $rel_file, 'comment' => $release_comment[$index], 'filename' => 'p' . $package_id . '_r' . $new_release_id[$index] . '/' . $fname, 'filepath' => 'p' . $package_id . '_r' . $new_release_id[$index] . '/' . $fname . '_' . $unix_release_time); if ($release_reference_md5[$index] && $release_reference_md5[$index] != '') { $array['reference_md5'] = $release_reference_md5[$index]; } $res = $frsff->update($array); if ($res) { $GLOBALS['Response']->addFeedback('info', $GLOBALS['Language']->getText('file_admin_editreleases', 'file_updated', $fname)); } } } } $index++; } } //add new files //files processing $http_files_list = array(); $processor_type_list = array(); $file_type_list = array(); $http_files_processor_type_list = array(); $ftp_files_processor_type_list = array(); if (isset($js) && $js == 'no_js') { //if javascript is not allowed, there is maximum one file to upload // TODO : fix warnings due to array instead of string for "file_processor", "file_type" & "reference_md5" if ($ftp_file[0] != -1) { $ftp_files_processor_type_list[] = array('name' => $ftp_file[0], 'processor' => $file_processor, 'type' => $file_type, 'reference_md5' => $reference_md5, 'comment' => $comment); } else { if (trim($_FILES['file']['name'][0]) != '') { $http_files_processor_type_list[] = array('error' => $_FILES['file']['error'][0], 'name' => stripslashes($_FILES['file']['name'][0]), 'tmp_name' => $_FILES['file']['tmp_name'][0], 'processor' => $file_processor, 'type' => $file_type, 'reference_md5' => $reference_md5, 'comment' => $comment); } } } else { //get http files with the associated processor type and file type in allowed javascript case $nb_files = isset($_FILES['file']) ? count($_FILES['file']['name']) : 0; for ($i = 0; $i < $nb_files; $i++) { if (trim($_FILES['file']['name'][$i]) != '') { $http_files_processor_type_list[] = array('error' => $_FILES['file']['error'][$i], 'name' => stripslashes($_FILES['file']['name'][$i]), 'tmp_name' => $_FILES['file']['tmp_name'][$i], 'processor' => $file_processor[$i], 'type' => $file_type[$i], 'reference_md5' => $reference_md5[$i], 'comment' => $comment[$i]); } } //remove hidden ftp_file input (if the user let the select boxe on --choose file) $tmp_file_list = array(); $index = 0; foreach ($ftp_file as $file) { if (trim($file) != '') { $ftp_files_processor_type_list[] = array('name' => $file, 'processor' => $ftp_file_processor[$index], 'type' => $ftp_file_type[$index], 'reference_md5' => $ftp_reference_md5[$index]); $index++; } } } if (count($http_files_processor_type_list) > 0 || count($ftp_files_processor_type_list) > 0) { //see if this release belongs to this project $res1 =& $frsrf->getFRSReleaseFromDb($release_id, $group_id); if (!$res1 || count($res1) < 1) { //release not found for this project $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('file_admin_editreleases', 'rel_not_yours')); } else { $now = time(); $addingFiles = false; //iterate and add the http files to the frs_file table foreach ($http_files_processor_type_list as $file) { $filename = $file['name']; if (isset($file['error'])) { switch ($file['error']) { case UPLOAD_ERR_OK: // all is OK break; case UPLOAD_ERR_INI_SIZE: case UPLOAD_ERR_FORM_SIZE: $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('global', 'error_upload_size', $file['error'])); break; case UPLOAD_ERR_PARTIAL: $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('global', 'error_upload_partial', $file['error'])); break; case UPLOAD_ERR_NO_FILE: $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('global', 'error_upload_nofile', $file['error'])); break; default: $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('global', 'error_upload_unknown', $file['error'])); } } if (is_uploaded_file($file['tmp_name'])) { $uploaddir = $frsff->getSrcDir($request->getProject()); $uploadfile = $uploaddir . "/" . basename($filename); if (!file_exists($uploaddir) || !is_writable($uploaddir) || !move_uploaded_file($file['tmp_name'], $uploadfile)) { $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('file_admin_editreleases', 'not_add_file') . ": " . basename($filename)); } else { $newFile = new FRSFile(); $newFile->setRelease($res1); $newFile->setFileName($filename); $newFile->setProcessorID($file['processor']); $newFile->setTypeID($file['type']); $newFile->setReferenceMd5($file['reference_md5']); $newFile->setUserId($user->getId()); $newFile->setComment($file['comment']); try { $frsff->createFile($newFile); $addingFiles = true; } catch (Exception $e) { $GLOBALS['Response']->addFeedback('error', $e->getMessage()); } } } else { $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('file_admin_editreleases', 'not_add_file') . ": " . basename($filename)); } } //iterate and add the ftp files to the frs_file table foreach ($ftp_files_processor_type_list as $file) { $filename = $file['name']; $newFile = new FRSFile(); $newFile->setRelease($res1); $newFile->setFileName($filename); $newFile->setProcessorID($file['processor']); $newFile->setTypeID($file['type']); $newFile->setReferenceMd5($file['reference_md5']); $newFile->setUserId($user->getId()); try { $frsff->createFile($newFile, ~FRSFileFactory::COMPUTE_MD5); $addingFiles = true; $em = EventManager::instance(); $em->processEvent(Event::COMPUTE_MD5SUM, array('fileId' => $newFile->getFileID())); $GLOBALS['Response']->addFeedback('info', $GLOBALS['Language']->getText('file_admin_editreleases', 'offline_md5', $filename)); } catch (Exception $e) { $GLOBALS['Response']->addFeedback('error', $e->getMessage()); } } } if ($addingFiles) { $GLOBALS['Response']->addFeedback('info', $GLOBALS['Language']->getText('file_admin_editreleases', 'add_files')); } } //redirect to files $GLOBALS['Response']->redirect('/file/?group_id=' . $group_id); } } else { $GLOBALS['Response']->addFeedback('error', $validator->getErrors()); } frs_display_release_form($is_update, $release, $group_id, $title, $url); }
var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.4"; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk'));</script> <div class="Header"> <a href="<?php echo base_url_admin; ?> "><div class="logo"></div></a> <?php // echo lText('Header'); ?> </div> <?php menuNavigation(); getText(); ?> <div id="container"> <?php /* * @script author: zura kiziria. no framework * @murk up, design: oto kiziria * @script lang: php5 * @create date: 2015.07 * @for company: binuli @website: binuli.ge */
public function __invoke() { $this->createLabel(); $alert_text = []; $history = []; $currentTime = new \DateTime(); $today = $currentTime->format('m') + 1 + "/" + $currentTime . getDate() + "/" + $currentTime->format('Y'); $keywordIterator; $line_counter = 0; while ($keywordIterator->hasNext()) { $keyword = keywordIterator . next(); $line_counter++; $current_quality_score = $keyword->qualityScore; $keywordLabelsIterator = keyword . labels() . withCondition("Name STARTS_WITH 'QS: '") . get(); if ($keywordLabelsIterator->hasNext()) { $keyword_label = $keywordLabelsIterator . next(); $matches = new RegExp('QS: ([0-9]+)$') . exec($keyword_label . getName()); $old_quality_score = $matches[1]; } else { $old_quality_score = 0; } // For the history also note the change or whether this keyword is new if ($old_quality_score > 0) { $change = $current_quality_score - $old_quality_score; } else { $change = "NEW"; } $row = [$today, $keyword . getCampaign() . getName(), $keyword . getAdGroup() . getName(), $keyword . getText(), $current_quality_score, $change]; $history . push(row); // If there is a previously tracked quality score and it's different from the current one... if ($old_quality_score > 0 && $current_quality_score != $old_quality_score) { // Make a note of this to log it and possibly send it via email later $alert_text . push($current_quality_score + "\t" + $old_quality_score + "\t" + $change + "\t" + $keyword . getText()); // Remove the old label $keyword . removeLabel($keyword_label . getName()); } // Store the current QS for the next time by using a label $keyword . applyLabel("QS: " + $current_quality_score); } if ($line_counter == 0) { $this->logger->log("Couldn't find any keywords marked for quality score tracking. To mark keywords for tracking, apply the label '" + $label_name + "' to those keywords."); return; } $this->logger->log("Tracked " + $line_counter + " keyword quality scores. To select different keywords for tracking, apply the label '" + $label_name + "' to those keywords."); // Store history $history_sheet = spreadsheet . getSheetByName('QS history'); $history_sheet . getRange($history_sheet . getLastRow() + 1, 1, $history . length, 6) . setValues($history); // If there are notes for alerts then prepare a message to log and possibly send via email if ($alert_text . length) { $message = "The following quality score changes were discovered:\nNew\tOld\tChange\tKeyword\n"; for ($i = 0; $i < count($alert_text); $i++) { $message += $alert_text[i] + "\n"; } // Also include a link to the spreadsheet $message += "\n" + "The complete history is available at " + $spreadsheet . getUrl(); $this->logger->log($message); // If there is an email address send out a notification if ($email_address && $email_address != "YOUR_EMAIL_HERE") { $this->mailer->sendEmail($email_address, "Quality Score Tracker: Changes detected", $message); } } }
<?php $aMyArray = array(array(array(getText('dfdf'), array('el' => 1, 'el' => 2)))); $a = array('1', '2', array(), array(), array()); for ($x; $x < 10; $x++) { echo $x; }
function rtbDecode($decodeNumS) { $decodeNum = intval($decodeNumS); return "<p>tanx: " . getText($decodeNum & 15) . " adx: " . getText($decodeNum >> 4 & 15) . " tade: " . getText($decodeNum >> 8 & 15) . " allyes: " . getText($decodeNum >> 12 & 15) . " bex: " . getText($decodeNum >> 16 & 15) . "</p>"; }
<?php $title = ''; $text = ''; $titleen = ''; $texten = ''; if (isset($_GET['edit']) and isset($_SESSION['status']) and $_SESSION['status'] >= '2') { $id = $_GET['edit']; $title = vievList($id); $titleen = vievListen($id); $text = getText($id); $texten = getTexten($id); $form = "<form name='' method='POST' action='index.php'>" . $lang['entertitle'] . "<div><input type='text' name='title' value='{$title}'></div>" . $lang['entertext'] . "<input type='hidden' name='language' value='en'>\n\t<textarea cols=60 rows=8 name='textarea'>{$text}</textarea>\n\t<div><input type='hidden' name='id' value='{$id}'></div>\n\t<div><div align='right'>" . $lang['en'] . "</div>" . $lang['entertitle'] . "<div><input type='text' name='titleen' value='{$titleen}'></div>" . $lang['entertext'] . "<input type='hidden' name='language' value='en'>\n\t<textarea cols=60 rows=8 name='textareaen'>{$texten}</textarea>\n\t<div><input type='submit' name='update' value='" . $lang['send'] . "'></div>\n\t</form>"; } else { $form = "<form name='' method='post' action=''>" . $lang['entertitle'] . "<div><input type='text' name='title' value='{$title}'></div>" . $lang['entertext'] . "<input type='hidden' name='language' value='ua'>\n<textarea cols=60 rows=8 name='textarea'>{$text}</textarea><div><div align='right'>" . $lang['en'] . "</div>" . $lang['entertitle'] . "</div><div><input type='text' name='titleen' value=''></div>" . $lang['entertext'] . "<input type='hidden' name='language' value='en'>\n<textarea cols=60 rows=8 name='textareaen'></textarea>\n<div><input type='submit' name='add' value='" . $lang['send'] . "'></div>\n</form>"; } if (isset($_GET['edit']) and getAllRating($_GET['edit'])) { echo "<div align='right'><b>" . $lang['rating:'] . " " . substr(getAllRating($_GET['edit']), 0, 4) . " / " . getCountRating($_GET['edit']) . "</b></div>"; if ($_SESSION['status'] == 3 and !isset($_GET['add'])) { echo "<div align='right'><a href=index.php?delrating=" . $_GET['edit'] . ">" . $lang['delete'] . "</a></div>"; } } else { echo "<div align='right'><b>" . $lang['rating is empty'] . "</b></div>"; } echo "<div align='right'>" . $lang['ua'] . "</div>"; echo $form;
if (isset($_GET['reg'])) { $_SESSION['error'] = ""; include "reg.php"; } //viev content if (isset($_GET['id'])) { if ($lang['lang'] == 'ua') { $title_t = vievList($_GET['id']); echo "<h3>" . $title_t . "</h3>"; //reting ua if (getAllRating($_GET['id'])) { echo "<div align='right'><b>" . $lang['rating:'] . " " . substr(getAllRating($_GET['id']), 0, 4) . " / " . getCountRating($_GET['id']) . "</b></div>"; } else { echo "<div align='right'><b>" . $lang['rating is empty'] . "</b></div>"; } echo "<div>" . getText($_GET['id']) . "</div>"; } if ($lang['lang'] == 'en') { $title_t = vievListen($_GET['id']); //reting en echo "<h4>" . $title_t . "</h4>"; if (getAllRating($_GET['id'])) { echo "<div align='right'><b>" . $lang['rating:'] . " " . substr(getAllRating($_GET['id']), 0, 4) . " / " . getCountRating($_GET['id']) . "</b></div>"; } else { echo "<div align='right'><b>" . $lang['rating is empty'] . "</b></div>"; } echo "<div>" . getTexten($_GET['id']) . "</div>"; } if (isset($_SESSION['status']) and $_SESSION['status'] >= '2') { echo "<a href='index.php?edit=" . $_GET['id'] . "'>" . $lang['edit page'] . "</a><br>"; echo "<a href='index.php?del=" . $_GET['id'] . "'>" . $lang['delpage'] . "</a>";
/** * Creates a new article or appends some text if it already * exists. This function is invoked by an ajax call. * * @param string $title * The name of the article * @param string $user * The name of the user * @param string $content * The initial content of the article. It is only set if the article * is newly created. * @param string optionalText * This text is appended to the article, if it is not already part * of it. The text may contain variables of the language files * that are replaced by their representation. * @param string creationComment * This text describes why the article has been created. * * @return string Comma separated list: * bool success * <true> if the operation was successful. * bool created * <true> if the article was created, * <false> if it was only modified * <denied> if the permission was denied * string title * Title of the (new) article * */ function smwf_om_CreateArticle($title, $user, $content, $optionalText, $creationComment) { global $smwgContLang, $smwgHaloContLang; $success = false; $created = true; $title = strip_tags($title); if ($title == '') { return "false"; } if (smwf_om_userCan($title, 'create') === "false") { return "false,denied,{$title}"; } $title = Title::newFromText($title); // add predefined content if configured global $smwhgAutoTemplates, $smwhgAutoTemplatesParameters; if (isset($smwhgAutoTemplates)) { if (array_key_exists($title->getNamespace(), $smwhgAutoTemplates)) { require_once 'SMW_Predefinitions.php'; $mappings = array_key_exists($title->getNamespace(), $smwhgAutoTemplatesParameters) ? $smwhgAutoTemplatesParameters[$title->getNamespace()] : array(); $metadataText = SMWPredefinitions::getPredefinitions($title, $smwhgAutoTemplates[$title->getNamespace()], $mappings); $content = $metadataText . $content; } } $article = new Article($title); if ($article->exists()) { // The article exists => get its current content. The passed content // will be ignored. $text = $article->getContent(); if ($text === false) { return "false,false," . $title . getText(); } $content = $text; $created = false; } if (!empty($optionalText)) { $supportedConstants = array("_SUBP", "SMW_SSP_HAS_DOMAIN_AND_RANGE_HINT", "SMW_SSP_HAS_MAX_CARD", "SMW_SSP_HAS_MIN_CARD", "_TYPE", "_rec", "_LIST"); // Some optional text is given $sp = $smwgContLang->getPropertyLabels() + $smwgContLang->getDatatypeLabels(); $ssp = $smwgHaloContLang->getSpecialSchemaPropertyArray(); $num = count($supportedConstants); for ($i = 0; $i < $num; $i++) { $constant = $supportedConstants[$i]; $pos = strpos($optionalText, $constant); if ($pos) { $langString = "Unsupported constant"; if (strpos($constant, "SMW_SSP_") !== false) { $langString = $ssp[constant($constant)]; } else { $langString = $sp[$constant]; } $optionalText = str_replace($constant, $langString, $optionalText); } } // does the optional text already exist? if ($article->exists()) { $pos = strpos($content, $optionalText); if ($pos === false) { // optional text not found => append it $content .= $optionalText; } } else { // The article will be created with content and optional text $content .= $optionalText; } } // Set the article's content $success = $article->doEdit($content, $creationComment); return ($success ? "true," : "false,") . ($created ? "true," : "false,") . $title->getNsText() . ":" . $title->getText(); }