function verify_theme_step1() { $_username = esc_attr($_REQUEST['envato_username']); $_code = esc_attr($_REQUEST['envato_item_code']); $_api_key = esc_attr($_REQUEST['envato_api_key']); $error = false; // Check for error if (empty($_username) || empty($_code)) { add_error_section(__('Enter envato marketplace username and item purchase code to verify.', 'spyropress')); $error = true; } if (empty($_username)) { add_error_message(__('Enter envato marketplace username to verify.', 'spyropress')); $error = true; } if (empty($_code)) { add_error_message(__('Enter item purchase code to verify.', 'spyropress')); $error = true; } if ($error) { return; } update_option('_spyropress_site_key_' . get_internal_name(), md5(home_url() . $_code)); update_option('_spyropress_envato_verification_' . get_internal_name(), $_code); update_option('_spyropress_envato_username_' . get_internal_name(), $_username); update_option('_spyropress_envato_api_key_' . get_internal_name(), $_api_key); add_notice_message(__('Redirecting...', 'spyropress') . '<script type="text/javascript"> //<![CDATA[ window.location.replace("' . admin_url('admin.php?page=spyropress&step=4') . '"); //]]> </script>'); }
function update_theme() { if (isset($_REQUEST['page'])) { // Sanitize page being requested. $_page = esc_attr($_REQUEST['page']); if ('spyropress-update' == $_page) { //Setup Filesystem $method = get_filesystem_method(); if (isset($_POST['spyropress_ftp_cred'])) { $cred = spyropress_decode($_POST['spyropress_ftp_cred']); $filesystem = WP_Filesystem($cred); } else { $filesystem = WP_Filesystem(); } if (false == $filesystem && 'Proceed' != $_POST['upgrade']) { add_error_message(sprintf(__('Failed: Filesystem preventing downloads. (%s)', 'spyropress'), $method)); return; } if (isset($_REQUEST['spyropress_updater'])) { // Sanitize action being requested. $_action = esc_attr($_REQUEST['spyropress_updater']); if ('framework' == $_action) { locate_template('framework/utilities/envato/class-envato-wordpress-theme-upgrader.php', true); $envato_api_key = get_option('_spyropress_envato_api_key_' . get_internal_name()); $envato_username = get_option('_spyropress_envato_username_' . get_internal_name()); $upgrader = new Envato_WordPress_Theme_Upgrader($envato_username, $envato_api_key); $result = $upgrader->upgrade_theme(); // Successfully Updated if ($result->success) { $message = __('New version successfully downloaded, extracted and updated.', 'spyropress'); $message .= '<script type="text/javascript"> //<![CDATA[ window.location.replace("' . admin_url('admin.php?page=spyropress-update') . '"); //]]> </script>'; add_success_message($message); } else { add_error_message($result->errors[0]); } } } } // END UPDATE HERE } }
/** * @Author: prabhakar * @Date: 2016-06-15 00:15:08 * @Last Modified by: Prabhakar Gupta * @Last Modified time: 2016-06-17 00:23:10 */ require_once 'inc/function.inc.php'; $api_url = "whatsapp-reader.php?filename="; $final_response = array(); $error_flag = false; $errors = []; if (isset($_FILES[0]['type'])) { if ($_FILES[0]['type'] != 'text/plain') { add_error_message($errors, $error_flag, 'Invalid file type uploaded!'); } else { $file_name = $_FILES[0]['name']; $file_tmp = $_FILES[0]['tmp_name']; move_uploaded_file($file_tmp, "conversations/" . $file_name); $url = get_current_url(true) . $api_url . $file_name; $response = whatsapp_reader($file_name); } } else { add_error_message($errors, $error_flag, 'Invalid request!'); } if (isset($response)) { $final_response = $response; } else { $final_response['success'] = !$error_flag; $final_response['errors'] = $errors; } echo json_encode($final_response, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP | JSON_UNESCAPED_UNICODE);
/** * main functionality function * @param [string] $filename * @return [array] */ function whatsapp_reader($filename) { $error_flag = false; $errors = []; $chat = []; $names_array = []; $chat_file_path = 'conversations/' . $filename; if (!file_exists($chat_file_path)) { add_error_message($errors, $error_flag, 'File 404<br>File is like a unicorn to our servers, file was not uploaded properly'); } else { $file_handle = fopen($chat_file_path, "r"); if (!$file_handle) { add_error_message($errors, $error_flag, 'Oh Snap!<br>Some technical glitch, it\'ll be resolved soon!'); } else { $index = 0; $first_message = true; while (($line = fgets($file_handle)) !== false) { $line = explode('-', $line); $timestamp = $line[0]; $timestamp = returntimestamp($timestamp); if (!$timestamp) { if ($first_message) { add_error_message($errors, $error_flag, 'It wasn\'t a valid text file or we were not able to convert it!'); $first_message = false; break; } $line = implode('-', $line); $last_element_index = sizeof($chat) - 1; $chat[$last_element_index]['line'] .= "\n" . $line; } else { if ($first_message) { $first_message = false; } unset($line[0]); $line = implode('-', $line); $line = explode(':', trim($line)); $name = trim($line[0]); unset($line[0]); $line = implode(':', $line); $final_chat_string = trim($line); $user_index = get_user_index($names_array, $name); if (strtolower($final_chat_string) == MEDIA_STRING) { $final_string_to_be_printed = null; } else { $final_string_to_be_printed = htmlspecialchars($final_chat_string); } $temp_element = ['index' => $user_index, 'line' => $final_string_to_be_printed, 'time' => $timestamp]; array_push($chat, $temp_element); } } // close file handle fclose($file_handle); // delete file // yes, i respect privary unlink($chat_file_path); } } $final_response = array('success' => !$error_flag); if ($error_flag) { $final_response['errors'] = $errors; } else { $final_response['chat'] = $chat; $final_response['users'] = $names_array; } return $final_response; }