function del()
 {
     $args = func_num_args() == 1 ? func_get_arg(0) : func_get_args();
     $privelege = $args[privelege] ? 0 : 1;
     $sql = $this->site->db->prepare("SELECT * FROM tyyp where tyyp_id=?", $this->all[tyyp_id]);
     $sth = new SQL($sql);
     $this->debug->msg($sth->debug->get_msgs());
     $tyyp = $sth->fetch();
     # vaatame millised t��bid lubavad alampuu kustutada
     $sql = "select tyyp_id from tyyp where on_alampuu_kustutamine='1'";
     $sth = new SQL($sql);
     $this->debug->msg($sth->debug->get_msgs());
     $tyybid = array();
     while ($tid = $sth->fetchsingle()) {
         array_push($tyybid, $tid);
     }
     $this->debug->msg("T��bid mida alampuuga kustutame: " . join(",", $tyybid));
     $parents = array();
     $alampuu = array();
     $blocked = array();
     $warnings = array();
     $has_multiple_parents = array();
     array_push($parents, $this->objekt_id);
     $h = 0;
     while (sizeof($parents) && $h++ < 25) {
         $this->debug->msg("parents = " . join(", ", $parents));
         $sql = $this->site->db->prepare("\n\t\t\t\tSELECT objekt.objekt_id, COUNT(parents_objekt.parent_id) AS parents_count, objekt.pealkiri, parent.tyyp_id \n\t\t\t\tFROM objekt \n\t\t\t\tLEFT JOIN objekt_objekt ON objekt.objekt_id=objekt_objekt.objekt_id \n\t\t\t\tLEFT JOIN objekt_objekt AS parents_objekt ON objekt.objekt_id=parents_objekt.objekt_id \n\t\t\t\tLEFT JOIN objekt as parent ON objekt_objekt.parent_id=parent.objekt_id \n\t\t\t\tWHERE objekt_objekt.parent_id IN(" . join(",", $parents) . ") AND parent.tyyp_id IN(" . join(",", $tyybid) . ") \n\t\t\t\tGROUP BY objekt.objekt_id, objekt.pealkiri, parent.tyyp_id");
         $sth = new SQL($sql);
         $this->debug->msg($sth->debug->get_msgs());
         $alampuu = array_merge($alampuu, $parents);
         $parents = array();
         while ($record = $sth->fetch()) {
             if (!$blocked[$record[objekt_id]]) {
                 $blocked[$record[objekt_id]] = 1;
                 if ($record[parents_count] > 1) {
                     array_push($warnings, $record);
                     # check if we are deleting recycle bin?
                     # If yes then in case of multiple parents we should delete only parent relation of recycle bin and not the object itself. (Bug #2306)
                     if ($this->site->fdat['empty_recycle_bin']) {
                         $has_multiple_parents[] = $record[objekt_id];
                     }
                     array_push($parents, $record[objekt_id]);
                 } else {
                     array_push($parents, $record[objekt_id]);
                 }
                 $this->debug->msg("{$record['objekt_id']} ({$record['parents_count']}) - {$record['pealkiri']} tyyp={$record['tyyp_id']}");
             }
         }
     }
     # while parents
     $this->debug->msg("L�plikus alampuus on " . sizeof($alampuu) . " objekte");
     ####### divide final objects array into 2 parts:
     # 1. delete entirely - $alampuu
     # 2. delete only trash parent relation - $has_multiple_parents
     if (sizeof($alampuu) > 0 && sizeof($has_multiple_parents) > 0) {
         $alampuu = array_minus_array($alampuu, $has_multiple_parents);
     }
     ######## 1. DELETE OBJECTS ENTIRELY
     if (sizeof($alampuu) > 0) {
         # for sanity
         # ----------------------
         # kustutame �ra :(
         # ----------------------
         # ----------------------
         # tabel objekt
         # ----------------------
         $sql = "DELETE FROM objekt WHERE objekt_id IN(" . join(",", $alampuu) . ")";
         $sth = new SQL($sql);
         $this->debug->msg($sth->debug->get_msgs());
         # ----------------------
         # tabelid obj_*
         # ----------------------
         $sql = "SELECT tabel FROM tyyp WHERE tabel<>'' OR NOT ISNULL(tabel) GROUP BY tabel";
         $sth = new SQL($sql);
         $this->debug->msg($sth->debug->get_msgs());
         while ($tabel = $sth->fetchsingle()) {
             $sql = $this->site->db->prepare("SELECT * FROM {$tabel} WHERE objekt_id IN(" . join(",", $alampuu) . ")");
             $sth2 = new SQL($sql);
             $this->debug->msg($sth2->debug->get_msgs());
             if ($tabel && $sth2->rows) {
                 # kui antud t��bi objektid leitud
                 # siis iga t��bi jaoks on oma erifunktsioonid
                 $this->debug->msg("Midagi on kustutamiseks {$tabel} taabelis");
                 if ($tabel == "obj_dokument") {
                     # DOKUMENT
                     if (!empty($this->site->CONF['documents_in_filesystem']) && !empty($this->site->CONF['documents_directory']) && file_exists(str_replace('//', '/', $this->site->absolute_path . $this->site->CONF['documents_directory']))) {
                         $sql = $this->site->db->prepare('SELECT objekt_id FROM obj_dokument WHERE objekt_id IN(' . join(',', $alampuu) . ')');
                         $sth3 = new SQL($sql);
                         $this->debug->msg($sth3->debug->get_msgs());
                         while ($oid = $sth3->fetchsingle()) {
                             $filename = md5($oid);
                             $filepath = str_replace('//', '/', $this->site->absolute_path . $this->site->CONF['documents_directory'] . '/' . $filename[0] . '/' . $filename);
                             if (@file_exists($filepath)) {
                                 $this->debug->msg('Kustutan faili ' . $filepath);
                                 unlink($filepath);
                             }
                         }
                     } else {
                         $sql = $this->site->db->prepare("SELECT fail FROM obj_dokument WHERE objekt_id IN(" . join(",", $alampuu) . ")");
                         $sth3 = new SQL($sql);
                         $this->debug->msg($sth3->debug->get_msgs());
                         while ($filename = $sth3->fetchsingle()) {
                             $this->debug->msg("Kustutan faili " . $this->site->CONF[documentsroot] . "/{$filename}");
                             unlink($this->site->CONF[documentsroot] . "/{$filename}");
                         }
                     }
                 } elseif ($tabel == "obj_gallup") {
                     # GALLUP
                     $sql = $this->site->db->prepare("DELETE FROM gallup_vastus WHERE objekt_id IN(" . join(",", $alampuu) . ")");
                     $sth3 = new SQL($sql);
                     $this->debug->msg($sth3->debug->get_msgs());
                     $sql = $this->site->db->prepare("DELETE FROM gallup_ip WHERE objekt_id IN(" . join(",", $alampuu) . ")");
                     $sth3 = new SQL($sql);
                     $this->debug->msg($sth3->debug->get_msgs());
                 }
                 $sql = $this->site->db->prepare("DELETE FROM {$tabel} WHERE objekt_id IN(" . join(",", $alampuu) . ")");
                 $sth3 = new SQL($sql);
                 $this->debug->msg($sth3->debug->get_msgs());
                 # DOCUMENT_PARTS
                 if ($tabel == "obj_dokument" || $tabel == "obj_pilt") {
                     $sql = $this->site->db->prepare("DELETE FROM document_parts WHERE objekt_id IN(" . join(",", $alampuu) . ")");
                     $sth3 = new SQL($sql);
                     $this->debug->msg($sth3->debug->get_msgs());
                 }
             }
             # if taabel && rows
         }
         # while taabel
         # ---------------------- #]
         # tabel objekt_objekt    #]
         # ---------------------- #]
         $sql = $this->site->db->prepare("DELETE FROM objekt_objekt WHERE objekt_id IN(" . join(",", $alampuu) . ") OR parent_id IN(" . join(",", $alampuu) . ")");
         $sth3 = new SQL($sql);
         $this->debug->msg($sth3->debug->get_msgs());
         # -----------------------
         # kustutame �ra grupp_objekt
         # -----------------------
         $sql = $this->site->db->prepare("DELETE FROM permissions WHERE type=? AND source_id IN(" . join(",", $alampuu) . ")", 'OBJ');
         $sth = new SQL($sql);
         $this->debug->msg($sth->debug->get_msgs());
         # -----------------------
         # kustutame �ra user_mailinglist
         # -----------------------
         $sql = $this->site->db->prepare("DELETE FROM user_mailinglist WHERE objekt_id IN(" . join(",", $alampuu) . ")");
         $sth = new SQL($sql);
         $this->debug->msg($sth->debug->get_msgs());
     }
     # if on midagi kustutada
     ######## / 1. DELETE OBJECTS ENTIRELY
     ######## 2. DELETE OBJECTS TRASH PARENT RELATION - because object has more parents
     if (sizeof($has_multiple_parents) > 0) {
         # ---------------------- #]
         # tabel objekt_objekt    #]
         # ---------------------- #]
         $trash_id = $this->site->alias(array('key' => 'trash'));
         $sql = $this->site->db->prepare("DELETE FROM objekt_objekt WHERE objekt_id IN(" . join(",", $has_multiple_parents) . ") AND objekt_objekt.parent_id=?", $trash_id);
         $sth3 = new SQL($sql);
         $this->debug->msg($sth3->debug->get_msgs());
     }
     ######## 2. / DELETE OBJECTS TRASH PARENT RELATION - because object has more parents
 }
 } elseif ($prof_row['source_table'] == 'obj_file') {
     $system_fields = array('objekt_id', 'fullpath', 'filename', 'mimetype', 'size', 'lastmodified', 'is_deleted', 'profile_id');
 } elseif ($profile['source_table'] == 'obj_folder') {
     $system_fields = array('objekt_id', 'profile_id', 'fullpath');
 } elseif (substr($prof_row['source_table'], 0, 4) == 'obj_') {
     $system_fields = array('objekt_id', 'profile_id');
 }
 # get missing fields: in table but not in profile:
 if (sizeof($tbl_fields) > 0 && sizeof($existing_fields) > 0) {
     $missing_fields = array_minus_array($tbl_fields, $existing_fields);
 } else {
     $missing_fields = $tbl_fields;
 }
 # exclude system fields:
 if (sizeof($missing_fields) > 0 && sizeof($system_fields) > 0) {
     $missing_fields = array_minus_array($missing_fields, $system_fields);
 }
 #printr($missing_fields);
 if (sizeof($missing_fields) > 0) {
     foreach ($missing_fields as $missing_field) {
         $new_field = array("name" => $missing_field, "type" => 'TEXT', "source_object" => '', "db_type" => 'varchar', "is_required" => 0, "is_active" => 0, "is_predefined" => 0);
         $existing_data[$missing_field] = $new_field;
     }
     # foreach missing
 }
 # if missing found
 #printr($existing_data);
 $update_data = serialize($existing_data);
 $sql = $site->db->prepare("UPDATE object_profiles SET data=? WHERE profile_id=?", $update_data, $site->fdat['profile_id']);
 $sth = new SQL($sql);
 $site->debug->msg($sth->debug->get_msgs());
