ninja-forms.php 16.6 KB
Newer Older
Kevin Stover's avatar
Kevin Stover committed
1 2 3
<?php
/*
Plugin Name: Ninja Forms
4
Plugin URI: http://ninjaforms.com/
Kevin Stover's avatar
Kevin Stover committed
5
Description: Ninja Forms is a webform builder with unparalleled ease of use and features.
Kevin Stover's avatar
Kevin Stover committed
6
Version: 2.2.50
Kevin Stover's avatar
Kevin Stover committed
7
Author: The WP Ninjas
8
Author URI: http://ninjaforms.com
9 10
Text Domain: ninja-forms
Domain Path: /lang/
Kevin Stover's avatar
Kevin Stover committed
11 12

Copyright 2011 WP Ninjas/Kevin Stover.
Kevin Stover's avatar
Kevin Stover committed
13

Kevin Stover's avatar
Kevin Stover committed
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

Ninja Forms also uses the following jQuery plugins. Their licenses can be found in their respective files.

	jQuery TipTip Tooltip v1.3
	code.drewwilson.com/entry/tiptip-jquery-plugin
	www.drewwilson.com
	Copyright 2010 Drew Wilson

36
	jQuery MaskedInput v.1.3.1
Kevin Stover's avatar
Kevin Stover committed
37 38 39 40 41 42 43
	http://digitalbush.co
	Copyright (c) 2007-2011 Josh Bush

	jQuery Tablesorter Plugin v.2.0.5
	http://tablesorter.com
	Copyright (c) Christian Bach 2012

44
	jQuery AutoNumeric Plugin v.1.9.15
Kevin Stover's avatar
Kevin Stover committed
45 46 47 48
	http://www.decorplanit.com/plugin/
	By: Bob Knothe And okolov Yura aka funny_falcon

*/
Kevin Stover's avatar
Kevin Stover committed
49
	
Kevin Stover's avatar
Kevin Stover committed
50 51
global $wpdb, $wp_version;

52 53
define("NINJA_FORMS_DIR", WP_PLUGIN_DIR."/".basename( dirname( __FILE__ ) ) );
define("NINJA_FORMS_URL", plugins_url()."/".basename( dirname( __FILE__ ) ) );
Kevin Stover's avatar
Kevin Stover committed
54
define("NINJA_FORMS_VERSION", "2.2.50");
Kevin Stover's avatar
Kevin Stover committed
55 56 57 58
define("NINJA_FORMS_TABLE_NAME", $wpdb->prefix . "ninja_forms");
define("NINJA_FORMS_FIELDS_TABLE_NAME", $wpdb->prefix . "ninja_forms_fields");
define("NINJA_FORMS_FAV_FIELDS_TABLE_NAME", $wpdb->prefix . "ninja_forms_fav_fields");
define("NINJA_FORMS_SUBS_TABLE_NAME", $wpdb->prefix . "ninja_forms_subs");
Pippin Williamson's avatar
Pippin Williamson committed
59

Kevin Stover's avatar
Kevin Stover committed
60
/* Require Core Files */
Pippin Williamson's avatar
Pippin Williamson committed
61 62 63 64 65 66
require_once( NINJA_FORMS_DIR . "/includes/database.php" );
require_once( NINJA_FORMS_DIR . "/includes/activation.php" );
require_once( NINJA_FORMS_DIR . "/includes/register.php" );
require_once( NINJA_FORMS_DIR . "/includes/shortcode.php" );
require_once( NINJA_FORMS_DIR . "/includes/widget.php" );
require_once( NINJA_FORMS_DIR . "/includes/field-type-groups.php" );
67
require_once( NINJA_FORMS_DIR . "/includes/eos.class.php" );
Pippin Williamson's avatar
Pippin Williamson committed
68 69

require_once( NINJA_FORMS_DIR . "/includes/display/scripts.php" );
70 71

