diff --git a/include/class.nav.php b/include/class.nav.php
index ad30e1219f8eb33f597867f64615773a710e2c90..a92a5629ec149579cd3d7883be2aa8ff2ef661fc 100644
--- a/include/class.nav.php
+++ b/include/class.nav.php
@@ -196,6 +196,7 @@ class AdminNav extends StaffNav{
                     $subnav[]=array('desc'=>'System Preferences','href'=>'settings.php?t=system','iconclass'=>'preferences');
                     $subnav[]=array('desc'=>'Tickets','href'=>'settings.php?t=tickets','iconclass'=>'ticket-settings');
                     $subnav[]=array('desc'=>'Emails','href'=>'settings.php?t=emails','iconclass'=>'email-settings');
+                    $subnav[]=array('desc'=>'Pages','href'=>'settings.php?t=pages','iconclass'=>'pages');
                     $subnav[]=array('desc'=>'Knowledgebase','href'=>'settings.php?t=kb','iconclass'=>'kb-settings');
                     $subnav[]=array('desc'=>'Autoresponder','href'=>'settings.php?t=autoresp','iconclass'=>'email-autoresponders');
                     $subnav[]=array('desc'=>'Alerts & Notices','href'=>'settings.php?t=alerts','iconclass'=>'alert-settings');
@@ -206,6 +207,7 @@ class AdminNav extends StaffNav{
                                         'title'=>'Ticket Filters','iconclass'=>'ticketFilters');
                     $subnav[]=array('desc'=>'SLA Plans','href'=>'slas.php','iconclass'=>'sla');
                     $subnav[]=array('desc'=>'API Keys','href'=>'apikeys.php','iconclass'=>'api');
+                    $subnav[]=array('desc'=>'Site Pages', 'href'=>'pages.php','title'=>'Pages','iconclass'=>'pages');
                     break;
                 case 'emails':
                     $subnav[]=array('desc'=>'Emails','href'=>'emails.php', 'title'=>'Email Addresses', 'iconclass'=>'emailSettings');
diff --git a/include/class.page.php b/include/class.page.php
new file mode 100644
index 0000000000000000000000000000000000000000..f0c1f604b125674d8ae208e1e77114b0a2b5daa7
--- /dev/null
+++ b/include/class.page.php
@@ -0,0 +1,261 @@
+<?php
+/*********************************************************************
+    class.page.php
+
+    Page class
+
+    Copyright (c)  2006-2013 osTicket
+    http://www.osticket.com
+
+    Released under the GNU General Public License WITHOUT ANY WARRANTY.
+    See LICENSE.TXT for details.
+
+    vim: expandtab sw=4 ts=4 sts=4:
+**********************************************************************/
+
+class Page {
+
+    var $id;
+    var $ht;
+
+    function Page($id) {
+        $this->id=0;
+        $this->ht = array();
+        $this->load($id);
+    }
+
+    function load($id=0) {
+
+        if(!$id && !($id=$this->getId()))
+            return false;
+
+        $sql='SELECT page.*, count(topic.page_id) as topics '
+            .' FROM '.PAGE_TABLE.' page '
+            .' LEFT JOIN '.TOPIC_TABLE. ' topic ON(topic.page_id=page.id) '
+            .' WHERE page.id='.db_input($id)
+            .' GROUP By page.id';
+
+        if (!($res=db_query($sql)) || !db_num_rows($res))
+            return false;
+
+        $this->ht = db_fetch_array($res);
+        $this->id = $this->ht['id'];
+
+        return true;
+    }
+
+    function reload() {
+        return $this->load();
+    }
+
+    function getId() {
+        return $this->id;
+    }
+
+    function getHashtable() {
+        return $this->ht;
+    }
+
+    function getType() {
+        return $this->ht['type'];
+    }
+
+    function getName() {
+        return $this->ht['name'];
+    }
+
+    function getBody() {
+        return $this->ht['body'];
+    }
+
+    function getNotes() {
+        return $this->ht['notes'];
+    }
+
+    function isActive() {
+        return ($this->ht['isactive']);
+    }
+
+    function isInUse() {
+        global $cfg;
+
+        return  ($this->getNumTopics()
+                    || in_array($this->getId(), $cfg->getDefaultPages()));
+    }
+
+
+    function getCreateDate() {
+        return $this->ht['created'];
+    }
+
+    function getUpdateDate() {
+        return $this->ht['updated'];
+    }
+
+    function getNumTopics() {
+        return $this->ht['topics'];
+    }
+
+    function update($vars, &$errors) {
+
+        if(!$vars['isactive'] && $this->isInUse()) {
+            $errors['err'] = 'A page currently in-use CANNOT be disabled!';
+            $errors['isactive'] = 'Page is in-use!';
+        }
+
+        if($errors || !$this->save($this->getId(), $vars, $errors))
+            return false;
+
+        $this->reload();
+
+        return true;
+    }
+
+    function disable() {
+
+        if(!$this->isActive())
+            return true;
+
+        if($this->isInUse())
+            return false;
+
+
+        $sql=' UPDATE '.PAGE_TABLE.' SET isactive=0 '
+            .' WHERE id='.db_input($this->getId());
+
+        if(!db_query($sql) || !db_affected_rows())
+            return false;
+
+        $this->reload();
+
+        return true;
+    }
+
+    function delete() {
+
+        if($this->isInUse())
+            return false;
+
+        $sql='DELETE FROM '.PAGE_TABLE
+            .' WHERE id='.db_input($this->getId())
+            .' LIMIT 1';
+
+        if(!db_query($sql) || !db_affected_rows())
+            return false;
+
+        db_query('UPDATE '.TOPIC_TABLE.' SET page_id=0 WHERE page_id='.db_input($this->getId()));
+
+        return true;
+    }
+
+    /* ------------------> Static methods <--------------------- */
+
+    function add($vars, &$errors) {
+        if(!($id=self::create($vars, $errors)))
+            return false;
+
+        return self::lookup($id);
+    }
+
+    function create($vars, &$errors) {
+        return self::save(0, $vars, $errors);
+    }
+
+    function getPages($criteria=array()) {
+
+        $sql = ' SELECT id FROM '.PAGE_TABLE.' WHERE 1';
+        if(isset($criteria['active']))
+            $sql.=' AND  isactive='.db_input($criteria['active']?1:0);
+        if(isset($criteria['type']))
+            $sql.=' AND `type`='.db_input($criteria['type']);
+
+        $sql.=' ORDER BY name';
+
+        $pages = array();
+        if(($res=db_query($sql)) && db_num_rows($res))
+            while(list($id) = db_fetch_row($res))
+                $pages[] = Page::lookup($id);
+
+        return array_filter($pages);
+    }
+
+    function getActivePages($criteria=array()) {
+
+        $criteria = array_merge($criteria, array('active'=>true));
+
+        return self::getPages($criteria);
+    }
+
+    function getActiveThankYouPages() {
+        return self::getActivePages(array('type' => 'thank-you'));
+    }
+
+    function getIdByName($name) {
+
+        $id = 0;
+        $sql = ' SELECT id FROM '.PAGE_TABLE.' WHERE name='.db_input($name);
+        if(($res=db_query($sql)) && db_num_rows($res))
+            list($id) = db_fetch_row($res);
+
+        return $id;
+    }
+
+    function lookup($id) {
+        return ($id
+                && is_numeric($id)
+                && ($p= new Page($id))
+                && $p->getId()==$id)
+            ? $p : null;
+    }
+
+    function save($id, $vars, &$errors) {
+
+        //Cleanup.
+        $vars['name']=Format::striptags(trim($vars['name']));
+
+        //validate
+        if($id && $id!=$vars['id'])
+            $errors['err'] = 'Internal error. Try again';
+
+        if(!$vars['type'])
+            $errors['type'] = 'Type required';
+        elseif(!in_array($vars['type'], array('landing', 'offline', 'thank-you', 'other')))
+            $errors['type'] = 'Invalid selection';
+
+        if(!$vars['name'])
+            $errors['name'] = 'Name required';
+        elseif(($pid=self::getIdByName($vars['name'])) && $pid!=$id)
+            $errors['name'] = 'Name already exists';
+
+        if(!$vars['body'])
+            $errors['body'] = 'Page body is required';
+
+        if($errors) return false;
+
+        //save
+        $sql=' updated=NOW() '
+            .', `type`='.db_input($vars['type'])
+            .', name='.db_input($vars['name'])
+            .', body='.db_input(Format::safe_html($vars['body']))
+            .', isactive='.db_input(isset($vars['isactive'])?1:0)
+            .', notes='.db_input($vars['notes']);
+
+        if($id) {
+            $sql='UPDATE '.PAGE_TABLE.' SET '.$sql.' WHERE id='.db_input($id);
+            if(db_query($sql))
+                return true;
+
+            $errors['err']='Unable to update page.';
+
+        } else {
+            $sql='INSERT INTO '.PAGE_TABLE.' SET '.$sql.', created=NOW()';
+            if(db_query($sql) && ($id=db_insert_id()))
+                return $id;
+
+            $errors['err']='Unable to create page. Internal error';
+        }
+
+        return false;
+    }
+}
+?>
diff --git a/include/staff/page.inc.php b/include/staff/page.inc.php
new file mode 100644
index 0000000000000000000000000000000000000000..be52b3607bda6e269d5f85bc7f8efc49f423b0bc
--- /dev/null
+++ b/include/staff/page.inc.php
@@ -0,0 +1,104 @@
+<?php
+if(!defined('OSTADMININC') || !$thisstaff || !$thisstaff->isAdmin()) die('Access Denied');
+$pageTypes = array(
+        'landing' => 'Landing page',
+        'offline' => 'Offline page',
+        'thank-you' => 'Thank you page',
+        'other' => 'Other',
+        );
+$info=array();
+$qstr='';
+if($page && $_REQUEST['a']!='add'){
+    $title='Update Page';
+    $action='update';
+    $submit_text='Save Changes';
+    $info=$page->getHashtable();
+    $qstr.='&id='.$page->getId();
+}else {
+    $title='Add New Page';
+    $action='add';
+    $submit_text='Add Page';
+    $info['isactive']=isset($info['isactive'])?$info['isactive']:0;
+    $qstr.='&a='.urlencode($_REQUEST['a']);
+}
+$info=Format::htmlchars(($errors && $_POST)?$_POST:$info);
+?>
+<form action="pages.php?<?php echo $qstr; ?>" method="post" id="save">
+ <?php csrf_token(); ?>
+ <input type="hidden" name="do" value="<?php echo $action; ?>">
+ <input type="hidden" name="a" value="<?php echo Format::htmlchars($_REQUEST['a']); ?>">
+ <input type="hidden" name="id" value="<?php echo $info['id']; ?>">
+ <h2>Email Template</h2>
+ <table class="form_table" width="940" border="0" cellspacing="0" cellpadding="2">
+    <thead>
+        <tr>
+            <th colspan="2">
+                <h4><?php echo $title; ?></h4>
+                <em>Page information.</em>
+            </th>
+        </tr>
+    </thead>
+    <tbody>
+        <tr>
+            <td width="180" class="required">
+              Name:
+            </td>
+            <td>
+                <input type="text" size="40" name="name" value="<?php echo $info['name']; ?>">
+                &nbsp;<span class="error">*&nbsp;<?php echo $errors['name']; ?></span>
+            </td>
+        </tr>
+        <tr>
+            <td width="180" class="required">
+                Type:
+            </td>
+            <td>
+                <select name="type">
+                    <option value="" selected="selected">Select Page Type</option>
+                    <?php
+                    foreach($pageTypes as $k => $v)
+                        echo sprintf('<option value="%s" %s>%s</option>',
+                                $k, (($info['type']==$k)?'selected="selected"':''), $v);
+                    ?>
+                </select>
+                &nbsp;<span class="error">*&nbsp;<?php echo $errors['type']; ?></span>
+            </td>
+        </tr>
+        <tr>
+            <td width="180" class="required">
+                Status:
+            </td>
+            <td>
+                <input type="radio" name="isactive" value="1" <?php echo $info['isactive']?'checked="checked"':''; ?>><strong>Active</strong>
+                <input type="radio" name="isactive" value="0" <?php echo !$info['isactive']?'checked="checked"':''; ?>>Disabled
+                &nbsp;<span class="error">*&nbsp;<?php echo $errors['isactive']; ?></span>
+            </td>
+        </tr>
+        <tr>
+            <th colspan="2">
+                <em><b>Page body</b>: Ticket variables are only supported in thank-you pages.<font class="error">*&nbsp;<?php echo $errors['body']; ?></font></em>
+            </th>
+        </tr>
+         <tr>
+            <td colspan=2 style="padding-left:3px;">
+                <textarea name="body" cols="21" rows="12" style="width:98%;" class="richtext"><?php echo $info['body']; ?></textarea>
+            </td>
+        </tr>
+        <tr>
+            <th colspan="2">
+                <em><strong>Admin Notes</strong>: Internal notes.&nbsp;</em>
+            </th>
+        </tr>
+        <tr>
+            <td colspan=2>
+                <textarea name="notes" cols="21" rows="8" style="width: 80%;"><?php echo $info['notes']; ?></textarea>
+            </td>
+        </tr>
+    </tbody>
+</table>
+<p style="padding-left:225px;">
+    <input type="submit" name="submit" value="<?php echo $submit_text; ?>">
+    <input type="reset"  name="reset"  value="Reset">
+    <input type="button" name="cancel" value="Cancel" onclick='window.location.href="pages.php"'>
+</p>
+</form>
diff --git a/include/staff/pages.inc.php b/include/staff/pages.inc.php
new file mode 100644
index 0000000000000000000000000000000000000000..8fc14be6239ff685c0bb57630fe17fc313e7951c
--- /dev/null
+++ b/include/staff/pages.inc.php
@@ -0,0 +1,152 @@
+<?php
+if(!defined('OSTADMININC') || !$thisstaff->isAdmin()) die('Access Denied');
+
+$qstr='';
+$sql='SELECT page.id, page.isactive, page.name, page.created, page.updated, count(topic.topic_id) as topics '
+     .' FROM '.PAGE_TABLE.' page '
+     .' LEFT JOIN '.TOPIC_TABLE.' topic ON(topic.page_id=page.id) '
+     .' WHERE 1 ';
+$sortOptions=array(
+        'name'=>'page.name', 'status'=>'page.isactive',
+        'created'=>'page.created', 'updated'=>'page.updated');
+
+$orderWays=array('DESC'=>'DESC','ASC'=>'ASC');
+$sort=($_REQUEST['sort'] && $sortOptions[strtolower($_REQUEST['sort'])])?strtolower($_REQUEST['sort']):'name';
+//Sorting options...
+if($sort && $sortOptions[$sort]) {
+    $order_column =$sortOptions[$sort];
+}
+
+$order_column=$order_column?$order_column:'page.name';
+
+if($_REQUEST['order'] && $orderWays[strtoupper($_REQUEST['order'])]) {
+    $order=$orderWays[strtoupper($_REQUEST['order'])];
+}
+$order=$order?$order:'ASC';
+
+if($order_column && strpos($order_column,',')){
+    $order_column=str_replace(','," $order,",$order_column);
+}
+$x=$sort.'_sort';
+$$x=' class="'.strtolower($order).'" ';
+$order_by="$order_column $order ";
+
+$total=db_count('SELECT count(*) FROM '.PAGE_TABLE.' page ');
+$page=($_GET['p'] && is_numeric($_GET['p']))?$_GET['p']:1;
+$pageNav=new Pagenate($total, $page, PAGE_LIMIT);
+$pageNav->setURL('pages.php',$qstr.'&sort='.urlencode($_REQUEST['sort']).'&order='.urlencode($_REQUEST['order']));
+//Ok..lets roll...create the actual query
+$qstr.='&order='.($order=='DESC'?'ASC':'DESC');
+$query="$sql GROUP BY page.id ORDER BY $order_by LIMIT ".$pageNav->getStart().",".$pageNav->getLimit();
+$res=db_query($query);
+if($res && ($num=db_num_rows($res)))
+    $showing=$pageNav->showing();
+else
+    $showing='No pages found!';
+
+?>
+
+<div style="width:700;padding-top:5px; float:left;">
+ <h2>Site Pages</h2>
+</div>
+<div style="float:right;text-align:right;padding-top:5px;padding-right:5px;">
+ <b><a href="pages.php?a=add" class="Icon newPage">Add New Page</a></b></div>
+<div class="clear"></div>
+<form action="pages.php" method="POST" name="tpls">
+ <?php csrf_token(); ?>
+ <input type="hidden" name="do" value="mass_process" >
+<input type="hidden" id="action" name="a" value="" >
+ <table class="list" border="0" cellspacing="1" cellpadding="0" width="940">
+    <caption><?php echo $showing; ?></caption>
+    <thead>
+        <tr>
+            <th width="7">&nbsp;</th>
+            <th width="380"><a <?php echo $name_sort; ?> href="pages.php?<?php echo $qstr; ?>&sort=name">Name</a></th>
+            <th width="120"><a  <?php echo $status_sort; ?> href="pages.php?<?php echo $qstr; ?>&sort=status">Status</a></th>
+            <th width="150" nowrap><a  <?php echo $created_sort; ?>href="pages.php?<?php echo $qstr; ?>&sort=created">Date Added</a></th>
+            <th width="150" nowrap><a  <?php echo $updated_sort; ?>href="pages.php?<?php echo $qstr; ?>&sort=updated">Last Updated</a></th>
+        </tr>
+    </thead>
+    <tbody>
+    <?php
+        $total=0;
+        $ids=($errors && is_array($_POST['ids']))?$_POST['ids']:null;
+        if($res && db_num_rows($res)):
+            $defaultPages=$cfg->getDefaultPages();
+            while ($row = db_fetch_array($res)) {
+                $sel=false;
+                if($ids && in_array($row['id'], $ids))
+                    $sel=true;
+                $inuse = ($row['topics'] || in_array($row['id'], $defaultPages));
+                ?>
+            <tr id="<?php echo $row['id']; ?>">
+                <td width=7px>
+                  <input type="checkbox" class="ckb" name="ids[]" value="<?php echo $row['id']; ?>"
+                            <?php echo $sel?'checked="checked"':''; ?>>
+                </td>
+                <td>&nbsp;<a href="pages.php?id=<?php echo $row['id']; ?>"><?php echo Format::htmlchars($row['name']); ?></a></td>
+                <td>
+                    &nbsp;<?php echo $row['isactive']?'Active':'<b>Disabled</b>'; ?>
+                    &nbsp;&nbsp;<?php echo $inuse?'<em>(in-use)</em>':''; ?>
+                </td>
+                <td>&nbsp;<?php echo Format::db_date($row['created']); ?></td>
+                <td>&nbsp;<?php echo Format::db_datetime($row['updated']); ?></td>
+            </tr>
+            <?php
+            } //end of while.
+        endif; ?>
+    <tfoot>
+     <tr>
+        <td colspan="6">
+            <?php if($res && $num){ ?>
+            Select:&nbsp;
+            <a id="selectAll" href="#ckb">All</a>&nbsp;&nbsp;
+            <a id="selectNone" href="#ckb">None</a>&nbsp;&nbsp;
+            <a id="selectToggle" href="#ckb">Toggle</a>&nbsp;&nbsp;
+            <?php }else{
+                echo 'No pages found';
+            } ?>
+        </td>
+     </tr>
+    </tfoot>
+</table>
+<?php
+if($res && $num): //Show options..
+    echo '<div>&nbsp;Page:'.$pageNav->getPageLinks().'&nbsp;</div>';
+?>
+<p class="centered" id="actions">
+    <input class="button" type="submit" name="enable" value="Enable" >
+    <input class="button" type="submit" name="disable" value="Disable" >
+    <input class="button" type="submit" name="delete" value="Delete" >
+</p>
+<?php
+endif;
+?>
+</form>
+
+<div style="display:none;" class="dialog" id="confirm-action">
+    <h3>Please Confirm</h3>
+    <a class="close" href="">&times;</a>
+    <hr/>
+    <p class="confirm-action" style="display:none;" id="enable-confirm">
+        Are you sure want to <b>enable</b> selected pages?
+    </p>
+    <p class="confirm-action" style="display:none;" id="disable-confirm">
+        Are you sure want to <b>disable</b>  selected pages?
+    </p>
+    <p class="confirm-action" style="display:none;" id="delete-confirm">
+        <font color="red"><strong>Are you sure you want to DELETE selected pages?</strong></font>
+        <br><br>Deleted pages CANNOT be recovered.
+    </p>
+    <div>Please confirm to continue.</div>
+    <hr style="margin-top:1em"/>
+    <p class="full-width">
+        <span class="buttons" style="float:left">
+            <input type="button" value="No, Cancel" class="close">
+        </span>
+        <span class="buttons" style="float:right">
+            <input type="button" value="Yes, Do it!" class="confirm">
+        </span>
+     </p>
+    <div class="clear"></div>
+</div>
diff --git a/main.inc.php b/main.inc.php
index 2a841be61dd65499ce6c08fce6df0bc09f6b0753..fc9e4c5b84dd6242a7445faa64f2827ac9bf7045 100644
--- a/main.inc.php
+++ b/main.inc.php
@@ -120,6 +120,7 @@
     require(INCLUDE_DIR.'class.http.php');
     require(INCLUDE_DIR.'class.signal.php');
     require(INCLUDE_DIR.'class.nav.php');
+    require(INCLUDE_DIR.'class.page.php');
     require(INCLUDE_DIR.'class.format.php'); //format helpers
     require(INCLUDE_DIR.'class.validator.php'); //Class to help with basic form input validation...please help improve it.
     require(INCLUDE_DIR.'class.mailer.php');
@@ -159,6 +160,8 @@
     define('TEAM_TABLE',TABLE_PREFIX.'team');
     define('TEAM_MEMBER_TABLE',TABLE_PREFIX.'team_member');
 
+    define('PAGE_TABLE', TABLE_PREFIX.'page');
+
     define('FAQ_TABLE',TABLE_PREFIX.'faq');
     define('FAQ_ATTACHMENT_TABLE',TABLE_PREFIX.'faq_attachment');
     define('FAQ_TOPIC_TABLE',TABLE_PREFIX.'faq_topic');
diff --git a/scp/css/scp.css b/scp/css/scp.css
index 8fd39dd21f6e539df9442f20006a8e8f8720ede1..27da30ce79989c3007dcf13bf1d50a30ead23dd0 100644
--- a/scp/css/scp.css
+++ b/scp/css/scp.css
@@ -292,6 +292,9 @@ a.departments { background:url(../images/icons/list_departments.gif) }
 a.newDepartment { background:url(../images/icons/new_department.gif) }
 
 
+a.pages { background:url(../images/icons/pages.gif) }
+a.newPage { background:url(../images/icons/new_page.gif) }
+
 /* Generic CSS based Icons. use=> <tag class="Icon iconname">text</tag> */
 
 .Icon {
@@ -1378,27 +1381,27 @@ ul.progress li.no small {color:red;}
 #bar.error { background: #ffd; text-align: center; color: #a00; font-weight: bold; }
 
 /* Overlay */
-#overlay { 
-    display: none; 
-    position: fixed; 
+#overlay {
+    display: none;
+    position: fixed;
     top: 0;
     left: 0;
     width: 100%;
     height: 100%;
     background: #000;
     z-index: 1000;
-    -webkit-transform: translate3d(0,0,0); 
+    -webkit-transform: translate3d(0,0,0);
 }
 
 #loading, #upgrading {
     border:1px solid #2a67ac;
-    padding: 10px 10px 10px 60px; 
-    width: 300px; 
-    height: 100px; 
+    padding: 10px 10px 10px 60px;
+    width: 300px;
+    height: 100px;
     background: rgb( 255, 255, 255) url('../images/FhHRx-Spinner.gif') 10px 50% no-repeat;
-    position: fixed; 
-    display: none; 
-    z-index: 3000; 
+    position: fixed;
+    display: none;
+    z-index: 3000;
 }
 
 #loading h4, #upgrading h4 { margin: 3px 0 0 0; padding: 0; color: #d80; }
