setBlock('image_insert'); $request_uri = urldecode(empty($HTTP_POST_VARS['request_uri'])?(empty($HTTP_GET_VARS['request_uri'])?'':$HTTP_GET_VARS['request_uri']):$HTTP_POST_VARS['request_uri']); // if set include file specified in $spaw_imglib_include if (!empty($spaw_imglib_include)) { include $spaw_imglib_include; } ?> '; if (is_array($value)) array_walk($value, 'is_array_value',$_imglib); if ($value == $_imglib){ $value_found=true; } } array_walk($spaw_imglibs, 'is_array_value',$imglib); if (!$value_found || empty($imglib)) { $imglib = $spaw_imglibs[0]['value']; } $lib_options = liboptions($spaw_imglibs,'',$imglib); $img = isset($HTTP_POST_VARS['imglist'])?$HTTP_POST_VARS['imglist']:''; $preview = ''; $errors = array(); if (isset($HTTP_POST_FILES['img_file']['size']) && $HTTP_POST_FILES['img_file']['size']>0) { if ($img = uploadImg('img_file')) { $preview = $spaw_base_url.$imglib.$img; } } // delete if ($spaw_img_delete_allowed && isset($HTTP_POST_VARS['lib_action']) && ($HTTP_POST_VARS['lib_action']=='delete') && !empty($img)) { deleteImg(); } ?> <?php echo $l->m('title')?>
m('library')?>:   m('preview')?>:
 
m('images')?>:
'; foreach ($errors as $err) { echo $err.'
'; } echo ''; } ?> m('upload')?>:
'.$prefix.$lib['text'].''."\n"; } return $buf; } function uploadImg($img) { global $HTTP_POST_FILES; global $HTTP_SERVER_VARS; global $spaw_valid_imgs; global $imglib; global $errors; global $l; global $spaw_upload_allowed; if (!$spaw_upload_allowed) return false; if (!ereg('/$', $HTTP_SERVER_VARS['DOCUMENT_ROOT'])) $_root = $HTTP_SERVER_VARS['DOCUMENT_ROOT'].'/'; else $_root = $HTTP_SERVER_VARS['DOCUMENT_ROOT']; if ($HTTP_POST_FILES[$img]['size']>0) { $data['type'] = $HTTP_POST_FILES[$img]['type']; $data['name'] = $HTTP_POST_FILES[$img]['name']; $data['size'] = $HTTP_POST_FILES[$img]['size']; $data['tmp_name'] = $HTTP_POST_FILES[$img]['tmp_name']; // get file extension $ext = strtolower(substr(strrchr($data['name'],'.'), 1)); if (in_array($ext,$spaw_valid_imgs)) { $dir_name = $_root.$imglib; $img_name = $data['name']; $i = 1; while (file_exists($dir_name.$img_name)) { $img_name = ereg_replace('(.*)(\.[a-zA-Z]+)$', '\1_'.$i.'\2', $data['name']); $i++; } if (!move_uploaded_file($data['tmp_name'], $dir_name.$img_name)) { $errors[] = $l->m('error_uploading'); return false; } return $img_name; } else { $errors[] = $l->m('error_wrong_type'); } } return false; } function deleteImg() { global $HTTP_SERVER_VARS; global $imglib; global $img; global $spaw_img_delete_allowed; global $errors; global $l; if (!$spaw_img_delete_allowed) return false; if (!ereg('/$', $HTTP_SERVER_VARS['DOCUMENT_ROOT'])) $_root = $HTTP_SERVER_VARS['DOCUMENT_ROOT'].'/'; else $_root = $HTTP_SERVER_VARS['DOCUMENT_ROOT']; $full_img_name = $_root.$imglib.$img; if (@unlink($full_img_name)) { return true; } else { $errors[] = $l->m('error_cant_delete'); return false; } } ?>