protected static function checkFileContent()
 {
     $fileContent = file_get_contents(static::$tmpFilepath);
     // check encoding and convert to utf-8 when necessary
     $detectedEncoding = mb_detect_encoding($fileContent, 'UTF-8, ISO-8859-1, WINDOWS-1252', true);
     if ($detectedEncoding) {
         if ($detectedEncoding !== 'UTF-8') {
             $fileContent = iconv($detectedEncoding, 'UTF-8', $fileContent);
         }
     } else {
         echo 'Zeichensatz der CSV-Date stimmt nicht. Der sollte UTF-8 oder ISO-8856-1 sein.';
         return false;
     }
     //prepare data array
     $tmpData = str_getcsv($fileContent, PHP_EOL);
     array_shift($tmpData);
     $preparedData = [];
     $data = array_map(function ($row) use(&$preparedData) {
         $tmpDataArray = str_getcsv($row, ';');
         $tmpKey = trim($tmpDataArray[0]);
         array_shift($tmpDataArray);
         $preparedData[$tmpKey] = $tmpDataArray;
     }, $tmpData);
     // generate json
     $jsonContent = json_encode($preparedData, JSON_HEX_TAG | JSON_HEX_AMP);
     self::$jsonContent = $jsonContent;
     return true;
 }
Exemplo n.º 2
4
 public function get($limit = 1024)
 {
     header('Content-Type: application/json');
     $dates = json_decode(file_get_contents('hoa://Application/Database/Dates.json'), true);
     echo json_encode(array_slice($dates, 0, $limit));
     return;
 }
