Exemple #1
0
         } else {
             $main_menu_fields_to_display1[$key] = $value;
             if (preg_match("/ as `?([\\w]+)`?/i", $value, $preg_results1)) {
                 $main_menu_fields_to_display[$key] = $preg_results1[1];
             }
         }
     }
     $main_menu_fields_to_display_string = join(", ", $main_menu_fields_to_display1);
     #$main_menu_fields_to_display_string = "`" . join( "`,`", $main_menu_fields_to_display ) . "`";
 }
 if (!$FORM['sort_field'] and !$FORM['sort_type']) {
     $sort_string = $default_sort_string;
 } else {
     $sort_string = "{$FORM['sort_field']} {$FORM['sort_type']}";
 }
 $records = mysql_extract_records_where($mysql_connect_id, $table_name, $where_clause, $main_menu_fields_to_display_string . $get_primary, $sort_string, "{$FORM['start']}, {$records_per_page}");
 #$FORM['starting'] = ( !$total_records ) ? 0 : $FORM['start'] + 1;
 #$FORM['ending'] = $FORM['start'] + $records_per_page;
 #$FORM['ending'] = ( $FORM['ending'] > $total_records ) ? $total_records : $FORM['ending'];
 #$total_pages = ceil( $total_records / $records_per_page );
 #$current_page = ceil( $FORM['starting'] / $records_per_page );
 $starting = !$total_records ? 0 : $FORM['start'] + 1;
 $ending = $FORM['start'] + $records_per_page;
 $ending = $ending > $total_records ? $total_records : $ending;
 $displaying = $ending - $starting + 1;
 $total_pages = ceil($total_records / $records_per_page);
 $current_page = ceil($starting / $records_per_page);
 $total_pages = $total_pages ? $total_pages : 0;
 $main_menu_total_fields = count($main_menu_fields_to_display);
 /* Showing <?php print $starting ?>-<?php print $ending ?> of <?php print $total_records ?> */
 /* [Page <?php print $current_page ?> of <?php print $total_pages ?>] */
<?php

