Аналіз та дослідження зв’язків між вузлами соціальної мережі в Інтернеті

Основні типи соціальних мереж, їх класифікація, характеристики та напрями застосування. Аналіз різноманітних математичних теорій, що використовуються для дослідження соціальних мереж. Психологічні аспекти користування онлайновими мережами в Інтернеті.

Рубрика Программирование, компьютеры и кибернетика
Вид дипломная работа
Язык украинский
Дата добавления 02.12.2014
Размер файла 3,0 M

Отправить свою хорошую работу в базу знаний просто. Используйте форму, расположенную ниже

Студенты, аспиранты, молодые ученые, использующие базу знаний в своей учебе и работе, будут вам очень благодарны.

foreach ($this->params as $key => $value)

{

$this->_check_param($key);

}

}

$this->_parse_query();

$this->_inner_execute();

if (config::get('debug_mode'))

{

$span = microtime(true) - $start_time;

tracer::add('db', array('query' => $this->query, 'timespan' => $span, 'alias' => $this->db_alias, 'operation' => ''));

$span = sprintf('%.1f ms', $span * 1000);

log::sql("$this->db_alias, $span, $this->query", $start_time, microtime(true));

if ( config::get('SQL_DEBUG_IN_FLOW') || db::$debug_in_flow)

{

echo $this->query . "<br/>";

}

}

if ( config::get('db_profiler') )

{

$queries = (array)cache::get('db_profiler_queries');

$queries[$this->statement] += 1;

cache::set( $queries, 60*60*24*30, 'db_profiler_queries' );

}

return $this->query_handle;

}

public function fetch_all()

{

$rows = array();

while ($row = mysql_fetch_assoc($this->query_handle))

{

$rows[] = $row;

}

return $rows;

}

public function fetch_cols()

{

$rows = array();

while ($a = mysql_fetch_row($this->query_handle))

{

$rows[] = $a[0];

}

return $rows;

}

function _inner_execute()

{

$this->query_handle = mysql_query($this->query, $this->db_handle);

if (!$this->query_handle)

{

$this->error_code = mysql_errno($this->db_handle);

$this->error_info = mysql_error($this->db_handle);

$this->db->error_code = $this->error_code;

$this->db->error_info = $this->error_info;

$log_line = $this->get_error_line($this->db_alias);

throw new Exception('SQL Error. ' . $log_line);

}

}

function _cast_values()

{

foreach ($this->params as $key => $value)

{

switch ($this->param_types[$key])

{

case SQL_PARAM_INT :

$this->paramsTemp[$key] = $this->sqlInteger($this->params[$key]);

break;

case SQL_PARAM_ARRAY_INT :

if (!is_array($this->params[$key]))

{

trigger_error('Error cast values. Parameter must be an array. ' . $this->statement, E_USER_ERROR);

}

foreach ($this->params[$key] as $_key => $_value)

{

$this->paramsTemp[$key][$_key] = $this->sqlInteger($this->params[$key][$_key]);

}

if (count($this->paramsTemp[$key]) > 0)

{

$this->paramsTemp[$key] = implode(',', $this->paramsTemp[$key]);

}

break;

case SQL_PARAM_ARRAY_STR :

if (!is_array($this->params[$key]))

{

die('Error cast values. Parameter must be an array');

}

$this->paramsTemp[$key] = array();

foreach ($this->params[$key] as $_key => $_value)

{

$this->paramsTemp[$key][$_key] = "'" . $this->sqlString($this->params[$key][$_key]) . "'";

}

if (count($this->paramsTemp[$key]) > 0)

{

$this->paramsTemp[$key] = implode(',', $this->paramsTemp[$key]);

}

break;

case SQL_PARAM_MATCH :

$to_encode = array("-","~","*","+","<",">","(",")");

$encoded = array("\-","\~","\*","\+","\<","\>","\(","\)");

$dummyArray = split(" ", trim(str_replace($to_encode, $encoded, $this->sqlString($this->params[$key]))));

$this->paramsTemp[$key] = "'+".implode("* +", $dummyArray)."*'";

break;

case SQL_PARAM_STR :

default :

if (isset ($this->paramLengths[$key]))

{

$this->paramsTemp[$key] = mb_substr($this->params[$key], 0, $this->paramLengths[$key], 'UTF-8');

}

else

{

$this->paramsTemp[$key] = $this->params[$key];

}

$this->paramsTemp[$key] = is_int($this->paramsTemp[$key]) ? $this->paramsTemp[$key] : "'" . $this->sqlString($this->paramsTemp[$key]) . "'";

break;

}

}

}

function errorCode()

{

return $this->errorCode;

}

function error_info()

{

return $this->errorInfo;

}

function get_error_line($db_alias)

{

if (!isset($this->db->db_params[$db_alias]['host']))

{

$host = 'undefined host';

}

else

{

$host = $this->db->db_params[$db_alias]['host'];

}

if (!isset($this->db->db_params[$db_alias]['db']))

{

$db = 'undefined db';

}

else

{

$db = $this->db->db_params[$db_alias]['db'];

}

$query = str_replace(array ("\n","\r","\t"), ' ', $this->query);

return date('Y-m-d H:i:s') . ' : [MySQL - ERROR] ' .

mysql_errno($this->db_handle) . " triggered by [" .

basename($_SERVER['PHP_SELF']) . " | " .

$operation . $db_alias."/".$host . "/" . $db . " | ". $query . " ] : " . mysql_error($this->db_handle) . "\n\n";

}

