function form(&$err)
{
    if (isset($_POST)) {
        global $_POST;
    } else {
        return;
    }
    global $db;
    if (sending()) {
        $_SESSION = array();
        if (isset($_POST['flash'])) {
            $flash = ' -flash';
        } else {
            $flash = '';
        }
        if ($list = getlist($_POST['number'])) {
            foreach ($list->numbers as $no) {
                $err->out = Gammu::infiniteSend($_POST['message'], $no, $flash);
                if ($err->out != 0) {
                    $err->numberInError[] = getNameOf($no);
                }
            }
        } else {
            $users = $db->table('directory')->find();
            foreach ($users as $user) {
                if (isset($user->name) and $user->name == $_POST['number']) {
                    $_POST['number'] = $user->number;
                }
            }
            $_POST['number'] = str_replace(' ', '', $_POST['number']);
            $err->out = Gammu::send($_POST['message'], $_POST['number'], $flash);
            if ($err->out != 0) {
                formSetSessionValues();
            }
        }
    } else {
        if (saveContact()) {
            $_POST['number'] = str_replace(' ', '', $_POST['number']);
            $err->in = $db->table('directory')->insert($_POST);
        } else {
            if (saveList()) {
                $list = array("list" => $_POST['list']);
                $i = 1;
                while (isset($_POST['number' . $i])) {
                    if (!empty($_POST['number' . $i])) {
                        if ($number = getNumberOfName($_POST['number' . $i])) {
                            $list['numbers'][] = $number;
                        } else {
                            $list['numbers'][] = $_POST['number' . $i];
                        }
                    }
                    $i++;
                }
                $err->listin = $db->table('lists')->insert($list);
            } else {
                $err->errorMessages();
            }
        }
    }
}
Beispiel #2
0
function saveList($parent, $children)
{
    global $wpdb, $excludePages;
    $parent = (int) $parent;
    $result = array();
    $i = 1;
    foreach ($children as $k => $v) {
        //IDs are 'JM_#' so strip first 3 characters
        $id = (int) substr($children[$k]->id, 3);
        //if it had the remove class it is now added to the excludePages array
        if (isset($v->hide)) {
            $excludePages[] = $id;
        }
        //update pages in db
        $postquery = "UPDATE {$wpdb->posts} SET ";
        $postquery .= "menu_order='{$i}'";
        if (isset($v->renamed)) {
            $postquery .= ", post_title='{$v->renamed}'";
        }
        if (isset($v->hide)) {
            $postquery .= ", post_status='draft'";
        } else {
            $postquery .= ", post_status='publish'";
        }
        $postquery .= " WHERE ID='{$id}'";
        $wpdb->query($postquery);
        echo $postquery;
        echo "\n";
        if (isset($v->children[0])) {
            saveList($id, $v->children);
        }
        $i++;
    }
}
Beispiel #3
0
function PageCompPageMainCode()
{
    global $iAmInPopup;
    global $aFields;
    $sPopupAdd = $iAmInPopup ? '&popup=1' : '';
    $sResultMsg = '';
    if (isset($_POST['action']) and $_POST['action'] == 'Save' and isset($_POST['PreList']) and is_array($_POST['PreList'])) {
        if (true === saveList($_POST['list'], $_POST['PreList'])) {
            $sResultMsg = _t('_Success');
        } else {
            $sResultMsg = _t('_Failed to apply changes');
        }
    }
    //get lists
    $aLists = array();
    $aKeys = getPreKeys();
    foreach ($aKeys as $aList) {
        $aLists[$aList['Key']] = $aList['Key'];
    }
    $sListIn = bx_get('list');
    if ($sListIn !== false) {
        $sList_db = process_db_input($sListIn);
        $sList = process_pass_data($sListIn);
        $iCount = getPreValuesCount($sListIn);
        if (!$iCount) {
            //if no rows returned...
            $aLists[$sList] = $sList;
        }
        //create new list
    } else {
        $sList = '';
    }
    ob_start();
    if ($sResultMsg) {
        echo MsgBox($sResultMsg);
    }
    ?>
    <script type="text/javascript">
        function createNewList()
        {
            var sNewList = prompt( '<?php 
    echo bx_js_string(_t('_adm_pvalues_msg_enter_list_name'));
    ?>
' );

            if( sNewList == null )
                return false;

            sNewList = $.trim( sNewList );

            if( !sNewList.length ) {
                alert( '<?php 
    echo bx_js_string(_t('_adm_pvalues_msg_enter_correct_name'));
    ?>
' );
                return false;
            }

            window.location = '<?php 
    echo $GLOBALS['site']['url_admin'] . 'preValues.php';
    ?>
?list=' + encodeURIComponent( sNewList ) + '<?php 
    echo $sPopupAdd;
    ?>
';
        }

        function addRow( eImg )
        {
            $( eImg ).parent().parent().before(
                '<tr>' +
                <?php 
    foreach ($aFields as $sField => $sHelp) {
        ?>
                    '<td><input type="text" class="value_input" name="PreList[' + iNextInd + '][<?php 
        echo $sField;
        ?>
]" value="" /></td>' +
                    <?php 
    }
    ?>
                    '<th class="row_controls">' +
                    	'<a class="row_control bx-def-margin-thd-left-auto" href="javascript:void(0)" onclick="javascript:delRow(this);" title="<?php 
    echo bx_html_attribute(_t('_Delete'));
    ?>
"><i class="sys-icon times"></i></a>' +
                		'<a class="row_control bx-def-margin-thd-left-auto" href="javascript:void(0)" onclick="javascript:moveUpRow(this);" title="<?php 
    echo bx_html_attribute(_t('_adm_pvalues_txt_move_up'));
    ?>
"><i class="sys-icon arrow-up"></i></a>' +
                		'<a class="row_control bx-def-margin-thd-left-auto" href="javascript:void(0)" onclick="javascript:moveDownRow(this);" title="<?php 
    echo bx_html_attribute(_t('_adm_pvalues_txt_move_down'));
    ?>
"><i class="sys-icon arrow-down"></i></a>' +
                    '</th>' +
                '</tr>'
            );

            iNextInd ++;

            sortZebra();
        }

        function delRow( eImg )
        {
            $( eImg ).parent().parent().remove();
            sortZebra();
        }

        function moveUpRow( eImg )
        {
            var oCur = $( eImg ).parent().parent();
            var oPrev = oCur.prev( ':not(.headers)' );
            if( !oPrev.length )
                return;

            // swap elements values
            var oCurElems  = $('input', oCur.get(0));
            var oPrevElems = $('input', oPrev.get(0));

            oCurElems.each( function(iInd) {
                var oCurElem  = $( this );
                var oPrevElem = oPrevElems.filter( ':eq(' + iInd + ')' );

                // swap them
                var sCurValue = oCurElem.val();
                oCurElem.val( oPrevElem.val() );
                oPrevElem.val( sCurValue );
            } );
        }

        function moveDownRow( eImg )
        {
            var oCur = $( eImg ).parent().parent();
            var oPrev = oCur.next( ':not(.headers)' );
            if( !oPrev.length )
                return;

            // swap elements values
            var oCurElems  = $('input', oCur.get(0));
            var oPrevElems = $('input', oPrev.get(0));

            oCurElems.each( function(iInd) {
                var oCurElem  = $( this );
                var oPrevElem = oPrevElems.filter( ':eq(' + iInd + ')' );

                // swap them
                var sCurValue = oCurElem.val();
                oCurElem.val( oPrevElem.val() );
                oPrevElem.val( sCurValue );
            } );
        }

        function sortZebra()
        {
            $( '#listEdit tr:even' ).removeClass( 'even odd' ).addClass( 'even' );
            $( '#listEdit tr:odd'  ).removeClass( 'even odd' ).addClass( 'odd'  );
        }

        //just a design
        $( document ).ready( sortZebra );
    </script>

    <form action="<?php 
    echo $GLOBALS['site']['url_admin'] . 'preValues.php';
    ?>
" method="post" enctype="multipart/form-data">
    	<div class="adm-pv-cp-selector bx-def-margin-bottom">
			<div class="adm-pv-cp-item">
				<span><?php 
    echo _t('_adm_pvalues_txt_select_list');
    ?>
:</span>
				<div class="input_wrapper input_wrapper_select bx-def-margin-sec-leftright clearfix">
					<select class="form_input_select bx-def-font-inputs" name="list" onchange="if( this.value != '' ) window.location = '<?php 
    echo $GLOBALS['site']['url_admin'] . 'preValues.php';
    ?>
' + '?list=' + encodeURIComponent( this.value ) + '<?php 
    echo $sPopupAdd;
    ?>
';"><?php 
    echo genListOptions($aLists, $sList);
    ?>
</select>
				</div>
			</div>
			<div class="input_wrapper input_wrapper_submit clearfix">
				<input  class="form_input_submit bx-btn" type="button" value="<?php 
    echo bx_html_attribute(_t('_adm_pvalues_txt_create_new'));
    ?>
" onclick="createNewList();" />
			</div>
		</div>
        <table class="bx-def-table" id="listEdit" cellpadding="0" cellspacing="1"><?php 
    $iNextInd = $sList !== '' ? genListRows($sList_db) : 0;
    ?>
</table>
		<div class="adm-pv-submit bx-def-margin-top">
			<input type="hidden" name="popup" value="<?php 
    echo $iAmInPopup;
    ?>
" />
			<input type="hidden" name="action" value="Save" />
			<div class="input_wrapper input_wrapper_submit clearfix">
				<input class="form_input_submit bx-btn" type="submit" name="submit" value="<?php 
    echo bx_html_attribute(_t('_Save'));
    ?>
" />
			</div>
		</div>
        <script type="text/javascript">
            iNextInd = <?php 
    echo $iNextInd;
    ?>
;
        </script>
    </form>
    <?php 
    return $GLOBALS['oAdmTemplate']->parseHtmlByName('design_box_content.html', array('content' => ob_get_clean()));
}
     showField($option);
     break;
 case "orderupField":
     cbSpoofCheck('field');
     checkCanAdminPlugins('core.edit.state');
     orderFields($cid[0], -1, $option);
     break;
 case "orderdownField":
     cbSpoofCheck('field');
     checkCanAdminPlugins('core.edit.state');
     orderFields($cid[0], 1, $option);
     break;
 case "saveList":
     cbSpoofCheck('list');
     checkCanAdminPlugins('core.edit');
     saveList($option);
     break;
 case "editList":
     checkCanAdminPlugins('core.edit');
     editList($cid[0], 1, $option);
     break;
 case "newList":
     checkCanAdminPlugins('core.edit');
     editList(0, $option);
     break;
 case "showLists":
     checkCanAdminPlugins('core.edit');
     showLists($option);
     break;
 case "removeList":
     cbSpoofCheck('list');
function PageCompPageMainCode()
{
    global $iAmInPopup;
    global $aFields;
    $sPopupAdd = $iAmInPopup ? '&popup=1' : '';
    if (isset($_POST['action']) and $_POST['action'] == 'Save' and isset($_POST['PreList']) and is_array($_POST['PreList'])) {
        saveList($_POST['list'], $_POST['PreList']);
        return;
    }
    //get lists
    $aLists = array('' => '- Select -');
    $sQuery = "SELECT DISTINCT `Key` FROM `PreValues`";
    $rLists = db_res($sQuery);
    while ($aList = mysql_fetch_assoc($rLists)) {
        $aLists[$aList['Key']] = $aList['Key'];
    }
    if (isset($_REQUEST['list'])) {
        $sList_db = process_db_input($_REQUEST['list']);
        $sList = process_pass_data($_REQUEST['list']);
        $sQuery = "SELECT * FROM `PreValues` WHERE `Key` = '{$sList_db}' ORDER BY `Order`";
        $rValues = db_res($sQuery);
        if (!mysql_num_rows($rValues)) {
            //if no rows returned...
            $aLists[$sList] = $sList;
        }
        //create new list
    } else {
        $sList = '';
    }
    ?>
	<script type="text/javascript">
		function createNewList() {
			var sNewList = prompt( 'Please enter name of new list' );
			
			if( sNewList == null )
				return false;
			
			sNewList = $.trim( sNewList );
			
			if( !sNewList.length ) {
				alert( 'You should enter correct name' );
				return false;
			}
			
			window.location = '<?php 
    echo $_SERVER['PHP_SELF'];
    ?>
?list=' + encodeURIComponent( sNewList ) + '<?php 
    echo $sPopupAdd;
    ?>
';
		}
		
		function addRow( eImg ) {
			$( eImg ).parent().parent().before(
				'<tr>' +
				<?php 
    foreach ($aFields as $sField => $sHelp) {
        ?>
					'<td><input type="text" class="value_input" name="PreList[' + iNextInd + '][<?php 
        echo $sField;
        ?>
]" value="" /></td>' +
					<?php 
    }
    ?>
					'<th>' +
						'<img src="images/minus1.gif"     class="row_control" title="Delete"    alt="Delete" onclick="delRow( this );" />' +
						'<img src="images/arrow_up.gif"   class="row_control" title="Move up"   alt="Delete" onclick="moveUpRow( this );" />' +
						'<img src="images/arrow_down.gif" class="row_control" title="Move down" alt="Delete" onclick="moveDownRow( this );" />' +
					'</th>' +
				'</tr>'
			);
			
			iNextInd ++;
			
			sortZebra();
		}
		
		function delRow( eImg ) {
			$( eImg ).parent().parent().remove();
			sortZebra();
		}
		
		function moveUpRow( eImg ) {
			var oCur = $( eImg ).parent().parent();
			var oPrev = oCur.prev( ':not(.headers)' );
			if( !oPrev.length )
				return;
			
			// swap elements values
			var oCurElems  = $('input', oCur.get(0));
			var oPrevElems = $('input', oPrev.get(0));
			
			oCurElems.each( function(iInd) {
				var oCurElem  = $( this );
				var oPrevElem = oPrevElems.filter( ':eq(' + iInd + ')' );
				
				// swap them
				var sCurValue = oCurElem.val();
				oCurElem.val( oPrevElem.val() );
				oPrevElem.val( sCurValue );
			} );
		}
		
		function moveDownRow( eImg ) {
			var oCur = $( eImg ).parent().parent();
			var oPrev = oCur.next( ':not(.headers)' );
			if( !oPrev.length )
				return;
			
			// swap elements values
			var oCurElems  = $('input', oCur.get(0));
			var oPrevElems = $('input', oPrev.get(0));
			
			oCurElems.each( function(iInd) {
				var oCurElem  = $( this );
				var oPrevElem = oPrevElems.filter( ':eq(' + iInd + ')' );
				
				// swap them
				var sCurValue = oCurElem.val();
				oCurElem.val( oPrevElem.val() );
				oPrevElem.val( sCurValue );
			} );
		}
		
		function sortZebra() {
			$( '#listEdit tr:even' ).removeClass( 'even odd' ).addClass( 'even' );
			$( '#listEdit tr:odd'  ).removeClass( 'even odd' ).addClass( 'odd'  );
		}
		
		//just a design
		$( document ).ready( sortZebra );
	</script>
	
	<form action="<?php 
    echo $_SERVER['PHP_SELF'];
    ?>
" method="post">
		<table id="listEdit" cellpadding="0" cellspacing="0">
			<tr>
				<th colspan="<?php 
    echo count($aFields) + 1;
    ?>
">
					Select a list:
					<select name="list"
					  onchange="if( this.value != '' ) window.location = '<?php 
    echo $_SERVER['PHP_SELF'];
    ?>
' + '?list=' + encodeURIComponent( this.value ) + '<?php 
    echo $sPopupAdd;
    ?>
';">
						<?php 
    echo genListOptions($aLists, $sList);
    ?>
					</select>
					<input type="button" value="Create New" onclick="createNewList();" />
				</th>
			</tr>
	<?php 
    if ($sList !== '') {
        $iNextInd = genListRows($sList_db);
        ?>
			<tr>
				<th colspan="8">
					<input type="hidden" name="popup" value="<?php 
        echo $iAmInPopup;
        ?>
" />
					<input type="submit" name="action" value="Save" />
				</th>
			</tr>
		<?php 
    } else {
        $iNextInd = 0;
    }
    ?>
		</table>
		
		<script type="text/javascript">
			iNextInd = <?php 
    echo $iNextInd;
    ?>
;
		</script>
	</form>
	<?php 
}
Beispiel #6
0
 public function save($lists)
 {
     foreach ($lists as $list) {
         saveList($list);
     }
 }