Example #3
0
     // Display
     $day++;
 }
 // CHECK AVAILABILITY OF DATE TIME DATA
 $scheduled_slots = count($scheduled_date_time_data);
 //echo "Scheduled Slots: ".$scheduled_slots."<br />";
 $available_date_time_data = array();
 $unavailable_date_time_data = array();
 $availability_count = check_schedule_availability($scheduled_date_time_data, $location_db_name[stripslashes($_REQUEST['location'])]);
 //echo "Availability Count: ".$availability_count."<br />";
 // All slots not available condition check.
 if ($scheduled_slots > $availability_count) {
     $page_error_message = 'Availability Problem: Not all of the selected date and time slots ' . 'are available for booking.  Please check the conflicting date and time slots, ' . 'make the necessary changes to your booking form and try again.';
     $unavailable_date_time_data = find_schedule_unavailability($scheduled_date_time_data, $location_db_name[stripslashes($_REQUEST['location'])]);
     if (count($unavailable_date_time_data) > 0) {
         $available_date_time_data = array_minus_array($scheduled_date_time_data, $unavailable_date_time_data);
     }
 } else {
     if (!ignoreRules && $availability_count > $remaining_booking_slots_allowed && ($user_info['max_bookings'] == '' || $user_info['max_bookings'] != 0)) {
         //user is attempting to book more slots than they are allowed to (and they are not allowed unlimited bookings).
         //report error to user and do not allow the booking without ammendments
         $page_error_message = 'You are attempting to book ' . $availability_count . ' slot';
         if ($availability_count > 1) {
             $page_error_message .= 's';
         }
         $page_error_message .= ', however you ';
         if ($total_bookings_already_made > 0) {
             $page_error_message .= 'already have ' . $total_bookings_already_made . ' slot';
             if ($total_bookings_already_made > 1) {
                 $page_error_message .= 's';
             }
		$all_fields = split(",", $site->db->get_fields(array(tabel => $profile_def['source_table'])) );

		if(is_array($profile_data)){ # if any profile field exists in database

			############ gather EXISTING PROFILE FIELDNAMES into arr
			$existing_fields = array_keys($profile_data);
			############ gather EXISTING PROFILE NAMES into arr
			foreach($profile_data as $key=>$tmpprof){ 
				$existing_names[] = $tmpprof['name'];
			}

		} # if any profile field exists in database

		############ find AVAILABLE FIELDNAMES for new field
		if(sizeof($existing_fields) > 0) {
			$available_fields = array_minus_array($all_fields,$existing_fields);
		}
		else { $available_fields = $all_fields; }

		############ make available fields BY TYPE array: for using in javascript
		if($profile_def['source_table'] == 'obj_asset') {
			foreach($available_fields as $key=>$field){
				if(eregi("varchar_(\d*)",$field)) {
					$available_fields_bytype["varchar"][] = $field;
				}
				elseif(eregi("int_(\d*)",$field)) {
					$available_fields_bytype["int"][] = $field;
				}
				elseif(eregi("float_(\d*)",$field)) {
					$available_fields_bytype["float"][] = $field;
				}
Example #5
0
 * http://www.php.net/array_diff
 */
function array_minus_array($a, $b)
{
    $c = array();
    foreach ($a as $key => $val) {
        $posb = array_search($val, $b);
        if (is_int($posb)) {
            unset($b[$posb]);
        } else {
            $c[] = $val;
        }
    }
    return $c;
}
$duplicates = array_minus_array($pieces_set, array_unique($pieces_set));
$pieces_set = array_unique($pieces_set);
$pieces_diff = array_merge(array_diff($pieces_used, $pieces_set), array_diff($pieces_set, $pieces_used));
if (!$pieces_diff && !$duplicates && !$untranslated) {
    exit('<h2>No Problems Found</h2>');
}
if (count($pieces_diff)) {
    echo '
	<h2>Problems Found</h2>
	<h3>These words were not found everywhere they should.</h4>
	<h4>Note: false positives may result when a method of $lang is called in the code.</h4>

	<table border="1" cellpadding="3" cellspacing="0">
	<tr>
		<td align="center"><b>Word</b></td>
		<td align="center"><b>Found in en.php</b></td>
Example #6
0
 public function import_list($data)
 {
     function array_minus_array($a, $b)
     {
         $c = array();
         foreach ($a as $key => $val) {
             $posb = array_search($val, $b);
             if (is_integer($posb)) {
                 unset($b[$posb]);
             } else {
                 $c[] = $val;
             }
         }
         return $c;
     }
     $dirinfo = get_dir_file_info($data['directory']);
     ksort($dirinfo);
     $archives = array();
     $matches = array();
     preg_match_all("/([\\d! ]+)/", $data['comic']->name, $matches, PREG_PATTERN_ORDER);
     $title_nums = $matches[0];
     $count = 0;
     foreach ($dirinfo as $key => $file) {
         if (!is_dir($file['server_path'])) {
             $extension = strtolower(pathinfo($file["server_path"], PATHINFO_EXTENSION));
             if ($extension != 'rar' && $extension != 'zip') {
                 continue;
             }
         }
         if (!is_dir($file['server_path'])) {
             $not_dir = TRUE;
         }
         $archives[$count]['filename'] = $file['name'];
         $archives[$count]['server_path'] = $file['server_path'];
         $archives[$count]['relative_path'] = $file['relative_path'];
         $archives[$count]['comic_id'] = $data['comic']->id;
         $matches = array();
         preg_match_all("/\\[([\\w! ]+)\\]/", $file['name'], $matches, PREG_PATTERN_ORDER);
         $archives[$count]['teams'] = $matches[0];
         $patches = array();
         preg_match_all("/([\\d! ]+)/", $file['name'], $matches, PREG_PATTERN_ORDER);
         $archives[$count]['numbers'] = array_minus_array($matches[0], $title_nums);
         $count++;
     }
     unset($count);
     return $archives;
 }
Example #7
0
    if ($group_obj->generate_from_id($group_ids) == OP_SUCCESSFUL) {
        $group['id'] = $group_obj->id;
        $group['name'] = $group_obj->get_name();
        $default_usergroups[] = $group;
    } else {
        // delete unproper entries
        unset($HTTP_SESSION_VARS['default_usergroup_ids'][$key]);
    }
}
foreach ($HTTP_SESSION_VARS['registered_users_usergroup_ids'] as $key => $group_ids) {
    $group_obj = new usergroup();
    if ($group_obj->generate_from_id($group_ids) == OP_SUCCESSFUL) {
        $group['id'] = $group_obj->id;
        $group['name'] = $group_obj->get_name();
        $registered_users_usergroups[] = $group;
    } else {
        // delete unproper entries
        unset($HTTP_SESSION_VARS['registered_users_usergroup_ids'][$key]);
    }
}
$smarty->assign('default_usergroup_ids', $default_usergroups);
$smarty->assign('registered_users_usergroup_ids', $registered_users_usergroups);
@$smarty->assign('not_default_usergroup_ids', array_minus_array($usergroups, $default_usergroups));
@$smarty->assign('not_registered_users_usergroup_ids', array_minus_array($usergroups, $registered_users_usergroups));
$smarty->assign('installed_templates', get_installed_templates());
$smarty->assign('installed_language', get_installed_languages());
$smarty->assign('config_vars', $config_vars);
if ($HTTP_SESSION_VARS['default_basket_enable']) {
    $smarty->assign('basket_enable', 'checked');
}
$smarty->display($userdata['photo_user_template'] . '/admin/config.tpl');