Exemplo n.º 3
2
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $path = $input->getArgument('path');
     if (!file_exists($path)) {
         $output->writeln("{$path} is not a file or a path");
     }
     $filePaths = [];
     if (is_file($path)) {
         $filePaths = [realpath($path)];
     } elseif (is_dir($path)) {
         $filePaths = array_diff(scandir($path), array('..', '.'));
     } else {
         $output->writeln("{$path} is not known.");
     }
     $generator = new StopwordGenerator($filePaths);
     if ($input->getArgument('type') === 'json') {
         echo json_encode($this->toArray($generator->getStopwords()), JSON_NUMERIC_CHECK | JSON_UNESCAPED_UNICODE);
         echo json_last_error_msg();
         die;
         $output->write(json_encode($this->toArray($generator->getStopwords())));
     } else {
         $stopwords = $generator->getStopwords();
         $stdout = fopen('php://stdout', 'w');
         echo 'token,freq' . PHP_EOL;
         foreach ($stopwords as $token => $freq) {
             fputcsv($stdout, [utf8_encode($token), $freq]) . PHP_EOL;
         }
         fclose($stdout);
     }
 }
 /**
  * Show the setup wizard
  */
 public function setup_wizard()
 {
     if (empty($_GET['page']) || 'wc-setup' !== $_GET['page']) {
         return;
     }
     $this->steps = array('introduction' => array('name' => __('Introduction', 'woocommerce'), 'view' => array($this, 'wc_setup_introduction'), 'handler' => ''), 'pages' => array('name' => __('Page Setup', 'woocommerce'), 'view' => array($this, 'wc_setup_pages'), 'handler' => array($this, 'wc_setup_pages_save')), 'locale' => array('name' => __('Store Locale', 'woocommerce'), 'view' => array($this, 'wc_setup_locale'), 'handler' => array($this, 'wc_setup_locale_save')), 'shipping_taxes' => array('name' => __('Shipping & Tax', 'woocommerce'), 'view' => array($this, 'wc_setup_shipping_taxes'), 'handler' => array($this, 'wc_setup_shipping_taxes_save')), 'payments' => array('name' => __('Payments', 'woocommerce'), 'view' => array($this, 'wc_setup_payments'), 'handler' => array($this, 'wc_setup_payments_save')), 'next_steps' => array('name' => __('Ready!', 'woocommerce'), 'view' => array($this, 'wc_setup_ready'), 'handler' => ''));
     $this->step = isset($_GET['step']) ? sanitize_key($_GET['step']) : current(array_keys($this->steps));
     $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
     wp_register_script('select2', WC()->plugin_url() . '/assets/js/select2/select2' . $suffix . '.js', array('jquery'), '3.5.2');
     wp_register_script('wc-enhanced-select', WC()->plugin_url() . '/assets/js/admin/wc-enhanced-select' . $suffix . '.js', array('jquery', 'select2'), WC_VERSION);
     wp_localize_script('wc-enhanced-select', 'wc_enhanced_select_params', array('i18n_matches_1' => _x('One result is available, press enter to select it.', 'enhanced select', 'woocommerce'), 'i18n_matches_n' => _x('%qty% results are available, use up and down arrow keys to navigate.', 'enhanced select', 'woocommerce'), 'i18n_no_matches' => _x('No matches found', 'enhanced select', 'woocommerce'), 'i18n_ajax_error' => _x('Loading failed', 'enhanced select', 'woocommerce'), 'i18n_input_too_short_1' => _x('Please enter 1 or more characters', 'enhanced select', 'woocommerce'), 'i18n_input_too_short_n' => _x('Please enter %qty% or more characters', 'enhanced select', 'woocommerce'), 'i18n_input_too_long_1' => _x('Please delete 1 character', 'enhanced select', 'woocommerce'), 'i18n_input_too_long_n' => _x('Please delete %qty% characters', 'enhanced select', 'woocommerce'), 'i18n_selection_too_long_1' => _x('You can only select 1 item', 'enhanced select', 'woocommerce'), 'i18n_selection_too_long_n' => _x('You can only select %qty% items', 'enhanced select', 'woocommerce'), 'i18n_load_more' => _x('Loading more results…', 'enhanced select', 'woocommerce'), 'i18n_searching' => _x('Searching…', 'enhanced select', 'woocommerce'), 'ajax_url' => admin_url('admin-ajax.php'), 'search_products_nonce' => wp_create_nonce('search-products'), 'search_customers_nonce' => wp_create_nonce('search-customers')));
     wp_enqueue_style('woocommerce_admin_styles', WC()->plugin_url() . '/assets/css/admin.css', array(), WC_VERSION);
     wp_enqueue_style('wc-setup', WC()->plugin_url() . '/assets/css/wc-setup.css', array('dashicons', 'install'), WC_VERSION);
     wp_register_script('wc-setup', WC()->plugin_url() . '/assets/js/admin/wc-setup.min.js', array('jquery', 'wc-enhanced-select'), WC_VERSION);
     wp_localize_script('wc-setup', 'wc_setup_params', array('locale_info' => json_encode(include WC()->plugin_path() . '/i18n/locale-info.php')));
     if (!empty($_POST['save_step']) && isset($this->steps[$this->step]['handler'])) {
         call_user_func($this->steps[$this->step]['handler']);
     }
     ob_start();
     $this->setup_wizard_header();
     $this->setup_wizard_steps();
     $this->setup_wizard_content();
     $this->setup_wizard_footer();
     exit;
 }
Exemplo n.º 5
1
 /**
  * @param string $url
  * @return array
  */
 public function oembed($url)
 {
     $embedly = new Embedly();
     $response = $embedly->oembed(['url' => $url]);
     $data = json_decode(json_encode(reset($response)), true);
     return $data;
 }