Beispiel #7
0
function PageCompPageMainCode()
{
    global $iAmInPopup;
    global $aFields;
    $sDeleteIcon = $GLOBALS['oAdmTemplate']->getImageUrl('minus1.gif');
    $sUpIcon = $GLOBALS['oAdmTemplate']->getImageUrl('arrow_up.gif');
    $sDownIcon = $GLOBALS['oAdmTemplate']->getImageUrl('arrow_down.gif');
    $sPopupAdd = $iAmInPopup ? '&popup=1' : '';
    $sResultMsg = '';
    if (isset($_POST['action']) and $_POST['action'] == 'Save' and isset($_POST['PreList']) and is_array($_POST['PreList'])) {
        if (true === saveList($_POST['list'], $_POST['PreList'])) {
            $sResultMsg = _t('_Success');
        } else {
            $sResultMsg = _t('_Failed to apply changes');
        }
    }
    //get lists
    $aLists = array('' => '- Select -');
    $aKeys = getPreKeys();
    foreach ($aKeys as $aList) {
        $aLists[$aList['Key']] = $aList['Key'];
    }
    $sListIn = bx_get('list');
    if ($sListIn !== false) {
        $sList_db = process_db_input($sListIn);
        $sList = process_pass_data($sListIn);
        $iCount = getPreValuesCount($sListIn);
        if (!$iCount) {
            //if no rows returned...
            $aLists[$sList] = $sList;
        }
        //create new list
    } else {
        $sList = '';
    }
    ob_start();
    if ($sResultMsg) {
        echo MsgBox($sResultMsg);
    }
    ?>
	
	<script type="text/javascript">
		function createNewList() {
			var sNewList = prompt( 'Please enter name of new list' );
			
			if( sNewList == null )
				return false;
			
			sNewList = $.trim( sNewList );
			
			if( !sNewList.length ) {
				alert( 'You should enter correct name' );
				return false;
			}
			
			window.location = '<?php 
    echo $GLOBALS['site']['url_admin'] . 'preValues.php';
    ?>
?list=' + encodeURIComponent( sNewList ) + '<?php 
    echo $sPopupAdd;
    ?>
';
		}
		
		function addRow( eImg ) {

			$( eImg ).parent().parent().before(
				'<tr>' +
				<?php 
    foreach ($aFields as $sField => $sHelp) {
        ?>
					'<td><input type="text" class="value_input" name="PreList[' + iNextInd + '][<?php 
        echo $sField;
        ?>
]" value="" /></td>' +
					<?php 
    }
    ?>
					'<th>' +
						'<img src="<?php 
    echo $sDeleteIcon;
    ?>
"     class="row_control" title="Delete"    alt="Delete" onclick="delRow( this );" />' +
						'<img src="<?php 
    echo $sUpIcon;
    ?>
"   class="row_control" title="Move up"   alt="Move up" onclick="moveUpRow( this );" />' +
						'<img src="<?php 
    echo $sDownIcon;
    ?>
" class="row_control" title="Move down" alt="Move down" onclick="moveDownRow( this );" />' +
					'</th>' +
				'</tr>'
			);
			
			iNextInd ++;
			
			sortZebra();
		}
		
		function delRow( eImg ) {
			$( eImg ).parent().parent().remove();
			sortZebra();
		}
		
		function moveUpRow( eImg ) {
			var oCur = $( eImg ).parent().parent();
			var oPrev = oCur.prev( ':not(.headers)' );
			if( !oPrev.length )
				return;
			
			// swap elements values
			var oCurElems  = $('input', oCur.get(0));
			var oPrevElems = $('input', oPrev.get(0));
			
			oCurElems.each( function(iInd) {
				var oCurElem  = $( this );
				var oPrevElem = oPrevElems.filter( ':eq(' + iInd + ')' );
				
				// swap them
				var sCurValue = oCurElem.val();
				oCurElem.val( oPrevElem.val() );
				oPrevElem.val( sCurValue );
			} );
		}
		
		function moveDownRow( eImg ) {
			var oCur = $( eImg ).parent().parent();
			var oPrev = oCur.next( ':not(.headers)' );
			if( !oPrev.length )
				return;
			
			// swap elements values
			var oCurElems  = $('input', oCur.get(0));
			var oPrevElems = $('input', oPrev.get(0));
			
			oCurElems.each( function(iInd) {
				var oCurElem  = $( this );
				var oPrevElem = oPrevElems.filter( ':eq(' + iInd + ')' );
				
				// swap them
				var sCurValue = oCurElem.val();
				oCurElem.val( oPrevElem.val() );
				oPrevElem.val( sCurValue );
			} );
		}
		
		function sortZebra() {
			$( '#listEdit tr:even' ).removeClass( 'even odd' ).addClass( 'even' );
			$( '#listEdit tr:odd'  ).removeClass( 'even odd' ).addClass( 'odd'  );
		}
		
		//just a design
		$( document ).ready( sortZebra );
	</script>
	
	<form action="<?php 
    echo $GLOBALS['site']['url_admin'] . 'preValues.php';
    ?>
