当前位置: 首页>>代码示例>>PHP>>正文


PHP displayinfo函数代码示例

本文整理汇总了PHP中displayinfo函数的典型用法代码示例。如果您正苦于以下问题:PHP displayinfo函数的具体用法?PHP displayinfo怎么用?PHP displayinfo使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了displayinfo函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: actionEdit

    public function actionEdit()
    {
        $validateScript = <<<VALSCRIPT
\t<script type="text/javascript">
\tfunction trim(str)
\t\t{
\t\t\t return str.replace(/^\\s+|\\s+\$/g, '');
\t\t}

\tfunction validate_empty()
\t\t{
\t\t\tvar empty = 0;
\t\t\tvar title = trim(document.AddNews.title.value);
\t\t\tvar feed  = trim(document.AddNews.feed.value);
\t
\t\t\tif(title.length == 0)
\t\t\t\t{
\t\t\t\t\tempty++;
\t\t\t\t\talert("The title should not be left blank");
\t\t\t\t\tdocument.AddNews.title.focus();
\t\t\t\t}
\t\t\telse if(feed.length == 0)
\t\t\t\t{
\t\t\t\t\tempty++;
\t\t\t\t\talert("Enter a Description of the News");
\t\t\t\t\tdocument.AddNews.feed.focus();
\t\t\t\t}
\t\t\treturn (empty == 0);
\t\t}
\t</script>
VALSCRIPT;
        if (isset($_GET['subaction'])) {
            global $ICONS;
            if (isset($_GET['newsid']) && ctype_digit($_GET['newsid'])) {
                if ($_GET['subaction'] == 'deletenews') {
                    $query1 = "SELECT * FROM `news_data` WHERE `news_id`='" . escape($_GET['newsid']) . "' AND `page_modulecomponentid` = '{$this->moduleComponentId}'";
                    $result = mysql_query($query1);
                    $row = mysql_fetch_assoc($result);
                    $query = "DELETE FROM `news_data` WHERE `news_id`='" . escape($_GET['newsid']) . "' AND `page_modulecomponentid`='{$this->moduleComponentId}'";
                    $result = mysql_query($query);
                    displayinfo('News feed has been successfully deleted.');
                } elseif ($_GET['subaction'] == 'editnews') {
                    $query = "SELECT * FROM `news_data` WHERE `news_id`='" . escape($_GET['newsid']) . "' AND `page_modulecomponentid` = '{$this->moduleComponentId}'";
                    $result = mysql_query($query);
                    $row = mysql_fetch_assoc($result);
                    $editForm = <<<EDITFORM
\t\t\t\t\t\t{$validateScript}
\t\t\t\t\t \t<fieldset><legend>{$ICONS['News Edit']['small']} Edit News<legend><form name="AddNews" action="./+edit" method="POST" onsubmit="return validate_empty();">
\t\t\t\t\t\t\tTitle of News Item  <input type="text" name="title" id="title" size="50" value="{$row['news_title']}"><br /><br />
\t\t\t\t\t\t\tNews Description  <br><textarea name="feed" id="feed" cols="50" rows="10">{$row['news_feed']}</textarea><br />
\t\t\t\t\t\t\tRank/Importance of Feed  <input type="text" name="rank" size="10" value="{$row['news_rank']}" /><br /><br />
\t\t\t\t\t\t\tRelative link  <input type="text" name="link" size=40 value="{$row['news_link']}" ><br><br>
\t\t\t\t\t\t\t<input type="submit" value="Save Changes" name="btnSaveChanges"/>
\t\t\t\t\t\t\t<input type="hidden" name="newsid" value="{$row['news_id']}" />
\t\t\t\t  \t</form></fieldset>
EDITFORM;
                    return $editForm;
                }
            } elseif ($_GET['subaction'] == 'addnews') {
                if (isset($_POST['btnAddNews'])) {
                    $query1 = "SELECT MAX(`news_id`) FROM `news_data` WHERE `page_modulecomponentid`='{$this->moduleComponentId}'";
                    $result = mysql_query($query1);
                    $resultArray = mysql_fetch_row($result);
                    $news_id = 1;
                    if (!is_null($resultArray[0])) {
                        $news_id = $resultArray[0] + 1;
                    }
                    $query2 = "INSERT INTO `news_data` (`page_modulecomponentid`, `news_id`, `news_title`, `news_feed`, `news_rank`,`news_link`) VALUES('{$this->moduleComponentId}','{$news_id}','" . escape($_POST['title']) . "','" . escape($_POST['feed']) . "','" . escape($_POST['rank']) . "','" . escape($_POST['link']) . "')";
                    $result = mysql_query($query2) or die(mysql_error() . '<br />' . $query2);
                } else {
                    $addnews = <<<NEWS
{$validateScript}
<fieldset><legend>{$ICONS['News Add']['small']} Add News<legend>
<form name="AddNews" action="./+edit&subaction=addnews" method="POST" onsubmit="return validate_empty()">
\t\t\t\t\t\t\t\tTitle of News Item  <input type="text" name="title" id="title" size=50 /><br><br>
\t\t\t\t\t\t\t\tNews Description  <br><textarea name="feed" id="feed" cols="50" rows="10"> </textarea><br>
\t\t\t\t\t\t\t\tRank/Importance of Feed <input type="text" name="rank" size=10 /><br><br>' .
\t\t\t\t\t\t\t\t\t\t'Relative link  <input type="text" name="link" size=40 /><br><br>
\t\t\t\t\t\t\t\t<input type="submit" name="btnAddNews" value="Submit News Feed" />
\t\t\t\t\t\t\t\t</form></fieldset>
NEWS;
                    return $addnews;
                }
            }
        } elseif (isset($_POST['btnSaveChanges']) && isset($_POST['newsid'])) {
            $query = "UPDATE `news_data` SET `news_title`='" . escape($_POST['title']) . "',`news_feed`='" . escape($_POST['feed']) . "',`news_rank`='" . escape($_POST['rank']) . "',`news_link`='" . escape($_POST['link']) . "' WHERE `news_id`='" . escape($_POST['newsid']) . "' AND `page_modulecomponentid`='{$this->moduleComponentId}'";
            $result = mysql_query($query);
            displayinfo("News feed has been successfully updated.");
        }
        if (isset($_POST['btnNewsPropSave'])) {
            $query = "UPDATE `news_desc` SET `news_title` = '" . escape($_POST['news_title']) . "', `news_description`='" . escape($_POST['news_desc']) . "', `news_link`='" . escape($_POST['news_link']) . "', `news_copyright`='" . escape($_POST['news_copyright']) . "' WHERE `page_modulecomponentid` = '{$this->moduleComponentId}'";
            if (mysql_query($query)) {
                displayinfo("News Page Properties has been successfully updated.");
            } else {
                displayerror("There has been some error in updating Properties.");
            }
        }
        $query = "SELECT * FROM `news_data` WHERE `page_modulecomponentid`='{$this->moduleComponentId}' ORDER BY `news_rank`,`news_id`";
        $result = mysql_query($query);
        $descResult = mysql_fetch_assoc(mysql_query("SELECT * FROM `news_desc` WHERE `page_modulecomponentid` = '{$this->moduleComponentId}'"));
//.........这里部分代码省略.........
开发者ID:nobelium,项目名称:pragyan,代码行数:101,代码来源:news.lib.php

示例2: getContent

function getContent($pageId, $action, $userId, $permission, $recursed = 0)
{
    if ($action == "login") {
        if ($userId == 0) {
            ///Commented the requirement of login.lib.php because it is already included in /index.php
            //require_once("login.lib.php");
            $newUserId = login();
            if (is_numeric($newUserId)) {
                return getContent($pageId, "view", $newUserId, getPermissions($newUserId, $pageId, "view"), 0);
            } else {
                return $newUserId;
            }
            ///<The login page
        } else {
            displayinfo("You are logged in as " . getUserName($userId) . "! Click <a href=\"./+logout\">here</a> to logout.");
        }
        return getContent($pageId, "view", $userId, getPermissions($userId, $pageId, "view"), $recursed = 0);
    }
    if ($action == "profile") {
        if ($userId != 0) {
            require_once "profile.lib.php";
            return profile($userId);
        } else {
            displayinfo("You need to <a href=\"./+login\">login</a> to view your profile.!");
        }
    }
    if ($action == "logout") {
        if ($userId != 0) {
            $newUserId = resetAuth();
            displayinfo("You have been logged out!");
            global $openid_enabled;
            if ($openid_enabled == 'true') {
                displaywarning("If you logged in via Open ID, make sure you also log out from your Open ID service provider's website. Until then your session in this website will remain active !");
            }
            return getContent($pageId, "view", $newUserId, getPermissions($newUserId, $pageId, "view"), 0);
        } else {
            displayinfo("You need to <a href=\"./+login\">login</a> first to logout!");
        }
    }
    if ($action == "search") {
        require_once "search.lib.php";
        $ret = getSearchBox();
        if (isset($_POST['query'])) {
            $ret .= getSearchResultString($_POST['query']);
        } elseif (isset($_GET['query'])) {
            $ret .= getSearchResultString($_GET['query']);
        }
        return $ret;
    }
    if (isset($_GET['subaction']) && $_GET['subaction'] == 'getchildren') {
        if (isset($_GET['parentpath'])) {
            global $urlRequestRoot;
            require_once 'menu.lib.php';
            $pidarr = array();
            parseUrlReal(escape($_GET['parentpath']), $pidarr);
            $pid = $pidarr[count($pidarr) - 1];
            $children = getChildren($pid, $userId);
            $response = array();
            $response['path'] = escape($_GET['parentpath']);
            $response['items'] = array();
            foreach ($children as $child) {
                $response['items'][] = array($urlRequestRoot . '/home' . escape($_GET['parentpath']) . $child[1], $child[2]);
            }
            //echo json_encode($response);
            exit;
        }
    }
    if ($permission != true) {
        if ($userId == 0) {
            $suggestion = "(Try <a href=\"./+login\">logging in?</a>)";
        } else {
            $suggestion = "";
        }
        displayerror("You do not have the permissions to view this page. {$suggestion}<br /><input type=\"button\" onclick=\"history.go(-1)\" value=\"Go back\" />");
        return '';
    }
    if ($action == "admin") {
        require_once "admin.lib.php";
        return admin($pageId, $userId);
    }
    ///default actions also to be defined here (and not outside)
    /// Coz work to be done after these actions do involve the page
    $pagetype_query = "SELECT page_module, page_modulecomponentid FROM " . MYSQL_DATABASE_PREFIX . "pages WHERE page_id='" . escape($pageId) . "'";
    $pagetype_result = mysql_query($pagetype_query);
    $pagetype_values = mysql_fetch_assoc($pagetype_result);
    if (!$pagetype_values) {
        displayerror("The requested page does not exist.");
        return "";
    }
    $moduleType = $pagetype_values['page_module'];
    $moduleComponentId = $pagetype_values['page_modulecomponentid'];
    if ($action == "settings") {
        ///<done here because we needed to check if the page exists for sure.
        require_once "pagesettings.lib.php";
        return pagesettings($pageId, $userId);
    }
    if ($action == "widgets") {
        return handleWidgetPageSettings($pageId);
    }
    if ($recursed == 0) {
//.........这里部分代码省略.........
开发者ID:rubulh,项目名称:pragyan,代码行数:101,代码来源:content.lib.php

示例3: actionCorrect

 /**
  * function actionCorrect:
  * handles all actions in Correct
  * Corrects user submission and displays userList with their Marks
  */
 public function actionCorrect()
 {
     if (isset($_POST['btnSetMark'])) {
         $quizid = escape($_POST['quizid']);
         $sectionid = escape($_POST['sectionid']);
         $questionid = escape($_POST['questionid']);
         $userid = escape($_POST['userid']);
         $mark = escape($_POST['mark']);
         $condition = "`page_modulecomponentid` = '{$quizid}' AND `quiz_sectionid` = '{$sectionid}' AND `quiz_questionid` = '{$questionid}' AND `user_id` = '{$userid}'";
         $result = mysql_query("SELECT `quiz_submittedanswer` FROM `quiz_answersubmissions` WHERE {$condition}");
         if ($row = mysql_fetch_array($result)) {
             $result = mysql_fetch_array(mysql_query("SELECT `question_positivemarks`, `question_negativemarks` FROM `quiz_weightmarks` WHERE `page_modulecomponentid` = '{$quizid}' AND `question_weight` = (SELECT `quiz_questionweight` FROM `quiz_questions` WHERE `page_modulecomponentid` = '{$quizid}' AND `quiz_sectionid` = '{$sectionid}' AND `quiz_questionid` = '{$questionid}')"));
             if ($_POST['mark'] > $result['question_positivemarks'] || $_POST['mark'] < -1 * $result['question_negativemarks']) {
                 displaywarning('Mark out of range for this question, so mark not set');
             } else {
                 mysql_query("UPDATE `quiz_answersubmissions` SET `quiz_marksallotted` = {$mark} WHERE {$condition}");
                 updateSectionMarks($quizid);
                 displayinfo('Mark set');
             }
         } else {
             displayerror('Unable to set value');
         }
     }
     if (isset($_GET['useremail'])) {
         $userId = getUserIdFromEmail($_GET['useremail']);
         if ($userId) {
             return getQuizCorrectForm($this->moduleComponentId, $userId);
         } else {
             displayerror('Error. Could not find user.');
         }
     } elseif (isset($_POST['btnDeleteUser']) && isset($_POST['hdnUserId']) && is_numeric($_POST['hdnUserId'])) {
         $quizObject = $this->getNewQuizObject();
         if ($quizObject !== false) {
             $quizObject->deleteEntries(intval($_POST['hdnUserId']));
         }
     }
     return getQuizUserListHtml($this->moduleComponentId);
 }
开发者ID:nobelium,项目名称:pragyan,代码行数:43,代码来源:quiz.lib.php

示例4: getUserId

if ($debugSet == "on") {
    $DEBUGINFO .= "Page Full text path : " . $pageFullPath . "<br /><br />\n";
    $DEBUGINFO .= "UID : " . getUserId() . "<br /><br />\n";
    $DEBUGINFO .= "GIDS : " . arraytostring(getGroupIds($userId)) . "<br /><br />\n";
    $DEBUGINFO .= "Action : " . $action . "<br /><br />\n";
    $DEBUGINFO .= "Get Vars : " . arraytostring($_GET) . "<br /><br />\n";
    $DEBUGINFO .= "Page Id : " . $pageId . "<br /><br />\n";
    $DEBUGINFO .= "Page id path : " . arraytostring($pageIdArray) . "\n<br /><br />";
    $DEBUGINFO .= "Title : " . $TITLE . "\n<br /><br />";
    $DEBUGINFO .= "SERVER info : " . arraytostring($_SERVER) . "\n<br /><br />";
    $DEBUGINFO .= "POST info : " . arraytostring($_POST) . "\n<br /><br />";
    $DEBUGINFO .= "FILES info : " . arraytostring($_FILES) . "\n<br /><br />";
    $DEBUGINFO .= "SESSION info : " . arraytostring($_SESSION) . "\n<br /><br />";
    $DEBUGINFO .= "STARTSCRIPTS : " . $STARTSCRIPTS . "\n<br/><br/>";
    if ($DEBUGINFO != "") {
        displayinfo($DEBUGINFO);
    }
}
///Used to check in subsequent requests if cookies are supported or not
setcookie("cookie_support", "enabled", 0, "/");
///Apply the template on the generated content and display the page
templateReplace($TITLE, $MENUBAR, $ACTIONBARMODULE, $ACTIONBARPAGE, $BREADCRUMB, $SEARCHBAR, $PAGEKEYWORDS, $INHERITEDINFO, $CONTENT, $FOOTER, $DEBUGINFO, $ERRORSTRING, $WARNINGSTRING, $INFOSTRING, $STARTSCRIPTS, $LOGINFORM);
disconnect();
exit;
/** Additional notes :

authenticate.lib.php -> Find out who requested it
	output: one int -> uid

parseurl.lib.php -> Find out the page id and action requested
	input:	url
开发者ID:ksb1712,项目名称:pragyan,代码行数:31,代码来源:index.php

示例5: deleteGroup

function deleteGroup($groupName)
{
    if (emptyGroup($groupName, true)) {
        $deleteQuery = 'DELETE FROM `' . MYSQL_DATABASE_PREFIX . 'groups` WHERE `group_name` = \'' . $groupName . '\'';
        if (mysql_query($deleteQuery)) {
            displayinfo("Group '{$groupName}' Deleted Successfully");
            return true;
        }
    }
    return false;
}
开发者ID:ksb1712,项目名称:pragyan,代码行数:11,代码来源:group.lib.php

示例6: session_start

//   IN.User.logout();
//   return true;
//}
?>
<body>
<div class="wide form"> 

<?php 
session_start();
// now insert data into db
$sql = "INSERT INTO job_app (first_name, last_name, email, address1, country, created)\nVALUES ('" . $_SESSION['name'] . "', '" . $_SESSION['lname'] . "', '" . $_SESSION['email'] . "', '" . $_SESSION['address1'] . "', '" . $_SESSION['loc'] . "', NOW() )";
echo "<p>" . $_SESSION['name'] . " " . $_SESSION['lname'];
if ($conn->query($sql) === TRUE) {
    echo " your job application was successfully submitted. <br/><br/>Below is the data you submitted:</p>";
    echo "<table class='DataTable'>";
    displayinfo();
    echo "</table>";
} else {
    echo " your job application was not submitted.</p>";
    echo "Error: " . $sql . "<br>" . $conn->error;
}
$conn->close();
?>

</div>

<br/>

<div class="buttons">
<a href="#" class="button" onclick="rethome()" id="home-link">
    Return to Home
开发者ID:aislinnmc,项目名称:AislinnPHP,代码行数:31,代码来源:applydb.php

示例7: login

/** Undocumented Function.
 * Basically performs the whole login routine
 * @todo Document it
 */
function login()
{
    $allow_login_query = "SELECT `value` FROM `" . MYSQL_DATABASE_PREFIX . "global` WHERE `attribute` = 'allow_login'";
    $allow_login_result = mysql_query($allow_login_query);
    $allow_login_result = mysql_fetch_array($allow_login_result);
    if (isset($_GET['subaction'])) {
        if ($_GET['subaction'] == "resetPasswd") {
            return resetPasswd($allow_login_result[0]);
        }
        if ($allow_login_result[0]) {
            if ($_GET['subaction'] == "register") {
                require_once "registration.lib.php";
                return register();
            }
        }
        global $openid_enabled;
        if ($openid_enabled == 'true' && $allow_login_result[0]) {
            if ($_GET['subaction'] == "openid_login") {
                if (isset($_POST['process'])) {
                    $openid_url = trim($_POST['openid_identifier']);
                    openid_endpoint($openid_url);
                }
            }
            if ($_GET['subaction'] == "openid_verify") {
                if ($_GET['openid_mode'] != "cancel") {
                    $openid_url = $_GET['openid_identity'];
                    // Get the user's OpenID Identity as returned to us from the OpenID Provider
                    $openid = new Dope_OpenID($openid_url);
                    //Create a new Dope_OpenID object.
                    $validate_result = $openid->validateWithServer();
                    //validate to see if everything was recieved properly
                    if ($validate_result === TRUE) {
                        $userinfo = $openid->filterUserInfo($_GET);
                        return openid_login($userinfo);
                    } else {
                        if ($openid->isError() === TRUE) {
                            // Else if you're here, there was some sort of error during processing.
                            $the_error = $openid->getError();
                            $error = "Error Code: {$the_error['code']}<br />";
                            $error .= "Error Description: {$the_error['description']}<br />";
                        } else {
                            //Else validation with the server failed for some reason.
                            $error = "Error: Could not validate the OpenID at {$_SESSION['openid_url']}";
                        }
                    }
                } else {
                    displayerror("User cancelled the OpenID authorization");
                }
            }
            if ($_GET['subaction'] == "openid_pass") {
                if (!isset($_SESSION['openid_url']) || !isset($_SESSION['openid_email'])) {
                    displayerror("You are trying to link an OpenID account without validating your log-in. Please <a href=\"./+login\">Login</a> with your OpenID account first.");
                    return;
                } else {
                    $openid_url = $_SESSION['openid_url'];
                    $openid_email = $_SESSION['openid_email'];
                    unset($_SESSION['openid_url']);
                    unset($_SESSION['openid_email']);
                    if (!isset($_POST['user_password'])) {
                        displayerror("Empty Passwords not allowed");
                        return;
                    }
                    $user_passwd = $_POST['user_password'];
                    $info = getUserInfo($openid_email);
                    if (!$info) {
                        displayerror("No user with Email {$openid_email}");
                    } else {
                        $check = checkLogin($info['user_loginmethod'], $info['user_name'], $openid_email, $user_passwd);
                        if ($check) {
                            //Password was correct. Link the account
                            $query = "INSERT INTO `" . MYSQL_DATABASE_PREFIX . "openid_users` (`openid_url`,`user_id`) VALUES ('{$openid_url}'," . $info['user_id'] . ")";
                            $result = mysql_query($query) or die(mysql_error() . " in login() subaction=openid_pass while trying to Link OpenID account");
                            if ($result) {
                                displayinfo("Account successfully Linked. Log In one more time to continue.");
                            }
                        } else {
                            displayerror("The password you specified was incorrect");
                        }
                    }
                }
            }
            if ($_GET['subaction'] == "quick_openid_reg") {
                if (!isset($_SESSION['openid_url']) || !isset($_SESSION['openid_email'])) {
                    displayerror("You are trying to register an OpenID account without validating your log-in. Please <a href=\"./+login\">Login</a> with your OpenID account first.");
                    return;
                } else {
                    $openid_url = $_SESSION['openid_url'];
                    $openid_email = $_SESSION['openid_email'];
                    unset($_SESSION['openid_url']);
                    unset($_SESSION['openid_email']);
                    if (!isset($_POST['user_name']) || $_POST['user_name'] == "") {
                        displayerror("You didn't specified your Full name. Please <a href=\"./+login\">Login</a> again.");
                        return;
                    }
                    $openid_fname = escape($_POST['user_name']);
                    //Now let's start making the dummy user
//.........这里部分代码省略.........
开发者ID:ksb1712,项目名称:pragyan,代码行数:101,代码来源:login.lib.php

示例8: actionEdit

    /**
     * function actionEdit:
     * Edit interface for all safedit module instances
     * will be called from $this->getHtml function
     */
    public function actionEdit()
    {
        $ret = <<<RET
<style type="text/css">
textarea {
\tfont-size: 130%;
\tbackground: white;
}
</style>
RET;
        global $sourceFolder, $ICONS;
        require_once $sourceFolder . "/upload.lib.php";
        submitFileUploadForm($this->moduleComponentId, "safedit", $this->userId, UPLOAD_SIZE_LIMIT);
        $end = "<fieldset id='uploadFile'><legend>{$ICONS['Uploaded Files']['small']}File Upload</legend>Upload files : <br />" . getFileUploadForm($this->moduleComponentId, "safedit", './+edit', UPLOAD_SIZE_LIMIT, 5) . getUploadedFilePreviewDeleteForm($this->moduleComponentId, "safedit", './+edit') . '</fieldset>';
        $val = mysql_fetch_assoc(mysql_query("SELECT `page_title` FROM `" . MYSQL_DATABASE_PREFIX . "pages` WHERE `page_module` = 'safedit' AND `page_modulecomponentid` = '{$this->moduleComponentId}'"));
        $ret .= "<h1>Editing '" . $val['page_title'] . "' page</h1>";
        if (isset($_GET['subaction'])) {
            if ($_GET['subaction'] == "addSection") {
                $show = isset($_POST['sectionShow']);
                $heading = escape($_POST['heading']);
                $result = mysql_query("SELECT MAX(`section_id`)+1 as `section_id` FROM `safedit_sections` WHERE `page_modulecomponentid` = '{$this->moduleComponentId}'") or die(mysql_error());
                $row = mysql_fetch_row($result);
                $sectionId = $row[0];
                $result = mysql_query("SELECT MAX(`section_priority`)+1 as `section_priority` FROM `safedit_sections` WHERE `page_modulecomponentid` = '{$this->moduleComponentId}'");
                $row = mysql_fetch_row($result);
                $priority = $row[0];
                $query = "INSERT INTO `safedit_sections`(`page_modulecomponentid`,`section_id`,`section_heading`,`section_type`,`section_show`,`section_priority`) VALUES ('{$this->moduleComponentId}','{$sectionId}','{$heading}','" . escape($_POST['type']) . "','{$show}','{$priority}')";
                mysql_query($query) or die($query . "<br>" . mysql_error());
                if (mysql_affected_rows() > 0) {
                    displayinfo("Section: {$heading}, created");
                } else {
                    displayerror("Couldn't create section");
                }
            } else {
                if ($_GET['subaction'] == 'deleteSection') {
                    $sectionId = escape($_GET['sectionId']);
                    $query = "DELETE FROM `safedit_sections` WHERE `page_modulecomponentid` = '{$this->moduleComponentId}' AND `section_id` = '{$sectionId}'";
                    mysql_query($query) or die($query . "<br>" . mysql_error());
                    if (mysql_affected_rows() > 0) {
                        displayinfo("Section deleted succesfully");
                    } else {
                        displayerror("Couldn't delete section");
                    }
                } else {
                    if ($_GET['subaction'] == 'saveSection') {
                        $sectionId = escape($_POST['sectionId']);
                        $heading = escape($_POST['heading']);
                        $typeUpdate = isset($_POST['type']) ? ", `section_type` = '{$_POST['type']}'" : '';
                        $show = ", `section_show` = '" . isset($_POST['sectionShow']) . "'";
                        $result = mysql_query("SELECT `section_type` FROM `safedit_sections` WHERE `page_modulecomponentid` = '{$this->moduleComponentId}' AND `section_id` = '{$sectionId}'");
                        $row = mysql_fetch_row($result);
                        $type = $row[0];
                        if ($type == "para" || $type == "ulist" || $type == "olist") {
                            $sectionContent = escape($this->processSave($_POST['content']));
                        } else {
                            if ($type == "picture") {
                                $sectionContent = escape($_POST['selectFile']);
                            }
                        }
                        $query = "UPDATE `safedit_sections` SET `section_heading` = '{$heading}', `section_content` = '{$sectionContent}'{$typeUpdate}{$show} WHERE `page_modulecomponentid` = '{$this->moduleComponentId}' AND `section_id` = '{$sectionId}'";
                        mysql_query($query) or die($query . "<br>" . mysql_error());
                        if (mysql_affected_rows() > 0) {
                            displayinfo("Section saved successfully");
                        }
                    } else {
                        if ($_GET['subaction'] == 'moveUp' || $_GET['subaction'] == 'moveDown') {
                            $compare = $_GET['subaction'] == 'moveUp' ? '<=' : '>=';
                            $arrange = $_GET['subaction'] == 'moveUp' ? 'DESC' : 'ASC';
                            $sectionId = escape($_GET['sectionId']);
                            $query = "SELECT `section_id`,`section_priority` FROM `safedit_sections` WHERE `page_modulecomponentid` = '{$this->moduleComponentId}' AND `section_priority` '{$compare}' (SELECT `section_priority` FROM `safedit_sections` WHERE `page_modulecomponentid` = '{$this->moduleComponentId}' AND `section_id` = '{$sectionId}') ORDER BY `section_priority` '{$arrange}' LIMIT 2";
                            $result = mysql_query($query);
                            $row = mysql_fetch_row($result);
                            $sid = $row[0];
                            $spr = $row[1];
                            if ($row = mysql_fetch_row($result)) {
                                mysql_query("UPDATE `safedit_sections` SET `section_priority` = '{$spr}' WHERE `page_modulecomponentid` = '{$this->moduleComponentId}' AND `section_id` = '{$row[0]}'");
                                mysql_query("UPDATE `safedit_sections` SET `section_priority` = '{$row[1]}' WHERE `page_modulecomponentid` = '{$this->moduleComponentId}' AND `section_id` = '{$sid}'");
                            }
                        } else {
                            if ($_GET['subaction'] == 'moveTop' || $_GET['subaction'] == 'moveBottom') {
                                $sectionId = escape($_GET['sectionId']);
                                $cpri = mysql_fetch_row(mysql_query("SELECT `section_priority` FROM `safedit_sections` WHERE `page_modulecomponentid` = '{$this->moduleComponentId}' AND `section_id` = '{$sectionId}'")) or die(mysql_error());
                                if ($_GET['subaction'] == 'moveTop') {
                                    $sign = '+';
                                    $cmpr = '<';
                                    $set = '0';
                                } else {
                                    $sign = '-';
                                    $cmpr = '>';
                                    $set = mysql_fetch_row(mysql_query("SELECT MAX(`section_priority`) FROM `safedit_sections` WHERE `page_modulecomponentid` = '{$this->moduleComponentId}'")) or die(mysql_error());
                                    $set = isset($set[0]) ? $set[0] : '';
                                }
                                $cmpr = $_GET['subaction'] == 'moveTop' ? '<' : '>';
                                $query = "UPDATE `safedit_sections` SET `section_priority` = `section_priority`{$sign}1 WHERE `page_modulecomponentid` = '{$this->moduleComponentId}' AND `section_priority` {$cmpr} '{$cpri[0]}'";
                                mysql_query($query) or die(mysql_error());
//.........这里部分代码省略.........
开发者ID:nobelium,项目名称:pragyan,代码行数:101,代码来源:safedit.lib.php

示例9: actionEdit

    public function actionEdit()
    {
        global $sourceFolder, $ICONS;
        //require_once("$sourceFolder/diff.lib.php");
        require_once $sourceFolder . "/upload.lib.php";
        if (isset($_GET['deldraft'])) {
            $dno = escape($_GET['dno']);
            $query = "DELETE FROM `article_draft` WHERE `page_modulecomponentid`='" . $this->moduleComponentId . "' AND `draft_number`=" . $dno;
            $result = mysql_query($query) or die(mysql_error());
        }
        global $ICONS;
        $header = <<<HEADER
\t\t<fieldset><legend><a name='topquicklinks'>Quicklinks</a></legend>
\t\t<table class='iconspanel'>
\t\t<tr>
\t\t<td><a href='#editor'><div>{$ICONS['Edit Page']['large']}<br/>Edit Page</div></a></td>
\t\t<td><a href='#files'><div>{$ICONS['Uploaded Files']['large']}<br/>Manage Uploaded Files</div></a></td>
\t\t<td><a href='#drafts'><div>{$ICONS['Drafts']['large']}<br/>Saved Drafts</div></a></td>
\t\t<td><a href='#revisions'><div>{$ICONS['Page Revisions']['large']}<br/>Page Revisions</div></a></td>
\t\t<td><a href='#comments'><div>{$ICONS['Page Comments']['large']}<br/>Page Comments</div></a></td>
\t\t</tr>
\t\t</table>
\t
        
\t\t</fieldset><br/><br/>
HEADER;
        submitFileUploadForm($this->moduleComponentId, "article", $this->userId, UPLOAD_SIZE_LIMIT);
        if (isset($_GET['delComment']) && $this->userId == 1) {
            mysql_query("DELETE FROM `article_comments` WHERE `comment_id` = '" . escape($_GET['delComment']) . "'");
            if (mysql_affected_rows()) {
                displayinfo("Comment deleted!");
            } else {
                displayerror("Error in deleting comment");
            }
        }
        if (isset($_GET['preview']) && isset($_POST['CKEditor1'])) {
            return "<div id=\"preview\" class=\"warning\"><a name=\"preview\">Preview</a></div>" . $this->actionView(stripslashes($_POST[CKEditor1])) . $this->getCkBody(stripslashes($_POST[CKEditor1]));
        }
        if (isset($_GET['version'])) {
            $revision = $this->getRevision($_GET['version']);
            return "<div id=\"preview\" class=\"warning\"><a name=\"preview\">Previewing Revision Number " . $_GET['version'] . "</a></div>" . $this->actionView($revision) . $this->getCkBody($revision);
        }
        if (isset($_GET['dversion'])) {
            $draft = $this->getDraft($_GET['dversion']);
            displayinfo("Viewing Draft number " . $_GET['dversion']);
            return $header . $this->getCkBody($draft);
        }
        if (isset($_POST['CKEditor1'])) {
            /*Save the diff :-*/
            $query = "SELECT article_content FROM article_content WHERE page_modulecomponentid='" . $this->moduleComponentId . "'";
            $result = mysql_query($query);
            $row = mysql_fetch_assoc($result);
            $diff = mysql_escape_string($this->diff($_POST['CKEditor1'], $row['article_content']));
            $query = "SELECT MAX(article_revision) AS MAX FROM `article_contentbak` WHERE page_modulecomponentid ='" . $this->moduleComponentId . "'";
            $result = mysql_query($query);
            if (!$result) {
                displayerror(mysql_error() . "article.lib L:44");
                return;
            }
            if (mysql_num_rows($result)) {
                $row = mysql_fetch_assoc($result);
                $revId = $row['MAX'] + 1;
            } else {
                $revId = 1;
            }
            $query = "INSERT INTO `article_contentbak` (`page_modulecomponentid` ,`article_revision` ,`article_diff`,`user_id`)\nVALUES ('{$this->moduleComponentId}', '{$revId}','{$diff}','{$this->userId}')";
            $result = mysql_query($query);
            if (!$result) {
                displayerror(mysql_error() . "article.lib L:44");
                return;
            }
            /*Save the diff end.*/
            $query = "UPDATE `article_content` SET `article_content` = '" . escape($_POST["CKEditor1"]) . "' WHERE `page_modulecomponentid` ='{$this->moduleComponentId}' ";
            $result = mysql_query($query);
            if (mysql_affected_rows() < 0) {
                displayerror("Unable to update the article content");
            } else {
                /* Index the page by sphider */
                $page = replaceAction(selfURI(), "edit", "view");
                global $sourceFolder, $moduleFolder;
                require_once "{$sourceFolder}/{$moduleFolder}/search/admin/spider.php";
                index_url($page, 0, 0, '', 0, 0, 1);
            }
            /* Update the choice of editor*/
            if (isset($_POST['editor'])) {
                $editor = escape($_POST['editor']);
                $query = "UPDATE `article_content` SET `default_editor` = '" . $editor . "' WHERE `page_modulecomponentid` ='{$this->moduleComponentId}' ";
                $result = mysql_query($query);
                if (mysql_affected_rows() < 0) {
                    displayerror("Unable to update the article Editor");
                }
            }
            return $this->actionView();
        }
        $fulleditpage = $this->getCkBody();
        $commentsedit = "<fieldset><legend><a name='comments'>{$ICONS['Page Comments']['small']}Comments</a></legend>";
        if ($this->isCommentsEnabled()) {
            $comments = mysql_query("SELECT `comment_id`,`user`,`timestamp`,`comment` FROM `article_comments` WHERE `page_modulecomponentid` = '{$this->moduleComponentId}' ORDER BY `timestamp`");
            if (mysql_num_rows($comments) == 0) {
                $commentsedit .= "No comments have been posted !";
//.........这里部分代码省略.........
开发者ID:nobelium,项目名称:pragyan,代码行数:101,代码来源:article.lib.php

示例10: groupManagementForm

function groupManagementForm($currentUserId, $modifiableGroups, &$pagePath)
{
    require_once "group.lib.php";
    global $ICONS;
    global $urlRequestRoot, $cmsFolder, $templateFolder, $moduleFolder, $sourceFolder;
    $scriptsFolder = "{$urlRequestRoot}/{$cmsFolder}/{$templateFolder}/common/scripts";
    $imagesFolder = "{$urlRequestRoot}/{$cmsFolder}/{$templateFolder}/common/images";
    /// Parse any get variables, do necessary validation and stuff, so that we needn't check inside every if
    $groupRow = $groupId = $userId = null;
    $subAction = '';
    //isset($_GET['subaction']) ? $_GET['subaction'] : '';
    if (isset($_GET['subsubaction']) && $_GET['subsubaction'] == 'editgroup' && isset($_GET['groupname']) || isset($_POST['btnEditGroup']) && isset($_POST['selEditGroups'])) {
        $subAction = 'showeditform';
    } elseif (isset($_GET['subsubaction']) && $_GET['subsubaction'] == 'associateform') {
        $subAction = 'associateform';
    } elseif (isset($_GET['subsubaction']) && $_GET['subsubaction'] == 'deleteuser' && isset($_GET['groupname']) && isset($_GET['useremail'])) {
        $subAction = 'deleteuser';
    } elseif (isset($_POST['btnAddUserToGroup'])) {
        $subAction = 'addusertogroup';
    } elseif (isset($_POST['btnSaveGroupProperties'])) {
        $subAction = 'savegroupproperties';
    } elseif (isset($_POST['btnEditGroupPriorities']) || isset($_GET['subsubaction']) && $_GET['subsubaction'] == 'editgrouppriorities') {
        $subAction = 'editgrouppriorities';
    }
    if (isset($_POST['selEditGroups']) || isset($_GET['groupname'])) {
        $groupRow = getGroupRow(isset($_POST['selEditGroups']) ? escape($_POST['selEditGroups']) : escape($_GET['groupname']));
        $groupId = $groupRow['group_id'];
        if ($subAction != 'editgrouppriorities' && (!$groupRow || !$groupId || $groupId < 2)) {
            displayerror('Error! Invalid group requested.');
            return;
        }
        if (!is_null($groupId)) {
            if ($modifiableGroups[count($modifiableGroups) - 1]['group_priority'] < $groupRow['group_priority']) {
                displayerror('You do not have the permission to modify the selected group.');
                return '';
            }
        }
    }
    if (isset($_GET['useremail'])) {
        $userId = getUserIdFromEmail($_GET['useremail']);
    }
    if ($subAction != 'editgrouppriorities' && (isset($_GET['subaction']) && $_GET['subaction'] == 'editgroups' && !is_null($groupId))) {
        if ($subAction == 'deleteuser') {
            if ($groupRow['form_id'] != 0) {
                displayerror('The group is associated with a form. To remove a user, use the edit registrants in the assoicated form.');
            } elseif (!$userId) {
                displayerror('Unknown E-mail. Could not find a registered user with the given E-mail Id');
            } else {
                $deleteQuery = 'DELETE FROM `' . MYSQL_DATABASE_PREFIX . 'usergroup` WHERE `user_id` = \'' . $userId . '\' AND `group_id` = ' . $groupId;
                $deleteResult = mysql_query($deleteQuery);
                if (!$deleteResult || mysql_affected_rows() != 1) {
                    displayerror('Could not delete user with the given E-mail from the given group.');
                } else {
                    displayinfo('Successfully removed user from the current group');
                    if ($userId == $currentUserId) {
                        $virtue = '';
                        $maxPriorityGroup = getMaxPriorityGroup($pagePath, $currentUserId, array_reverse(getGroupIds($currentUserId)), $virtue);
                        $modifiableGroups = getModifiableGroups($currentUserId, $maxPriorityGroup, $ordering = 'asc');
                    }
                }
            }
        } elseif ($subAction == 'savegroupproperties' && isset($_POST['txtGroupDescription'])) {
            $updateQuery = "UPDATE `" . MYSQL_DATABASE_PREFIX . "groups` SET `group_description` = '" . escape($_POST['txtGroupDescription']) . "' WHERE `group_id` = '{$groupId}'";
            $updateResult = mysql_query($updateQuery);
            if (!$updateResult) {
                displayerror('Could not update database.');
            } else {
                displayinfo('Changes to the group have been successfully saved.');
            }
            $groupRow = getGroupRow($groupRow['group_name']);
        } elseif ($subAction == 'addusertogroup' && isset($_POST['txtUserEmail']) && trim($_POST['txtUserEmail']) != '') {
            if ($groupRow['form_id'] != 0) {
                displayerror('The selected group is associated with a form. To add a user, register the user to the form.');
            } else {
                $passedEmails = explode(',', escape($_POST['txtUserEmail']));
                for ($i = 0; $i < count($passedEmails); $i++) {
                    $hyphenPos = strpos($passedEmails[$i], '-');
                    if ($hyphenPos >= 0) {
                        $userEmail = trim(substr($passedEmails[$i], 0, $hyphenPos - 1));
                    } else {
                        $userEmail = escape($_POST['txtUserEmail']);
                    }
                    $userId = getUserIdFromEmail($userEmail);
                    if (!$userId || $userId < 1) {
                        displayerror('Unknown E-mail. Could not find a registered user with the given E-mail Id');
                    }
                    if (!addUserToGroupName($groupRow['group_name'], $userId)) {
                        displayerror('Could not add the given user to the current group.');
                    } else {
                        displayinfo('User has been successfully inserted into the given group.');
                    }
                }
            }
        } elseif ($subAction == 'associateform') {
            if (isset($_POST['btnAssociateGroup'])) {
                $pageIdArray = array();
                $formPageId = parseUrlReal(escape($_POST['selFormPath']), $pageIdArray);
                if ($formPageId <= 0 || getPageModule($formPageId) != 'form') {
                    displayerror('Invalid page selected! The page you selected is not a form.');
                } elseif (!getPermissions($currentUserId, $formPageId, 'editregistrants', 'form')) {
//.........这里部分代码省略.........
开发者ID:nobelium,项目名称:pragyan,代码行数:101,代码来源:admin.lib.php

示例11: actionEdit

    public function actionEdit()
    {
        $module_ComponentId = $this->moduleComponentId;
        if (isset($_POST['edit_share'])) {
            $desc = safe_html($_POST['share_desc']);
            $ftype = escape($_POST['file_type']);
            if (strlen($desc) < 50 || strlen($ftype) == 0) {
                displayerror("Could not update the page. Either the share description or file type doesnot meet the requirements!!");
            } else {
                $max_size = escape($_POST['file_size']);
                $query = "UPDATE `share` SET `page_desc` = '{$desc}', `file_type` = '{$ftype}', `maxfile_size` = '{$max_size}' WHERE `page_modulecomponentid` = '{$module_ComponentId}'";
                $result = mysql_query($query);
                if (mysql_affected_rows() < 0) {
                    displayerror("Error in updating the database. Please Try again later");
                } else {
                    displayinfo("All settings updated successfully");
                }
            }
        }
        $query = "SELECT * FROM `share` WHERE `page_modulecomponentid` = '{$module_ComponentId}'";
        $result = mysql_query($query) or displayerror(mysql_error() . " Error in share.lib.php L:322");
        $result = mysql_fetch_array($result) or displayerror(mysql_error() . "Error in share.lib.php L:323");
        $edit_form = <<<EDIT
<script type="text/javascript" language="javascript">
function checkForm()
{
\tvar desc = document.edit_share.share_desc.value;
\tvar length = desc.length;
\tif(length<50)
\t{
\t\tdocument.getElementById('share_desc').focus();
\t\talert("Please enter the Share Description (min. 50 characters)");
\t\treturn false;
\t}
\tvar type = document.edit_share.file_type.value;
\tvar tlength = type.length;
\tif(tlength==0)
\t{
\t\tdocument.getElementById('file_type').focus();
\t\talert("Please enter the File types that can be uploaded");
\t\treturn false;
\t}
\treturn true;
}
</script>
\t<fieldset><legend>EDIT SHARE</legend>
\t<form method="POST" name="edit_share" action="./+edit">
\t<table>
\t<tr><td>Share Description </td><td><textarea name="share_desc" id="share_desc" cols="50" rows="5" class="textbox" >{$result['page_desc']}</textarea></td></tr>
\t<tr><td>Uploadable FIle types</td><td><input type='text' name="file_type" id="file_type" value={$result['file_type']}></td></tr>
\t<tr><td>Max File Size(in bytes)</td><td><input type='text' name="file_size" id="file_size" value={$result['maxfile_size']}></td></tr>
\t<tr><td colspan=2 style="text-align:center"><input type="submit" value="submit" name="edit_share" onclick="return checkForm();"><input type="reset" value="Reset"></td></tr>
\t</table>\t
\t</form>\t
\t</fieldset>
EDIT;
        return $edit_form;
    }
开发者ID:ksb1712,项目名称:pragyan,代码行数:58,代码来源:share.lib.php

示例12: updateWidgetConf

/**
 * Handles the submission of the widget configuration forms (both global and instance-specific) and updates the database.
 * @param $widgetid ID of the widget.
 * @param $widgetinstanceid Widget Instance ID of the widget for instance-specific configurations, default is -1 for global configurations.
 * @param $isglobal Default is set to true if handling global configurations, for instance-specific configurations must be set to false explicitly.
 * @note It uses $_POST variables implicitly to retrieve submitted form values.
 */
function updateWidgetConf($widgetid, $widgetinstanceid = -1, $isglobal = TRUE)
{
    $query = "SELECT `config_name`,`config_type`,`config_default`,`config_options` FROM `" . MYSQL_DATABASE_PREFIX . "widgetsconfiginfo` WHERE `widget_id`='{$widgetid}' AND `is_global`=" . (int) $isglobal;
    $res = mysql_query($query);
    if ($isglobal) {
        $widgetinstanceid = -1;
    }
    while ($row = mysql_fetch_array($res)) {
        $conftype = $row['config_type'];
        $confname = $row['config_name'];
        $confdef = $row['config_default'];
        $confoptions = $row['config_options'];
        if ($isglobal) {
            $postvar = "globalconfform_" . $confname;
        } else {
            $postvar = "pageconfform_" . $confname;
        }
        $confcur = false;
        $query = "SELECT `config_value` FROM `" . MYSQL_DATABASE_PREFIX . "widgetsconfig` WHERE `config_name`='{$confname}' AND `widget_id`='{$widgetid}' AND `widget_instanceid`='{$widgetinstanceid}'";
        $result = mysql_query($query);
        while ($row = mysql_fetch_assoc($result)) {
            $confcur = $row['config_value'];
        }
        if ($conftype == 'checkbox') {
            $confval = escape(interpretSubmitValue($conftype, $postvar, $confoptions));
        } else {
            $confval = escape(interpretSubmitValue($conftype, $postvar));
        }
        ///If there was no submit value, then check for the current value, if even that's missing then use the default value
        $confval = $confval === false ? $confcur === false ? $confdef : $confcur : $confval;
        if (mysql_num_rows($result) == 0) {
            $query = "INSERT INTO `" . MYSQL_DATABASE_PREFIX . "widgetsconfig` (`widget_id`,`widget_instanceid`,`config_name`,`config_value`) VALUES ({$widgetid},{$widgetinstanceid},'{$confname}','{$confval}')";
            mysql_query($query);
        } else {
            if ($confval != $confcur) {
                $query = "UPDATE `" . MYSQL_DATABASE_PREFIX . "widgetsconfig` SET `config_value`='{$confval}' WHERE `config_name`='{$confname}' AND `widget_id`='{$widgetid}' AND `widget_instanceid`='{$widgetinstanceid}'";
                mysql_query($query);
            }
        }
    }
    displayinfo("Configurations updated successfully!");
}
开发者ID:ksb1712,项目名称:pragyan,代码行数:49,代码来源:widget.lib.php

示例13: unregisterUser

/** Unegister a user in form_regdata table and remove his data from elementdata table*/
function unregisterUser($moduleCompId, $userId, $silentOnSuccess = false)
{
    if (verifyUserRegistered($moduleCompId, $userId)) {
        $unregisteruser_query = "DELETE FROM `form_regdata` WHERE `user_id` = '{$userId}' AND `page_modulecomponentid` = '{$moduleCompId}'";
        $unregisteruser_result = mysql_query($unregisteruser_query);
        /// Remove any files uploaded by the user
        $fileFieldQuery = 'SELECT `form_elementdata` FROM `form_elementdata`, `form_elementdesc` WHERE ' . "`form_elementdata`.`page_modulecomponentid` = '{$moduleCompId}' AND `form_elementtype` = 'file' AND " . "`form_elementdata`.`user_id` = '{$userId}' AND `form_elementdesc`.`page_modulecomponentid` = `form_elementdata`.`page_modulecomponentid` AND " . "`form_elementdata`.`form_elementid` = `form_elementdesc`.`form_elementid`";
        $fileFieldResult = mysql_query($fileFieldQuery);
        global $sourceFolder;
        require_once "{$sourceFolder}/upload.lib.php";
        while ($fileFieldRow = mysql_fetch_row($fileFieldResult)) {
            deleteFile($moduleCompId, 'form', $fileFieldRow[0]);
        }
        $deleteelementdata_query = "DELETE FROM `form_elementdata` WHERE `user_id` = '{$userId}' AND `page_modulecomponentid` = '{$moduleCompId}' ";
        $deleteelementdata_result = mysql_query($deleteelementdata_query);
        if ($deleteelementdata_result) {
            global $sourceFolder;
            require_once $sourceFolder . "/group.lib.php";
            $groupId = getGroupIdFromFormId($moduleCompId);
            if ($groupId != false) {
                if (removeUserFromGroupId($groupId, $userId)) {
                    if (!$silentOnSuccess) {
                        displayinfo("User successfully unregistered");
                    }
                    return true;
                } else {
                    displayerror("Unable to unregister user from group.");
                    return false;
                }
            } else {
                if (!$silentOnSuccess) {
                    displayinfo("User successfully unregistered");
                }
                return true;
            }
        } else {
            displayerror("Error in unregistering user.");
            return false;
        }
    } else {
        displaywarning("User not registered!");
        return false;
    }
}
开发者ID:nobelium,项目名称:pragyan,代码行数:45,代码来源:registrationformsubmit.php

示例14: mailer

 function mailer($to, $mailtype, $key, $from)
 {
     if (empty($from)) {
         $from = "from: " . CMS_TITLE . " <" . CMS_EMAIL . ">";
     }
     //init mail template file path
     $mail_filepath = MAILPATH . "/" . LANGUAGE . "/email/{$mailtype}.txt";
     $drop_header = '';
     if (!file_exists($mail_filepath)) {
         displayerror(safe_html("NO FILE called {$mail_filepath} FOUND !"));
     }
     //check file
     if (($data = @file_get_contents($mail_filepath)) === false) {
         displayerror("{$mail_filepath} FILE READ ERROR !");
     }
     //read contents
     //escape quotes
     $body = str_replace("'", "\\'", $data);
     //replace the vars in file content with those defined
     $body = preg_replace('#\\{([a-z0-9\\-_]*?)\\}#is', "' . ((isset(\$this->vars['\\1'])) ? \$this->vars['\\1'] : '') . '", $body);
     //Make the content parseable
     eval("\$body = '{$body}';");
     //Extract the SUBJECT from mail content
     $match = array();
     if (preg_match('#^(Subject:(.*?))$#m', $body, $match)) {
         //Find SUBJECT
         $subject = trim($match[2]) != '' ? trim($match[2]) : $subject;
         $drop_header .= '[\\r\\n]*?' . preg_quote($match[1], '#');
     }
     if ($drop_header) {
         //Remove SUBJECT from BODY of mail
         $body = trim(preg_replace('#' . $drop_header . '#s', '', $body));
     }
     //Debug info
     //echo displayinfo($from.' <br> '.$to.' <br> '.$subject.' <br> '.$body);
     //Send mail
     global $debugSet;
     if ($debugSet == "on") {
         displayinfo("Vars :" . arraytostring($this->vars));
         displayinfo("Mail sent to {$to} from {$from} with subject {$subject} and body {$body}");
     }
     return mail($to, $subject, $body, $from);
 }
开发者ID:ksb1712,项目名称:pragyan,代码行数:43,代码来源:common.lib.php

示例15: actionView

    public function actionView()
    {
        $userId = $this->userId;
        global $urlRequestRoot, $moduleFolder, $cmsFolder, $templateFolder, $sourceFolder;
        $templatesImageFolder = "{$urlRequestRoot}/{$cmsFolder}/{$templateFolder}/" . TEMPLATE;
        $temp = $urlRequestRoot . "/" . $cmsFolder . "/" . $moduleFolder . "/forum/images";
        $table_name = "forum_threads";
        $table1_name = "forum_posts";
        $forumHtml = <<<PRE
\t\t<link rel="stylesheet" href="{$temp}/styles.css" type="text/css" />
PRE;
        $forum_lastVisit = $this->forumLastVisit();
        $moderator = getPermissions($this->userId, getPageIdFromModuleComponentId("forum", $this->moduleComponentId), "moderate");
        //to check last visit to the forum
        $table_visit = "forum_visits";
        $query_checkvisit = "SELECT * from `{$table_visit}` WHERE `user_id`='{$userId}' AND `page_modulecomponentid`='{$this->moduleComponentId}'";
        $result_checkvisit = mysql_query($query_checkvisit);
        $check_visits = mysql_fetch_array($result_checkvisit);
        if (mysql_num_rows($result_checkvisit) < 1) {
            $forum_lastviewed = date("Y-m-d H:i:s");
        } else {
            $forum_lastviewed = $check_visits['last_visit'];
        }
        //set user's last visit
        $time_visit = date("Y-m-d H:i:s");
        $query_visit = "SELECT * FROM `{$table_visit}` WHERE `user_id`='{$userId}' AND `page_modulecomponentid`='{$this->moduleComponentId}'";
        $result_visit = mysql_query($query_visit);
        $num_rows_visit = mysql_num_rows($result_visit);
        if ($num_rows_visit < 1) {
            $query_setvisit = "INSERT INTO `{$table_visit}`(`page_modulecomponentid`,`user_id`,`last_visit`) VALUES('{$this->moduleComponentId}','{$userId}','{$time_visit}')";
        } else {
            $query_setvisit = "UPDATE `{$table_visit}` SET `last_visit`='{$time_visit}' WHERE `user_id`='{$userId}' AND `page_modulecomponentid`='{$this->moduleComponentId}'";
        }
        mysql_query($query_setvisit);
        require_once "{$sourceFolder}/{$moduleFolder}/forum/bbeditor.php";
        require_once "{$sourceFolder}/{$moduleFolder}/forum/bbparser.php";
        if (!isset($_GET['thread_id'])) {
            if (isset($_GET['subaction']) && $_GET['subaction'] == "delete_thread") {
                $thread_id = escape($_GET['forum_id']);
                $query = "DELETE FROM `{$table_name}` WHERE `forum_thread_id`='{$thread_id}' AND `page_modulecomponentid`='{$this->moduleComponentId}' LIMIT 1";
                $res = mysql_query($query);
                $query1 = "DELETE FROM `{$table1_name}` WHERE `forum_thread_id`='{$thread_id}' AND `page_modulecomponentid`='{$this->moduleComponentId}'";
                $res1 = mysql_query($query1);
                if (!res || !res1) {
                    displayerror("Could not perform the delete operation on the selected thread!");
                }
            }
            if ($userId > 0) {
                $new_mt = '0';
                $new_mp = '0';
                $new_p = '0';
                $new_t = '0';
                if ($moderator) {
                    $qum_0 = "SELECT * FROM `{$table_name}` WHERE `page_modulecomponentid`='" . $this->moduleComponentId . "' AND `forum_post_approve` = 0";
                    $resm_0 = mysql_query($qum_0);
                    $numm_0 = mysql_num_rows($resm_0);
                    for ($j = 1; $j <= $numm_0; $j++) {
                        $rows = mysql_fetch_array($resm_0, MYSQL_ASSOC);
                        if ($forum_lastVisit < $rows['forum_thread_datetime']) {
                            $new_mt = $new_mt + '1';
                        }
                    }
                    $qum_1 = "SELECT * FROM `{$table1_name}` WHERE `page_modulecomponentid`='" . $this->moduleComponentId . "' AND `forum_post_approve` = 0";
                    $resm_1 = mysql_query($qum_1);
                    $numm_1 = mysql_num_rows($resm_1);
                    for ($j = 1; $j <= $numm_1; $j++) {
                        $rows = mysql_fetch_array($resm_1, MYSQL_ASSOC);
                        if ($forum_lastVisit < $rows['forum_post_datetime']) {
                            $new_mp = $new_mp + '1';
                        }
                    }
                    if ($new_mt) {
                        $show_t = $new_mt . " new threads to be moderated since your last visit";
                        displayinfo($show_t);
                    }
                    if ($new_mp) {
                        $show_p = $new_mp . " new posts to be moderated since your last visit";
                        displayinfo($show_p);
                    }
                }
                $qu_0 = "SELECT * FROM `{$table_name}` WHERE `page_modulecomponentid`='" . $this->moduleComponentId . "' AND `forum_post_approve` = 1 AND `forum_thread_user_id` !='{$this->userId}'";
                $res_0 = mysql_query($qu_0);
                $num_0 = mysql_num_rows($res_0);
                for ($j = 1; $j <= $num_0; $j++) {
                    $rows = mysql_fetch_array($res_0, MYSQL_ASSOC);
                    if ($forum_lastVisit < $rows['forum_thread_datetime']) {
                        $new_t = $new_t + '1';
                    }
                }
                $qu_1 = "SELECT * FROM `{$table1_name}` WHERE `page_modulecomponentid`='" . $this->moduleComponentId . "' AND `forum_post_approve` = 1 AND `forum_post_user_id` !='{$this->userId}'";
                $res_1 = mysql_query($qu_1) or die(mysql_error());
                $num_1 = mysql_num_rows($res_1);
                for ($j = 1; $j <= $num_1; $j++) {
                    $rows = mysql_fetch_array($res_1, MYSQL_ASSOC);
                    if ($forum_lastVisit < $rows['forum_post_datetime']) {
                        $new_p = $new_p + '1';
                    }
                }
                if ($new_t && $new_t != $new_mt) {
                    $show_t = $new_t . " new threads since your last visit";
//.........这里部分代码省略.........
开发者ID:nobelium,项目名称:pragyan,代码行数:101,代码来源:forum.lib.php


注:本文中的displayinfo函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。