Exemplo n.º 6
1
function sendPushNotificationToGCM($registration_ids, $message)
{
    $GCM_SERVER_API_KEY = $_ENV["GCM_SERVER_API_KEY"];
    $url = 'https://fcm.googleapis.com/fcm/send';
    $fields = array('registration_ids' => $registration_ids, 'data' => $message);
    // Update your Google Cloud Messaging API Key
    if (!defined('GOOGLE_API_KEY')) {
        define("GOOGLE_API_KEY", $GCM_SERVER_API_KEY);
    }
    $headers = array('Authorization: key=' . GOOGLE_API_KEY, 'Content-Type: application/json');
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));
    $result = curl_exec($ch);
    if ($result === FALSE) {
        die('Curl failed: ' . curl_error($ch));
    }
    curl_close($ch);
    return $result;
}
Exemplo n.º 7
1
function search_ac_init(&$a)
{
    if (!local_channel()) {
        killme();
    }
    $start = x($_REQUEST, 'start') ? $_REQUEST['start'] : 0;
    $count = x($_REQUEST, 'count') ? $_REQUEST['count'] : 100;
    $search = x($_REQUEST, 'search') ? $_REQUEST['search'] : "";
    if (x($_REQUEST, 'query') && strlen($_REQUEST['query'])) {
        $search = $_REQUEST['query'];
    }
    // Priority to people searches
    if ($search) {
        $people_sql_extra = protect_sprintf(" AND `xchan_name` LIKE '%" . dbesc($search) . "%' ");
        $tag_sql_extra = protect_sprintf(" AND term LIKE '%" . dbesc($search) . "%' ");
    }
    $r = q("SELECT `abook_id`, `xchan_name`, `xchan_photo_s`, `xchan_url`, `xchan_addr` FROM `abook` left join xchan on abook_xchan = xchan_hash WHERE abook_channel = %d \n\t\t{$people_sql_extra}\n\t\tORDER BY `xchan_name` ASC ", intval(local_channel()));
    $results = array();
    if ($r) {
        foreach ($r as $g) {
            $results[] = array("photo" => $g['xchan_photo_s'], "name" => '@' . $g['xchan_name'], "id" => $g['abook_id'], "link" => $g['xchan_url'], "label" => '', "nick" => '');
        }
    }
    $r = q("select distinct term, tid, url from term where type in ( %d, %d ) {$tag_sql_extra} group by term order by term asc", intval(TERM_HASHTAG), intval(TERM_COMMUNITYTAG));
    if (count($r)) {
        foreach ($r as $g) {
            $results[] = array("photo" => $a->get_baseurl() . '/images/hashtag.png', "name" => '#' . $g['term'], "id" => $g['tid'], "link" => $g['url'], "label" => '', "nick" => '');
        }
    }
    header("content-type: application/json");
    $o = array('start' => $start, 'count' => $count, 'items' => $results);
    echo json_encode($o);
    logger('search_ac: ' . print_r($x, true));
    killme();
}
Exemplo n.º 8
0
 /**
  * Sending Push Notification
  */
 public function send_notification($registation_ids, $message)
 {
     // include config
     include_once './config.php';
     // Set POST variables
     $url = 'https://android.googleapis.com/gcm/send';
     $fields = array('registration_ids' => $registation_ids, 'data' => $message);
     $headers = array('Authorization: key=' . GOOGLE_API_KEY, 'Content-Type: application/json');
     // Open connection
     $ch = curl_init();
     // Set the url, number of POST vars, POST data
     curl_setopt($ch, CURLOPT_URL, $url);
     curl_setopt($ch, CURLOPT_POST, true);
     curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     // Disabling SSL Certificate support temporarly
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
     curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));
     // Execute post
     $result = curl_exec($ch);
     if ($result === FALSE) {
         die('Curl failed: ' . curl_error($ch));
     }
     // Close connection
     curl_close($ch);
     echo $result;
 }
 /**
  *用户ID方式登录
  */
 public function getQuestionListAction()
 {
     //基础元素,必须参与验证
     $Config['Time'] = abs(intval($this->request->Time));
     $Config['ReturnType'] = $this->request->ReturnType ? $this->request->ReturnType : 2;
     //URL验证码
     $sign = trim($this->request->sign);
     //私钥,以后要移开到数据库存储
     $p_sign = 'lm';
     $sign_to_check = Base_common::check_sign($Config, $p_sign);
     //不参与验证的元素
     //验证URL是否来自可信的发信方
     if ($sign_to_check == $sign) {
         //验证时间戳,时差超过600秒即认为非法
         if (abs($Config['Time'] - time()) <= 600) {
             $QuestionList = $this->oSecurityAnswer->getAll();
             $result = array('return' => 1, 'QuestionList' => $QuestionList);
         } else {
             $result = array('return' => 0, 'comment' => "时间有误");
         }
     } else {
         $result = array('return' => 0, 'comment' => "验证失败,请检查URL");
     }
     if ($Config['ReturnType']) {
         echo json_encode($result);
     } else {
         //			$r = $result['return']."|".iconv('UTF-8','GBK',$result['comment']);;
         //			if($result['return']==1)
         //			{
         //				$r = $r."|".$result['LoginId']."|".$result['adult'];
         //			}
         //			echo $r;
     }
 }
 /**
  * Tests that the serialization of messages works as expected
  */
 public function testSerialization()
 {
     $request = new DummyRequest('type', 'payload');
     $expected = json_encode(['type' => 'type', 'payload' => 'payload']);
     $actual = json_encode($request);
     $this->assertEquals($expected, $actual);
 }