// Include Processing Functions if a form has been submitted.
Pippin Williamson's avatar
Pippin Williamson committed
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
require_once( NINJA_FORMS_DIR . "/includes/display/processing/class-ninja-forms-processing.php" );
require_once( NINJA_FORMS_DIR . "/includes/display/processing/pre-process.php" );
require_once( NINJA_FORMS_DIR . "/includes/display/processing/process.php" );
require_once( NINJA_FORMS_DIR . "/includes/display/processing/post-process.php" );
require_once( NINJA_FORMS_DIR . "/includes/display/processing/save-sub.php" );
require_once( NINJA_FORMS_DIR . "/includes/display/processing/filter-msgs.php" );
require_once( NINJA_FORMS_DIR . "/includes/display/processing/error-test.php" );
require_once( NINJA_FORMS_DIR . "/includes/display/processing/email-admin.php" );
require_once( NINJA_FORMS_DIR . "/includes/display/processing/email-user.php" );
require_once( NINJA_FORMS_DIR . "/includes/display/processing/email-add-fields.php" );
require_once( NINJA_FORMS_DIR . "/includes/display/processing/attachment-test.php" );
require_once( NINJA_FORMS_DIR . "/includes/display/processing/fields-pre-process.php" );
require_once( NINJA_FORMS_DIR . "/includes/display/processing/fields-process.php" );
require_once( NINJA_FORMS_DIR . "/includes/display/processing/fields-post-process.php" );
require_once( NINJA_FORMS_DIR . "/includes/display/processing/req-fields-pre-process.php" );
87 88
require_once( NINJA_FORMS_DIR . "/includes/display/processing/term-name-filter.php" );
require_once( NINJA_FORMS_DIR . "/includes/display/processing/update-terms.php" );
Kevin Stover's avatar
Kevin Stover committed
89 90

//Display Form Functions
Pippin Williamson's avatar
Pippin Williamson committed
91 92 93 94 95
require_once( NINJA_FORMS_DIR . "/includes/display/form/display-form.php" );
require_once( NINJA_FORMS_DIR . "/includes/display/fields/display-fields.php" );
require_once( NINJA_FORMS_DIR . "/includes/display/form/response-message.php" );
require_once( NINJA_FORMS_DIR . "/includes/display/fields/label.php" );
require_once( NINJA_FORMS_DIR . "/includes/display/fields/help.php" );
96
require_once( NINJA_FORMS_DIR . "/includes/display/fields/desc.php" );
Pippin Williamson's avatar
Pippin Williamson committed
97 98 99 100
require_once( NINJA_FORMS_DIR . "/includes/display/form/form-title.php" );
require_once( NINJA_FORMS_DIR . "/includes/display/form/process-message.php" );
require_once( NINJA_FORMS_DIR . "/includes/display/fields/field-error-message.php" );
require_once( NINJA_FORMS_DIR . "/includes/display/form/form-wrap.php" );
101
require_once( NINJA_FORMS_DIR . "/includes/display/form/fields-wrap.php" );
Pippin Williamson's avatar
Pippin Williamson committed
102 103 104 105 106 107 108 109
require_once( NINJA_FORMS_DIR . "/includes/display/form/required-label.php" );
require_once( NINJA_FORMS_DIR . "/includes/display/form/open-form-tag.php" );
require_once( NINJA_FORMS_DIR . "/includes/display/form/close-form-tag.php" );
require_once( NINJA_FORMS_DIR . "/includes/display/form/hidden-fields.php" );
require_once( NINJA_FORMS_DIR . "/includes/display/form/form-visibility.php" );
require_once( NINJA_FORMS_DIR . "/includes/display/fields/restore-progress.php" );
require_once( NINJA_FORMS_DIR . "/includes/display/fields/inside-label-hidden.php" );
require_once( NINJA_FORMS_DIR . "/includes/display/fields/field-type.php" );
110
require_once( NINJA_FORMS_DIR . "/includes/display/fields/calc-filter.php" );
111
require_once( NINJA_FORMS_DIR . "/includes/display/fields/list-term-filter.php" );
112
require_once( NINJA_FORMS_DIR . "/includes/display/fields/default-value-filter.php" );
Kevin Stover's avatar
Kevin Stover committed
113 114 115

/* Require Pre-Registered Tabs and their sidebars */

