/**
 * Execute a MySQL query
 *
 * @param	array		$dsn
 * @param	string	$query
 * @return	void	FALSE / array
 */
function myQuery($dsn, $query)
{
    require_once 'DB.php';
    $db =& DB::connect($dsn['DB_dsn'], $dsn['DB_options']);
    //	if (PEAR::isError($db)) {
    if (DB::isError($db)) {
        myLog($db->getMessage() . $db->getUserInfo());
        return false;
    }
    $db->setFetchMode(DB_FETCHMODE_ASSOC);
    // always set utf8
    $result = $db->query('SET NAMES utf8;');
    if (DB::isError($result)) {
        myLog('Query error:' . $result->getMessage());
        return false;
    }
    //	$result = $db->query($query);
    $result = $db->getAll($query);
    if (DB::isError($result)) {
        myLog('Query error: "' . $query . '" -> ' . $result->getMessage());
        return false;
    }
    $db->disconnect();
    return $result;
}
Example #2
0
 /**
  * Create Project on open refine.
  * 
  * @param string $project_name
  * @param string $file_path
  * @return boolean
  */
 function create_project($project_name, $file_path)
 {
     $data = NULL;
     $uri = $this->server . '/command/core/create-project-from-upload';
     myLog("URL=> {$uri}");
     myLog("File Path=> {$file_path}");
     $post_field = array('project-file' => "@{$file_path}", 'project-name' => $project_name);
     $response = $this->send_curl_request($uri, $post_field);
     /* Checking the google refine url */
     $pattern = '`.*?((http)://[\\w#$&+,\\/:;=?@.-]+)[^\\w#$&+,\\/:;=?@.-]*?`i';
     //this regexp finds your url
     if (preg_match_all($pattern, $response, $matches)) {
         $project_url = $matches[1][0];
     }
     //project ID URL
     if (isset($project_url)) {
         $data['project_url'] = $project_url;
         $explode_url = explode('project=', $project_url);
         $data['project_id'] = $explode_url[1];
         return $data;
     } else {
         return FALSE;
     }
 }
Example #3
0
            myLog($descs[$i] . ' ' . ($args[$i] != null ? $args[$i] : '') . ' ' . '(' . intval($i) . ') ' . MDMDevice::getConnectionName($conns[$j]));
            $device = $devices[$j];
            if (USE_SERVER) {
                $device->exec((int) $argv[3], (int) $argv[4], $cmds[$i], 300000, 300000, $args[$i]);
                $resultCode = $device->getResponseCode();
                $resultMsg = $device->getResponseMessage();
                myLog($device->getRawResponse());
                if ($resultCode != 0) {
                    throw new Exception('Command failed: ' . $resultCode . ': ' . $resultMsg);
                }
                if ($responses[$i] != null) {
                    myLog(print_r($device->{$responses}[$i](), true));
                }
            } else {
                $output = array();
                $ret = 0;
                $cmd = '../../bin/mdm_test_device_dslam_huawei_ma5600 ' . intval($conns[$j]) . ' ' . (int) $argv[3] . ' ' . (int) $argv[4] . ' ' . $tgts[$j] . ' user pass ' . intval($cmds[$i]) . ' ' . ($args[$i] != null ? $args[$i] : '');
                myLog($cmd);
                exec($cmd, $output, $ret);
                if ($ret != 0) {
                    throw new Exception('Command returned error.');
                }
                myLog(print_r($output, true));
            }
        }
    }
} catch (Exception $e) {
    myLog('Error: ' . $e->getMessage());
}
myLog('Done.');
Example #4
0
 /**
  * Store or Update migration event type
  * 
  * @param Array   $event_row        row of spreed sheet
  * @param Integer $instantiation_id use to match event instantiation id
  * 
  * @return helper
  */
 private function _store_event_type_migration($event_row, $instantiation_id)
 {
     if (isset($event_row[17]) && !empty($event_row[17])) {
         $event_type = 'migration';
         $event_data['instantiations_id'] = $instantiation_id;
         $event_data['event_types_id'] = $this->instantiation->_get_event_type($event_type);
         if (isset($event_row[17]) && !empty($event_row[17])) {
             $event_data['event_date'] = date('Y-m-d', strtotime(str_replace("'", '', trim($event_row[17]))));
         }
         if (isset($event_row[34]) && !empty($event_row[34])) {
             if ($event_row[34] === 'N' || strtolower($event_row[34]) === 'no') {
                 $event_data['event_outcome'] = 0;
             } else {
                 $event_data['event_outcome'] = 1;
             }
         }
         if (isset($event_row[35]) && !empty($event_row[35])) {
             $event_data['event_note'] = $event_row[35];
         }
         $this->instantiation->_insert_or_update_event($instantiation_id, $event_data['event_types_id'], $event_data);
     } else {
         myLog('No Event Migration info from Spreadsheet');
     }
 }