require_once '/var/www/bais.islamiconlineuniversity.com/bais/config.php';
//  require_once('/home/eomanico/public_html/ecampus/config.php');
require_once $CFG->dirroot . '/course/lib.php';
require_once $CFG->dirroot . '/lib/blocklib.php';
include "centerconn.php";
include "php_lib3/misc.php";
include "php_lib3/mysql.php";
$mysql_connect_id = mysql_start($mysql_server, $center_db, $mysql_username, $mysql_password);
//check if the page is to be shown or not
$checkpage = mysql_extract_records_where("", "CenterSuggestPage", "id=1 ", "status");
//echo $check;
$status = $checkpage[1]['status'];
if ($status == 1) {
    header("location: suggestoff.php");
}
if ($USER->id) {
    #session_start();
    if (isset($_POST['Submit'])) {
        //function to ensure the value is numeric
        function fnValidateNumber($value)
        {
            if (ereg("\\+?([0-9]{3})-?([0-9]{6,7})", $value) || $value == "") {
                return true;
            } else {
                return false;
            }
        }
        //Function to sanitize values received from the form. Prevents SQL injection
        function clean($str)
    <td  width="12%"><span><strong>Address</strong></span></td>
    <td  width="8%"><span><strong>Center email and Website	</strong></span></td>
    <td  width="12%"><span><strong>Phone no</strong></span></td>
    
    <!-- <td  width="5%"><span><strong>Student Capacity</strong></span></td>-->
   <td  width="10%"><span><strong>Status</strong></span></td>
    <td  width="5%"><span><strong>Proctor</strong></span></td>
    <td width="3%" align="center"><span><strong>Center Id</strong></span></td>
  </tr>	
<?php 
$bg_color = "#F0F0F0";
foreach ($search_results as $record) {
    //print_r($record);
    $bg_color = !$bg_color ? "#F0F0F0" : "";
    $countryid = $record['CountryId'];
    $country_data = mysql_extract_records_where("", "Countries", "CountryId={$countryid}", "CountryName");
    foreach ($country_data as $c_record) {
        $country = $c_record['CountryName'];
    }
    $city = $record['CityName'];
    $active = $record['Active'];
    if ($active == 0) {
        // $status="<a href='statusrev.php?who=$record[EnteredById]' onclick='return popitup(statusrev.php?who=$record[EnteredById])'>Unapproved</a>";
        $status = "<a href='statusrev.php?who={$record['EnteredById']}&&centid={$record['CenterId']}' target='_blank'> Unapproved </a>";
    } else {
        $status = "Approved";
    }
    $centername = $record['CenterName'];
    //echo $centername;
    $centeremail = $record['Email'];
    // echo $centeremail;
function get_users_country($connect_id, $ip_address = "", $country_db = "", $country_table = "")
{
    $country_db = $country_db ? $country_db : "theemira_count";
    $country_table = $country_table ? $country_table : "ip_to_country";
    $ip_address = $ip_address ? $ip_address : $_SERVER['REMOTE_ADDR'];
    $current_db = mysql_current_databse($connect_id);
    #preg_match( "/(\d*)\.(\d*)\.(\d*)\.(\d*)/", $_SERVER['REMOTE_ADDR'], $ip_parts );
    #$ip_2_long = ($ip_parts[1] * 16777216) + ($ip_parts[2] * 65536) + ($ip_parts[3] * 256) + $ip_parts[4];
    $ip_2_long = sprintf("%u", ip2long($ip_address));
    if ($current_db != $country_db) {
        mysql_change_db($connect_id, $country_db);
    }
    #$country_record = mysql_extract_records_where( $connect_id, $country_table, array( "ip_from <= $ip_2_long" => '', "ip_to >= $ip_2_long" => '' ) );
    $country_record = mysql_extract_records_where($connect_id, $country_table, "ip_from <= {$ip_2_long} AND ip_to >= {$ip_2_long}");
    if (!$country_record[1]['country_code2']) {
        $user_country_code = "UN";
        $user_country_name = "Unknown";
    } else {
        $user_country_code = $country_record[1]['country_code2'];
        $user_country_name = $country_record[1]['country_name'];
    }
    if ($current_db != $country_db) {
        mysql_change_db($connect_id, $current_db);
    }
    return array($user_country_code, $user_country_name);
}
    $select_addons['LIMIT'] = "{$FORM['start']}, {$records_per_page}";
} else {
    $select_addons['LIMIT'] = "{$FORM['start']}, {$records_per_page}";
}
#print mysql_create_select_statement( $table_to_query, $fields_to_extract, $select_addons );
#exit;
$mysql_version = intval(mysql_version());
if ($mysql_version >= 4) {
    $time_start = microtime_float();
    $select_addons['FOUND_ROWS'] = '';
    $search_results = mysql_extract_records_where($mysql_connection_id, $table_to_query, $select_addons, $fields_to_extract);
    $total_records = mysql_select_total_records($mysql_connection_id);
    $time_end = microtime_float();
} else {
    $time_start = microtime_float();
    $search_results = mysql_extract_records_where($mysql_connection_id, $table_to_query, $select_addons, $fields_to_extract);
    if ($select_addons['LIMIT']) {
        //            $field_list = "";
        //            if ( $select_addons['LIMIT'] ) {
        //               $field_list =
        //            }
        $total_records = mysql_count_query_records($mysql_connection_id, $table_to_query, $select_addons);
    } else {
        $total_records = count($search_results);
    }
    $time_end = microtime_float();
}
$mysql_execute_time = $time_end - $time_start;
$total_records = $total_records == "" ? 0 : $total_records;
$starting = !$total_records ? 0 : $FORM['start'] + 1;
$ending = $FORM['start'] + $records_per_page;
Exemple #6
0
function mysql_get_foreign_key_list($connect_id, $database, $table, $key_field, $display_fields, $where_clause = "", $order_by_field = "")
{
    if ($database) {
        $current_db = mysql_current_databse($connect_id);
        if ($current_db != $database) {
            mysql_change_db($connect_id, $database);
        } else {
            $database = "";
        }
    }
    $key_field = strtolower($key_field);
    if (preg_match("/field\\[([^\\]]+)\\]/i", $display_fields)) {
        $display_fields_new = $display_fields;
        while (preg_match("/field\\[([^\\]]+)\\]/i", $display_fields_new, $preg_results)) {
            $display_fields_new = str_replace($preg_results[0], "", $display_fields_new);
            $field_list[] = strtolower($preg_results[1]);
        }
        $fields_to_extract = join(",", $field_list);
    } else {
        $field_list = preg_split("/\\s*,\\s*/", $display_fields);
        $fields_to_extract = $display_fields;
        $text_separator = " - ";
    }
    if (array_search($key_field, $field_list) === FALSE) {
        $extract_keys = "{$key_field},{$fields_to_extract}";
    } else {
        $extract_keys = $fields_to_extract;
        $disable_array_shift = 1;
    }
    $fkey_records = mysql_extract_records_where($connect_id, $table, $where_clause, $extract_keys, $order_by_field);
    if ($fkey_records) {
        foreach ($fkey_records as $value) {
            if (!$disable_array_shift) {
                $record_value = array_shift($value);
            } else {
                $record_value = $value[$key_field];
            }
            if ($text_separator) {
                $record_title = join($text_separator, $value);
            } else {
                # Allows formatting of the $display_fields string
                $display_fields_new = $display_fields;
                while (preg_match("/field\\[([^\\]>]+)\\]|field<([^>]+)>/i", $display_fields_new, $preg_results)) {
                    $preg_value = strtolower($preg_results[1]);
                    $display_fields_new = str_replace($preg_results[0], $value[$preg_value], $display_fields_new);
                }
                $bracket_types = array("[" => "]", "<" => ">");
                foreach ($bracket_types as $open_bracket => $close_bracket) {
                    $open_bracket = preg_quote($open_bracket);
                    $close_bracket = preg_quote($close_bracket);
                    $preg_query = "/(?:fk|fkey)" . $open_bracket . "([^\\.]+)\\.([^\\.]+)\\.([^=]+)=([^,]+), ([^" . $close_bracket . "]+)" . $close_bracket . "/i";
                    while (preg_match($preg_query, $display_fields_new, $preg_results)) {
                        # Usage   - fkey[database.table.field=value, fieldstodisplay]
                        # Example - fkey[general.city.code=DXB, 'field<name>-field<country_code>']
                        $preg_results[5] = preg_replace("/^'/", "", $preg_results[5]);
                        $preg_results[5] = preg_replace("/'\$/", "", $preg_results[5]);
                        $text_replace = mysql_get_foreign_key_text($connect_id, $preg_results[1], $preg_results[2], array($preg_results[3] => $preg_results[4]), $preg_results[5]);
                        $display_fields_new = str_replace($preg_results[0], $text_replace, $display_fields_new);
                    }
                }
                $record_title = $display_fields_new;
            }
            #$values_and_titles[] = $record_value . "=" . str_replace( ",", "&#44;", $record_title );
            $values_and_titles[$record_value] = $record_title;
        }
    } else {
        #print "#Error# No Results in FK List<br>\r\n";
    }
    if ($database) {
        mysql_change_db($connect_id, $current_db);
    }
    if ($values_and_titles) {
        #return join( ",", $values_and_titles );
        return $values_and_titles;
    } else {
        return 0;
    }
}