function exception($e) { $v = new View('exception'); $v->e = $e; _log($e->getMessage() . ' ' . $e->getFile()); die($v); }
/** * Performs the import task. */ public function perform() { // Set current user for this long running job. // Zend_Registry::get('bootstrap')->bootstrap('Acl'); $memoryLimit = (int) get_option('oai_pmh_static_repository_memory_limit'); if ($memoryLimit) { ini_set('memory_limit', $memoryLimit); } $folder = $this->_getFolder(); if (empty($folder)) { throw new UnexpectedValueException(__('Unable to process folder #%d, it does not exist.', $this->_folderId)); } // Resent jobs can remain queued after all the items themselves have // been deleted. Skip if that's the case. if ($folder->status == OaiPmhStaticRepository::STATUS_DELETED) { _log('[OaiPmhStaticRepository] ' . __('The folder for uri "%s" (# %d) was deleted prior to running this job.', $folder->uri, $folder->id), Zend_Log::NOTICE); return; } try { $folder->process($this->_processType); } catch (Exception $e) { $message = $e->getMessage(); $folder->setStatus(OaiPmhStaticRepository::STATUS_ERROR); $folder->addMessage($message, OaiPmhStaticRepository::MESSAGE_CODE_ERROR); _log('[OaiPmhStaticRepository] ' . __('Error when processing folder "%s" (#%d): %s', $folder->uri, $folder->id, $message), Zend_Log::ERR); } }
/** * 连接数据库方法 * @access public */ public function connect($config = '', $linkNum = 0) { if (!isset($this->linkID[$linkNum])) { if (empty($config)) { $config = $this->config; } try { if (empty($config['dsn'])) { $config['dsn'] = $this->parseDsn($config); } if (version_compare(PHP_VERSION, '5.3.6', '<=')) { //禁用模拟预处理语句 $this->options[PDO::ATTR_EMULATE_PREPARES] = false; } if (C('CONNECT_POOL') === true) { _log($options, 'connect', 'Think\\Db\\Lite', 'INFO'); $this->linkID[$linkNum] = new \pdo_connect_pool(array('master' => array('data_source' => $config['dsn'], 'username' => $config['username'], 'pwd' => $config['password']))); } else { $this->linkID[$linkNum] = new PDO($config['dsn'], $config['username'], $config['password'], $this->options); } } catch (\PDOException $e) { E($e->getMessage()); } } return $this->linkID[$linkNum]; }
public function import() { if (!$this->record) { $this->record = new ExhibitPageBlock(); } $this->record->page_id = $this->responseData['page_id']; $this->record->layout = $this->responseData['layout']; $this->record->text = $this->responseData['text']; $this->record->order = $this->responseData['order']; $this->record->options = json_encode($this->responseData['options']); try { $this->record->save(true); $this->addOmekaApiImportRecordIdMap(); } catch (Exception $e) { _log($e); } $attachmentAdapter = new ApiImport_ResponseAdapter_Omeka_GenericAdapter(null, $this->endpointUri, 'ExhibitBlockAttachment'); $attachmentAdapter->setResourceProperties(array('file' => 'File', 'item' => 'Item')); foreach ($this->responseData['attachments'] as $order => $attachmentData) { $attachmentData['order'] = $order; $attachmentData['block_id'] = $this->record->id; $attachmentAdapter->resetResponseData($attachmentData); $attachmentAdapter->import(); } }
function openvox_hook_sendsms($smsc, $sms_sender, $sms_footer, $sms_to, $sms_msg, $uid = '', $gpid = 0, $smslog_id = 0, $sms_type = 'text', $unicode = 0) { global $plugin_config; _log("enter smsc:" . $smsc . " smslog_id:" . $smslog_id . " uid:" . $uid . " to:" . $sms_to, 3, "openvox_hook_sendsms"); // override plugin gateway configuration by smsc configuration $plugin_config = gateway_apply_smsc_config($smsc, $plugin_config); $sms_footer = stripslashes($sms_footer); $sms_msg = stripslashes($sms_msg); if ($sms_footer) { $sms_msg = $sms_msg . $sms_footer; } if ($plugin_config['openvox']['gateway_host'] && $plugin_config['openvox']['gateway_port'] && $sms_to && $sms_msg) { $query_string = "username="******"&password="******"&phonenumber=" . urlencode($sms_to) . "&message=" . urlencode($sms_msg) . "&report=JSON&smslog_id=" . $smslog_id; $url = 'http://' . $plugin_config['openvox']['gateway_host'] . ":" . $plugin_config['openvox']['gateway_port'] . '/sendsms?' . $query_string; _log("url:[" . $url . "]", 3, "openvox outgoing"); $resp = json_decode(file_get_contents($url), true); $data = $resp['report'][0][0][0]; $data['message'] = $resp['message']; _log('response result:' . $data['result'] . ' port:' . $data['port'] . ' to:' . $data['phonenumber'] . ' time:' . $data['time'], 3, 'openvox_hook_sendsms'); if ($data['result'] == 'success') { $p_status = 1; dlr($smslog_id, $uid, $p_status); } else { $p_status = 2; dlr($smslog_id, $uid, $p_status); } } return TRUE; }
/** * Passed a file name, it will initilize the zoomify and cut the tiles. * * @param filename of image */ public function createTiles($filename) { require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'Zoomify' . DIRECTORY_SEPARATOR . 'Zoomify.php'; // Tiles are built in-place, in a subdir of the original image folder. // TODO Add a destination path to use local server path and to avoid move. $originalDir = FILES_DIR . DIRECTORY_SEPARATOR . 'original' . DIRECTORY_SEPARATOR; list($root, $ext) = $this->getRootAndExtension($filename); $sourcePath = $originalDir . $root . OpenLayersZoom_Creator::ZOOM_FOLDER_EXTENSION; $zoomify = new Zoomify($originalDir); $zoomify->zoomifyObject($filename, $originalDir); // Move the tiles into their storage directory. if (file_exists($sourcePath)) { // Check if destination folder exists, else create it. $destinationPath = $this->getZDataDir($filename); if (!is_dir(dirname($destinationPath))) { $result = mkdir(dirname($destinationPath), 0755, true); if (!$result) { $message = __('Impossible to create destination directory: "%s" for file "%s".', $destinationPath, basename($filename)); _log($message, Zend_Log::WARN); throw new Omeka_Storage_Exception($message); } } $result = rename($sourcePath, $destinationPath); } }
public function import() { $localElementSet = $this->db->getTable('OmekaApiImportRecordIdMap')->localRecord('ElementSet', $this->responseData['element_set']['id'], $this->endpointUri); //look for a local record, first by whether it's been imported, which is done in construct, //then by the element set name if (!$this->record) { $this->record = $this->db->getTable('Element')->findByElementSetNameAndElementName($localElementSet->name, $this->responseData['name']); } if (!$this->record) { $this->record = new Element(); } //set new value if element set exists and override is set, or if it is brand new if ($this->record->exists() && get_option('omeka_api_import_override_element_set_data') || !$this->record->exists()) { $this->record->description = $this->responseData['description']; $this->record->name = $this->responseData['name']; $this->record->element_set_id = $localElementSet->id; $this->record->order = $this->responseData['order']; $this->record->comment = $this->responseData['comment']; } try { $this->record->save(true); $this->addOmekaApiImportRecordIdMap(); } catch (Exception $e) { _log($e); } }
function _exit() { _log(L_INFO, "Shutting down..."); $icarus = Icarus::getInstance(); if ($icarus->isRunning()) $icarus->end(); exit; }
function addRow() { global $db; _log(__FILE__ . " - line " . __LINE__ . ": Adding row not supported: " . print_r($_REQUEST, TRUE)); exit(0); // flag jQueryGrid that this failed }
/** * Function get response from QB * * @return string * @param object $param * @access public * @version 2013-03-15 */ public function receiveResponseXML($param = '') { $response = simplexml_load_string($param->response); $iteratorID = trim($response->QBXMLMsgsRs->CustomerQueryRs->attributes()->iteratorID); // set new iteratorID requestId($iteratorID); if ($param->ticket == QB_TICKET && isset($response->QBXMLMsgsRs->CustomerQueryRs->CustomerRet)) { $rows = $response->QBXMLMsgsRs->CustomerQueryRs; settype($rows, 'array'); // if list contain only one item row if (isset($rows['CustomerRet']->ListID)) { $rows = array($rows['CustomerRet']); } else { $rows = $rows['CustomerRet']; } $data = array(); foreach ($rows as $i => $r) { settype($r, 'array'); $data[] = array('qb_id' => trim($r['ListID']), 'qb_es' => trim($r['EditSequence']), 'is_active' => trim($r['IsActive']), 'phone' => trim($r['Phone']), 'notes' => trim($r['Notes']), 'fax' => trim($r['Fax']), 'company_name' => trim($r['Name']), 'b_email' => trim($r['Email']), 'b_email_other' => trim($r['Cc']), 'b_phone' => trim($r['AltPhone']), 'b_salutation' => trim($r['Salutation']), 'b_fname' => trim($r['FirstName']), 'b_lname' => trim($r['LastName']), 'b_address' => trim($r['BillAddress']->Addr1), 'b_address2' => trim($r['BillAddress']->Addr2), 'b_address3' => trim($r['BillAddress']->Addr3), 'b_city' => trim($r['BillAddress']->City), 'b_state' => trim($r['BillAddress']->State), 'b_country' => trim($r['BillAddress']->Country), 'b_zip' => trim($r['BillAddress']->PostalCode)); } // echo data into log file _log(print_r($data, 1)); $this->response->receiveResponseXMLResult = '30'; } else { $this->response->receiveResponseXMLResult = '100'; } return $this->response; }
/** * Performs an authentication attempt. * * @return Zend_Auth_Result The result of the authentication. */ public function authenticate() { // Use the parent method to authenticate the user. $result = parent::authenticate(); // Check if user actually authenticated. if ($result->isValid()) { if (get_option('central_auth_email')) { // If user matching is by email, create email address. $lookup = $this->getUsername() . '@' . get_option('central_auth_email_domain'); // Lookup the user by their email address in the user table. $user = get_db()->getTable('User')->findByEmail($lookup); } else { // Otherwise use the username. $lookup = $this->getUsername(); // Lookup the user by their username in the user table. $user = get_db()->getTable('User')->findBySql('username = ?', array($lookup), true); } // If the user was found and active, return success. if ($user && $user->active) { return new Zend_Auth_Result(Zend_Auth_Result::SUCCESS, $user->id); } // Return that the user does not have an active account. return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND, $lookup, array(__('User matching "%s" not found.', $lookup))); } // Otherwise, log messages to error log. $messages = $result->getMessages(); _log('CentralAuth_LdapAdapter: ' . implode("\n", $messages), Zend_Log::ERR); // Return the parent's result with error message meant for user. return new Zend_Auth_Result($result->getCode(), $result->getIdentity(), array($messages[0])); }
public function import() { if (!$this->record) { $this->record = new $this->recordType(); } $this->setFromResponseData(); // Rewrite required_element_ids and required_multielement_ids to // make sure they use the local ids. $requiredElementIds = json_decode($this->record->required_element_ids, true); $localRequiredElementIds = array(); foreach ($requiredElementIds as $id) { // data for getLocalResourceId is an array $data = array('id' => $id); $localRequiredElementIds[] = $this->getLocalResourceId($data, 'Element'); } $this->record->required_element_ids = json_encode($localRequiredElementIds); $requiredMultiElementIds = json_decode($this->record->require_multielement_ids, true); $localRequiredMultiElementIds = array(); foreach ($requiredMultiElementIds as $id) { // data for getLocalResourceId is an array $data = array('id' => $id); $localRequiredMultiElementIds[] = $this->getLocalResourceId($data, 'UserProfilesMultiElement'); } $this->record->required_multielement_ids = json_encode($localRequiredMultiElementIds); try { $this->record->save(true); $this->addOmekaApiImportRecordIdMap(); } catch (Exception $e) { _log($e); } return $this->record; }
/** * Build the form. */ public function init() { parent::init(); $this->setMethod('post'); $this->setAttrib('id', 'datastream-form'); // Server. $this->addElement('select', 'server', array('label' => __('Server'), 'description' => __('Select a Fedora server.'), 'multiOptions' => $this->getServersForSelect())); // PID. $this->addElement('text', 'pid', array('label' => __('PID'), 'description' => __('Enter the PID of the Fedora resource.'), 'size' => 40)); // Datastream. $this->addElement('multiselect', 'dsids', array('label' => __('Datastreams'), 'description' => __('Choose one or more datastreams.'), 'attribs' => array('size' => 20), 'multiOptions' => array())); // Import. $this->addElement('checkbox', 'import', array('label' => 'Import now?', 'description' => 'Import Fedora data when the Item is saved.')); // Query datastreams uri. $this->addElement('hidden', 'datastreams-uri', array('value' => url('fedora-connector/datastreams'))); /************************************************************ *REVISIONS * Ver Date Author Description * -------- ---------- -------------- ---------------------- * 1.0 09/02/2015 mrs175 1. added try catch blocks ************************************************************/ // Saved dsid. try { $this->addElement('hidden', 'saved-dsids'); } catch (Exception $e) { _log($e->getMessage()); } try { $this->addDisplayGroup(array('server', 'pid', 'dsids', 'import', 'datastreams-uri', 'saved-dsids'), 'fedora'); } catch (Exception $e) { _log($e->getMessage()); } }
function s_ajax_page_save_log() { if (LOG_DEBUG_INFO) { $debuglog_str = dflush_str(); _log("[[ Ajax info ]]\n\n{$debuglog_str}\n\n"); } }
/** * Import the Dublin Core Metadata stored in the descProperties datastream * * @param Omeka_Record $object The Fedora object record. * @param string $dsid The datastream ID to import. */ public function import($object, $dsid) { //Gets the url to the item's datastream content (ex: /fedora/objects/abc:defg890/datastreams/descMetadata/content) $url = $object->getMetadataUrl($dsid); $descMetadataContent = file_get_contents($url); //these are the only metadata types in the datastream $CPHMetadataTypes = explode(' ', 'Title Creator Subject Description Publisher Contributor Type Format Identifier Language Relation Rights'); $elements = $this->db->getTable('Element')->findBySet('Dublin Core'); $itemID = $object->getItem()->id; //save datastream element texts foreach ($elements as $element) { //current element is one of the types in the datastream if (in_array($element->name, $CPHMetadataTypes, true)) { $elementName = strtolower($element->name) . '> "'; $start = strpos($descMetadataContent, $elementName); $end = strpos($descMetadataContent, '" .', $start); $elementNameLength = strlen($elementName); $elementText = substr($descMetadataContent, $start + $elementNameLength, $end - $start - $elementNameLength); $checkIfEmpty = trim($elementText); //only save the element if it has content if (!empty($checkIfEmpty)) { try { $this->saveElementText($itemID, $element->id, $elementText); } catch (Exception $e) { _log($e->getMessage()); } } } } }
/** * @param string $pContent le contenu à afficher */ public function beforeDisplay(&$pContent) { $elapsedTime = $this->_timer->stop(); switch ($this->config->trigger) { case 'url': if (CopixRequest::get('SpeedView') == 'show') { $this->_speedprocess = true; } break; case 'display': $this->_speedprocess = true; break; } if ($this->_speedprocess) { switch ($this->config->target) { case 'comment': $pContent = str_replace('<head>', '<head><!-- ' . $elapsedTime . ' --> ', $pContent); break; case 'display': $pContent = str_replace('</body>', $elapsedTime . '</body>', $pContent); break; case 'log': _log($elapsedTime, 'speedview', CopixLog::INFORMATION); } } }
public function loadConfig() { //todo fix empty config caching $cache = new \CPHPCache(); $cacheFile = $_SERVER['DOCUMENT_ROOT'] . "/bitrix/cache/" . $cache->GetPath(__CLASS__); // проверяем, обновлялся ли конфиг $cacheWritten = filemtime($cacheFile); $configWritten = filemtime($this->configFile); // устаревший кеш или неудачно начатый кеш перезаписываем if ($configWritten > $cacheWritten || !$cache->InitCache(self::TTL, __CLASS__, '/')) { $cache->Clean(__CLASS__, '/'); try { parent::loadConfig(); if ($cache->StartDataCache(self::TTL, __CLASS__, '/')) { $cache->EndDataCache(array('config' => $this->config)); } else { _log('Caching failed', 'widgets'); } } catch (Exception $e) { _log('loading config error: ' . $e->getMessage(), 'widgets'); } } else { $vars = $cache->GetVars(); $this->config = $vars['config']; } }
/** * Searches Europeana. */ public function searchAction() { $records = array(); $totalResults = 0; $errorMessage = null; $searchParams = $this->getApiSearchParams(); if (!empty($searchParams['query'])) { $response = $this->getApiSearchResponse($searchParams); if ($response['success']) { if ($response['itemsCount'] > 0) { foreach ($response['items'] as $item) { $er = new EuropeanaRecord(); $er->setArray($item); $records[] = $er; } } $totalResults = $response['totalResults']; if ($totalResults) { Zend_Registry::set('pagination', array('page' => $this->getCurrentPage(), 'per_page' => $searchParams['rows'], 'total_results' => $totalResults)); } } else { $errorMessage = $response['error']; _log("Europeana API error: " . $errorMessage, Zend_Log::ERR); } } $this->view->assign(array('query' => $this->getParam('q'), 'records' => $records, 'totalResults' => $totalResults, 'error' => $errorMessage)); }
function callURL($URL, $encodedRequest) { $output = ""; _log(__FILE__ . ":" . __LINE__ . " URL call: " . $URL . " Data: " . $encodedRequest); try { // create curl resource $ch = curl_init(); // set url curl_setopt($ch, CURLOPT_URL, $URL); curl_setopt($ch, CURLOPT_POSTFIELDS, $encodedRequest); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_POST, 1); //return the transfer as a string curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 60); // $output contains the output string $output = curl_exec($ch); // close curl resource to free up system resources curl_close($ch); } catch (Exception $e) { echo $e->getCode() . ": " . $e->getMessage() . "<br />"; echo "cURL error: " . curl_error($ch) . "<br />"; _log(__FILE__ . ":" . __LINE__ . "cURL error: " . curl_error($ch)); return null; } // echo "cURL call returned: -->" . $output . " <--<br />"; return $output; }
/** * * Check if all the parts exist, and * gather all the parts of the file together * @param string $dir - the temporary directory holding all the parts of the file * @param string $fileName - the original file name * @param string $chunkSize - each chunk size (in bytes) * @param string $totalSize - original file size (in bytes) */ function createFileFromChunks($temp_dir, $fileName, $chunkSize, $totalSize) { // count all the parts of this file $total_files = 0; foreach (scandir($temp_dir) as $file) { if (stripos($file, $fileName) !== false) { $total_files++; } } // check that all the parts are present // the size of the last part is between chunkSize and 2*$chunkSize if ($total_files * $chunkSize >= $totalSize - $chunkSize + 1) { // create the final destination file if (($fp = fopen('../files/' . $_POST['course_id'] . '/' . $fileName, 'w')) !== false) { for ($i = 1; $i <= $total_files; $i++) { fwrite($fp, file_get_contents($temp_dir . '/' . $fileName . '.part' . $i)); _log('writing chunk ' . $i); } fclose($fp); } else { echo 'cannot create the destination file'; return false; } // rename the temporary directory (to avoid access from other // concurrent chunks uploads) and than delete it if (rename($temp_dir, $temp_dir . '_UNUSED')) { rrmdir($temp_dir . '_UNUSED'); } else { rrmdir($temp_dir); } } }
public function import() { if ($this->record && $this->record->exists()) { //already mapped return; } //try by email address $user = $this->db->getTable('User')->findByEmail($this->responseData['email']); if ($user) { $this->record = $user; } else { $this->record = new User(); foreach ($this->responseData as $key => $value) { if ($key != 'id' && $key != 'external_resources' && $key != 'url') { $this->record->{$key} = $value; } } try { $this->record->save(true); $this->addOmekaApiImportRecordIdMap(); } catch (Exception $e) { _log($e->getMessage()); } } }
function nexmo_hook_sendsms($smsc, $sms_sender, $sms_footer, $sms_to, $sms_msg, $uid = '', $gpid = 0, $smslog_id = 0, $sms_type = 'text', $unicode = 0) { global $plugin_config; _log("enter smsc:" . $smsc . " smslog_id:" . $smslog_id . " uid:" . $uid . " to:" . $sms_to, 3, "nexmo_hook_sendsms"); // override plugin gateway configuration by smsc configuration $plugin_config = gateway_apply_smsc_config($smsc, $plugin_config); $sms_sender = stripslashes($sms_sender); if ($plugin_config['nexmo']['module_sender']) { $sms_sender = $plugin_config['nexmo']['module_sender']; } $sms_footer = stripslashes($sms_footer); $sms_msg = stripslashes($sms_msg); $ok = false; if ($sms_footer) { $sms_msg = $sms_msg . $sms_footer; } if ($sms_sender && $sms_to && $sms_msg) { $unicode = ""; if ($unicode) { if (function_exists('mb_convert_encoding')) { // $sms_msg = mb_convert_encoding($sms_msg, "UCS-2BE", "auto"); $sms_msg = mb_convert_encoding($sms_msg, "UCS-2", "auto"); $unicode = "&type=unicode"; // added at the of query string if unicode } } $query_string = "api_key=" . $plugin_config['nexmo']['api_key'] . "&api_secret=" . $plugin_config['nexmo']['api_secret'] . "&to=" . urlencode($sms_to) . "&from=" . urlencode($sms_sender) . "&text=" . urlencode($sms_msg) . $unicode . "&status-report-req=1&client-ref=" . $smslog_id; $url = $plugin_config['nexmo']['url'] . "?" . $query_string; _log("url:[" . $url . "]", 3, "nexmo outgoing"); // fixme anton // rate limit to 1 second per submit - nexmo rule sleep(1); $resp = json_decode(file_get_contents($url), true); if ($resp['message-count']) { $c_status = $resp['messages'][0]['status']; $c_message_id = $resp['messages'][0]['message-id']; $c_network = $resp['messages'][0]['network']; $c_error_text = $resp['messages'][0]['error-text']; _log("sent smslog_id:" . $smslog_id . " message_id:" . $c_message_id . " status:" . $c_status . " error:" . $c_error_text, 2, "nexmo outgoing"); $db_query = "\n\t\t\t\tINSERT INTO " . _DB_PREF_ . "_gatewayNexmo (local_smslog_id,remote_smslog_id,status,network,error_text)\n\t\t\t\tVALUES ('{$smslog_id}','{$c_message_id}','{$c_status}','{$c_network}','{$c_error_text}')"; $id = @dba_insert_id($db_query); if ($id && $c_status == 0) { $ok = true; $p_status = 1; dlr($smslog_id, $uid, $p_status); } } else { // even when the response is not what we expected we still print it out for debug purposes $resp = str_replace("\n", " ", $resp); $resp = str_replace("\r", " ", $resp); _log("failed smslog_id:" . $smslog_id . " resp:" . $resp, 2, "nexmo outgoing"); } } if (!$ok) { $p_status = 2; dlr($smslog_id, $uid, $p_status); } return $ok; }
/** * 读取Session * @access public * @param string $sessID * @return mixed */ public function read($sessID) { _log($this->prefix . $this->sessionName . $sessID, 'read', 'Session::Memcached', 'INFO'); $sessData = $this->handle->get($this->prefix . $this->sessionName . $sessID); _log($sessData, 'read', 'Session::Memcached', 'T'); $sessData = $this->prefix . '|' . serialize(json_decode($sessData, true)); return $sessData; }
public function indexAction() { //check cli path try { Omeka_Job_Process_Dispatcher::getPHPCliPath(); } catch (RuntimeException $e) { $this->_helper->flashMessenger(__("The background.php.path in config.ini is not valid. The correct path must be set for the import to work."), 'error'); } if (isset($_POST['submit'])) { set_option('omeka_api_import_override_element_set_data', $_POST['omeka_api_import_override_element_set_data']); if (!empty($_POST['api_url'])) { //do a quick check for whether the API is active $client = new Zend_Http_Client(); $client->setUri($_POST['api_url'] . '/site'); $response = json_decode($client->request()->getBody(), true); if (isset($response['message'])) { $this->_helper->flashMessenger(__("The API at %s is not active", $_POST['api_url']), 'error'); } else { $import = new OmekaApiImport(); $import->endpoint_uri = $_POST['api_url']; $import->status = 'starting'; $import->save(); $args = array('endpointUri' => $_POST['api_url'], 'key' => $_POST['key'], 'importId' => $import->id); try { Zend_Registry::get('bootstrap')->getResource('jobs')->sendLongRunning('ApiImport_ImportJob_Omeka', $args); } catch (Exception $e) { $import->status = 'error'; $import->save(); _log($e); } } } if (isset($_POST['undo'])) { $urls = $this->_helper->db->getTable('OmekaApiImport')->getImportedEndpoints(); foreach ($_POST['undo'] as $endpointIndex) { $mapRecords = $this->_helper->db->getTable('OmekaApiImportRecordIdMap')->findBy(array('endpoint_uri' => $urls[$endpointIndex])); foreach ($mapRecords as $record) { $record->delete(); } $imports = $this->_helper->db->getTable('OmekaApiImport')->findBy(array('endpoint_uri' => $urls[$endpointIndex])); foreach ($imports as $import) { $import->delete(); } } } } if (!isset($import)) { $imports = $this->_helper->db->getTable('OmekaApiImport')->findBy(array('sort_field' => 'id', 'sort_dir' => 'd'), 1); if (empty($imports)) { $import = null; } else { $import = $imports[0]; } } $this->view->import = $import; $urls = $this->_helper->db->getTable('OmekaApiImport')->getImportedEndpoints(); $this->view->urls = $urls; }
function _backtrace_files() { $backtrace = debug_backtrace(); foreach ($backtrace as $key => $trace) { if (isset($trace['file'])) { _log($trace['file']); } } }
function inspect() { $VMFilter = function ($k, $v, $o) { if ($v instanceof KernelSettings || $v instanceof NavigationInterface || $v instanceof NavigationLinkInterface || $v instanceof SessionInterface || $v instanceof ServerRequestInterface || $v instanceof DocumentContext || $v instanceof Component) { return '...'; } return true; }; return _log()->getTable([Debug::getType($this->viewModel) => Debug::RAW_TEXT . _log()->getTable($this->viewModel, '', true, true, 2, $VMFilter), is_null($this->props) ? 'Properties' : Debug::getType($this->props) => Debug::RAW_TEXT . _log()->getTable($this->props, '', true, true, 1, ['props', 'component', 'hidden'])], Debug::getType($this)); }
function blocked_hook_sendsms($smsc, $sms_sender, $sms_footer, $sms_to, $sms_msg, $uid = '', $gpid = 0, $smslog_id = 0, $sms_type = 'text', $unicode = 0) { global $plugin_config; _log("enter smsc:" . $smsc . " smslog_id:" . $smslog_id . " uid:" . $uid . " to:" . $sms_to, 3, "blocked_hook_sendsms"); // override plugin gateway configuration by smsc configuration $plugin_config = gateway_apply_smsc_config($smsc, $plugin_config); $p_status = 2; dlr($smslog_id, $uid, $p_status); return TRUE; }
protected function getContributor() { $contributorId = $this->responseData['contributor']['id']; $response = $this->service->contribution_contributors->get($contributorId); if ($response->getStatus() == 200) { $this->contributorData = json_decode($response->getBody(), true); } else { _log($response->getMessage()); } }
function add_directory_to_zip(&$z, $dir, $base_dir = NULL) { global $exclude_files, $exclude_dirs; if (empty($z)) { _die('Error in ZIP Parameter'); } if (is_null($base_dir)) { $base_dir = trim($dir, '/'); $base_dir = trim($base_dir, '\\'); } if (!file_exists($dir)) { _log('dir: ' . $dir . ' does not exist'); return; } foreach (scandir($dir) as $file) { if (in_array($file, array('.', '..'))) { continue; } // check the exclude dirs $continue = false; if (!empty($exclude_dirs)) { foreach ($exclude_dirs as $e_dir) { if (preg_match($e_dir, $dir . DIRECTORY_SEPARATOR . $file)) { $continue = true; } } } if ($continue) { continue; } // check the exclude files $continue = false; if (!empty($exclude_files)) { foreach ($exclude_files as $e_file) { if (preg_match($e_file, $dir . DIRECTORY_SEPARATOR . $file)) { $continue = true; } } } if ($continue) { continue; } if (is_dir($dir . DIRECTORY_SEPARATOR . $file)) { // add add_directory_to_zip($z, $dir . DIRECTORY_SEPARATOR . $file, $base_dir); } elseif (is_readable($dir . DIRECTORY_SEPARATOR . $file)) { // directory for the ZIP file $zDir = str_replace($base_dir, '', $dir); $zDir = trim($zDir, '/'); $zDir = trim($zDir, '\\'); $zDir .= empty($zDir) ? '' : '/'; $z->addFile($dir . DIRECTORY_SEPARATOR . $file, $zDir . $file); } } }
public function perform() { if ($memoryLimit = reports_get_config('memoryLimit')) { ini_set('memory_limit', $memoryLimit); _log("Set memory limit to {$memoryLimit}"); } $fileId = $this->_options['fileId']; $report = $this->_db->getTable('Reports_File')->find($fileId); $generator = $report->getGenerator(); $generator->generate(); $report->save(); }