Exemplo n.º 11
0
 /**
  * Execute API Call
  *
  * @param   string $apiCall    API Call
  * @param   string $method     Http Method
  * @param   array  $parameters API call parameters
  *
  * @return array
  */
 public static function makeApiCall($apiCall, $method = 'GET', $parameters = array())
 {
     self::getHttp();
     $apiEndpoint = NenoSettings::get('api_server_url');
     $licenseCode = NenoSettings::get('license_code');
     $response = null;
     $responseStatus = false;
     if (!empty($apiEndpoint) && !empty($licenseCode)) {
         $method = strtolower($method);
         if (method_exists(self::$httpClient, $method)) {
             if ($method === 'get') {
                 if (!empty($parameters)) {
                     $query = implode('/', $parameters);
                     $apiCall = $apiCall . '/' . $query;
                 }
                 $apiResponse = self::$httpClient->{$method}($apiEndpoint . $apiCall, array('Authorization' => $licenseCode));
             } else {
                 $apiResponse = self::$httpClient->{$method}($apiEndpoint . $apiCall, json_encode($parameters), array('Content-Type' => 'application/json', 'Authorization' => $licenseCode));
             }
             /* @var $apiResponse JHttpResponse */
             $data = $apiResponse->body;
             if ($apiResponse->headers['Content-Type'] === 'application/json') {
                 $data = json_decode($data, true);
             }
             $response = $data;
             if ($apiResponse->code == 200) {
                 $responseStatus = true;
             }
         }
     }
     return array($responseStatus, $response);
 }
Exemplo n.º 12
0
 private function xmlToArray($data)
 {
     $data = simplexml_load_string($data);
     $data = json_encode($data);
     $data = json_decode($data, true);
     return $data;
 }
Exemplo n.º 13
0
 public function createDefaultGroup()
 {
     $defaultgroups = json_decode(MONITIS_ADMIN_CONTACT_GROUPS, true);
     $existedGroups = MonitisApi::getContactGroupList();
     // existed monitis groups
     foreach ($defaultgroups as $mType => $groupName) {
         $group = MonitisHelper::in_array($existedGroups, 'id', MonitisConf::$settings['groups'][$mType]['groupId']);
         $alerts = json_decode(MONITIS_NOTIFICATION_RULE, true);
         if ($mType == 'internal') {
             $alerts['minFailedLocationCount'] = null;
         }
         $groupId = $group['id'] ? $group['id'] : 0;
         $notifByTypeGroup = MonitisApiHelper::getNotificationRuleByType($mType, $groupId);
         $alertRulesDefault = $notifByTypeGroup ? $notifByTypeGroup : $alerts;
         if ($group) {
             MonitisConf::$settings['groups'][$mType]['groupId'] = $group['id'];
             MonitisConf::$settings['groups'][$mType]['groupName'] = $group['name'];
             MonitisConf::$settings['groups'][$mType]['alert'] = $alertRulesDefault;
         } else {
             $newGroupName = $groupName;
             $resp = MonitisApi::addContactGroup(1, $newGroupName);
             if ($resp['status'] == 'ok') {
                 MonitisConf::$settings['groups'][$mType]['groupId'] = $resp['data'];
                 MonitisConf::$settings['groups'][$mType]['groupName'] = $newGroupName;
                 MonitisConf::$settings['groups'][$mType]['alert'] = $alertRulesDefault;
             } else {
                 // error
                 return array('status' => 'error', 'msg' => 'Add contact group error ' . $resp['error']);
             }
         }
         // $r = $this->addContacts(ucfirst($mType), MonitisConf::$settings['groups'][$mType]['groupId']);
     }
     MonitisConf::update_settings(json_encode(MonitisConf::$settings));
     return array('status' => 'ok', 'msg' => 'External, internal groups sets success');
 }