diff --git a/scp/images/icons/new_page.gif b/scp/images/icons/new_page.gif
new file mode 100644
index 0000000000000000000000000000000000000000..0a675850c713e6b6ea9eda5920c39e158c2f05f8
Binary files /dev/null and b/scp/images/icons/new_page.gif differ
diff --git a/scp/images/icons/pages.gif b/scp/images/icons/pages.gif
new file mode 100644
index 0000000000000000000000000000000000000000..10a29ef0490733aaeee4f9b658cd1bb4962f021f
Binary files /dev/null and b/scp/images/icons/pages.gif differ
diff --git a/scp/pages.php b/scp/pages.php
new file mode 100644
index 0000000000000000000000000000000000000000..295852bafd112f2e4a1254e480862845a3cba558
--- /dev/null
+++ b/scp/pages.php
@@ -0,0 +1,108 @@
+<?php
+/*********************************************************************
+    pages.php
+
+    Site pages.
+
+    Peter Rotich <peter@osticket.com>
+    Copyright (c)  2006-2013 osTicket
+    http://www.osticket.com
+
+    Released under the GNU General Public License WITHOUT ANY WARRANTY.
+    See LICENSE.TXT for details.
+
+    vim: expandtab sw=4 ts=4 sts=4:
+**********************************************************************/
+require('admin.inc.php');
+require_once(INCLUDE_DIR.'class.page.php');
+
+$page = null;
+if($_REQUEST['id'] && !($page=Page::lookup($_REQUEST['id'])))
+   $errors['err']='Unknown or invalid page';
+
+if($_POST) {
+    switch(strtolower($_POST['do'])) {
+        case 'add':
+            if(($pageId=Page::create($_POST, $errors))) {
+                $_REQUEST['a'] = null;
+                $msg='Page added successfully';
+            } elseif(!$errors['err'])
+                $errors['err'] = 'Unable to add page. Try again!';
+        break;
+        case 'update':
+            if(!$page)
+                $errors['err'] = 'Invalid or unknown page';
+            elseif($page->update($_POST, $errors)) {
+                $msg='Page updated successfully';
+                $_REQUEST['a']=null; //Go back to view
+            } elseif(!$errors['err'])
+                $errors['err'] = 'Unable to update page. Try again!';
+            break;
+        case 'mass_process':
+            if(!$_POST['ids'] || !is_array($_POST['ids']) || !count($_POST['ids'])) {
+                $errors['err'] = 'You must select at least one page.';
+            } elseif(array_intersect($_POST['ids'], $cfg->getDefaultPages()) && strcasecmp($_POST['a'], 'enable')) {
+                 $errors['err'] = 'One or more of the selected pages is in-use and CANNOT be disabled/deleted.';
+            } else {
+                $count=count($_POST['ids']);
+                switch(strtolower($_POST['a'])) {
+                    case 'enable':
+                        $sql='UPDATE '.PAGE_TABLE.' SET isactive=1 '
+                            .' WHERE id IN ('.implode(',', db_input($_POST['ids'])).')';
+                        if(db_query($sql) && ($num=db_affected_rows())) {
+                            if($num==$count)
+                                $msg = 'Selected pages enabled';
+                            else
+                                $warn = "$num of $count selected pages enabled";
+                        } else {
+                            $errors['err'] = 'Unable to enable selected pages';
+                        }
+                        break;
+                    case 'disable':
+                        $i = 0;
+                        foreach($_POST['ids'] as $k=>$v) {
+                            if(($p=Page::lookup($v)) && $p->disable())
+                                $i++;
+                        }
+
+                        if($i && $i==$count)
+                            $msg = 'Selected pages disabled';
+                        elseif($i>0)
+                            $warn = "$num of $count selected pages disabled";
+                        elseif(!$errors['err'])
+                            $errors['err'] = 'Unable to disable selected pages';
+                        break;
+                    case 'delete':
+                        $i=0;
+                        foreach($_POST['ids'] as $k=>$v) {
+                            if(($p=Page::lookup($v)) && $p->delete())
+                                $i++;
+                        }
+
+                        if($i && $i==$count)
+                            $msg = 'Selected pages deleted successfully';
+                        elseif($i>0)
+                            $warn = "$i of $count selected pages deleted";
+                        elseif(!$errors['err'])
+                            $errors['err'] = 'Unable to delete selected pages';
+                        break;
+                    default:
+                        $errors['err']='Unknown action - get technical help.';
+                }
+            }
+            break;
+        default:
+            $errors['err']='Unknown action/command';
+            break;
+    }
+}
+
+$inc='pages.inc.php';
+if($page || $_REQUEST['a']=='add')
+    $inc='page.inc.php';
+
+$nav->setTabActive('manage');
+require_once(STAFFINC_DIR.'header.inc.php');
+require_once(STAFFINC_DIR.$inc);
+require_once(STAFFINC_DIR.'footer.inc.php');
+?>