Example #1
0
         * home tag from previous home page
         */
        if ($home == 1) {
            query('update ' . DB_PAGES . ' set home=0 where home=1');
        }
        /**
         * save page to database 
         */
        query('insert into ' . DB_PAGES . ' values ("","' . $name . '","' . $content . '","' . $slug . '","' . $template . '","' . $type . '","' . date("Y-m-d\n\t\t") . '","' . $User->name() . '","10000","' . $parent . '","' . $perm . '","' . $home . '","' . $navigation . '")');
        /**
         * clear pages cache and redirect to edit pages
         */
        cache_clear('PAGES');
        $id = mysql_insert_id();
        // update options if they exist
        update_options(@$_POST['options'], 'page_' . $id);
        header('location: pages.php?page=edit&error=3&id=' . $id);
    } else {
        $Template->runtimeError('4', $name);
    }
}
/**
 * set page options in case its used!
 */
$page_options = array();
/**
 * page specific javascript 
 */
$javascript = '
$(document).ready(function(){
Example #2
0
function init()
{
    affiche_titre_options();
    update_options($_REQUEST['upd']);
    affiche_liste_options();
}
    function control()
    {
        $data = get_option('ultimate_follow_me');
        if ($data['uf_title'] != '') {
            $title = $data['uf_title'];
        } else {
            $title = "Follow Me On The Web!";
        }
        $check_rss = '';
        if ($data['uf_display_rss'] == 'on') {
            $check_rss = 'checked';
        }
        ?>
      	<table>
            <tr>
	  			
                <td align="right"><label>Title:</label></td>
                <td valign="bottom"><input name="uf_title" type="text" value="<?php 
        echo $title;
        ?>
" /></td>
            </tr>
            <tr>
	  			
                <td align="right"><label>Facebook username or profile ID <small>(http://facebook.com/<u>username</u><br/>or http://facebook.com/profile.php?id=<u>profile_id</u>)</small>:</label></td>
                <td valign="bottom"><input name="uf_fb_id" type="text" value="<?php 
        echo $data['uf_fb_id'];
        ?>
" /></td>
            </tr>
            <tr>
                <td align="right"><label>Twitter username <small>(http://www.twitter.com/<u>username</u>)</small>:</label></td>
                <td><input name="uf_tw_id" type="text" value="<?php 
        echo $data['uf_tw_id'];
        ?>
" /></td>
            </tr>
            <tr>
	  			
                <td align="right"><label>Linkedin username <small>(http://www.linkedin.com/in/<u>username</u>)</small>:</label></td>
                <td><input name="uf_li_id" type="text" value="<?php 
        echo $data['uf_li_id'];
        ?>
" /></td>
            </tr> 
            <tr>
	  			
                <td align="right"><label>Google Plus user ID <small>(https://plus.google.com/u/1/<u>user ID</u>)</small>:</label></td>
                <td><input name="uf_gp_id" type="text" value="<?php 
        echo $data['uf_gp_id'];
        ?>
" /></td>
            </tr> 
            <tr>
	  			
                <td align="right"><label>Youtube username <small>(http://www.youtube.com/<u>username</u>)</small>:</label></td>
                <td><input name="uf_yt_id" type="text" value="<?php 
        echo $data['uf_yt_id'];
        ?>
" /></td>
            </tr>       
<tr>
                <td align="right"><label>Email address or URL to contact us page:</label></td>
                <td><input name="uf_email_address" type="text" value="<?php 
        echo $data['uf_email_address'];
        ?>
" /></td>
            </tr> 
            <tr>
                <td align="right"><label>Display rss feed?</label></td>
                <td><input name="uf_display_rss" type="checkbox" <?php 
        echo $check_rss;
        ?>
/></td>
            </tr>              
<tr>
            	<td colspan="3" align="center">
                	<b>Display style</b>
                </td>
            </tr>
            <tr>
            	<td colspan="3" align="center"><input type="radio" name="uf_style" value="1" <?php 
        if ($data['uf_style'] == 1) {
            echo 'checked';
        }
        ?>
/><img src="<?php 
        echo get_preview_image(1);
        ?>
">
                </td>
            </tr>
            <tr>            
				<td colspan="3" align="center"><input type="radio" name="uf_style" value="2" <?php 
        if ($data['uf_style'] == 2) {
            echo 'checked';
        }
        ?>
/><img src="<?php 
        echo get_preview_image(2);
        ?>
"> 
                </td>
            </tr> 
            <tr>          
				<td colspan="3" align="center"><input type="radio" name="uf_style" value="3" <?php 
        if ($data['uf_style'] == 3) {
            echo 'checked';
        }
        ?>
/><img src="<?php 
        echo get_preview_image(3);
        ?>
">
               	</td>
            </tr>            
       </table>
	  <?php 
        update_options($data);
    }
Example #4
0
 /**
  * Delete all option on uninstall
  *
  */
 function hook_uninstall()
 {
     update_options('mappress', '');
 }
function update_record($fields_labels_ar, $table_name, $table_internal_name, $where_field, $where_value)
{
    global $null_checkbox_prefix, $year_field_suffix, $month_field_suffix, $day_field_suffix, $db;
    $uploaded_file_names_count = 0;
    $field_to_check = "present_insert_form_field";
    // build the update statement
    /////////////////////////////
    $where = "{$where_field} = '{$where_value}'";
    $archive_type = "datadmin_update";
    $db->archive_table_row($table_name, $where, $archive_type);
    $sql = "";
    $sql .= "UPDATE `{$table_name}` SET ";
    $count_temp = count($fields_labels_ar);
    for ($i = 0; $i < $count_temp; $i++) {
        $field_name_temp = $fields_labels_ar[$i]["name_field"];
        if ($fields_labels_ar[$i][$field_to_check] == "1" or $fields_labels_ar[$i]["type_field"] == "update_date" or $fields_labels_ar[$i]["type_field"] == "update_timestamp") {
            // if the field is in the form or need to be inserted because it's an update data
            switch ($fields_labels_ar[$i]["type_field"]) {
                case "update_timestamp":
                    $sql .= "`{$field_name_temp}` = ";
                    // add the field name to the sql statement
                    $timestamp = time();
                    $sql .= "'" . $timestamp . "', ";
                    // add the field name to the sql statement
                    break;
                case "select_single":
                    $field_name_other_temp = $field_name_temp . "_other____";
                    if ($fields_labels_ar[$i]["other_choices_field"] == "1" and $_POST[$field_name_temp] == "......" and $_POST[$field_name_other_temp] != "") {
                        // insert the "other...." choice
                        $primary_key_field_field = $fields_labels_ar[$i]["primary_key_field_field"];
                        if ($primary_key_field_field != "") {
                            $linked_fields_ar = explode($fields_labels_ar[$i]["separator_field"], $fields_labels_ar[$i]["linked_fields_field"]);
                            $primary_key_field_field = insert_other_field($fields_labels_ar[$i]["primary_key_table_field"], $linked_fields_ar[0], $_POST[$field_name_other_temp]);
                            $sql .= "`" . $field_name_temp . "` = ";
                            // add the field name to the sql statement
                            $sql .= "'" . $primary_key_field_field . "', ";
                            // add the field value to the sql statement
                        } else {
                            // no foreign key field
                            $sql .= "`" . $field_name_temp . "` = ";
                            // add the field name to the sql statement
                            $sql .= "'" . $_POST[$field_name_other_temp] . "', ";
                            // add the field value to the sql statement
                            if (strpos($fields_labels_ar[$i]["select_options_field"], $fields_labels_ar[$i]["separator_field"] . $_POST[$field_name_other_temp] . $fields_labels_ar[$i]["separator_field"]) === false) {
                                // the other field inserted is not already present in the $fields_labels_ar[$i]["select_options_field"] so we have to add it
                                update_options($fields_labels_ar[$i], $field_name_temp, $_POST[$field_name_other_temp]);
                                // re-get the array containg label ant other information about the fields changed with the above instruction
                                $fields_labels_ar = build_fields_labels_array($table_internal_name, "1");
                            }
                            // end if
                        }
                        // end else
                    } else {
                        $sql .= "`" . $field_name_temp . "` = ";
                        // add the field name to the sql statement
                        $sql .= "'" . $_POST[$field_name_temp] . "', ";
                        // add the field value to the sql statement
                    }
                    // end else
                    break;
                default:
                    // textual field
                    $sql .= "`" . $field_name_temp . "` = ";
                    // add the field name to the sql statement
                    $sql .= "'" . $_POST[$field_name_temp] . "', ";
                    // add the field value to the sql statement
                    break;
            }
            // end switch
        }
        // end if
    }
    // end for
    $sql = substr($sql, 0, -2);
    // delete the last two characters: ", "
    $sql .= " WHERE `" . $where_field . "` = '" . $where_value . "'";
    /////////////////////////////
    // end build the update statement
    display_sql($sql);
    // update the record
    $db->send_query($sql);
}
Example #6
0
function manage_surveys()
{
    global $table_prefix, $wpdb;
    $survey_table = $table_prefix . "surveys";
    if (isset($_REQUEST["wpsurv_submit"])) {
        require_once 'functions.php';
        if ($_POST["wpsurv_submit"] == __('Edit', 'wp-surveys') || $_POST["wpsurv_submit"] == __('Cancel', 'wp-surveys') || $_POST["wpsurv_submit"] == __('Back to Edit Survey', 'wp-surveys')) {
            edit($_POST['survey_id']);
        } elseif ($_POST["wpsurv_submit"] == __('Update', 'wp-surveys')) {
            update($_POST['survey_id']);
        } elseif ($_POST["wpsurv_submit"] == __('Update Options', 'wp-surveys')) {
            update_options($_POST['survey_id'], $_POST['question_id']);
        } elseif ($_POST["wpsurv_submit"] == __('Activate', 'wp-surveys') || $_POST["wpsurv_submit"] == __('Make Active', 'wp-surveys')) {
            activate($_POST['survey_id']);
        } elseif ($_POST["wpsurv_submit"] == __('Retire', 'wp-surveys')) {
            retire($_POST['survey_id']);
        } elseif ($_POST["wpsurv_submit"] == __('Update Leaderboard', 'wp-surveys')) {
            recach_utility($_POST['survey_id']);
        } elseif ($_POST["wpsurv_submit"] == __('Edit Options', 'wp-surveys') || $_POST["wpsurv_submit"] == __('Add Some Options', 'wp-surveys') || $_POST["wpsurv_submit"] == __('Edit or Add more Options', 'wp-surveys')) {
            edit_options($_POST['survey_id'], $_POST['question_id']);
        } elseif ($_POST["wpsurv_submit"] == __('Add More Questions', 'wp-surveys') || $_POST["wpsurv_submit"] == __('Add Some Questions', 'wp-surveys')) {
            add_question($_POST['survey_id']);
        } elseif ($_POST["wpsurv_submit"] == __('Step 2', 'wp-surveys')) {
            step2($_POST['survey_id']);
        } elseif ($_POST["wpsurv_submit"] == __('Create Question', 'wp-surveys')) {
            create_quest($_POST['survey_id']);
        } elseif ($_POST["wpsurv_submit"] == __('Change Survey', 'wp-surveys') || $_POST["wpsurv_submit"] == __('Add Survey', 'wp-surveys')) {
            survey($_POST['survey_id']);
        } elseif ($_POST["wpsurv_submit"] == __('Add This Survey', 'wp-surveys')) {
            add_survey($_POST['survey_id']);
        } elseif ($_POST["wpsurv_submit"] == __('View Survey Results', 'wp-surveys')) {
            results($_POST['survey_id']);
        }
        //elseif($_POST["wpsurv_submit"] == __('View Survey Results in CSV File', 'wp-surveys'))
        //results_CSV($_POST['survey_id']);
        //elseif($_POST["wpsurv_submit"] == __('Delete File', 'wp-surveys'))
        //delete_file($_POST['survey_id']);
    } else {
        $current_plugins = get_option('active_plugins');
        if (file_exists(ABSPATH . PLUGINDIR . '/polyglot.php') && in_array('polyglot.php', $current_plugins)) {
            $polyglot = true;
        }
        echo '<div class="wrap">';
        $open_surveys = $wpdb->get_results("SELECT * FROM `" . $survey_table . "` WHERE `survey_open`='1' LIMIT 1;", ARRAY_A);
        echo '<h2>' . __('Survey Management', 'wp-surveys') . '</h2><h3><u>' . __('Active Survey', 'wp-surveys') . '</u>:</h3>';
        if ($open_surveys) {
            echo '<table class="widefat" width="100%" cellpadding="4" cellspacing="4">';
            echo '<tr><th align="left">' . __('Title', 'wp-surveys') . '</th><th align="left">' . __('Description', 'wp-surveys') . '</th><th></th><th></th><th></th></tr>';
            foreach ($open_surveys as $survey) {
                echo '<tr class="alternate">';
                if ($polyglot) {
                    echo '<td><b>' . polyglot_filter(stripcslashes($survey['survey_name'])) . '</b></td><td>' . polyglot_filter(stripcslashes($survey['survey_describe'])) . '</td>';
                } elseif (!$polyglot) {
                    echo '<td><b>' . stripcslashes($survey['survey_name']) . '</b></td><td>' . stripcslashes($survey['survey_describe']) . '</td>';
                }
                echo '<td class="submit" align="center"><form method="post" action=""><input type="hidden" name="survey_id" value="' . $survey['survey_id'] . '" />';
                echo '<input type="submit" name="wpsurv_submit" value="' . __('Edit', 'wp-surveys') . '" /></form></td>';
                echo '<td class="submit" align="center"><form method="post" action=""><input type="hidden" name="survey_id" value="' . $survey['survey_id'] . '" />';
                echo '<input type="submit" name="wpsurv_submit" value="' . __('Retire', 'wp-surveys') . '" /></form></td>';
                echo '<td class="submit" align="center"><form method="post" action=""><input type="hidden" name="survey_id" value="' . $survey['survey_id'] . '" />';
                echo '<input type="submit" name="wpsurv_submit" value="' . __('View Survey Results', 'wp-surveys') . '" /></form></td>';
                //echo '<td align="center"><form method="post" action=""><input type="hidden" name="survey_id" value="'.$survey['survey_id'].'" />';
                //echo '<input type="submit" name="wpsurv_submit" value="'.__('View Survey Results in CSV File', 'wp-surveys').'" /></form></td>';
                echo '</tr>';
            }
            echo '</table>';
            $next = ++$survey['survey_id'];
            echo '<br /><form method="post" action=""><input type="hidden" name="survey_id" value="' . $next . '" /><input class="button" type="submit" name="wpsurv_submit" value="' . __('Change Survey', 'wp-surveys') . '" title="' . __('Current Survey will be saved as Retired', 'wp-surveys') . '" /></form>';
        } else {
            echo __('There are no open tournaments or contests.', 'wp-surveys') . '.';
            //$last = $wpdb->get_var("SELECT COUNT(`survey_id`) FROM `".$survey_table."`;");
            $last = $wpdb->get_var("SELECT `survey_id` FROM `" . $survey_table . "` ORDER BY `survey_id` DESC LIMIT 1;");
            $next = ++$last;
            echo '<br /><br /><form method="post" action=""><input type="hidden" name="survey_id" value="' . $next . '" /><input class="button" type="submit" name="wpsurv_submit" value="' . __('Add Survey', 'wp-surveys') . '" /></form>';
        }
        $closed_surveys = $wpdb->get_results("SELECT * FROM `" . $survey_table . "` WHERE `survey_open`='0';", ARRAY_A);
        echo '<h3><u>' . __('Retired Surveys', 'wp-surveys') . '</u>:</h3>';
        if ($closed_surveys) {
            echo '<table class="widefat" width="100%" cellpadding="4" cellspacing="4">';
            echo '<tr><th align="left">' . __('Title', 'wp-surveys') . '</th><th align="left">' . __('Description', 'wp-surveys') . '</th><th></th><th></th><th></th></tr>';
            foreach ($closed_surveys as $survey) {
                echo '<tr class="alternate">';
                if ($polyglot) {
                    echo '<td><b>' . polyglot_filter(stripcslashes($survey['survey_name'])) . '</b></td><td>' . polyglot_filter(stripcslashes($survey['survey_describe'])) . '</td>';
                } elseif (!$polyglot) {
                    echo '<td><b>' . stripcslashes($survey['survey_name']) . '</b></td><td>' . stripcslashes($survey['survey_describe']) . '</td>';
                }
                echo '<td class="submit" align="center"><form method="post" action=""><input type="hidden" name="survey_id" value="' . $survey['survey_id'] . '" />';
                echo '<input type="submit" name="wpsurv_submit" value="' . __('Edit', 'wp-surveys') . '" /></form></td>';
                echo '<td class="submit" align="center"><form method="post" action=""><input type="hidden" name="survey_id" value="' . $survey['survey_id'] . '" />';
                echo '<input type="submit" name="wpsurv_submit" value="' . __('Make Active', 'wp-surveys') . '" /></form></td>';
                echo '<td class="submit" align="center"><form method="post" action=""><input type="hidden" name="survey_id" value="' . $survey['survey_id'] . '" />';
                echo '<input type="submit" name="wpsurv_submit" value="' . __('View Survey Results', 'wp-surveys') . '" /></form></td>';
                //echo '<td align="center"><form method="post" action=""><input type="hidden" name="survey_id" value="'.$survey['survey_id'].'" />';
                //echo '<input type="submit" name="wpsurv_submit" value="'.__('View Survey Results in CSV File', 'wp-surveys').'" /></form></td>';
                echo '</tr>';
            }
            echo '</table>';
        } else {
            echo __('There are no retired surveys', 'wp-surveys') . '.';
        }
        echo '</div>';
    }
}
Example #7
0
function refresh_listview($db_name, $table_name, $append_data_file = null)
{
    if (is_array($append_data_file)) {
        if (empty($append_data_file)) {
            return false;
        }
    }
    $data_path = table_root($db_name, $table_name);
    $schema = object_read("{$data_path}/schema.json");
    $listview = $schema['listview'];
    $fields = $schema['fields'];
    $merged_fields = merge_fields($fields);
    $mapper_fields = get_mapper_fields($merged_fields);
    $options_fields = get_options_fields($merged_fields);
    $id_index = array_search('ID', $listview);
    $listview_data = array();
    $mapper_data = array();
    $options_data = array();
    do {
        if (empty($listview)) {
            break;
        }
        $glob_files = array();
        //更新单个文件
        if ($append_data_file) {
            $listview_data = object_read("{$data_path}/listview.json");
            $mapper_data = object_read("{$data_path}/mapper.json");
            $options_data = object_read("{$data_path}/options.json");
            if (is_array($append_data_file)) {
                $append_data_file = array_unique($append_data_file);
                foreach ($append_data_file as $data_file) {
                    $merge_items = merge_fields(object_read($data_file));
                    $id_input = @$merge_items['ID'];
                    if (empty($id_input)) {
                        continue;
                    }
                    $id_input = intval($id_input);
                    //找到就是替换并直接退出,找不到就是追加,并抛给下一个流程
                    foreach ($listview_data as &$subitem) {
                        $id_list = intval($subitem[$id_index]);
                        if ($id_list !== $id_input) {
                            continue;
                        }
                        //替换listview,完成任务退出
                        $subitem = new_listview_item($listview, $merge_items, $merged_fields);
                        update_mappers($schema, $mapper_data, $mapper_fields, $merge_items);
                        update_options($options_data, $options_fields, $merge_items);
                        continue 2;
                    }
                    //需要后续处理的
                    $glob_files[] = $data_file;
                }
            } else {
                $merge_items = merge_fields(object_read($append_data_file));
                $id_input = $merge_items['ID'];
                //找到就是替换并直接退出,找不到就是追加,并抛给下一个流程
                foreach ($listview_data as &$subitem) {
                    if ($subitem[$id_index] !== $id_input) {
                        continue;
                    }
                    //替换listview,完成任务退出
                    $subitem = new_listview_item($listview, $merge_items, $merged_fields);
                    update_mappers($schema, $mapper_data, $mapper_fields, $merge_items);
                    update_options($options_data, $options_fields, $merge_items);
                    break 2;
                }
                //需要后续处理的
                $glob_files[] = $append_data_file;
            }
        } else {
            set_time_limit(0);
            $glob_files = glob("{$data_path}/*.json");
        }
        /*
        		$listview_maker = function($file)use(&$schema, &$listview, &$merged_fields, &$listview_data,
        				&$mapper_data, &$mapper_fields, &$options_data, &$options_fields) {
        
        			$data_obj = object_read($file);
        			if (empty($data_obj)) {return;}
        
        			$merge_items = merge_fields($data_obj);
        
        			//生成listview
        			$new_listview = new_listview_item($listview, $merge_items, $merged_fields);
        			array_unshift($listview_data, $new_listview);
        			//生成mapper
        			update_mappers($schema, $mapper_data, $mapper_fields, $merge_items);
        			//更新options
        			update_options($options_data, $options_fields, $merge_items);
        			unset($data_obj);
        			unset($merge_items);
        			unset($new_listview);
        		};
        */
        ini_set('memory_limit', '1024M');
        foreach ($glob_files as $file) {
            if (is_dir($file)) {
                continue;
            }
            if (!preg_match('~/(\\d+)\\.json$~', $file, $matches)) {
                continue;
            }
            $item_id = $matches[1];
            //call_user_func($listview_maker, $file);
            $data_obj = object_read($file);
            if (empty($data_obj)) {
                continue;
            }
            $merge_items = merge_fields($data_obj);
            //生成listview
            $new_listview = new_listview_item($listview, $merge_items, $merged_fields);
            array_unshift($listview_data, $new_listview);
            //生成mapper
            update_mappers($schema, $mapper_data, $mapper_fields, $merge_items);
            //更新options
            update_options($options_data, $options_fields, $merge_items);
        }
    } while (false);
    object_save("{$data_path}/mapper.json", $mapper_data);
    object_save("{$data_path}/listview.json", $listview_data);
    object_save("{$data_path}/options.json", $options_data);
    if ($append_data_file === null) {
        wh_event($db_name, $table_name, 'refresh');
    }
    return count($listview_data);
}
/**
 * set up form validation
 */
$conds = array('Title' => array('name' => $Template->e('configuration_website_title'), 'required' => true), 'SubTitle' => array('name' => $Template->e('configuration_website_subtitle'), 'required' => true), 'URL' => array('name' => $Template->e('configuration_website_url'), 'required' => true, 'url' => true));
$valid = validate($conds, "#config-settings", 'settings_general');
/**
 * executed if form is submitted 
 */
if (isset($_POST['settings_general']) && $valid == true) {
    $SETTINGS['site_title'] = addslashes($_POST['Title']);
    $SETTINGS['site_subtitle'] = addslashes($_POST['SubTitle']);
    $SETTINGS['maintenance'] = (int) @$_POST['Maintenance'];
    $SETTINGS['index'] = (int) @$_POST['Index'];
    $url = @$_POST['URL'];
    $constants = array();
    update_options(@$_POST['options'], 'configuration_page_options');
    /**
     * set the diagnostic mode setting if
     * diagnostic mode is to be enabled
     */
    if (@$_POST['DiagnosticMode'] == 1) {
        $constants['DIAGNOSTIC_MODE'] = 1;
        $Template->diagnosticMode = 1;
    } else {
        $constants['DIAGNOSTIC_MODE'] = 0;
        $Template->diagnosticMode = 0;
    }
    /**
     * if the siteurl has changes, then add the new
     * value to the constants array
     */