Exemplo n.º 14
0
    public function __construct(){
        parent::__construct();
		Language::read('member_store_statistics');
		import('function.statistics');
        import('function.datehelper');
        $model = Model('stat');
        //存储参数
		$this->search_arr = $_REQUEST;
		//处理搜索时间
		if (in_array($this->search_arr['op'],array('price','hotgoods'))){
		    $this->search_arr = $model->dealwithSearchTime($this->search_arr);
    		//获得系统年份
    		$year_arr = getSystemYearArr();
    		//获得系统月份
    		$month_arr = getSystemMonthArr();
    		//获得本月的周时间段
    		$week_arr = getMonthWeekArr($this->search_arr['week']['current_year'], $this->search_arr['week']['current_month']);
    		Tpl::output('year_arr', $year_arr);
    		Tpl::output('month_arr', $month_arr);
    		Tpl::output('week_arr', $week_arr);
		}
        Tpl::output('search_arr', $this->search_arr);
        /**
         * 处理商品分类
         */
        $this->choose_gcid = ($t = intval($_REQUEST['choose_gcid']))>0?$t:0;
        $gccache_arr = Model('goods_class')->getGoodsclassCache($this->choose_gcid,3);
        $this->gc_arr = $gccache_arr['showclass'];
	    Tpl::output('gc_json',json_encode($gccache_arr['showclass']));
		Tpl::output('gc_choose_json',json_encode($gccache_arr['choose_gcid']));
    }
Exemplo n.º 15
0
 public function updateNotice($data = array())
 {
     $update = array('TITLE' => trim($data['TITLE']), 'CONTENT' => json_encode($data['CONTENT']), 'START_DATE' => trim($data['START_DATE']), 'END_DATE' => trim($data['END_DATE']), 'IS_SHOW' => trim($data['IS_SHOW']), 'UPDATE_DATE' => date('Y-m-d H:i:s'));
     $wheres = array('NOTICE_ID' => $data['NOTICE_ID']);
     $this->db->where($wheres)->update('notices', $update);
     return true;
 }
Exemplo n.º 16
0
 private function _format($id, $data, $type)
 {
     switch ($type) {
         case '1':
             // json
             if (CHARSET == 'gbk') {
                 $data = array_iconv($data, 'gbk', 'utf-8');
             }
             return json_encode($data);
             break;
         case '2':
             // xml
             $xml = Loader::lib('Xml');
             return $xml->xml_serialize($data);
             break;
         case '3':
             // js
             Loader::func('dbsource:global');
             ob_start();
             include template_url($id);
             $html = ob_get_contents();
             ob_clean();
             return format_js($html);
             break;
     }
 }
Exemplo n.º 17
0
 public function getJsonLanguages()
 {
     if ($this->languages instanceof stdClass || is_array($this->languages)) {
         return json_encode($this->languages, JSON_UNESCAPED_UNICODE);
     }
     return $this->languages;
 }
Exemplo n.º 18
0
 public function data()
 {
     $courses = LearnHub::all();
     $res = DB::table('LearnHub')->select('category')->groupBy('category')->get();
     $categories = json_encode($res);
     return json_encode([$courses, $res]);
 }