" method="post">
		<table id="listEdit" cellpadding="0" cellspacing="0">
			<tr>
				<th colspan="<?php 
    echo count($aFields) + 1;
    ?>
">
					Select a list:
					<select name="list"
					  onchange="if( this.value != '' ) window.location = '<?php 
    echo $GLOBALS['site']['url_admin'] . 'preValues.php';
    ?>
' + '?list=' + encodeURIComponent( this.value ) + '<?php 
    echo $sPopupAdd;
    ?>
';">
						<?php 
    echo genListOptions($aLists, $sList);
    ?>
					</select>
					<input type="button" value="Create New" onclick="createNewList();" />
				</th>
			</tr>
	<?php 
    if ($sList !== '') {
        $iNextInd = genListRows($sList_db);
        ?>
			<tr>
				<th colspan="8">
					<input type="hidden" name="popup" value="<?php 
        echo $iAmInPopup;
        ?>
" />
					<input type="submit" name="action" value="Save" />
				</th>
			</tr>
		<?php 
    } else {
        $iNextInd = 0;
    }
    ?>
		</table>
		
		<script type="text/javascript">
			iNextInd = <?php 
    echo $iNextInd;
    ?>
;
		</script>
	</form>
	<?php 
    return $GLOBALS['oAdmTemplate']->parseHtmlByName('design_box_content.html', array('content' => ob_get_clean()));
}
Beispiel #8
0
<?php

