public function exportAll($get, $post)
 {
     if (isset($get['all']) && isset($get['_wpnonce'])) {
         if (wp_verify_nonce($get['_wpnonce'], 'cred-export-all')) {
             CRED_Loader::load('CLASS/XML_Processor');
             $filename = isset($get['filename']) ? urldecode($get['filename']) : '';
             CRED_XML_Processor::exportToXML('all', isset($get['ajax']), $filename);
             die;
         }
     }
     die;
 }
Example #2
0
    } else {
        $cred_import_file = null;
    }
    if ($cred_import_file !== null && !empty($cred_import_file)) {
        $options = array();
        if (isset($_POST["cred-overwrite-forms"])) {
            $options['overwrite_forms'] = 1;
        }
        if (isset($_POST["cred-overwrite-settings"])) {
            $options['overwrite_settings'] = 1;
        }
        if (isset($_POST["cred-overwrite-custom-fields"])) {
            $options['overwrite_custom_fields'] = 1;
        }
        CRED_Loader::load('CLASS/XML_Processor');
        $user_results = CRED_XML_Processor::importUserFromXML($cred_import_file, $options);
    }
}
$settings_model = CRED_Loader::get('MODEL/Settings');
$settings = $settings_model->getSettings();
$url = admin_url('admin.php') . '?page=CRED_Settings';
$doaction = isset($_POST['cred_settings_action']) ? $_POST['cred_settings_action'] : false;
if ($doaction) {
    check_admin_referer('cred-settings-action', 'cred-settings-field');
    switch ($doaction) {
        case 'edit':
            $settings = isset($_POST['settings']) ? (array) $_POST['settings'] : array();
            if (!isset($settings['wizard'])) {
                $settings['wizard'] = 0;
            }
            $settings_model->updateSettings($settings);
Example #3
0
 public function exportAll($get, $post)
 {
     if (!current_user_can(CRED_CAPABILITY)) {
         wp_die();
     }
     if (isset($get['all']) && isset($get['_wpnonce'])) {
         if (wp_verify_nonce($get['_wpnonce'], 'cred-export-all')) {
             CRED_Loader::load('CLASS/XML_Processor');
             //https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/196173458/comments
             //Security Fix added validate_file and sanitize
             $filename = isset($get['filename']) && validate_file($get['filename']) ? urldecode($get['filename']) : '';
             if (isset($get['type']) && $get['type'] == 'user') {
                 CRED_XML_Processor::exportUsersToXML('all', isset($get['ajax']), $filename);
             } else {
                 CRED_XML_Processor::exportToXML('all', isset($get['ajax']), $filename);
             }
             die;
         }
     }
     die;
 }
Example #4
0
function cred_export_to_xml_string($forms)
{
    CRED_Loader::load('CLASS/XML_Processor');
    $xmlstring = CRED_XML_Processor::exportToXMLString($forms);
    return $xmlstring;
}
Example #5
0
 public static function import_modules_cred_items($res, $xmlstring, $items = false)
 {
     CRED_Loader::load('CLASS/XML_Processor');
     if (false !== $items && is_array($items)) {
         $import_items = array();
         foreach ($items as $item) {
             $import_items[] = str_replace(_CRED_MODULE_MANAGER_KEY_, '', $item);
         }
         unset($items);
         $results = CRED_XML_Processor::importFromXMLString($xmlstring, array('overwrite_forms' => true, 'items' => $import_items));
     } else {
         $results = CRED_XML_Processor::importFromXMLString($xmlstring);
     }
     if (false === $results || is_wp_error($results)) {
         $error = false === $results ? __('Error during CRED import', 'wp-cred') : $results->get_error_message($results->get_error_code());
         $results = array('new' => 0, 'updated' => 0, 'failed' => 0, 'errors' => array($error));
     }
     unset($results['settings']);
     return $results;
 }
Example #6
0
 public static function modules_cred_user_items_exist($items)
 {
     foreach ($items as $key => $item) {
         // item exists already
         $form = get_page_by_title($item['title'], OBJECT, CRED_USER_FORMS_CUSTOM_POST_NAME);
         if ($form) {
             $items[$key]['exists'] = true;
             if (isset($item['hash'])) {
                 CRED_Loader::load('CLASS/XML_Processor');
                 $hash = CRED_XML_Processor::computeHashForUserForm($form->ID);
                 if ($hash && $item['hash'] != $hash) {
                     $items[$key]['is_different'] = true;
                 } else {
                     $items[$key]['is_different'] = false;
                 }
                 //$hashes[$form->ID];
             }
         } else {
             $items[$key]['exists'] = false;
         }
     }
     return $items;
 }