Exemplo n.º 19
0
 protected function initContent()
 {
     $request = $this->getContext()->getRequest();
     $auth = $this->getContext()->getAuth();
     $this->setTitle("Job status");
     $this->setRobots("noindex,nofollow");
     $this->bodyScripts[] = swarmpath("js/job.js");
     $error = $this->getAction()->getError();
     $data = $this->getAction()->getData();
     $html = '';
     if ($error) {
         $html .= html_tag('div', array('class' => 'alert alert-error'), $error['info']);
     }
     if (!isset($data["info"])) {
         return $html;
     }
     $this->setSubTitle('#' . $data["info"]["id"]);
     $project = $data['info']['project'];
     $isOwner = $auth && $auth->project->id === $project['id'];
     $html .= '<h2>' . $data["info"]["nameHtml"] . '</h2>' . '<p><em>Submitted by ' . html_tag('a', array('href' => $project['viewUrl']), $project['display_title']) . ' ' . self::getPrettyDateHtml($data["info"], 'created') . '</em>.</p>';
     if ($isOwner) {
         $html .= '<script>SWARM.jobInfo = ' . json_encode($data["info"]) . ';</script>';
         $action_bar = '<div class="form-actions swarm-item-actions">' . ' <button class="swarm-reset-runs-failed btn btn-info">Reset failed runs</button>' . ' <button class="swarm-reset-runs btn btn-info">Reset all runs</button>' . ' <button class="swarm-delete-job btn btn-danger">Delete job</button>' . '</div>' . '<div class="swarm-wipejob-error alert alert-error" style="display: none;"></div>';
     } else {
         $action_bar = '';
     }
     $html .= $action_bar;
     $html .= '<table class="table table-bordered swarm-results swarm-results-unbound-auth"><thead>' . self::getUaHtmlHeader($data['userAgents']) . '</thead><tbody>' . self::getUaRunsHtmlRows($data['runs'], $data['userAgents'], $isOwner) . '</tbody></table>';
     $html .= $action_bar;
     return $html;
 }
Exemplo n.º 20
0
 public function put($url, $body = null)
 {
     curl_setopt($this->_ch, CURLOPT_CUSTOMREQUEST, 'PUT');
     curl_setopt($this->_ch, CURLOPT_URL, $this->_base_uri . $url);
     curl_setopt($this->_ch, CURLOPT_POSTFIELDS, json_encode($body));
     return json_decode(curl_exec($this->_ch));
 }
 protected function getRequestMessage()
 {
     Json::arrayRecursive($this->request, "urlencode", false);
     $tMessage = json_encode($this->request);
     $tMessage = urldecode($tMessage);
     return $tMessage;
 }
 function ajax_calls($call, $data)
 {
     global $sitepress_settings, $sitepress;
     switch ($call) {
         case 'set_pickup_mode':
             $method = intval($data['icl_translation_pickup_method']);
             $iclsettings['translation_pickup_method'] = $method;
             $sitepress->save_settings($iclsettings);
             if (!empty($sitepress_settings)) {
                 $data['site_id'] = $sitepress_settings['site_id'];
                 $data['accesskey'] = $sitepress_settings['access_key'];
                 $data['create_account'] = 0;
                 $data['pickup_type'] = $method;
                 $icl_query = new ICanLocalizeQuery();
                 $res = $icl_query->updateAccount($data);
             }
             if ($method == ICL_PRO_TRANSLATION_PICKUP_XMLRPC) {
                 wp_clear_scheduled_hook('icl_hourly_translation_pickup');
             } else {
                 wp_schedule_event(time(), 'hourly', 'icl_hourly_translation_pickup');
             }
             echo json_encode(array('message' => 'OK'));
             break;
         case 'pickup_translations':
             if ($sitepress_settings['translation_pickup_method'] == ICL_PRO_TRANSLATION_PICKUP_POLLING) {
                 $fetched = $this->poll_for_translations(true);
                 echo json_encode(array('message' => 'OK', 'fetched' => urlencode('&nbsp;' . sprintf(__('Fetched %d translations.', 'sitepress'), $fetched))));
             } else {
                 echo json_encode(array('error' => __('Manual pick up is disabled.', 'sitepress')));
             }
             break;
     }
 }
