public function license() { global $LANG; if (empty($_SESSION['step2'])) { if (!empty($_SESSION['step1'])) { if (empty($_SESSION['val'])) { $_SESSION['val']['license'] = ''; } if ($_SERVER['REQUEST_METHOD'] == 'POST' && !empty($_POST['license'])) { $_SESSION['val']['license'] = $_POST['license']; if (check_license($_POST['license'])) { $_SESSION['status_license'] = 'success'; $_SESSION['step2'] = 1; unset($_SESSION['val']); redirect(PH7_URL_SLUG_INSTALL . 'config_path'); } else { $_SESSION['status_license'] = 'failure'; $aErrors[] = $LANG['failure_license']; } } } else { redirect(PH7_URL_SLUG_INSTALL); } } else { redirect(PH7_URL_SLUG_INSTALL . 'config_path'); } $this->oView->assign('sept_number', 2); $this->oView->assign('errors', @$aErrors); unset($aErrors); $this->oView->display('license.tpl'); }
function savePackage($post) { if (!current_user_can('edit_posts', $post)) { return; } if (get_post_type() != 'wpdmpro' || !isset($_POST['file'])) { return; } check_license(); // Deleted old zipped file $zipped = get_post_meta($post, "__wpdm_zipped_file", true); if ($zipped != '' && file_exists($zipped)) { @unlink($zipped); } $cdata = get_post_custom($post); foreach ($cdata as $k => $v) { $tk = str_replace("__wpdm_", "", $k); if (!isset($_POST['file'][$tk]) && $tk !== $k) { delete_post_meta($post, $k); } } foreach ($_POST['file'] as $meta_key => $meta_value) { $key_name = "__wpdm_" . $meta_key; if ($meta_key == 'package_dir' && $meta_value != '') { $meta_value = realpath($meta_value); } update_post_meta($post, $key_name, $meta_value); } if (get_post_meta($post, '__wpdm_masterkey', true) == '') { update_post_meta($post, '__wpdm_masterkey', uniqid()); } if (isset($_POST['reset_key']) && $_POST['reset_key'] == 1) { update_post_meta($post, '__wpdm_masterkey', uniqid()); } if (isset($_REQUEST['reset_udl'])) { delete_post_meta($post, '__wpdmx_user_download_count'); } //do_action('after_update_package',$post, $_POST['file']); }
/** * @usage Import CSV File */ function Import() { global $wpdb; if (!isset($_GET['task']) || $_GET['task'] != 'wpdm-import-csv' || !current_user_can(WPDM_ADMIN_CAP)) { return; } if (!ini_get("auto_detect_line_endings")) { ini_set("auto_detect_line_endings", '1'); } check_license(); $max_line_length = 10000; $source_file = $_FILES['csv']['tmp_name']; $alldata = file_get_contents($source_file); $alldata = str_replace("\r", "\n", $alldata); $alldata = str_replace("\n\n", "\n", $alldata); $alldata = str_getcsv($alldata, "\n"); if (is_array($alldata)) { foreach ($alldata as &$data) { $data = str_getcsv($data, ","); } $columns = array_shift($alldata); foreach ($alldata as $idx => $adata) { $adata[0] = trim($adata[0]); while (count($adata) < count($columns)) { array_push($adata, NULL); } $values = quote_all_array($adata); $drow = array_combine($columns, $values); if (isset($drow['url_key'])) { unset($drow['url_key']); } $drow['files'] = explode(',', $drow['files']); $drow['category'] = explode(',', $drow['category']); $drow['create_date'] = isset($drow['create_date']) ? date("Y-m-d H:i:s", strtotime($drow['create_date'])) : date("Y-m-d H:i:s", time()); $drow['update_date'] = isset($drow['update_date']) ? date("Y-m-d H:i:s", strtotime($drow['update_date'])) : date("Y-m-d H:i:s", time()); $access = explode(",", $drow['access']); $drow['access'] = isset($drow['access']) && $drow['access'] != '' ? $access : array('guest'); if (!isset($drow['ID'])) { $postdata = array('post_title' => $drow['title'], 'post_content' => utf8_encode($drow['description']), 'post_date' => $drow['create_date'], 'post_modified' => $drow['update_date'], 'post_type' => 'wpdmpro', 'post_status' => 'publish', 'filter' => false); $post_id = wp_insert_post($postdata); foreach ($drow['category'] as $index => $term) { if ((int) $term > 0) { $term = (int) $term; } if (term_exists($term, 'wpdmcategory')) { $eterm = term_exists($term, 'wpdmcategory'); $drow['category'][$index] = $eterm['term_id']; } else { $tinf = wp_insert_term($term, 'wpdmcategory'); if (is_array($tinf) && isset($tinf['term_id'])) { $drow['category'][$index] = $tinf['term_id']; } } } $ret = wp_set_post_terms($post_id, $drow['category'], 'wpdmcategory'); } else { $post_id = $drow['ID']; } if (isset($drow['title'])) { unset($drow['title']); } if (isset($drow['description'])) { unset($drow['description']); } if (isset($drow['create_date'])) { unset($drow['create_date']); } if (isset($drow['additional_previews']) && $drow['additional_previews'] != '') { $drow['additional_previews'] = explode(",", $drow['additional_previews']); } if (isset($drow['preview']) && $drow['preview'] != '') { $mime_type = ''; $wp_filetype = wp_check_filetype(basename($drow['preview']), null); if (isset($wp_filetype['type']) && $wp_filetype['type']) { $mime_type = $wp_filetype['type']; } unset($wp_filetype); $attachment = array('post_mime_type' => $mime_type, 'post_parent' => $post_id, 'post_title' => basename($drow['preview']), 'post_status' => 'inherit'); $attachment_id = wp_insert_attachment($attachment, $drow['preview'], $post_id); unset($attachment); if (!is_wp_error($attachment_id)) { $attachment_data = wp_generate_attachment_metadata($attachment_id, $drow['preview']); wp_update_attachment_metadata($attachment_id, $attachment_data); unset($attachment_data); set_post_thumbnail($post_id, $attachment_id); } unset($drow['preview']); } foreach ($drow as $meta_key => $value) { update_post_meta($post_id, "__wpdm_" . $meta_key, $value); } do_action('after_add_package', $post_id, $drow); } } @unlink($source_file); header("location: edit.php?post_type=wpdmpro"); die; }
<?php /** * @author Pierre-Henry Soria <*****@*****.**> * @copyright (c) 2012-2016, Pierre-Henry Soria. All Rights Reserved. * @license GNU General Public License; See PH7.LICENSE.txt and PH7.COPYRIGHT.txt in the root directory. * @package PH7 / Inc / Ajax */ namespace PH7; define('PH7', 1); require '_ajax.inc.php'; if (!empty($_POST['lic'])) { if (check_license($_POST['lic'])) { echo '<p class="success">' . $LANG['success_license'] . '</p>'; } else { echo '<p class="error">' . $LANG['failure_license'] . '</p>'; } }
} // End Check Function # Get Variables from storage (retrieve from wherever it's stored - DB, file, etc...) $licensekey = "WHMCS-c5adf50c9a"; $localkey = '9tjIxIzNwgDMwIjI6gjOztjIlRXYkt2Ylh2YioTO6M3OicmbpNnblNWasx1cyVmdyV2ccNXZsVHZv1GX zNWbodHXlNmc192czNWbodHXzN2bkRHacBFUNFEWcNHduVWb1N2bExFd0FWTcNnclNXVcpzQioDM4ozc 7ISey9GdjVmcpRGZpxWY2JiO0EjOztjIx4CMuAjL3ITMioTO6M3OiAXaklGbhZnI6cjOztjI0N3boxWY j9Gbuc3d3xCdz9GasF2YvxmI6MjM6M3Oi4Wah12bkRWasFmdioTMxozc7ISeshGdu9WTiozN6M3OiUGb jl3Yn5WasxWaiJiOyEjOztjI3ATL4ATL4ADMyIiOwEjOztjIlRXYkVWdkRHel5mI6ETM6M3OicDMtcDM tgDMwIjI6ATM6M3OiUGdhR2ZlJnI6cjOztjIlNXYlxEI5xGa052bNByUD1ESXJiO5EjOztjIl1WYuR3Y 1R2byBnI6ETM6M3OicjI6EjOztjIklGdjVHZvJHcioTO6M3Oi02bj5ycj1Ga3BEd0FWbioDNxozc7ICb pFWblJiO1ozc7IyUD1ESXBCd0FWTioDMxozc7ISZtFmbkVmclR3cpdWZyJiO0EjOztjIlZXa0NWQiojN 6M3OiMXd0FGdzJiO2ozc7pjMxoTY8baca0885830a33725148e94e693f3f073294c0558d38e31f844 c5e399e3c16a'; # The call below actually performs the license check. You need to pass in the license key and the local key data $results = check_license($licensekey, $localkey); # For Debugging, Echo Results echo "<textarea cols=100 rows=20>"; print_r($results); echo "</textarea>"; if ($results["status"] == "Active") { # Allow Script to Run if ($results["localkey"]) { # Save Updated Local Key to DB or File $localkeydata = $results["localkey"]; } } elseif ($results["status"] == "Invalid") { # Show Invalid Message } elseif ($results["status"] == "Expired") { # Show Expired Message } elseif ($results["status"] == "Suspended") {
public function license() { global $LANG; if (!empty($_SESSION['step4']) && is_file(PH7_ROOT_PUBLIC . '_constants.php')) { if (empty($_SESSION['val']['license'])) { $_SESSION['val']['license'] = ''; } if ($_SERVER['REQUEST_METHOD'] == 'POST' && !empty($_POST['license'])) { $sKey = trim($_POST['license']); if (check_license($sKey)) { @(require_once PH7_ROOT_PUBLIC . '_constants.php'); @(require_once PH7_PATH_APP . 'configs/constants.php'); try { require_once PH7_ROOT_INSTALL . 'inc/_db_connect.inc.php'; $oSqlQuery = $DB->prepare('UPDATE ' . $_SESSION['db']['prefix'] . 'License SET licenseKey = :key WHERE licenseId = 1'); $oSqlQuery->execute(array('key' => $sKey)); redirect(PH7_URL_SLUG_INSTALL . 'finish'); } catch (\PDOException $oE) { $aErrors[] = $LANG['database_error'] . escape($oE->getMessage()); } } else { $aErrors[] = $LANG['failure_license']; } } } else { redirect(PH7_URL_SLUG_INSTALL . 'config_site'); } $this->oView->assign('sept_number', 6); $this->oView->assign('errors', @$aErrors); unset($aErrors); $this->oView->display('license.tpl'); }
function license_file() { check_license(); }