116
//if ( is_admin() ) {
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155

	//Require EDD autoupdate file
	if( !class_exists( 'EDD_SL_Plugin_Updater' ) ) {
		// load our custom updater if it doesn't already exist
		require_once(NINJA_FORMS_DIR."/includes/EDD_SL_Plugin_Updater.php");
	}

	require_once( NINJA_FORMS_DIR . "/includes/class-extension-updater.php" );

	require_once( NINJA_FORMS_DIR . "/includes/admin/scripts.php" );
	require_once( NINJA_FORMS_DIR . "/includes/admin/sidebar.php" );
	require_once( NINJA_FORMS_DIR . "/includes/admin/tabs.php" );
	require_once( NINJA_FORMS_DIR . "/includes/admin/post-metabox.php" );

	require_once( NINJA_FORMS_DIR . "/includes/admin/ajax.php" );
	require_once( NINJA_FORMS_DIR . "/includes/admin/admin.php" );
	require_once( NINJA_FORMS_DIR . "/includes/admin/sidebar-fields.php" );
	require_once( NINJA_FORMS_DIR . "/includes/admin/display-screen-options.php" );
	require_once( NINJA_FORMS_DIR . "/includes/admin/register-screen-options.php" );
	require_once( NINJA_FORMS_DIR . "/includes/admin/register-screen-help.php" );
	require_once( NINJA_FORMS_DIR . "/includes/admin/export-subs.php" );
	require_once( NINJA_FORMS_DIR . "/includes/admin/output-tab-metabox.php" );
	require_once( NINJA_FORMS_DIR . "/includes/admin/form-preview.php" );

	//Edit Field Functions
	require_once( NINJA_FORMS_DIR . "/includes/admin/edit-field/edit-field.php" );
	require_once( NINJA_FORMS_DIR . "/includes/admin/edit-field/label.php" );
	require_once( NINJA_FORMS_DIR . "/includes/admin/edit-field/hr.php" );
	require_once( NINJA_FORMS_DIR . "/includes/admin/edit-field/req.php" );
	require_once( NINJA_FORMS_DIR . "/includes/admin/edit-field/custom-class.php" );
	require_once( NINJA_FORMS_DIR . "/includes/admin/edit-field/help.php" );
	require_once( NINJA_FORMS_DIR . "/includes/admin/edit-field/desc.php" );
	require_once( NINJA_FORMS_DIR . "/includes/admin/edit-field/li.php" );
	require_once( NINJA_FORMS_DIR . "/includes/admin/edit-field/remove-button.php" );
	require_once( NINJA_FORMS_DIR . "/includes/admin/edit-field/save-button.php" );
	require_once( NINJA_FORMS_DIR . "/includes/admin/edit-field/calc.php" );
	require_once( NINJA_FORMS_DIR . "/includes/admin/edit-field/user-info-fields.php" );
	require_once( NINJA_FORMS_DIR . "/includes/admin/edit-field/list-terms.php" );
	require_once( NINJA_FORMS_DIR . "/includes/admin/edit-field/post-meta-values.php" );
Kevin Stover's avatar
Kevin Stover committed
156

157
	/* * * * ninja-forms - Main Form Editing Page
Kevin Stover's avatar
Kevin Stover committed
158

159
	/* Tabs */
Kevin Stover's avatar
Kevin Stover committed
160

161 162
	/* Form List */
	require_once( NINJA_FORMS_DIR . "/includes/admin/pages/ninja-forms/tabs/form-list/form-list.php" );
Kevin Stover's avatar
Kevin Stover committed
163

164 165 166
	/* Form Settings */
	require_once( NINJA_FORMS_DIR . "/includes/admin/pages/ninja-forms/tabs/form-settings/form-settings.php" );
	require_once( NINJA_FORMS_DIR . "/includes/admin/pages/ninja-forms/tabs/form-settings/help.php" );
Kevin Stover's avatar
Kevin Stover committed
167