include "config.php";
include "functions.php";
if (isset($_POST['save-data'])) {
    //Connect MySQL
    $key = saveList($_POST['save-data']);
    header('Location: /shopping/' . $key);
}
//print_r($_POST);
Beispiel #9
0
     $list->create($user_id, $list_name, $editable);
     if ($list_name != "") {
         $list->save();
         View::render('dashboard.php');
     } else {
         $_SESSION['error_message'] = "Please enter a list name";
         View::render('dashboard.php');
     }
 }
 if (isset($_POST['list_option'])) {
     $list_id = $_POST['list_id'];
     switch ($_POST['list_option']) {
         case 'save':
             $new_name = ucwords(strtolower(rtrim($_POST['list_name'])));
             $editable = $_POST['list_permission'];
             saveList($list, $new_name, $editable, $list_id, $user_id);
             echo $new_name;
             break;
         case 'delete':
             deleteList($list, $list_id, $user_id);
             break;
     }
 }
 if (isset($_POST['share_list_rqst'])) {
     $list_id = $_POST['shared_list_id'];
     $contacts_id = $_POST['shared_with_contacts'];
     $shared_list = new SharedList();
     $names = [];
     foreach ($contacts_id as $contact) {
         if (!$shared_list->check($user_id, $contact, $list_id)) {
             $shared_list->create($user_id, $contact, $list_id);