function mass_import_handler() { global $wpdb; $frmarr = get_me_all_forms(); //add_action('admin_print_scripts', 'the_admin_scripts'); //add_action('admin_print_styles', 'the_admin_styles'); ?> <div style="padding: 5px 0 20px 0;"><img style="float:left;padding-right: 20px;" src="http://aryanduntley.com/wp-content/plugins/gravityforms/images/gravity-edit-icon-32.png"><h1>Import CSV</h1> <?php $version_info = GFCommon::get_version_info(false); if (version_compare("1.9", $version_info['version'], '<')) { ?> <h2>This plugin does not support your version of Gravity Forms.</h2><p>Since I no longer support this plugin and will not make changes to compensate for the code changes in Gravity Forms 1.9+, for those of you wishing to continue using Gravity Forms and need similar functionality, you can visit <a href="https://gravityview.co/extensions/gravity-forms-entry-importer/?ref=141" target="_blank">GravityView.Co</a>. They have developed a 1.9+ importer for gravity forms, along with many other gravity forms addons.</p> <?php } ?> <h2>choose which form you wish to import into:</h2></div> <div style="clear:both;padding-bottom:20px"><form style="float: left; padding-left: 20px;" action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_blank"><input type="hidden" name="cmd" value="_s-xclick" /><input type="hidden" name="cpp_header_image" value="http://aryanduntley.com/donatemy.png" /><input type="hidden" name="page_style" value="paypal" /><input type="hidden" name="cpp_logo_image" value="http://aryanduntley.com/donatemy.png" /><input type="hidden" name="cpp_payflow_color" value="#FAFAFA" /><input type="hidden" name="cn" value="Feel free to add any notes or comments about the plugin! Please name the plugin you are donating to so I can keep track of which are most valuable to users." /><input type="hidden" name="cpp_headerback_color" value="#F0F0F0" /><input type="hidden" name="hosted_button_id" value="ZXSGVRM9DWEUY" /><input type="image" name="submit" src="https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif" alt="PayPal - The safer, easier way to pay online!" /><img src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" alt="" width="1" height="1" border="0" /></form></div> <p> <label style="float:left;padding-top:3px;">Select which form you would like to import into</label> <select id="myList" style="float:left; margin-left: 20px"> <option value = "" disabled="true" selected="true"> Select One...</option> <?php for ($r = 0; $r < sizeof($frmarr); $r++) { echo '<option value=' . $frmarr[$r]['id'] . '>' . $frmarr[$r]['title'] . '</option>'; } ?> </select> </p> <div style="clear:both"></div> <div class="showstuff"></div> <div style="clear:both"></div> <div id="up_load_er"></div> <?php if (isset($_POST['mode'])) { if ($_POST['mode'] == "submit") { require 'parsecsv.lib.php'; if (isset($_POST['formnum'])) { //$arr_rows = file($_FILES['csv_file']['tmp_name']);//You can use file_get_contents() to return the contents of a file as a string. $entry_tracking_table = $wpdb->prefix . "rg_lead"; //This first in order to track lead_id for rest. $entry_standard_stuff = $wpdb->prefix . "rg_lead_meta"; $actual_entry_data = $wpdb->prefix . "rg_lead_detail"; //$lastnum = $wpdb->get_col( $wpdb->prepare("SELECT * FROM $entry_tracking_table",0) ); //CHange here provided by @eselk from wordpress.org on this plugin's support page $lastnum = $wpdb->get_col($wpdb->prepare("SELECT * FROM {$entry_tracking_table} order by id desc limit 1", 0)); //print ($lastnum[sizeof($lastnum)-1]); $formnum = $_POST['formnum']; //echo ("<div class='updated'>All users appear to be have been imported successfully.<br/>".$formnum."</div>"); $ararr = apply_filters('massimport_getfields', $formnum); //require('../../../wp-load.php'); $csv = new parseCSV(); $csv->last_form_id = max($lastnum); //$lastnum[sizeof($lastnum)-1]; $csv->form_using = $formnum; $csv->actHeaders = $ararr; //$retarn = $csv->auto($_FILES['csv_file']['tmp_name'], true, null, ',', '"'); $retarn = $csv->parse_file($_FILES['csv_file']['tmp_name']); //stuff here; echo '<div class="updated" style="padding-bottom:10px;">' . $retarn . '</div>'; } else { echo '<div class="updated" style="color: red;">It seems the file was not uploaded correctly.</div>'; } } } }
function import($data_type, $formFields) { extract($formFields); //If you uploaded a file via browser, use that otherwise use whatever url was passed $file = $formFields['source']; $csv = new parseCSV($file); $csv->auto(); $this->logger->debug("CSVImport: " . print_r($formFields, 1)); if (isset($limit) && is_array($limit) && is_numeric($limit['x'])) { $this->logger->debug("Limit Range had been defined: {$limit['x']} - {$limit['y']}"); $dataSet = array_slice((array) $csv->parse_file(), $limit['x'], $limit['y']); } elseif (is_numeric($limit)) { $this->logger->debug("Limit, return row {$limit}"); $dataSet = array_slice((array) $csv->parse_file(), $limit, 1); } else { $this->logger->debug("No Limit set, return all"); $dataSet = (array) $csv->parse_file(); } $this->logger->debug('CSVImport::Importing:' . print_r($dataSet, 1)); $this->runDataTypeImport($data_type, $dataSet); }