session_start();
authenticate();
foreach ($_POST as $name => $value) {
    $req[$name] = trim(clean($value, 64));
}
if (isset($req['sub'])) {
    $sql_insert_sub = "INSERT INTO subs (name, created_by_user_id) \n\t\t\tVALUES ('" . $req['sub'] . "', " . $_SESSION['id'] . ")";
    @mysql_query($sql_insert_sub);
    $sql_get_sub_id = "SELECT id FROM subs WHERE name = '" . $req['sub'] . "'";
    $sth_get_sub_id = @mysql_query($sql_get_sub_id);
    $row_get_sub_id = @mysql_fetch_assoc($sth_get_sub_id);
    $sub_id = $row_get_sub_id['id'];
    $sql_get_users = "SELECT id FROM users";
    $sth_get_users = @mysql_query($sql_get_users);
    $sql_insert_ptrs = "INSERT INTO pointers (user_id, sub_id) VALUES ";
    while ($row_get_users = @mysql_fetch_assoc($sth_get_users)) {
        $sql_insert_ptrs .= "(" . $row_get_users['id'] . "," . $sub_id . "), ";
    }
    $sql_insert_ptrs = rtrim($sql_insert_ptrs);
    $sql_insert_ptrs = substr($sql_insert_ptrs, 0, -1);
    if ($sth_insert_ptrs = @mysql_query($sql_insert_ptrs)) {
        incrementStat($_SESSION['id'], 'subs');
        myLog('NEWSUB', $_SESSION['id'], $req['sub']);
        $_SESSION['success'] = "Sub added!";
        header("Location: http://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . "/addsub.php");
        exit;
    }
}
$_SESSION['error'] = "Could not add sub.";
header("Location: http://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . "/addsub.php");
exit;
Example #6
0
<?php

//引用库
define("DAWN_PATH", "F:/xampp/htdocs/txtBlog/DawnPHP/");
include 'DawnPHP/door.php';
//获取数据
$c = Dawn::get('c', 'Index') . 'Controller';
//控制器
$a = Dawn::get('a', 'index');
//动作
$k = Dawn::get('k', 'PHP');
//关键词
$id = Dawn::get('id', '0_0');
//关键词下的页面,由页面序号索引到文件名
//获取完整的url(http://www.cnblogs.com/A-Song/archive/2011/12/14/2288215.html)
$url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
//记录日志
myLog($url);
//实例化控制器
$controller = new $c();
//调用操作
$controller->{$a}($k, $id);
    $sql_insert_ptrs .= "(" . $user_id . ", " . $row_get_subs['id'] . "), ";
}
$sql_insert_ptrs = rtrim($sql_insert_ptrs);
$sql_insert_ptrs = substr($sql_insert_ptrs, 0, -1);
$my_success = @mysql_query($sql_insert_stats);
if (!$my_success) {
    $_SESSION['error'] = 'Database error.';
    header("Location: http://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . "/signup.php");
    exit;
}
$my_success = @mysql_query($sql_insert_prefs);
if (!$my_success) {
    $_SESSION['error'] = 'Database error.';
    header("Location: http://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . "/signup.php");
    exit;
}
$my_success = @mysql_query($sql_insert_ptrs);
if (!$my_success) {
    $_SESSION['error'] = 'Database error.';
    header("Location: http://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . "/signup.php");
    exit;
}
$_SESSION['alias'] = $req['alias'];
$_SESSION['sl'] = DEFAULT_SL;
$_SESSION['logged_in'] = 1;
$_SESSION['id'] = getUserID($req['alias']);
$_SESSION['sub'] = 1;
myLog('NEWUSER', $_SESSION['id']);
myLog('LOGIN', $_SESSION['id']);
header("Location: http://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . "/login.php?new=true");
exit;
<?php

require_once 'lib/utils.php';
require_once 'lib/config.php';
session_start();
authenticate();
$automessage = trim(clean($_POST['automessage'], MAXMSGLENGTH));
$sql_insert_automessage = "INSERT INTO automessages (automessage, user_id, date) VALUES ('" . $automessage . "', " . $_SESSION['id'] . ", NOW())";
if (@mysql_query($sql_insert_automessage)) {
    incrementStat($_SESSION['id'], 'automessages');
    myLog('AUTOMESS', $_SESSION['id']);
    header("Location: http://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . "/automessage.php?success=true");
    exit;
} else {
    header("Location: http://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . "/automessage.php?success=false");
    exit;
}
Example #9
0
function shellsort(array $arr)
{
    $n = myCount($arr);
    $t = myCeil(myLog($n, 2));
    $d = [0, 1];
    for ($i = 2; $i <= $t; $i++) {
        $d[$i] = 2 * $d[$i - 1] + 1;
    }
    $d = myArrayReverse($d);
    foreach ($d as $curIncrement) {
        for ($i = $curIncrement; $i < $n; $i++) {
            $x = $arr[$i];
            $j = $i - $curIncrement;
            while ($j >= 0 && $x < $arr[$j]) {
                $arr[$j + $curIncrement] = $arr[$j];
                $j = $j - $curIncrement;
            }
            $arr[$j + $curIncrement] = $x;
        }
    }
    return $arr;
}
Example #10
0
 /**
  * Process all pending PBCore 1.x files.
  * @param type $folder_id
  * @param type $station_cpb_id
  * @param type $offset
  * @param type $limit 
  */
 function process_xml_file_child($folder_id, $offset = 0, $limit = 100)
 {
     error_reporting(E_ALL);
     ini_set('display_errors', 1);
     $folder_data = $this->cron_model->get_data_folder_by_id($folder_id);
     if ($folder_data) {
         $data_files = $this->cron_model->get_pbcore_file_by_folder_id($folder_data->id, $offset, $limit);
         if (isset($data_files) && !is_empty($data_files)) {
             foreach ($data_files as $d_file) {
                 if ($d_file->is_processed == 0) {
                     $this->cron_model->update_prcoess_data(array("processed_start_at" => date('Y-m-d H:i:s')), $d_file->id);
                     $file_path = '';
                     $file_path = trim($folder_data->folder_path . $d_file->file_path);
                     if (file_exists($file_path)) {
                         $this->import_media_files($file_path);
                         $this->cron_model->update_prcoess_data(array('is_processed' => 1, "processed_at" => date('Y-m-d H:i:s'), 'status_reason' => 'Complete'), $d_file->id);
                     } else {
                         myLog(" Is File Check Issues " . $file_path);
                         $this->cron_model->update_prcoess_data(array('status_reason' => 'file_not_found'), $d_file->id);
                     }
                 }
             }
             unset($data_files);
         } else {
             myLog(" Data files not found ");
         }
     } else {
         myLog(" folders Data not found " . $file_path);
     }
 }
Example #11
0
<?php

session_start();
require_once 'lib/config.php';
require_once 'lib/utils.php';
if (isset($_GET['error']) and $_GET['error'] == 'You are now logged out.') {
    if (isset($_SESSION['id'])) {
        myLog('LOGOUT', $_SESSION['id']);
    }
    $_SESSION['logged_in'] = null;
    unset($_SESSION['logged_in']);
    $_SESSION['alias'] = null;
    unset($_SESSION['alias']);
    $_SESSION['id'] = null;
    unset($_SESSION['id']);
    $_SESSION['sl'] = null;
    unset($_SESSION['sl']);
} else {
    if (isset($_SESSION['id'])) {
        header("Location: http://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . "/main_frames.php?login=true&newscan=true&sub=1");
    }
}
$sql_get_motto = "SELECT motto FROM mottos ORDER BY RAND() LIMIT 1";
$row = @mysql_fetch_assoc(@mysql_query($sql_get_motto));
echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?" . ">";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title><?php 
echo BBSNAME;
Example #12
0
File: xml.php Project: TheHexa1/AMS
 /**
  * Export records from AMS for PBCore and PREMIS and save all the exported records in zip file using BagIt.
  * 
  * @return void
  */
 function export_pbcore()
 {
     @ini_set("max_execution_time", 999999999999.0);
     # unlimited
     @ini_set("memory_limit", "2000M");
     # 2GB
     error_reporting(E_ALL);
     ini_set('display_errors', 1);
     $export_job = $this->export_job->get_export_jobs('pbcore');
     if (count($export_job) > 0) {
         $this->export_job->update_job($export_job->id, array('status' => '1'));
         myLog('Started export for ID =>' . $export_job->id);
         $bag_name = 'ams_export_' . time();
         $bagit_info = array('Source-Organization' => 'WGBH on behalf of the American Archive of Public Broadcasting', 'Organization-Address' => 'Media Library & Archives, One Guest Street, Boston, MA 02135', 'Contact-Name' => 'Casey E. Davis, Project Manager', 'Contact-Phone' => '+1 617-300-5921', 'Contact-Email' => 'info@americanarchive.org ', 'External-Description' => 'The American Archive of Public Broadcasting, a collaboration between WGBH Boston and the Library of Congress, includes millions of records of public television and radio assets contributed by over 100 stations and organizations across the United States.');
         $bagit_lib = new BagIt("{$this->bagit_path}{$bag_name}", TRUE, TRUE, FALSE, $bagit_info);
         $bagit_lib->setHashEncoding('md5');
         $total_size = 0;
         $total_files = 0;
         if ($export_job->query_loop == 0) {
             $export_ids = explode(',', $export_job->export_query);
             foreach ($export_ids as $asset_id) {
                 $this->do_export($asset_id, $total_size, $total_files, $bagit_lib);
             }
         } else {
             for ($i = 0; $i < $export_job->query_loop; $i++) {
                 $query = $export_job->export_query;
                 $query .= ' LIMIT ' . $i * 100000 . ', 100000';
                 $records = $this->export_job->get_csv_records($query);
                 foreach ($records as $value) {
                     $this->do_export($value->id, $total_size, $total_files, $bagit_lib);
                 }
             }
         }
         $bagit_lib->setBagInfoData('Payload-Oxum', $total_size . '.' . $total_files);
         $bagit_lib->setBagInfoData('Bagging-Date', date('Y-m-d'));
         $bagit_lib->setBagInfoData('Bag-Size', sizeFormat($total_size));
         $bagit_lib->update();
         $bagit_lib->package("{$this->bagit_path}{$bag_name}", 'zip');
         exec("rm -rf {$this->temp_path}");
         exec("rm -rf {$this->bagit_path}{$bag_name}");
         $this->export_job->update_job($export_job->id, array('status' => '1', 'file_path' => "{$this->bagit_path}{$bag_name}.zip"));
         $user = $this->users->get_user_by_id($export_job->user_id)->row();
         $data['user_profile'] = $this->user_profile->get_profile($export_job->user_id)->row();
         $data['user'] = $user;
         $data['export_id'] = $export_job->id;
         myLog('Sending Email to ' . $user->email);
         send_email($user->email, $this->config->item('from_email'), 'AMS XML Export', $this->load->view('email/export_pbcore', $data, TRUE));
         myLog('email sent successfully ' . $user->email);
     } else {
         myLog('No record availabe for export');
     }
     exit_function();
 }
Example #13
0
<?php

require_once 'lib/utils.php';
session_start();
authenticate();
foreach ($_POST as $name => $value) {
    $req[$name] = trim(clean($value, 255));
}
if (!isset($req['motto']) or $req['motto'] == '') {
    header("Location: http://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . "/motto.php?badmotto=true");
    exit;
}
$req['motto'] = clean($req['motto'], 255);
$sql_put_motto = "INSERT INTO mottos (motto) VALUES ('" . $req['motto'] . "')";
if (@mysql_query($sql_put_motto)) {
    myLog('MOTTO', $_SESSION['id'], $req['motto']);
    incrementStat($_SESSION['id'], 'mottos');
    $_SESSION['success'] = "Motto added!";
    header("Location: http://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . "/motto.php");
    exit;
} else {
    $_SESSION['error'] = "Could not add motto.";
    header("Location: http://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . "/motto.php");
    exit;
}
Example #14
0
<?php

require_once 'lib/utils.php';
session_start();
authenticate();
foreach ($_POST as $name => $value) {
    $req[$name] = trim(clean($value, 255));
}
if (!isset($req['id']) or !isset($req['option']) or hasVoted($_SESSION['id'], $req['id'])) {
    header("Location: http://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . "/voting_vote.php?badvote=true" . "&id=" . $req['id']);
    exit;
}
$sql_tally = "INSERT INTO votes (user_id, topic_id, option_id) SELECT u.id AS user_id, \n\t\tvt.id AS topic_id, vo.id AS option_id FROM users u, voting_topics vt, voting_options vo\n\t\tWHERE u.alias = '" . $_SESSION['alias'] . "' AND vt.id = " . $req['id'] . " AND vo.opt \n\t\t= '" . $req['option'] . "'";
myLog('VOTE', $_SESSION['id'], $req['id']);
if (@mysql_query($sql_tally)) {
    header("Location: http://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . "/voting_vote.php?id=" . $req['id']);
    exit;
} else {
    header("Location: http://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . "/voting_vote.php?badvote=true" . "&id=" . $req['id']);
    exit;
}
Example #15
0
 /**
  * Save Facet Search Values into memcahed.
  * 
  * @return 
  */
 function auto_memcached_facets()
 {
     $this->load->library('memcached_library');
     $this->load->model('sphinx_model', 'sphinx');
     $memcached = new StdClass();
     $memcached->ins = 'instantiations_list';
     $memcached->asset = 'assets_list';
     $search_facet = new stdClass();
     $search_facet->state = 'state';
     $search_facet->stations = 'organization';
     $search_facet->status = 'status';
     $search_facet->media_type = 'media_type';
     $search_facet->physical = 'physical_format_name';
     $search_facet->digital = 'digital_format_name';
     $search_facet->generations = 'facet_generation';
     $search_facet->digitized = 'digitized';
     $search_facet->migration = 'migration';
     foreach ($memcached as $index => $index_name) {
         foreach ($search_facet as $columns => $facet) {
             $result = $this->sphinx->facet_index($facet, $index_name, $columns);
             if (in_array($facet, array('media_type', 'physical_format_name', 'digital_format_name', 'facet_generation'))) {
                 $make_facet = array();
                 foreach ($result['records'] as $_row) {
                     $exploded_facet = explode('___', $_row[$facet]);
                     foreach ($exploded_facet as $single_value) {
                         if (isset($make_facet[trim($single_value)])) {
                             $make_facet[trim($single_value)] = $make_facet[trim($single_value)] + $_row['@count'];
                         } else {
                             $make_facet[trim($single_value)] = $_row['@count'];
                         }
                     }
                 }
                 $final_facet = array();
                 foreach ($make_facet as $_index => $_single_facet) {
                     if ($_index != '(**)' && $_index != '') {
                         $final_facet[] = array($facet => $_index, '@count' => $_single_facet);
                     }
                 }
                 $this->memcached_library->set($index . '_' . $columns, json_encode(sortByOneKey($final_facet, $facet, TRUE)), 36000);
             } else {
                 if (in_array($columns, array('digitized', 'migration'))) {
                     $this->memcached_library->set($index . '_' . $columns, json_encode(sortByOneKey($result['records'], $facet, FALSE)), 36000);
                 } else {
                     if ($columns == 'stations') {
                         $result = $this->sphinx->facet_index($facet, $index_name);
                         $this->memcached_library->set($index . '_' . $columns, json_encode(sortByOneKey($result['records'], $facet)), 36000);
                     } else {
                         $result = $this->sphinx->facet_index($facet, $index_name);
                         $this->memcached_library->set($index . '_' . $columns, json_encode(sortByOneKey($result['records'], $facet, FALSE)), 36000);
                     }
                 }
             }
         }
         myLog("Succussfully Updated {$index_name} Facet Search");
     }
     exit;
 }
Example #16
0
 /**
  * You need to add instantiations.id in an array that you want to update. and then run this script.
  * 
  */
 function update_instantiations_index()
 {
     $instantiation_ids = array(1, 2, 3, 4);
     foreach ($instantiation_ids as $_id) {
         $instantiation = $this->searchd_model->run_query("SELECT id from instantiations WHERE id = {$_id}")->row();
         $instantiation_list = $this->searchd_model->get_ins_index(array($instantiation));
         $new_list_info = make_instantiation_sphnix_array($instantiation_list[0], FALSE);
         $this->sphnixrt->update($this->config->item('instantiatiion_index'), $new_list_info);
         myLog('Instantiation successfully update with id=> ' . $_id);
     }
 }
    exit;
}
$sql_add_topic = "INSERT INTO voting_topics (name, date) VALUES ('" . $req['topic'] . "', NOW())";
if (!@mysql_query($sql_add_topic)) {
    $_SESSION['error'] = "Add topic failed.";
    header("Location: http://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . "/voting_booth.php");
    exit;
}
$sql_get_id = "SELECT id FROM voting_topics WHERE name = '" . $req['topic'] . "'";
$sth_get_id = @mysql_query($sql_get_id);
$row = @mysql_fetch_assoc($sth_get_id);
$opt_id = $row['id'];
$sql_add_options = "INSERT INTO voting_options (topic_id, opt) VALUES ";
for ($i = 1; $i <= 10; $i++) {
    if ($req['o' . $i] != '') {
        $sql_add_options .= "({$opt_id}, '" . $req['o' . $i] . "'), ";
    }
}
$sql_add_options = rtrim($sql_add_options);
$sql_add_options = substr($sql_add_options, 0, -1);
#debug($sql_add_options); exit;
if (@mysql_query($sql_add_options)) {
    myLog('VTOPIC', $_SESSION['id'], $req['topic']);
    $_SESSION['success'] = "Topic added!";
    header("Location: http://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . "/voting_booth.php");
    exit;
} else {
    $_SESSION['error'] = "Add topic failed.";
    header("Location: http://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . "/voting_booth.php");
    exit;
}
Example #18
0
 /**
  * Update assets information from csv that is exported from AMS Refine.
  * 
  * @param string $csv_path complete path of csv
  * 
  * @return
  */
 function update_assets($csv_path, $user_id)
 {
     $records = file($csv_path);
     foreach ($records as $index => $line) {
         if ($index != 0) {
             $exploded_columns = preg_split("/\t/", $line);
             $asset_id = $exploded_columns[51];
             myLog('Asset ID => ' . $asset_id);
             $asset_date_id = $exploded_columns[50];
             $asset_identifier_id = $exploded_columns[49];
             $asset_type_id = $exploded_columns[48];
             $asset_right_id = $exploded_columns[47];
             $asset_annotation_id = $exploded_columns[46];
             $asset_rating_id = $exploded_columns[45];
             $asset_level_id = $exploded_columns[44];
             $asset_coverage_id = $exploded_columns[43];
             $asset_publisher_id = $exploded_columns[42];
             $asset_contributer_id = $exploded_columns[41];
             $asset_creator_id = $exploded_columns[40];
             $asset_genre_id = $exploded_columns[39];
             $asset_subject_id = $exploded_columns[38];
             /* Check and update Subject Start */
             if (!empty($exploded_columns[3])) {
                 $subjects = $this->assets_model->get_subjects_id_by_subject($exploded_columns[3]);
                 if (isset($subjects) && isset($subjects->id)) {
                     $subject_id = $subjects->id;
                 } else {
                     $subject_d['subject'] = $exploded_columns[3];
                     $subject_d['subject_source'] = $exploded_columns[4];
                     $subject_d['subject_ref'] = $exploded_columns[5];
                     $subject_id = $this->assets_model->insert_subjects($subject_d);
                 }
                 if (!empty($asset_subject_id)) {
                     $this->refine_modal->update_asset_subject($asset_id, $asset_subject_id, array('subjects_id' => $subject_id));
                 } else {
                     $subject_data = array('subjects_id' => $subject_id, 'assets_id' => $asset_id);
                     $this->assets_model->insert_assets_subjects($subject_data);
                 }
             }
             /* Check and update Subject End */
             /* Check and update Genre Start */
             if (!empty($exploded_columns[6])) {
                 $asset_genre['assets_id'] = $asset_id;
                 $asset_genre_type = $this->assets_model->get_genre_type($exploded_columns[6]);
                 if (isset($asset_genre_type) && isset($asset_genre_type->id)) {
                     $asset_genre['genres_id'] = $asset_genre_type->id;
                 } else {
                     $asset_genre_d['genre'] = $exploded_columns[6];
                     $asset_genre_d['genre_source'] = $exploded_columns[7];
                     $asset_genre_d['genre_ref'] = $exploded_columns[8];
                     $asset_genre['genres_id'] = $this->assets_model->insert_genre($asset_genre_d);
                 }
                 if (!empty($asset_genre_id)) {
                     $this->refine_modal->update_asset_genre($asset_id, $asset_genre_id, array('genres_id' => $asset_genre['genres_id']));
                 } else {
                     $this->assets_model->insert_asset_genre($asset_genre);
                 }
             }
             /* Check and update Genre Start */
             /* Check and update Creator Start */
             if (!empty($exploded_columns[9])) {
                 $assets_creators_roles_d['assets_id'] = $asset_id;
                 $creator_d = $this->assets_model->get_creator_by_creator_name($exploded_columns[9]);
                 if (isset($creator_d) && isset($creator_d->id)) {
                     $assets_creators_roles_d['creators_id'] = $creator_d->id;
                 } else {
                     $creator_data = array('creator_name' => $exploded_columns[9], 'creator_affiliation' => $exploded_columns[10], 'creator_source' => $exploded_columns[11], 'creator_ref' => $exploded_columns[12]);
                     $assets_creators_roles_d['creators_id'] = $this->assets_model->insert_creators($creator_data);
                 }
                 if (!empty($asset_creator_id)) {
                     $this->refine_modal->update_creator_role($asset_id, $asset_creator_id, array('creators_id' => $assets_creators_roles_d['creators_id']));
                 } else {
                     $this->assets_model->insert_assets_creators_roles($assets_creators_roles_d);
                 }
             }
             /* Check and update Creator End */
             /* Check and update Contributer Start */
             if (!empty($exploded_columns[13])) {
                 $assets_contributer_roles_d['assets_id'] = $asset_id;
                 $contributer_d = $this->assets_model->get_contributor_by_contributor_name($exploded_columns[13]);
                 if (isset($contributer_d) && isset($contributer_d->id)) {
                     $assets_contributer_roles_d['contributors_id'] = $contributer_d->id;
                 } else {
                     $contributer_data = array('contributor_name' => $exploded_columns[13], 'contributor_affiliation' => $exploded_columns[14], 'contributor_source' => $exploded_columns[15], 'contributor_ref' => $exploded_columns[16]);
                     $assets_contributer_roles_d['contributors_id'] = $this->assets_model->insert_contributors($contributer_data);
                 }
                 if (!empty($asset_contributer_id)) {
                     $this->refine_modal->update_contributer_role($asset_id, $asset_contributer_id, array('contributors_id' => $assets_contributer_roles_d['contributors_id']));
                 } else {
                     $this->assets_model->insert_assets_contributors_roles($assets_contributer_roles_d);
                 }
             }
             /* Check and update Contributer End */
             /* Check and update Publisher Start */
             if (!empty($exploded_columns[17])) {
                 $assets_publisher_d['assets_id'] = $asset_id;
                 $publisher_d = $this->assets_model->get_publishers_by_publisher($exploded_columns[17]);
                 if (isset($publisher_d) && isset($publisher_d->id)) {
                     $assets_publisher_d['publishers_id'] = $publisher_d->id;
                 } else {
                     $publisher_data = array('publisher' => $exploded_columns[17], 'publisher_affiliation' => $exploded_columns[18], 'publisher_ref' => $exploded_columns[19]);
                     $assets_publisher_d['publishers_id'] = $this->assets_model->insert_publishers($publisher_data);
                 }
                 if (!empty($asset_publisher_id)) {
                     $this->refine_modal->update_publisher_role($asset_id, $asset_publisher_id, array('publishers_id' => $assets_publisher_d['publishers_id']));
                 } else {
                     $this->assets_model->insert_assets_publishers_role($assets_publisher_d);
                 }
             }
             /* Check and update Publisher End */
             /* Check and update Coverage Start */
             if (!empty($exploded_columns[20])) {
                 $coverage['coverage'] = $exploded_columns[20];
                 $coverage['coverage_type'] = $exploded_columns[21];
                 if (!empty($asset_coverage_id)) {
                     $this->refine_modal->update_asset_coverage($asset_id, $asset_coverage_id, $coverage);
                 } else {
                     $coverage['assets_id'] = $asset_id;
                     $asset_coverage = $this->assets_model->insert_coverage($coverage);
                 }
             }
             /* Check and update Coverage End */
             /* Check and update Audience Level Start */
             if (!empty($exploded_columns[22])) {
                 $asset_audience_level['assets_id'] = $asset_id;
                 $db_audience_level = $this->assets_model->get_audience_level($exploded_columns[22]);
                 if (isset($db_audience_level) && isset($db_audience_level->id)) {
                     $asset_audience_level['audience_levels_id'] = $db_audience_level->id;
                 } else {
                     $audience_level['audience_level'] = $exploded_columns[22];
                     $audience_level['audience_level_source'] = $exploded_columns[23];
                     $audience_level['audience_level_ref'] = $exploded_columns[24];
                     $asset_audience_level['audience_levels_id'] = $this->assets_model->insert_audience_level($audience_level);
                 }
                 if (!empty($asset_level_id)) {
                     $this->refine_modal->update_asset_audience_level($asset_id, $asset_level_id, array('audience_levels_id' => $asset_audience_level['audience_levels_id']));
                 } else {
                     $asset_audience = $this->assets_model->insert_asset_audience($asset_audience_level);
                 }
             }
             /* Check and update Audience Level End */
             /* Check and update Audience Rating Start */
             if (!empty($exploded_columns[25])) {
                 $asset_audience_rating['assets_id'] = $asset_id;
                 $db_audience_rating = $this->assets_model->get_audience_rating($audience_rating['audience_rating']);
                 if (isset($db_audience_rating) && isset($db_audience_rating->id)) {
                     $asset_audience_rating['audience_ratings_id'] = $db_audience_rating->id;
                 } else {
                     $audience_rating['audience_rating'] = $exploded_columns[25];
                     $audience_rating['audience_rating_source'] = $exploded_columns[26];
                     $audience_rating['audience_rating_ref'] = $exploded_columns[27];
                     $asset_audience_rating['audience_ratings_id'] = $this->assets_model->insert_audience_rating($audience_rating);
                 }
                 if (!empty($asset_rating_id)) {
                     $this->refine_modal->update_asset_audience_rating($asset_id, $asset_rating_id, array('audience_ratings_id' => $asset_audience_rating['audience_ratings_id']));
                 } else {
                     $asset_audience_rate = $this->assets_model->insert_asset_audience_rating($asset_audience_rating);
                 }
             }
             /* Check and update Audience Rating End */
             /* Check and update Annotation Start */
             if (!empty($exploded_columns[28])) {
                 $annotation['annotation'] = $exploded_columns[28];
                 $annotation['annotation_type'] = $exploded_columns[29];
                 $annotation['annotation_ref'] = $exploded_columns[30];
                 if (!empty($asset_annotation_id)) {
                     $this->refine_modal->update_annotation_type($asset_id, $asset_annotation_id, $annotation);
                 } else {
                     $annotation['assets_id'] = $asset_id;
                     $asset_annotation = $this->assets_model->insert_annotation($annotation);
                 }
             }
             /* Check and update Annotation End */
             /* Check and update Rights Start */
             if (!empty($exploded_columns[31])) {
                 $rights_summary_d['rights'] = $exploded_columns[31];
                 $rights_summary_d['rights_link'] = $exploded_columns[32];
                 if (!empty($asset_right_id)) {
                     $this->refine_modal->update_right_summary($asset_id, $asset_right_id, $rights_summary_d);
                 } else {
                     $rights_summary_d['assets_id'] = $asset_id;
                     $this->assets_model->insert_rights_summaries($rights_summary_d);
                 }
             }
             /* Check and update Rights End */
             /* Check and update Asset Type Start */
             if (!empty($exploded_columns[33])) {
                 $asset_type_d['assets_id'] = $asset_id;
                 if ($asset_type = $this->assets_model->get_assets_type_by_type($exploded_columns[33])) {
                     $asset_type_d['asset_types_id'] = $asset_type->id;
                 } else {
                     $asset_type_d['asset_types_id'] = $this->assets_model->insert_asset_types(array("asset_type" => $exploded_columns[33]));
                 }
                 if (!empty($asset_type_id)) {
                     $this->refine_modal->update_asset_type($asset_id, $asset_right_id, array('asset_types_id' => $asset_type_d['asset_types_id']));
                 } else {
                     $this->assets_model->insert_assets_asset_types($asset_type_d);
                 }
             }
             /* Check and update Asset Type End */
             /* Check and update Asset Identifier Start */
             if (!empty($exploded_columns[34])) {
                 $identifier_d['identifier'] = $exploded_columns[34];
                 $identifier_d['identifier_source'] = $exploded_columns[35];
                 $identifier_d['identifier_ref'] = $exploded_columns[36];
                 if (!empty($asset_identifier_id)) {
                     $this->refine_modal->update_asset_identifier($asset_id, $asset_identifier_id, $identifier_d);
                 } else {
                     $identifier_d['assets_id'] = $asset_id;
                     $this->assets_model->insert_identifiers($identifier_d);
                 }
             }
             /* Check and update Asset Identifier End */
             /* Check and update Asset Date Start */
             if (!empty($exploded_columns[37])) {
                 $asset_date['asset_date'] = $exploded_columns[37];
                 if (!empty($asset_date_id)) {
                     $this->refine_modal->update_asset_date($asset_id, $asset_date_id, $asset_date);
                 } else {
                     $asset_date['assets_id'] = $asset_id;
                     $this->assets_model->insert_asset_date($asset_date);
                 }
             }
             /* Check and update Asset Date Start */
             $log = array('user_id' => $user_id, 'record_id' => $asset_id, 'record' => 'asset', 'type' => 'refine', 'comments' => 'record updated using refine.');
             $this->audit_trail($log);
             // Update Sphnix Indexes
             $asset_list = $this->searchd_model->get_asset_index(array($asset_id));
             $new_asset_info = make_assets_sphnix_array($asset_list[0], FALSE);
             $this->sphnixrt->update('assets_list', $new_asset_info);
             $instantiations_of_asset = $this->searchd_model->get_ins_by_asset_id($asset_id);
             if (count($instantiations_of_asset) > 0) {
                 foreach ($instantiations_of_asset as $ins_asset) {
                     $instantiation_list = $this->searchd_model->get_ins_index(array($ins_asset->id));
                     $new_list_info = make_instantiation_sphnix_array($instantiation_list[0], FALSE);
                     $this->sphnixrt->update('instantiations_list', $new_list_info);
                 }
             }
             // End Update Sphnix Indexes
         }
     }
 }
Example #19
0
<?php

/*
*  Hello World client
*  Connects REQ socket to tcp://localhost:5555
*  Sends "Hello" to server, expects "World" back
* @author Ian Barber <ian(dot)barber(at)gmail(dot)com>
*/
ini_set("display_errors", true);
$context = new ZMQContext();
//  Socket to talk to server
echo "Connecting to hello world server…\n";
$requester = new ZMQSocket($context, ZMQ::SOCKET_REQ);
$requester->connect("tcp://192.168.1.79:5555");
for ($request_nbr = 0; $request_nbr <= 10; $request_nbr++) {
    printf("Sending request %d…\n", $request_nbr);
    myLog("before send ");
    $requester->send("Hello");
    myLog("after send ");
    $reply = $requester->recv();
    myLog("after rev :" . $reply);
    printf("Received reply %d: [%s]\n", $request_nbr, $reply);
}
function myLog($content, $isObj = false)
{
    if ($isObj) {
        $content = serialize($content);
    }
    $logTxt = fopen(dirname(__FILE__) . "/log.txt", "a+");
    fwrite($logTxt, $content . "\r\n");
}
    case LOOP:
        $sql_get_tagline = "SELECT t.id FROM taglines t, users u WHERE u.last_tagline = t.id AND u.id = " . $_SESSION['id'];
        $sth_get_tagline = @mysql_query($sql_get_tagline);
        if ($sth_get_tagline and @mysql_num_rows($sth_get_tagline) > 0) {
            $row_get_tagline = @mysql_fetch_assoc($sth_get_tagline);
            $tagline = $row_get_tagline['id'];
        } else {
            $sql_get_tagline = "SELECT t.id FROM taglines t WHERE user_id = " . $_SESSION['id'];
            if ($sth_get_tagline and @mysql_num_rows($sth_get_tagline) > 0) {
                $row_get_tagline = @mysql_fetch_assoc($sth_get_tagline);
                $tagline = $row_get_tagline['id'];
            }
        }
        break;
}
if ($tagline) {
    $sql_post = "INSERT INTO messages (sub_id, user_id, message, date, tag_id) VALUES (" . $_SESSION['sub'] . ", " . $_SESSION['id'] . ", '" . $message . "', NOW(), " . $tagline . " )";
} else {
    $sql_post = "INSERT INTO messages (sub_id, user_id, message, date) VALUES (" . $_SESSION['sub'] . ", " . $_SESSION['id'] . ", '" . $message . "', NOW())";
}
if (@mysql_query($sql_post)) {
    incrementStat($_SESSION['id'], 'posts');
    myLog('POST', $_SESSION['id'], $_SESSION['sub']);
    $_SESSION['success'] = "Message posted!";
    header("Location: http://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . "/main.php?newscan=true&current=true&nojump=true&sub=" . $_SESSION['sub']);
    exit;
} else {
    $_SESSION['error'] = "Post failed.";
    header("Location: http://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . "/main.php?newscan=true&current=true&nojump=true&sub=" . $_SESSION['sub']);
    exit;
}
$playback = "";
while (true) {
    myLog("Waiting for incoming connections...");
    $msgsock = socket_accept($sock);
    if ($msgsock === false) {
        myLog("Failed accepting a connection: " . socket_strerror(socket_last_error()));
        break;
    }
    $buf = socket_read($msgsock, 2048, PHP_NORMAL_READ);
    myLog('Received: "' . trim($buf) . '"');
    // Shutdown command
    if (trim($buf) == 'shutdown') {
        myLog("Shutting down.");
        socket_close($msgsock);
        break;
    } else {
        if (trim($buf) == 'playback') {
            myLog("Returning playback: \"{$playback}\"");
            socket_write($msgsock, $playback);
        } else {
            $playback .= trim($buf);
        }
    }
    socket_close($msgsock);
}
myLog("Closing socket.");
socket_close($sock);
function myLog($msg)
{
    echo date("Y-m-d H:i:s") . " {$msg}\n";
}
Example #22
0
 /**
  * Parse XML file for importing.
  * 
  * @param string $path file path
  */
 function parse_xml_file($path, $station_id)
 {
     error_reporting(E_ALL);
     ini_set('display_errors', 1);
     @ini_set("max_execution_time", 999999999999.0);
     myLog($path);
     $file_content = file_get_contents($this->mint_path . 'unzipped/' . $path);
     $xml_string = @simplexml_load_string($file_content);
     unset($file_content);
     $xmlArray = xmlObjToArr($xml_string);
     foreach ($xmlArray['children']['ams:pbcoredescriptiondocument'] as $document) {
         if (isset($document['children'])) {
             $asset_id = $this->assets_model->insert_assets(array("stations_id" => $station_id, "created" => date("Y-m-d H:i:s")));
             myLog('Created Asset ID ' . $asset_id);
             $this->import_asset_info($asset_id, $station_id, $document['children']);
             myLog('Successfully inserted assets info.');
             $this->import_instantiation_info($asset_id, $document['children']);
             myLog('Successfully imported all the information to AMS');
         }
     }
 }
function createResourceAssociation($wsObj, $asso)
{
    //use_soap_error_handler (false);
    $result = "";
    try {
        $response = $wsObj->createResourceAssociation(array('resourceAssociation' => $asso));
        //var_dump($response);
        $result = true;
        myLog("createResourceAssociation OK: " . $asso['role'], 0, "");
    } catch (SoapFault $exception) {
        //var_dump($exception);
        //echo "\n\n\n\n\n\n\n\n\n\n============================================\n\n";
        //echo $exception->faultstring."\n";
        //echo $exception->faultcode."\n";
        //echo $exception->faultcodens."\n";
        //echo $exception->detail->NrfServiceException->reason."\n";
        //echo $exception->faultstring."\n";
        myLog("createResrouceAssociation ErrorSOAP:" . $exception->__toString(), 1, "createResourceAssociation");
        myLog("createResourceAssociation ErrorSOAP:" . $exception->faultstring . " (" . $exception->faultcode . ") " . $exception->detail->NrfServiceException->reason, 0, "createResrouceAssociation");
        //die();
        $result = false;
    }
    return $result;
}
Example #24
0
*/
if (!isset($req['alias']) or !isset($req['password'])) {
    myLog('BADPW', getUserID($req['alias']), $req['password']);
    $_SESSION['error'] = "Bad user name and/or password.";
    header("Location: http://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']));
    exit;
}
$sql_check_password = "******" . $req['alias'] . "'";
$sth_check_password = @mysql_query($sql_check_password);
if ($sth_check_password) {
    $row = @mysql_fetch_assoc($sth_check_password);
    if (md5(crypt($req['password'], substr($req['alias'], 0, 2))) == $row['password']) {
        $_SESSION['alias'] = $req['alias'];
        $_SESSION['id'] = $row['id'];
        $_SESSION['logged_in'] = 1;
        $_SESSION['sl'] = $row['sl'];
        $_SESSION['sub'] = 1;
        incrementStat($row['id'], 'logins');
        myLog('LOGIN', $row['id']);
        header("Location: http://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . "/main_frames.php?login=true&newscan=true&sub=1");
        exit;
    } else {
        myLog('BADPW', getUserID($req['alias']), $req['password']);
        $_SESSION['error'] = "Bad user name and/or password.";
        header("Location: http://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']));
        exit;
    }
}
$_SESSION['error'] = "Bad user name and/or password.";
myLog('BADPW', getUserID($req['alias']), $req['password']);
header("Location: http://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']));
<?php

/*
$dataArray = array (
	'code' => 500,
	'log' => true,
	'description' => 'Votre requête n\'a pu aboutir car une erreur interne au serveur est survenue !',
);
*/
if (!empty($dataArray['log'])) {
    require_once dirname(__FILE__) . '/functions.inc.php';
    myLog($dataArray['code']);
}
// format français
if (setlocale(LC_TIME, 'fr_FR.utf8') === FALSE) {
    die('unable to setlocale()!');
}
$htmlDate = strftime('le %A %d %B %Y, à %H heures %M minutes et %S secondes', time());
$htmlRequesturi = 'http://' . htmlentities($_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'], ENT_QUOTES);
$htmlRemoteAddr = htmlentities($_SERVER['REMOTE_ADDR'], ENT_QUOTES);
if (gethostbyaddr($_SERVER['REMOTE_ADDR']) != $_SERVER['REMOTE_ADDR']) {
    $htmlRemoteAddr .= ' (' . htmlentities(gethostbyaddr($_SERVER['REMOTE_ADDR'])) . ')';
}
$htmlAgent = htmlentities($_SERVER['HTTP_USER_AGENT'], ENT_QUOTES);
$htmlReferer = '-';
if (!empty($_SERVER['HTTP_REFERER'])) {
    // TODO: better cause petable and syntaxe
    $htmlReferer = '<a href="' . $_SERVER['HTTP_REFERER'] . '" title="Revenir à la page de provenance">' . htmlentities($_SERVER['HTTP_REFERER'], ENT_QUOTES) . '</a>';
}
$htmlPost = '';
foreach ($_POST as $k => $v) {
Example #26
0
 /**
  * 
  * @param array $db_instantiation_id
  */
 function update_ins_asset_index($db_instantiation_id)
 {
     $this->_CI->load->library('sphnixrt');
     $this->_CI->load->model('searchd_model');
     $this->_CI->load->helper('sphnixdata');
     $instantiation_list = $this->_CI->searchd_model->get_ins_index(array($db_instantiation_id));
     $new_list_info = make_instantiation_sphnix_array($instantiation_list[0], FALSE);
     myLog('Instantiation Updated');
     $this->_CI->sphnixrt->update('instantiations_list', $new_list_info);
     $asset_list = $this->_CI->searchd_model->get_asset_index(array($instantiation_list[0]->assets_id));
     $new_asset_info = make_assets_sphnix_array($asset_list[0], FALSE);
     $this->_CI->sphnixrt->update('assets_list', $new_asset_info);
 }