Exemplo n.º 23
0
function errorDie($paramError, $paramErrorCode)
{
    $arrayToJs = array();
    $arrayToJs["response"] = $paramError;
    $arrayToJs["response_code"] = $paramErrorCode;
    die(json_encode($arrayToJs));
}
Exemplo n.º 24
0
 /**
  * Return JS configuration of the htmlArea plugins registered by the extension
  *
  * @return string JS configuration for registered plugins
  */
 public function buildJavascriptConfiguration()
 {
     $schema = array('types' => array(), 'properties' => array());
     // Parse configured schemas
     if (is_array($this->configuration['thisConfig']['schema.']) && is_array($this->configuration['thisConfig']['schema.']['sources.'])) {
         foreach ($this->configuration['thisConfig']['schema.']['sources.'] as $source) {
             $fileName = trim($source);
             $absolutePath = GeneralUtility::getFileAbsFileName($fileName);
             // Fallback to default schema file if configured file does not exists or is of zero size
             if (!$fileName || !file_exists($absolutePath) || !filesize($absolutePath)) {
                 $fileName = 'EXT:' . $this->extensionKey . '/Resources/Public/Rdf/MicrodataSchema/SchemaOrgAll.rdf';
             }
             $fileName = $this->getFullFileName($fileName);
             $rdf = file_get_contents($fileName);
             if ($rdf) {
                 $this->parseSchema($rdf, $schema);
             }
         }
     }
     uasort($schema['types'], array($this, 'compareLabels'));
     uasort($schema['properties'], array($this, 'compareLabels'));
     // Insert no type and no property entries
     $languageService = $this->getLanguageService();
     $noSchema = $languageService->sL('LLL:EXT:rtehtmlarea/Resources/Private/Language/Plugins/MicrodataSchema/locallang.xlf:No type');
     $noProperty = $languageService->sL('LLL:EXT:rtehtmlarea/Resources/Private/Language/Plugins/MicrodataSchema/locallang.xlf:No property');
     array_unshift($schema['types'], array('name' => 'none', 'label' => $noSchema));
     array_unshift($schema['properties'], array('name' => 'none', 'label' => $noProperty));
     // Store json encoded array in temporary file
     return 'RTEarea[editornumber].schemaUrl = "' . $this->writeTemporaryFile('schema_' . $this->configuration['language'], 'js', json_encode($schema)) . '";';
 }
Exemplo n.º 25
0
function wsl_watchdog_log_to_database($action_name, $action_args = array(), $user_id = 0, $provider = '')
{
    global $wpdb;
    $sql = "CREATE TABLE IF NOT EXISTS `{$wpdb->prefix}wslwatchdog` ( \n\t\t\t  `id` int(11) NOT NULL AUTO_INCREMENT,\n\t\t\t  `session_id` varchar(50) NOT NULL,\n\t\t\t  `user_id` int(11) NOT NULL,\n\t\t\t  `user_ip` varchar(50) NOT NULL,\n\t\t\t  `url` varchar(450) NOT NULL,\n\t\t\t  `provider` varchar(50) NOT NULL,\n\t\t\t  `action_name` varchar(255) NOT NULL,\n\t\t\t  `action_args` text NOT NULL,\n\t\t\t  `is_connected` int(11) NOT NULL,\n\t\t\t  `created_at` varchar(50) NOT NULL,\n\t\t\t  PRIMARY KEY (`id`) \n\t\t\t)";
    $wpdb->query($sql);
    $wpdb->insert("{$wpdb->prefix}wslwatchdog", array("session_id" => session_id(), "user_id" => $user_id, "user_ip" => $_SERVER['REMOTE_ADDR'], "url" => wsl_get_current_url(), "provider" => $provider, "action_name" => $action_name, "action_args" => json_encode($action_args), "is_connected" => get_current_user_id() ? 1 : 0, "created_at" => microtime(true)));
}
Exemplo n.º 26
0
 /**
  * search user/corporation or alliance by name
  * @param $f3
  * @param $params
  */
 public function search($f3, $params)
 {
     $accessData = [];
     if (array_key_exists('arg1', $params) && array_key_exists('arg2', $params)) {
         $searchType = strtolower($params['arg1']);
         $searchToken = strtolower($params['arg2']);
         $accessModel = null;
         switch ($searchType) {
             case 'user':
                 $accessModel = Model\BasicModel::getNew('UserModel');
                 break;
             case 'corporation':
                 $accessModel = Model\BasicModel::getNew('CorporationModel');
                 break;
             case 'alliance':
                 $accessModel = Model\BasicModel::getNew('AllianceModel');
                 break;
         }
         if (is_object($accessModel)) {
             // find "active" entries that have their "sharing" option activated
             $accessList = $accessModel->find(array("LOWER(name) LIKE :token AND " . "active = 1 AND " . "shared = 1 ", ':token' => '%' . $searchToken . '%'));
             if ($accessList) {
                 foreach ($accessList as $accessObject) {
                     $accessData[] = $accessObject->getData();
                 }
             }
         }
     }
     echo json_encode($accessData);
 }
 public function setConfig($config = array(), $id = null)
 {
     $id = $this->getId($id);
     if ($id <= 0) {
         $name = wa()->getConfig()->getGeneralSettings('name');
         if (!$name) {
             $name = date('c');
         }
         $description = '';
         if (($raw = waRequest::request('profile')) && is_array($raw)) {
             if (!empty($raw['name'])) {
                 $name = $raw['name'];
             }
             if (!empty($raw['description'])) {
                 $description = $raw['description'];
             }
         }
         $id = $this->addConfig($name, $description);
     }
     $fields = array('id' => $id, 'plugin' => $this->plugin);
     $data = array('config' => json_encode($config));
     if (!empty($this->name)) {
         $data['name'] = $this->name;
     }
     $this->model->updateByField($fields, $data);
     return $id;
 }
