$v) {
$tk = str_replace("__wpdm_", "", $k);
if (!isset($_POST['file'][$tk]) && $tk !== $k && $tk != "masterkey") {
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); }
if($meta_key == 'package_size' && (double)$meta_value == 0) $meta_value = "";
if($meta_key == 'files') $meta_value = array_unique($meta_value);
if($meta_key == 'files'){
foreach ($meta_value as &$value){
$value = wpdm_escs($value);
}
} else
$meta_value = is_array($meta_value)?wpdm_sanitize_array($meta_value):wpdm_escs($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']);
}
function uploadFile(){
check_ajax_referer(NONCE_KEY);
if(!current_user_can('upload_files')) die('-2');
$name = isset($_FILES['package_file']['name']) && !isset($_REQUEST["chunks"])?$_FILES['package_file']['name']:$_REQUEST['name'];
$name = esc_attr($name);
$ext = explode('.', $name);
$ext = end($ext);
$ext = strtolower($ext);
if(in_array($ext, array('php', 'js', 'html', 'py', 'pl', 'htaccess', 'svg', 'shtml', 'html5'))) die('-3');
if(file_exists(UPLOAD_DIR.$name) && get_option('__wpdm_overwrrite_file',0) == 1){
@unlink(UPLOAD_DIR.$name);
}
if(file_exists(UPLOAD_DIR.$name) && !isset($_REQUEST["chunks"]))
$filename = time().'wpdm_'.$name;
else
$filename = $name;
do_action("wpdm_before_upload_file", $_FILES['package_file']);
if(get_option('__wpdm_sanitize_filename', 0) == 1)
$filename = sanitize_file_name($filename);
if(isset($_REQUEST["chunks"])) $this->chunkUploadFile(UPLOAD_DIR.$filename);
else {
move_uploaded_file($_FILES['package_file']['tmp_name'], UPLOAD_DIR . $filename);
do_action("wpdm_after_upload_file", UPLOAD_DIR . $filename);
}
//@unlink($status['file']);
echo "|||".$filename."|||".wpdm_file_size(UPLOAD_DIR.$filename)."|||";
exit;
}
function chunkUploadFile($destFilePath){
$chunk = isset($_REQUEST["chunk"]) ? intval($_REQUEST["chunk"]) : 0;
$chunks = isset($_REQUEST["chunks"]) ? intval($_REQUEST["chunks"]) : 0;
$out = @fopen("{$destFilePath}.part", $chunk == 0 ? "wb" : "ab");
if ($out) {
// Read binary input stream and append it to temp file
$in = @fopen($_FILES['package_file']['tmp_name'], "rb");
if ($in) {
while ($buff = fread($in, 4096))
fwrite($out, $buff);
} else
die('-3');
@fclose($in);
@fclose($out);
@unlink($_FILES['package_file']['tmp_name']);
} else
die('-3');
if (!$chunks || $chunk == $chunks - 1) {
// Strip the temp .part suffix off
rename("{$destFilePath}.part", $destFilePath);
do_action("wpdm_after_upload_file", $destFilePath);
}
}
function columnsTH($defaults) {
if(get_post_type()!='wpdmpro') return $defaults;
$img['image'] = "";
wpdm_array_splice_assoc( $defaults, 1, 0, $img );
$otf['download_count'] = "";
$otf['wpdmshortcode'] = 'Short-code';
wpdm_array_splice_assoc( $defaults, 3, 0, $otf );
return $defaults;
}
function columnsTD($column_name, $post_ID) {
if(get_post_type()!='wpdmpro') return;
if ($column_name == 'download_count') {
echo (int)get_post_meta($post_ID, '__wpdm_download_count', true);
}
if ($column_name == 'wpdmshortcode') {
echo "";
}
if ($column_name == 'image') {
if(has_post_thumbnail($post_ID))
echo get_the_post_thumbnail( $post_ID, 'thumbnail', array('class'=>'img60px') );
else {
$icon = get_post_meta($post_ID,'__wpdm_icon', true);
if($icon!=''){
$icon = $icon;
echo "
";
}
}
}
}
function orderbyDownloads( $vars ) {
if ( isset( $vars['orderby'] ) && 'download_count' == $vars['orderby'] ) {
$vars = array_merge( $vars, array(
'meta_key' => '__wpdm_download_count',
'orderby' => 'meta_value_num'
) );
}
return $vars;
}
function sortableDownloads( $columns ) {
if(get_post_type()!='wpdmpro') return $columns;
$columns['download_count'] = 'download_count';
return $columns;
}
function rowActions($actions, $post)
{
if($post->post_type == 'wpdmpro')
$actions['download_link'] = '';
return $actions;
}
function quickEditForm($column_name, $post_type){
}
function footerScripts(){
global $pagenow;
if($pagenow === 'themes.php' || $pagenow === 'theme-install.php'){
if(!file_exists(ABSPATH.'/wp-content/themes/attire/')) {
?>