168 169 170 171 172 173 174 175 176 177 178 179
	/* Field Settings */
	require_once( NINJA_FORMS_DIR . "/includes/admin/pages/ninja-forms/tabs/field-settings/field-settings.php" );
	require_once( NINJA_FORMS_DIR . "/includes/admin/pages/ninja-forms/tabs/field-settings/empty-rte.php" );
	require_once( NINJA_FORMS_DIR . "/includes/admin/pages/ninja-forms/tabs/field-settings/edit-field-ul.php" );
	require_once( NINJA_FORMS_DIR . "/includes/admin/pages/ninja-forms/tabs/field-settings/help.php" );
	require_once( NINJA_FORMS_DIR . "/includes/admin/pages/ninja-forms/tabs/field-settings/sidebars/def-fields.php" );
	require_once( NINJA_FORMS_DIR . "/includes/admin/pages/ninja-forms/tabs/field-settings/sidebars/fav-fields.php" );
	require_once( NINJA_FORMS_DIR . "/includes/admin/pages/ninja-forms/tabs/field-settings/sidebars/template-fields.php" );
	require_once( NINJA_FORMS_DIR . "/includes/admin/pages/ninja-forms/tabs/field-settings/sidebars/layout-fields.php" );
	require_once( NINJA_FORMS_DIR . "/includes/admin/pages/ninja-forms/tabs/field-settings/sidebars/user-info.php" );
	require_once( NINJA_FORMS_DIR . "/includes/admin/pages/ninja-forms/tabs/field-settings/sidebars/payment-fields.php" );
	require_once( NINJA_FORMS_DIR . "/includes/admin/pages/ninja-forms/tabs/field-settings/sidebars/post-fields.php" );
Kevin Stover's avatar
Kevin Stover committed
180

181 182
	/* Form Preview */
	require_once( NINJA_FORMS_DIR . "/includes/admin/pages/ninja-forms/tabs/form-preview/form-preview.php" );
Kevin Stover's avatar
Kevin Stover committed
183 184


185
	/* * * * ninja-forms-settings - Settings Page
Kevin Stover's avatar
Kevin Stover committed
186

187
	/* Tabs */
Kevin Stover's avatar
Kevin Stover committed
188

189 190
	/* General Settings */
	require_once( NINJA_FORMS_DIR . "/includes/admin/pages/ninja-forms-settings/tabs/general-settings/general-settings.php" );
Kevin Stover's avatar
Kevin Stover committed
191

192 193
	/* Favorite Field Settings */
	require_once( NINJA_FORMS_DIR . "/includes/admin/pages/ninja-forms-settings/tabs/favorite-fields/favorite-fields.php" );
Kevin Stover's avatar
Kevin Stover committed
194

195 196
	/* Label Settings */
	require_once( NINJA_FORMS_DIR . "/includes/admin/pages/ninja-forms-settings/tabs/label-settings/label-settings.php" );
Kevin Stover's avatar
Kevin Stover committed
197

198 199
	/* Ajax Settings */
	require_once( NINJA_FORMS_DIR . "/includes/admin/pages/ninja-forms-settings/tabs/ajax-settings/ajax-settings.php" );
Kevin Stover's avatar
Kevin Stover committed
200

201 202
	/* License Settings */
	require_once( NINJA_FORMS_DIR . "/includes/admin/pages/ninja-forms-settings/tabs/license-settings/license-settings.php" );
Kevin Stover's avatar
Kevin Stover committed
203

204
	//require_once( NINJA_FORMS_DIR . "/includes/admin/pages/ninja-forms-settings/tabs/conversion-test/conversion-test.php" );
Kevin Stover's avatar
Kevin Stover committed
205

206
	/* * * * ninja-forms-impexp - Import / Export Page
Kevin Stover's avatar
Kevin Stover committed
207

208
	/* Tabs */
Kevin Stover's avatar
Kevin Stover committed
209

210 211
	/* Import / Export Forms */
	require_once( NINJA_FORMS_DIR . "/includes/admin/pages/ninja-forms-impexp/tabs/impexp-forms/impexp-forms.php" );
Kevin Stover's avatar
Kevin Stover committed
212

213 214
	/* Import / Export Fields */
	require_once( NINJA_FORMS_DIR . "/includes/admin/pages/ninja-forms-impexp/tabs/impexp-fields/impexp-fields.php" );