Exemplo n.º 28
0
 private function http2_request($method, $path, $params)
 {
     $url = $this->api . rtrim($path, '/') . '/';
     if (!strcmp($method, "POST")) {
         $req = new HTTP_Request2($url, HTTP_Request2::METHOD_POST);
         $req->setHeader('Content-type: application/json');
         if ($params) {
             $req->setBody(json_encode($params));
         }
     } else {
         if (!strcmp($method, "GET")) {
             $req = new HTTP_Request2($url, HTTP_Request2::METHOD_GET);
             $url = $req->getUrl();
             $url->setQueryVariables($params);
         } else {
             if (!strcmp($method, "DELETE")) {
                 $req = new HTTP_Request2($url, HTTP_Request2::METHOD_DELETE);
                 $url = $req->getUrl();
                 $url->setQueryVariables($params);
             }
         }
     }
     $req->setAdapter('curl');
     $req->setConfig(array('timeout' => 30, 'ssl_verify_peer' => FALSE));
     $req->setAuth($this->auth_id, $this->auth_token, HTTP_Request2::AUTH_BASIC);
     $req->setHeader(array('Connection' => 'close', 'User-Agent' => 'PHPPlivo'));
     $r = $req->send();
     $status = $r->getStatus();
     $body = $r->getbody();
     $response = json_decode($body, true);
     return array("status" => $status, "response" => $response);
 }
 /**
  * Execute the job.
  *
  * @return void
  */
 public function handle(ContactRepository $repository)
 {
     $contact = $repository->get($this->id);
     $repository->remove($contact);
     // Trigger Event to Update All the Clients
     pusher()->trigger('contacts', 'remove', json_encode($contact));
 }
Exemplo n.º 30
0
 function callMethod()
 {
     $resultMethod = $this->createJSON();
     $apiName = stripcslashes($this->apiFunctionName[0]) . 'Api';
     $status = ApiConstants::$STATUS;
     if (file_exists(SERVER_DIR . 'app/Controller/Api/method/' . $apiName . '.php')) {
         $apiClass = ApiCore::getApiEngineByName($apiName);
         $apiReflection = new ReflectionClass($apiName);
         try {
             $functionName = $this->apiFunctionName[1];
             $apiReflection->getMethod($functionName);
             $response = ApiConstants::$RESPONSE;
             $res = $apiClass->{$functionName}($this->apiFunctionParams);
             if ($res == null) {
                 $resultMethod->{$status} = ApiConstants::$ERROR_NOT_FOUND_RECORD;
             } else {
                 if ($res->err == ApiConstants::$ERROR_PARAMS) {
                     $resultMethod->{$status} = ApiConstants::$ERROR_PARAMS;
                     $resultMethod->params = json_encode($apiFunctionParams);
                 } else {
                     $resultMethod->{$response} = $res;
                     $resultMethod->{$status} = ApiConstants::$ERROR_NO;
                 }
             }
         } catch (Exception $ex) {
             $resultMethod->errStr = $ex->getMessage();
         }
     } else {
         $resultMethod->errStr = 'Not found method';
         $resultMethod->{$status} = ApiConstants::$ERROR_NOT_FOUND_METHOD;
         $resultMethod->params = $this->apiFunctionParams;
     }
     return json_encode($resultMethod, JSON_UNESCAPED_UNICODE);
 }