Example #1
0
function check_user($username)
{
    // Global variables
    global $db_server, $db_username, $db_password, $db_name, $schema;
    // Check valid username
    if (!isset($username) || strlen($username) < 4 || strlen($username) > 30 || !ctype_alnum($username)) {
        return 'Username not valid';
    }
    // Create connection
    $connection = new mysqli($db_server, $db_username, $db_password, $db_name);
    if ($connection->connect_error) {
        return 'Error while connecting to the database';
    }
    // Set charset to utf8
    $connection->set_charset("utf8");
    // Create table if it does not exist
    if (check_table($connection, 'ewatcher', $schema['ewatcher']) === false) {
        $connection->close();
        return 'Error while creating the EWatcher configuration table';
    }
    // Check if user exists in the users table, get userid
    $result = $connection->query("SELECT id FROM users WHERE username='******';");
    if ($result === FALSE || empty($result) || $result->num_rows == 0) {
        $connection->close();
        return 'Username does not exist';
    }
    $userid = $result->fetch_object()->id;
    // Check if user exists in the ewatcher table
    $result = $connection->query("SELECT * FROM ewatcher WHERE userid={$userid};");
    if ($result === FALSE || empty($result) || $result->num_rows == 0) {
        // Create ewatcher user config if it does not exist
        if ($connection->query("INSERT INTO ewatcher (userid) VALUES ({$userid});") === FALSE) {
            $connection->close();
            return 'Error while creating user configuration (EWatcher)';
        }
    }
    $connection->close();
    return true;
}
     break;
 case 'get_menu':
     $keyword = $_GET['keyword'];
     $data['menu_id'] = select_menu($keyword);
     return $data;
     break;
 case 'delete_history':
     $id = get_isset($_GET['id']);
     $table_id = get_isset($_GET['table_id']);
     delete_history($id);
     header("Location: transaction.php?table_id={$table_id}&did=3");
     break;
 case 'list_history':
     //get_header($title);
     $table_id = get_isset($_GET['table_id']);
     $check_table = check_table($table_id);
     if ($check_table > 0) {
         $query_history = select_history($table_id);
         include '../views/transaction/history_order.php';
     }
     //get_footer();
     break;
 case 'form_widget':
     $menu_id = $_GET['menu_id'];
     $jumlah = $_GET['jumlah'];
     $table_id = $_GET['table_id'];
     $get_widget = get_widget($menu_id, $table_id);
     if ($jumlah == 0) {
         delete_config("widget_tmp", "menu_id = '{$menu_id}' and user_id = '" . $_SESSION['user_id'] . "' and table_id = '{$table_id}'");
     } else {
         if ($get_widget == 0) {
Example #3
0
 /**
  * Create a new domain mapping
  *
  * @param $site Site ID, or site object from {@see get_blog_details}
  * @return Mapping|WP_Error
  */
 public static function create($site, $domain, $active = false)
 {
     global $wpdb;
     // Allow passing a site object in
     if (is_object($site) && isset($site->blog_id)) {
         $site = $site->blog_id;
     }
     if (!is_numeric($site)) {
         return new \WP_Error('mercator.mapping.invalid_id');
     }
     $site = absint($site);
     $active = (bool) $active;
     // Did we get a full URL?
     if (strpos($domain, '://') !== false) {
         // Parse just the domain out
         $domain = parse_url($domain, PHP_URL_HOST);
     }
     // Does this domain exist already?
     $existing = static::get_by_domain($domain);
     if (is_wp_error($existing)) {
         return $existing;
     }
     if (!empty($existing)) {
         // Domain exists already...
         if ($site !== $existing->get_site_id()) {
             // ...and points to another site
             return new \WP_Error('mercator.mapping.domain_exists');
         }
         // ...and points to this site, so nothing to do
         return $existing;
     }
     // Create the mapping!
     $prev_errors = !empty($GLOBALS['EZSQL_ERROR']) ? $GLOBALS['EZSQL_ERROR'] : array();
     $suppress = $wpdb->suppress_errors(true);
     $result = $wpdb->insert($wpdb->dmtable, array('blog_id' => $site, 'domain' => $domain, 'active' => $active), array('%d', '%s', '%d'));
     $wpdb->suppress_errors($suppress);
     if (empty($result)) {
         // Check that the table exists...
         if (check_table() === 'created') {
             // Table created, try again
             return static::create($site, $domain);
         }
         // Other error. We suppressed errors before, so we need to make sure
         // we handle that now.
         $recent_errors = array_diff_key($GLOBALS['EZSQL_ERROR'], $prev_errors);
         while (count($recent_errors) > 0) {
             $error = array_shift($recent_errors);
             $wpdb->print_error($error['error_str']);
         }
         return new \WP_Error('mercator.mapping.insert_failed');
     }
     // Ensure the cache is flushed
     wp_cache_delete('id:' . $site, 'domain_mapping');
     wp_cache_delete('domain:' . $domain, 'domain_mapping');
     $mapping = static::get($wpdb->insert_id);
     /**
      * Fires after a mapping has been created.
      *
      * @param Mercator\Mapping $mapping         The mapping object.
      */
     do_action('mercator.mapping.created', $mapping);
     return $mapping;
 }
Example #4
0
 function installed($pref)
 {
     $n = 4;
     // number of features to be installed
     if (!check_table($pref, 'item_codes')) {
         $n--;
     }
     //		if (!check_table($pref, 'company', 'foreign_codes')) $n--;
     if (!check_table($pref, 'suppliers', 'credit_limit')) {
         $n--;
     }
     if (!check_table($pref, 'bank_trans', 'reconciled', array('Type' => 'date'))) {
         $n--;
     }
     if (!check_table($pref, 'trans_tax_details')) {
         $n--;
     }
     return $n == 0 ? true : 5 - $n;
 }
Example #5
0
/**
 * drop_column
 * 
 * drops the specified column from the table
 * 
 */
function drop_column($table, $column)
{
    $check = check_table($table, $column);
    if ($check === false) {
        return 'Column ' . $column . ' NOT found in table ' . $table . '<br />';
    }
    $conn = author_connect();
    $query = "ALTER TABLE " . $table . " DROP " . $column;
    $conn->query($query);
    if ($conn->error) {
        return 'error: ' . $conn->error . '<br />';
    }
    if (!$conn->error) {
        return 'Dropped column ' . $column . ' from table ' . $table . '<br />';
    }
}
Example #6
0
     debug(mysql_error());
     $fatal = true;
 } else {
     debug("Connected to database server.");
     if (!mysql_select_db($db_name, $connection)) {
         debug("<span class=\"err\">ERROR</span>: There was an error selecting the database");
         debug(mysql_error());
         $fatal = true;
     }
 }
 if ($fatal) {
     debug("There was a fatal error. Exiting.");
     echo debug_echo();
     die;
 }
 if (check_table("data")) {
     debug("Table 'data' was found, deleting");
     if (!mysql_query("DROP TABLE `data`")) {
         debug("<span class=\"err\">ERROR</span>: There was an error deleting the old database table");
         debug(mysql_error());
         $fatal = true;
     } else {
         debug("Table 'data' was dropped");
     }
     if ($fatal) {
         debug("There was a fatal error. Exiting.");
         echo debug_echo();
         die;
     }
 }
 $input_pass = NULL;
Example #7
0
        $fatal = true;
    }
} else {
    debug("Table core_entry2tag does already exist, skipping creation");
}
if (!check_table("core_pages")) {
    debug("Creating table \"core_pages\"");
    if (!mysql_query("\nCREATE TABLE `core_pages` (\n  `page_id` smallint(5) unsigned NOT NULL auto_increment,\n  `page_title` varchar(255) NOT NULL default '',\n  `page_url` varchar(30) NOT NULL default '',\n  `page_position` smallint(5) unsigned NOT NULL default '0',\n  `hits` int(10) unsigned NOT NULL default '0',\n  PRIMARY KEY  (`page_id`),\n  UNIQUE KEY `page_title` (`page_title`,`page_url`,`page_position`)\n) ENGINE=MyISAM  DEFAULT CHARSET=utf8;\n")) {
        debug("<span class=\"err\">ERROR</span>: There was an error creating table \"core_entries\"");
        debug(mysql_error());
        $fatal = true;
    }
} else {
    debug("Table core_pages does already exist, skipping creation");
}
if (!check_table("core_tags")) {
    debug("Creating table \"core_tags\"");
    if (!mysql_query("\nCREATE TABLE `core_tags` (\n  `tag_id` int(10) unsigned NOT NULL auto_increment,\n  `tag_text` varchar(255) character set latin1 NOT NULL default '',\n  `tag_position` int(10) unsigned NOT NULL default '0',\n  PRIMARY KEY  (`tag_id`),\n  UNIQUE KEY `tag_text` (`tag_text`)\n) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_bin;\n")) {
        debug("<span class=\"err\">ERROR</span>: There was an error creating table \"core_entries\"");
        debug(mysql_error());
        $fatal = true;
    }
} else {
    debug("Table core_tags does already exist, skipping creation");
}
if ($fatal) {
    debug("There was a fatal error. Exiting.");
    echo debug_echo();
    ?>
    <p class="btn add" onclick="loadData('get_db_input.php')">Back</p>
    <?php 
Example #8
0
function errors($username, $password)
{
    // Check if attempts is set or not, if it isn't set it to 1
    if (!isset($_SESSION['attempts'])) {
        $_SESSION['attempts'] = 1;
    }
    if (!check_length($username, 8, 16) || !check_length($password, 8, 16) || !check_table("users", "username", $username) || $_SESSION['attempts'] > 50) {
        // There were errors
        $_SESSION['attempts']++;
        return TRUE;
    } else {
        // No errors
        return FALSE;
    }
}
Example #9
0
 function installed($pref)
 {
     $n = 1;
     // number of patches to be installed
     $patchcnt = 0;
     if (!$this->beta) {
         $n = 16;
         if (check_table($pref, 'company')) {
             // skip in 2.3
             $n -= 3;
         } else {
             if (check_table($pref, 'company', 'custom1_name')) {
                 $patchcnt++;
             }
             if (!check_table($pref, 'company', 'profit_loss_year_act')) {
                 $patchcnt++;
             }
             if (!check_table($pref, 'company', 'login_tout')) {
                 $patchcnt++;
             }
         }
         if (!check_table($pref, 'stock_category', 'dflt_no_sale')) {
             $patchcnt++;
         }
         if (!check_table($pref, 'users', 'sticky_doc_date')) {
             $patchcnt++;
         }
         if (!check_table($pref, 'users', 'startup_tab')) {
             $patchcnt++;
         }
         if (!check_table($pref, 'cust_branch', 'inactive')) {
             $patchcnt++;
         }
         if (!check_table($pref, 'chart_class', 'ctype')) {
             $patchcnt++;
         }
         if (!check_table($pref, 'audit_trail')) {
             $patchcnt++;
         }
         if (!check_table($pref, 'currencies', 'auto_update')) {
             $patchcnt++;
         }
         if (!check_table($pref, 'stock_master', 'no_sale')) {
             $patchcnt++;
         }
         if (!check_table($pref, 'suppliers', 'supp_ref')) {
             $patchcnt++;
         }
         if (!check_table($pref, 'users', 'role_id')) {
             $patchcnt++;
         }
         if (!check_table($pref, 'sales_orders', 'reference')) {
             $patchcnt++;
         }
         if (!check_table($pref, 'tags')) {
             $patchcnt++;
         }
     }
     if (!check_table($pref, 'useronline')) {
         $patchcnt++;
     }
     $n -= $patchcnt;
     return $n == 0 ? true : $patchcnt;
 }
				function errors($email) {
					if (
					!check_table("users", "email", $email) ||
					check_table("confirmation", "email", $email)
					) {
						// There were errors
						return TRUE;
					} else {
						// No errors
						return FALSE;
					}
				}
Example #11
0
 function installed($pref)
 {
     $this->beta = !check_table($pref, 'suppliers', 'tax_included');
     $n = 1;
     // number of patches to be installed
     $patchcnt = 0;
     if (!$this->beta) {
         $n += 3;
         if (!check_table($pref, 'comments', 'type', array('Key' => 'MUL'))) {
             $patchcnt++;
         }
         if (!check_table($pref, 'sys_prefs')) {
             $patchcnt++;
         }
         if (!check_table($pref, 'sales_orders', 'payment_terms')) {
             $patchcnt++;
         }
     }
     if (!check_table($pref, 'purch_orders', 'tax_included')) {
         $patchcnt++;
     }
     return $n == $patchcnt ? true : ($patchcnt ? $patchcnt . '/' . $n : 0);
 }
Example #12
0
 /**
  * Create a new domain mapping
  *
  * @param $site Site ID, or site object from {@see get_blog_details}
  * @return bool
  */
 public static function create($site, $domain, $active = false)
 {
     global $wpdb;
     // Allow passing a site object in
     if (is_object($site) && isset($site->blog_id)) {
         $site = $site->blog_id;
     }
     if (!is_numeric($site)) {
         return new \WP_Error('mercator.mapping.invalid_id');
     }
     $site = absint($site);
     $active = (bool) $active;
     // Did we get a full URL?
     if (strpos($domain, '://') !== false) {
         // Parse just the domain out
         $domain = parse_url($domain, PHP_URL_HOST);
     }
     // Does this domain exist already?
     $existing = static::get_by_domain($domain);
     if (is_wp_error($existing)) {
         return $existing;
     }
     if (!empty($existing)) {
         // Domain exists already...
         if ($site !== $mapping->get_site_id()) {
             // ...and points to another site
             return new \WP_Error('mercator.mapping.domain_exists');
         }
         // ...and points to this site, so nothing to do
         return $existing;
     }
     // Create the mapping!
     $result = $wpdb->insert($wpdb->dmtable, array('blog_id' => $site, 'domain' => $domain, 'active' => $active), array('%d', '%s', '%d'));
     if (empty($result)) {
         // Check that the table exists...
         if (check_table() === 'created') {
             // Table created, try again
             return static::create($site, $domain);
         }
         return new \WP_Error('mercator.mapping.insert_failed');
     }
     // Ensure the cache is flushed
     wp_cache_delete('id:' . $site, 'domain_mapping');
     wp_cache_delete('domain:' . $domain, 'domain_mapping');
     return static::get($wpdb->insert_id);
 }
Example #13
0
				function errors($firstname, $lastname, $username, $password1, $password2, $email1, $email2) {
					if (
					contains_whitespace($firstname) ||
					contains_whitespace($lastname) ||
					!check_length($firstname, 1, 255) ||
					!check_length($lastname, 1, 255) ||
					!check_length($username, 8, 16) ||
					!check_length($password1, 8, 16) ||
					$password1 !== $password2 ||
					!filter_var($email1, FILTER_VALIDATE_EMAIL) ||
					$email1 !== $email2 ||
					check_table("users", "username", $username) ||
					check_table("confirmation", "username", $username) ||
					check_table("users", "email", $email1) ||
					check_table("confirmation", "email", $email1)
					) {
						// There were errors
						return TRUE;
					} else {
						// No errors
						return FALSE;
					}
				}
Example #14
0
            echo <<<QQQQ
W&auml;en Sie ihre Mannschaft aus:&nbsp;<select name="team" size="1">
QQQQ;
            while ($row_team = mysql_fetch_assoc($sql_teams_result)) {
                $select_team = $row_team['name'];
                echo "<option>{$select_team}</option>";
            }
            echo "</select>";
        } else {
            echo "Liga ID nicht in der Datenbank.";
        }
    } else {
        $catch_liga = catch_ligadata($_GET['liga_id']);
        if ($catch_liga) {
            write_ligadata_to_database("../data/ergebnisse_" . $_GET['liga_id'] . ".xml", $_GET['liga_id']);
            $table_id_exists = check_table("tabelle_{$_GET['liga_id']}");
            if ($table_id_exists) {
                $sql_teams = "SELECT *\n\t      FROM `tabelle_{$_GET['liga_id']}`";
                mysql_query('SET character_set_client = utf8');
                mysql_query('SET character_set_results = utf8');
                mysql_query('SET character_set_connection = utf8');
                $sql_teams_result = mysql_query($sql_teams) or die(mysql_error());
                if (mysql_num_rows($sql_teams_result)) {
                    echo <<<QQQQ
W&auml;en Sie ihre Mannschaft aus:&nbsp;<select name="team" size="1">
QQQQ;
                    while ($row_team = mysql_fetch_assoc($sql_teams_result)) {
                        $select_team = $row_team['name'];
                        echo "<option>{$select_team}</option>";
                    }
                    echo "</select>";