Kevin Stover's avatar
Kevin Stover committed
215

216 217
	/* Import / Export Submissions */
	require_once( NINJA_FORMS_DIR . "/includes/admin/pages/ninja-forms-impexp/tabs/impexp-subs/impexp-subs.php" );
Kevin Stover's avatar
Kevin Stover committed
218

219 220
	/* Backup / Restore */
	require_once( NINJA_FORMS_DIR . "/includes/admin/pages/ninja-forms-impexp/tabs/impexp-backup/impexp-backup.php" );
Kevin Stover's avatar
Kevin Stover committed
221

222
	/* * * * ninja-forms-subs - Submissions Review Page
Kevin Stover's avatar
Kevin Stover committed
223

224
	/* Tabs */
Kevin Stover's avatar
Kevin Stover committed
225

226 227 228 229 230 231
	/* View Submissions */
	require_once( NINJA_FORMS_DIR . "/includes/admin/pages/ninja-forms-subs/tabs/view-subs/view-subs.php" );
	require_once( NINJA_FORMS_DIR . "/includes/admin/pages/ninja-forms-subs/tabs/view-subs/fields-pre-process.php" );
	require_once( NINJA_FORMS_DIR . "/includes/admin/pages/ninja-forms-subs/tabs/view-subs/fields-process.php" );
	require_once( NINJA_FORMS_DIR . "/includes/admin/pages/ninja-forms-subs/tabs/view-subs/fields-post-process.php" );
	require_once( NINJA_FORMS_DIR . "/includes/admin/pages/ninja-forms-subs/tabs/view-subs/sidebars/select-subs.php" );
Kevin Stover's avatar
Kevin Stover committed
232

233
	/* * * ninja-forms-addons - Addons Manager Page
Kevin Stover's avatar
Kevin Stover committed
234

235
	/* Tabs */
Kevin Stover's avatar
Kevin Stover committed
236

237 238
	/* Manage Addons */
	require_once( NINJA_FORMS_DIR . "/includes/admin/pages/ninja-forms-addons/tabs/addons/addons.php" );
239
//}
Kevin Stover's avatar
Kevin Stover committed
240 241

/* Require Pre-Registered Fields */
Pippin Williamson's avatar
Pippin Williamson committed
242 243 244 245 246 247 248 249 250 251 252
require_once( NINJA_FORMS_DIR . "/includes/fields/textbox.php" );
require_once( NINJA_FORMS_DIR . "/includes/fields/checkbox.php" );
require_once( NINJA_FORMS_DIR . "/includes/fields/list.php" );
require_once( NINJA_FORMS_DIR . "/includes/fields/hidden.php" );
require_once( NINJA_FORMS_DIR . "/includes/fields/organizer.php" );
require_once( NINJA_FORMS_DIR . "/includes/fields/submit.php" );
require_once( NINJA_FORMS_DIR . "/includes/fields/spam.php" );
require_once( NINJA_FORMS_DIR . "/includes/fields/hr.php" );
require_once( NINJA_FORMS_DIR . "/includes/fields/desc.php" );
require_once( NINJA_FORMS_DIR . "/includes/fields/textarea.php" );
require_once( NINJA_FORMS_DIR . "/includes/fields/password.php" );
Kevin Stover's avatar
Kevin Stover committed
253
require_once( NINJA_FORMS_DIR . "/includes/fields/rating.php" );
254
require_once( NINJA_FORMS_DIR . "/includes/fields/calc.php" );
Kevin Stover's avatar
Kevin Stover committed
255 256
require_once( NINJA_FORMS_DIR . "/includes/fields/country.php" );
require_once( NINJA_FORMS_DIR . "/includes/fields/tax.php" );
Kevin Stover's avatar
Kevin Stover committed
257
require_once( NINJA_FORMS_DIR . "/includes/fields/credit-card.php" );
258
/*
259 260 261 262 263
require_once( NINJA_FORMS_DIR . "/includes/fields/post-title.php" );
require_once( NINJA_FORMS_DIR . "/includes/fields/post-content.php" );
require_once( NINJA_FORMS_DIR . "/includes/fields/post-tags.php" );
require_once( NINJA_FORMS_DIR . "/includes/fields/post-terms.php" );
require_once( NINJA_FORMS_DIR . "/includes/fields/post-excerpt.php" );
264
*/
Pippin Williamson's avatar
Pippin Williamson committed
265
require_once( NINJA_FORMS_DIR . "/includes/admin/save.php" );
Kevin Stover's avatar
Kevin Stover committed
266 267 268 269

