Beispiel #1
42
function fill($prefix, $listid)
{
    global $server_name, $tables, $table_prefix;
    # check for not too many
    $domain = getConfig('domain');
    $res = Sql_query("select count(*) from {$tables['user']}");
    $row = Sql_fetch_row($res);
    if ($row[0] > 50000) {
        error('Hmm, I think 50 thousand users is quite enough for a test<br/>This machine does need to do other things you know.');
        print '<script language="Javascript" type="text/javascript"> document.forms[0].output.value="Done. Now there are ' . $row[0] . ' users in the database";</script>' . "\n";
        return 0;
    }
    # fill the database with "users" who have any combination of attribute values
    $attributes = array();
    $res = Sql_query("select * from {$tables['attribute']} where type = \"select\" or type = \"checkbox\" or type=\"radio\"");
    $num_attributes = Sql_Affected_rows();
    $total_attr = 0;
    $total_val = 0;
    while ($row = Sql_fetch_array($res)) {
        array_push($attributes, $row['id']);
        ++$total_attr;
        $values[$row['id']] = array();
        $res2 = Sql_query("select * from {$table_prefix}" . 'listattr_' . $row['tablename']);
        while ($row2 = Sql_fetch_array($res2)) {
            array_push($values[$row['id']], $row2['id']);
            ++$total_val;
        }
    }
    $total = $total_attr * $total_val;
    if (!$total) {
        Fatal_Error('Can only do stress test when some attributes exist');
        return 0;
    }
    for ($i = 0; $i < $total; ++$i) {
        $data = array();
        reset($attributes);
        while (list($key, $val) = each($attributes)) {
            $data[$val] = current($values[$val]);
            if (!$data[$val]) {
                reset($values[$val]);
                $data[$val] = current($values[$val]);
            }
            next($values[$val]);
        }
        $query = sprintf('insert into %s (email,entered,confirmed) values("testuser%s",now(),1)', $tables['user'], $prefix . '-' . $i . '@' . $domain);
        $result = Sql_query($query, 0);
        $userid = Sql_insert_id();
        if ($userid) {
            $result = Sql_query("replace into {$tables['listuser']} (userid,listid,entered) values({$userid},{$listid},now())");
            reset($data);
            while (list($key, $val) = each($data)) {
                if ($key && $val) {
                    Sql_query("replace into {$tables['user_attribute']} (attributeid,userid,value) values(" . $key . ",{$userid}," . $val . ')');
                }
            }
        }
    }
    return 1;
}
Beispiel #2
0
function setHistory($options = array())
{
    $defaultOptions = array();
    $defaultOptions['page_name'] = '';
    $defaultOptions['action_type'] = '';
    $defaultOptions['table'] = '';
    $defaultOptions['id_name'] = 'id';
    $defaultOptions['id_value'] = '';
    $defaultOptions['remote'] = false;
    $defaultOptions['pname'] = '';
    $options = array_merge($defaultOptions, $options);
    extract($options);
    $localcn = connectDB();
    $user_id = $_SESSION['UserID'];
    $user_name = $_SESSION['UserName'];
    if ($localcn == '' || trim($action_type) == '' || trim($table) == '' || trim($id_value) == '' || trim($remote) == true && trim($pname) == '' || trim($action_type) != "add" && trim($action_type) != "delete" && trim($action_type) == 'edit') {
        return false;
    }
    $connection_string = $localcn;
    $remote_name = NULL;
    if ($remote === true) {
        $remoteCn = remote_connectDB($pname);
        $connection_string = $remoteCn;
        $remote_name = $pname;
    }
    $qry = "Select * from `{$table}` where {$id_name} = '{$id_value}'";
    $res = Sql_exec($connection_string, $qry);
    $result = Sql_fetch_assoc($res);
    $value_json = json_encode($result);
    if ($remoteCn) {
        ClosedDBConnection($remoteCn);
        rollback_main_connectDB();
    }
    if ($action_type == 'update') {
        $comments = 'Updated !';
    } elseif ($action_type == 'add') {
        $comments = 'Inserted !';
    }
    $row_value = $value_json;
    $action_command = $action_type;
    if ($page_name == "") {
        $page_name = $table;
    }
    $table_name = $table;
    $action_date = date("Y-m-d", strtotime("now"));
    $action_time = date("H:i:s", strtotime("now"));
    $ip_address = $_SERVER['REMOTE_ADDR'];
    $browser = $_SERVER['HTTP_USER_AGENT'];
    $referrer = $_SERVER['HTTP_REFERER'];
    $qry = "INSERT INTO tbl_audit_trail (user_id,user_name,action_command,pname,page_name,table_name,primary_key_column,action_date,action_time,rowvalue,comments,ip_address,browser,referer) VALUES";
    $qry .= "('{$user_id}','{$user_name}','{$action_command}','{$remote_name}','{$page_name}','{$table_name}','{$id_name}','{$action_date}','{$action_time}','{$row_value}','{$comments}','{$ip_address}','{$browser}', '{$referrer}');";
    $result = Sql_exec($localcn, $qry);
    $insert_id = Sql_insert_id($localcn);
    return $insert_id;
}
    $qry = "INSERT INTO `tbl_smsgw_contact_group` (`group_name`,`last_updated`)VALUES('{$group}',NOW())";
} elseif ($action == "update") {
    $qry = "UPDATE `tbl_smsgw_contact_group` SET `group_name`='{$group}' WHERE `id`='{$action_id}'";
} elseif ($action == "delete") {
    $qry = "UPDATE `tbl_smsgw_contact_group` SET `is_active` = 'inactive' WHERE `is_active`='active' AND `id`='{$action_id}'";
}
try {
    $rs = Sql_exec($cn, $qry);
    if ($action != "delete") {
        if ($action == "update") {
            $options['page_name'] = "Bulk SMS Group";
            $options['action_type'] = $action;
            $options['table'] = "tbl_smsgw_contact_group";
            $options['id_value'] = $action_id;
            setHistory($options);
        } else {
            $action_id = Sql_insert_id($cn);
            $action = 'add';
            $options['page_name'] = "Bulk SMS Group";
            $options['action_type'] = $action;
            $options['table'] = "tbl_smsgw_contact_group";
            $options['id_value'] = $action_id;
            setHistory($options);
        }
    }
    //$is_error = 0;
} catch (Exception $e) {
    $is_error = 1;
}
ClosedDBConnection($cn);
echo $is_error;
Beispiel #4
0
            print $GLOBALS['I18N']->get('You cannot delete yourself') . "\n";
        } else {
            print $GLOBALS['I18N']->get('Deleting') . " {$delete} ..\n";
            Sql_query(sprintf('delete from %s where id = %d', $GLOBALS['tables']['admin'], $_GET['delete']));
            Sql_query(sprintf('delete from %s where adminid = %d', $GLOBALS['tables']['admin_attribute'], $_GET['delete']));
            Sql_query(sprintf('delete from %s where adminid = %d', $GLOBALS['tables']['admin_task'], $_GET['delete']));
            print '..' . $GLOBALS['I18N']->get('Done') . "<br /><hr><br />\n";
            Redirect("admins&start={$start}");
        }
    }
    ob_end_flush();
    if (isset($add)) {
        if (isset($new)) {
            $query = 'insert into ' . $tables['admin'] . " (email,entered) values(\"{$new}\",now())";
            $result = Sql_query($query);
            $userid = Sql_insert_id();
            $query = 'insert into ' . $tables['listuser'] . " (userid,listid,entered) values({$userid},{$id},now())";
            $result = Sql_query($query);
        }
        echo '<br/>' . $GLOBALS['I18N']->get('Admin added') . '<br/>';
    }
}
if ($external) {
    $admins = $GLOBALS['admin_auth']->listAdmins();
    $total = count($admins);
    $found = $total;
    $ls = new WebblerListing($GLOBALS['I18N']->get('Administrators'));
    foreach ($admins as $adminid => $adminname) {
        $ls->addElement($adminname);
        #,PageUrl2("admin",$GLOBALS['I18N']->get('Show'),"id=".$adminid));
    }
Beispiel #5
0
function addLogToDB($step_name, $step_response, $step_id, $parent_id = 0)
{
    date_default_timezone_set("Asia/Dhaka");
    $create_date = date('Y-m-d H:i:s');
    $step_response = str_ireplace("'", '+', $step_response);
    $query = "INSERT INTO debug_log_monitor ( step_name, step_response, step_id, parent_id, create_date ) VALUES ( '{$step_name}', '{$step_response}', '{$step_id}', '{$parent_id}', '{$create_date}' ) ";
    $cn = connectDB();
    $result = Sql_exec_continue($cn, $query);
    if ($result) {
        return Sql_insert_id($cn);
    } else {
        return 0;
    }
}
         if (Sql_affected_rows()) {
             // Email exists, remember some values to add them to the lists
             $user = Sql_fetch_array($result);
             $adminid = $admin["id"];
         } else {
             // Email does not exist
             $loginname = $data["loginname"];
             if (!$loginname && $email) {
                 $loginname = $email;
                 Warn($GLOBALS['I18N']->get("Empty loginname, using email:") . " " . $email);
             }
             $query = sprintf('INSERT INTO %s
 (email,loginname,namelc,created,modifiedby,password,superuser,disabled)
 values("%s","%s","%s",now(),"%s","%s",0,0)', $tables["admin"], $email, $loginname, normalize($loginname), adminName($_SESSION["logindetails"]["id"]), $data["password"]);
             $result = Sql_query($query);
             $adminid = Sql_insert_id();
             $count_email_add++;
             $some = 1;
         }
         reset($import_attribute);
         foreach ($import_attribute as $item) {
             if ($data[$item["index"]]) {
                 $attribute_index = $item["record"];
                 $value = $data[$item["index"]];
                 # check whether this is a textline or a selectable item
                 $att = Sql_Fetch_Row_Query("select type,tablename,name from " . $tables["adminattribute"] . " where id = {$attribute_index}");
                 switch ($att[0]) {
                     case "select":
                     case "radio":
                         $val = Sql_Query("select id from {$table_prefix}" . "adminattr_{$att['1']} where name = \"{$value}\"");
                         # if we don't have this value add it
Beispiel #7
0
				addslashes($subject),
				addslashes($from),
				addslashes($_POST["tofield"]),
				addslashes($_POST["replyto"]),
				$embargo->getDate()."	".$embargo->getTime().":00",
				$_POST["repeatinterval"],
				$repeatuntil->getDate()."	".$repeatuntil->getTime().":00",
				addslashes($_POST["message"]),
				addslashes($_POST["footer"]),
				$status,"now()",
				$htmlformatted,
				$_POST["sendformat"],
				$_POST["template"],$_POST["rsstemplate"],$_SESSION["logindetails"]['id']
			);
		$result	=	Sql_query($query);
		$messageid = Sql_insert_id();

		// More	"Insert	only"	stuff	here (no need	to change	it on	an edit!)
		if (is_array($_POST["list"]))	{
			if ($_POST["list"]["all"]) {
				$res = Sql_query("select * from	$tables[list]	$subselect");
				while($row = Sql_fetch_array($res))	{
					$listid	=	$row["id"];
					if ($row["active"])	{
						$result	=	Sql_query("insert	into $tables[listmessage]	(messageid,listid,entered) values($messageid,$listid,now())");
					}
				}
			}	else {
				while(list($key,$val)= each($_POST["list"])) {
					if ($val ==	"signup")
						$result	=	Sql_query("insert	into $tables[listmessage]	(messageid,listid,entered) values($messageid,$key,now())");
     } else {
         $msg = "Successfully Saved";
         $qry = "insert into `service`( `ShortCode`,`Keyword`, `ServiceID`,  `SubServiceID`,  `SourceType`,`URL`,  `Status` ) values ('{$shortcode}','{$keyword}','{$ServiceID}','{$SubServiceID}','{$SourceType}','{$URL}','{$Status}')";
     }
 }
 try {
     if ($qry != '') {
         $res = Sql_exec($remoteCn, $qry);
         $is_error = 0;
         if ($action != "delete") {
             if ($action == "update") {
                 $action_name = $action;
                 $id_val = $action_id;
             } else {
                 $action_name = 'add';
                 $id_val = Sql_insert_id($remoteCn);
             }
         }
         ClosedDBConnection($remoteCn);
         rollback_main_connectDB();
         $options['page_name'] = "SMS Gateway Services";
         $options['action_type'] = $action_name;
         $options['table'] = "service";
         $options['id_value'] = $id_val;
         $options['remote'] = true;
         $options['pname'] = 'SMSGW';
         setHistory($options);
     }
 } catch (Exception $e) {
 }
 if ($is_error) {
Beispiel #9
0
function fill($prefix,$listid) {
  global $server_name,$tables,$table_prefix;
  # check for not too many
  $domain = getConfig("domain");
  $res = Sql_query("select count(*) from $tables[user]");
  $row = Sql_fetch_row($res);
  if ($row[0] > 50000) {
    error("Hmm, I think 50 thousand users is quite enough for a test<br>This machine does need to do other things you know.");
    print '<script language="Javascript" type="text/javascript">finish();</script>';
    print '<script language="Javascript" type="text/javascript"> document.forms[0].output.value="Done. Now there are '.$row[0].' users in the database";</script>'."\n";
    return 0;
  }

  # fill the database with "users" who have any combination of attribute values
  $attributes = array();
  $res = Sql_query("select * from $tables[attribute] where type = \"select\" or type = \"checkbox\" or type=\"radio\"");
  $num_attributes = Sql_Affected_rows();
  $total_attr = 0;
  $total_val = 0;

  while ($row = Sql_fetch_array($res)) {
    array_push($attributes,$row["id"]);
    $total_attr++;
    $values[$row["id"]] = array();
    $res2 = Sql_query("select * from $table_prefix"."listattr_".$row["tablename"]);
    while ($row2 = Sql_fetch_array($res2)) {
      array_push($values[$row["id"]],$row2["id"]);
      $total_val++;
    }
  }
  $total = $total_attr * $total_val;
  if (!$total) {
    print '<script language="Javascript" type="text/javascript"> finish(); </script>';
    Fatal_Error("Can only do stress test when some attributes exist");
		return 0;
  }

  for ($i = 0;$i< $total;$i++) {
    $data = array();
    reset($attributes);
    while (list($key,$val) = each ($attributes)) {
      $data[$val] = pos($values[$val]);
      if (!$data[$val]) {
        reset($values[$val]);
        $data[$val] = pos($values[$val]);
      }
      next($values[$val]);
    }

    $query = sprintf('insert into %s (email,entered,confirmed) values("testuser%s",now(),1)',
			$tables["user"], $prefix . '-' . $i . '@' . $domain);
    $result = Sql_query($query,0);

    $userid = Sql_insert_id();
		if ($userid) {
			$result = Sql_query("replace into $tables[listuser] (userid,listid,entered) values($userid,$listid,now())");
			reset($data);
			while (list($key,$val) = each ($data))
				if ($key && $val)
					Sql_query("replace into $tables[user_attribute] (attributeid,userid,value) values(".$key.",$userid,".$val.")");
		}
  }
  return 1;
}