function sqlString($string, $nonDB = false)

{

if (get_magic_quotes_gpc())

{

$string = stripslashes($string);

}

return mysql_real_escape_string($string) ;

}

function sqlInteger($i, $isNegative = false)

{

$isNegative = $i < 0;

if ( $isNegative )

{

return (int)$i;

} else

{

return abs((int)$i);

}

}

}

class log

{

public static $logs = array();

public static $files = array();

public static $enable = true;

public static function enabled()

{

return config::get('log_enabled');

}

public static function msg($msg)

{

$tmp['msg'] = $msg;

return self::log_data(__FUNCTION__, $tmp);

}

public static function err($errno, $errstr = '', $errfile = '', $errline = '', $errcontext = '')

{

if (func_num_args() == 1)

{

$errstr = $errno;

}

$tmp['msg'] = $errstr;

return self::log_data(__FUNCTION__, $tmp);

}

public static function exc($e)

{

$tmp['msg'] = $e->getMessage();

$tmp['file'] = $e->getFile();

$tmp['line'] = $e->getLine();

$tmp['trace'] = $e->getTraceAsString();

return self::log_data(__FUNCTION__, $tmp);

}

public static function sql($msg)

{

$msg = str_replace("\n", " ", $msg);

$msg = str_replace("\t", " ", $msg);

$msg = str_replace(" ", " ", $msg);

self::write2file('sql', $msg);

}

public static function show($type = '')

{

$str = '';

if (!$type)

{

$tmp = self::$logs;

}

else

{

$tmp[$type] = self::$logs[$type];

}

foreach ($tmp as $type => $data)

{

if (!$data)

{

continue;

}

$str .= "<fieldset style=\"font-size:14px; border:1px solid #ccc; clear:both;\">\n<legend>".strtoupper($type)."</legend>\n<pre>\n";

foreach ($data as $d)

{

$str .= var_export($d, true);

}

$str .= "</pre>\n</fieldset>\n";

}

echo $str;

}

public static function write2file($type, $str)

{

if ( !self::enabled() )

{

return false;

}

$str .= "\n";

$files = config::get('log_files');

if ( !$fp = @fopen(self::$files[$type], 'a+') )

{

return;

}

fwrite($fp, $str);

fclose($fp);

}

public static function dump2file()

{

if ( !self::enabled() )

{

return false;

}

foreach (self::$logs as $type => $data)

{

if (!$data)

{

continue;

}

$files = config::get('log_files');

$fp = @fopen(self::$files[$type], 'a+');

if (!$fp)

{

@fclose($fp);

continue;

}

$str = '';

foreach (self::$logs[$type] as $data)

{

$str .= "MSG: ".$data['msg']."\n";

if (isset($data['time']))

{

$str .= "TIME: ".$data['time']."\n";

}

if (isset($data['file']))

{

$str .= "FILE: ".$data['file']."\n";

}

if (isset($data['line']))

{

$str .= "LINE: ".$data['line']."\n";

}

if (isset($data['trace']))

{

$str .= "TRACE: ".$data['trace']."\n";

}

$str .= "DATE: ".$data['date']."\n";

$str .= "URI: ".$data['uri']."\n";

$str .= "UID: ".$data['uid']."\n\n";

}

fwrite($fp, $str);

fclose($fp);

}

}

private static function log_data($type, $data)

{

if ( !self::$enable )

{

return;

}

if (!isset($data['msg']) || !$data['msg'])

{

$data['msg'] = 'No message specified!';

}

if (!isset($data['date']))

{

$data['date'] = date('Y-m-d H:i:s');

}

if (!isset($data['uri']) && isset($_SERVER['REQUEST_URI']))

{

$data['uri'] = $_SERVER['REQUEST_URI'];

}

if (!isset($data['uid']) && isset($GLOBALS['moifakultet_user_ID']))

{

$data['uid'] = $GLOBALS['moifakultet_user_ID'];

}

self::$logs[$type][] = $data;

return true;

}

}

class tracer

{

public static $enable = true;

private $trace = array();

public static function get_instance()

{

static $instance = null;

if (!$instance)

{

$instance = new tracer();

}

return $instance;

}

public static function add($class, $data)

{

if (self::$enable)

{

self::get_instance()->add_entry($class, $data);

}

}

public static function get($class)

{

return self::get_instance()->get_trace($class);

}

public function add_entry($class, $data)

{

if (isset($this->trace[$class]))

{

$this->trace[$class][] = $data;

}

else

{

$this->trace[$class] = array($data);

}

}

public function get_trace($class)

{

return $this->trace[$class];

}

}

Размещено на Allbest.ru


Подобные документы

Работы в архивах красиво оформлены согласно требованиям ВУЗов и содержат рисунки, диаграммы, формулы и т.д.
PPT, PPTX и PDF-файлы представлены только в архивах.
Рекомендуем скачать работу.