if(session_id() == '') {
	session_start();
}
270

Kevin Stover's avatar
Kevin Stover committed
271 272 273
$_SESSION['NINJA_FORMS_DIR'] = NINJA_FORMS_DIR;
$_SESSION['NINJA_FORMS_URL'] = NINJA_FORMS_URL;

274 275 276 277 278 279 280 281 282 283 284 285 286 287
// Set $_SESSION variable used for storing items in transient variables
function ninja_forms_set_transient_id(){
	if ( !isset ( $_SESSION['ninja_forms_transient_id'] ) AND !is_admin() ) {
		$t_id = ninja_forms_random_string();
		// Make sure that our transient ID isn't currently in use.
		while ( get_transient( $t_id ) !== false ) {
			$_id = ninja_forms_random_string();
		}
		$_SESSION['ninja_forms_transient_id'] = $t_id;		
	}
}

add_action( 'init', 'ninja_forms_set_transient_id', 1 );

Kevin Stover's avatar
Kevin Stover committed
288
function ninja_forms_load_lang() {
289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309

	/** Set our unique textdomain string */
	$textdomain = 'ninja-forms';

	/** The 'plugin_locale' filter is also used by default in load_plugin_textdomain() */
	$locale = apply_filters( 'plugin_locale', get_locale(), $textdomain );

	/** Set filter for WordPress languages directory */
	$wp_lang_dir = apply_filters(
		'ninja_forms_wp_lang_dir',
		WP_LANG_DIR . '/ninja-forms/' . $textdomain . '-' . $locale . '.mo'
	);

	/** Translations: First, look in WordPress' "languages" folder = custom & update-secure! */
	load_textdomain( $textdomain, $wp_lang_dir );

	/** Translations: Secondly, look in plugin's "lang" folder = default */
	$plugin_dir = basename( dirname( __FILE__ ) );
	$lang_dir = apply_filters( 'ninja_forms_lang_dir', $plugin_dir . '/lang/' );
	load_plugin_textdomain( $textdomain, FALSE, $lang_dir );

Kevin Stover's avatar
Kevin Stover committed
310
}
311
add_action('plugins_loaded', 'ninja_forms_load_lang');
312 313 314

function ninja_forms_update_version_number(){
	$plugin_settings = get_option( 'ninja_forms_settings' );
315 316

	if ( !isset ( $plugin_settings['version'] ) OR ( NINJA_FORMS_VERSION != $plugin_settings['version'] ) ) {
317 318 319 320 321 322 323
		$plugin_settings['version'] = NINJA_FORMS_VERSION;
		update_option( 'ninja_forms_settings', $plugin_settings );
	}
}

add_action( 'admin_init', 'ninja_forms_update_version_number' );

Kevin Stover's avatar
Kevin Stover committed
324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352
register_activation_hook( __FILE__, 'ninja_forms_activation' );

function ninja_forms_return_echo($function_name){
	$arguments = func_get_args();
    array_shift($arguments); // We need to remove the first arg ($function_name)
    ob_start();
    call_user_func_array($function_name, $arguments);
	$return = ob_get_clean();
	return $return;
}

function ninja_forms_random_string($length = 10){
	$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
    $random_string = '';
    for ($i = 0; $i < $length; $i++) {
        $random_string .= $characters[rand(0, strlen($characters) - 1)];
    }
    return $random_string;
}

function ninja_forms_remove_from_array($arr, $key, $val, $within = FALSE) {
    foreach ($arr as $i => $array)
            if ($within && stripos($array[$key], $val) !== FALSE && (gettype($val) === gettype($array[$key])))
                unset($arr[$i]);
            elseif ($array[$key] === $val)
                unset($arr[$i]);

    return array_values($arr);
}