public static function get_temp_root() { if (empty(self::$temp_root)) { self::$temp_root = sys_get_temp_dir(); } return self::$temp_root; }
protected static function boot() { parent::boot(); static::creating(function ($entity) { if (!Schema::hasCollection('entities')) { static::createSchema(); } if (empty($entity->project)) { throw new Exception("No project was given"); } if (!empty($entity->hash) && !empty($entity->project)) { if (Entity::withTrashed()->where('hash', $entity->hash)->where('project', $entity->project)->first()) { throw new Exception("Hash already exists for: " . $entity->title . " in project " . $entity->project); } } $entity->_id = static::generateIncrementedBaseURI($entity); if (Auth::check()) { $entity->user_id = Auth::user()->_id; } else { $entity->user_id = "crowdtruth"; } }); static::saved(function ($entity) { Temp::truncate(); Cache::flush(); }); static::deleted(function ($entity) { Cache::flush(); }); }
/** * Store to the database the given entities as entities decendent from the given * document. * * @param $document Parent document -- Must be a document entity on the database. * @param $entities List of entities to be created as decendents from the given document. * * @return multitype:string A status array containing the result status information. */ public function store($parent, $units, $type) { if (count($units) <= 0 && count($units) >= 10000) { // We will have problems processing empty files or more than 10,000 entities return ['error' => 'Unable to process files with more than 10,000 lines: ' . $nEnts . 'found']; } $activity = new \Activity(); $activity->softwareAgent_id = $this->softwareComponent->_id; $activity->save(); $entities = []; foreach ($units as $unit) { try { $entity = new Unit(); $entity->project = $parent->project; $entity->activity_id = $activity->_id; $entity->documentType = $type; $entity->parents = [$parent->_id]; $entity->content = $unit; $entity->hash = md5(serialize($entity)); $entity->save(); array_push($entities, $entity); } catch (Exception $e) { foreach ($entities as $en) { $en->forceDelete(); } throw $e; } } \Temp::truncate(); return ['success' => 'Sentences created successfully']; }
static function getClasses() { if (!($data = Temp::get('list_classes'))) { $data = array_merge(File::readDirFiles(CLASS_DIR, true), File::readDirFiles(APP_DIR, true, '/.*\\.model\\.php/u')); $data = serialize(array_merge($data, File::readDirFiles(APP_DIR, true, '/.*\\.class\\.php/u'))); Temp::set('list_classes', $data); } $result = unserialize($data); return $result; }
public function get_ads() { if (Login::get_instance()->check_login() == 'valid') { if (is_numeric($_POST['status'])) { $user_data = Register::get_instance()->get_current_user(); $ads = ads::load_ads(1, array('user_id' => $user_data['id'], 'status' => intval($_POST['status']))); if (!empty($ads)) { echo Temp::ad_container_list($ads); } else { echo 'لا توجد اعلانات للعرض'; } } } }
function execute() { $search = Request::post('search'); $searchUser = ConnectionSearchUser::create(); $saveTemp = false; $user = ConnectionHelper::userLogin(); if (ConnectionHelper::isLogin() && !$search) { $saveTemp = Temp::get('user_' . $user['id'] . '_advanced_filter'); $saveTemp = $saveTemp ? unserialize($saveTemp) : false; } if (!$saveTemp) { $saveTemp = array('query' => $search, 'filter' => $searchUser->filterSearchField($search)); if (ConnectionHelper::isLogin()) { Temp::set('user_' . $user['id'] . '_advanced_filter', serialize($saveTemp)); } } $this->setSeoPage('advanced_search'); if ($search || true) { print_r($saveTemp); } }
<input id="deactivate_clinics" type="submit" class="button" value="تعطيل" style="background:gray; margin-top:0;"> <input id="activate_clinics" type="submit" class="button" value="تفعيل" style="margin-top:0;"> </div> <form id="clinics_form"> <table dir="rtl"> <thead> <tr> <th width="40"><input type="checkbox" check="clinics" name="all"></th> <th width="100">رقم العيادة</th> <th width="">اسم العيادة</th> <th width="">الحالة</th> </tr> </thead> <tbody id="clinics_body"> <?php echo empty($clinics) ? '<tr><td colspan="4">لا يوجد عيادات للعرض</td></tr>' : Temp::ad_container_rows($clinics, 2); ?> </tbody> </table> </form> <input type="hidden" name="clinics_page" value="1"> <input type="hidden" name="clinics_total" value="<?php echo $total_clinics; ?> "> <div id="clinics_more"> <?php if ($total_clinics > 18) { ?> <input id="clinics_button" type="submit" value="المزيد"> <?php
<div><img src="<?php echo TEMPLATE_URL; ?> /img/1.jpg"></div> ... </div> </div>--> <!--ads grid view start--> <div class="row" style="margin:0 0 16px 0;"> <ul class="small-block-grid-1 medium-block-grid-1 large-block-grid-3 ads_view"> <?php $msg = $search == 2 ? 'لا توجد عيادات للعرض' : 'لا توجد اعلانات للعرض'; ?> <?php echo empty($ads) ? $msg : Temp::ad_container_list($ads, $search); ?> </ul> </div> <!--ads grid view start--> <!--paginatios start--> <div class="row" style="margin:0 0 16px 0; padding:0;"> <?php echo empty($ads) ? '' : $pagination; ?> </div> <!--paginatios end--> </div> <!--main content end-->
</div> <div class=" small-12 columns" style="padding:0;"> <div class="small-12 columns right"> <h5 style="color:#09c; border-bottom:1px solid #60e0f5; padding-bottom:6px; margin-bottom:6px;">فلترة البحث</h5> </div> <div class="small-12 meduim-6 large-4 columns"> <label>الدولة <select id="search_country" name="search_country"> <option value="">اختار الدولة</option> <?php echo Temp::load_list_options('ads_countries'); ?> </select> </label> </div> <div class="small-12 meduim-6 large-4 columns"> <label>المدينة <select id="search_city" name="search_city"> <option value="">اختار المدينة</option> </select> </label> </div>
<div class="content" id="panel2" style="width:100% !important;"> <ul class="small-block-grid-1 medium-block-grid-1 large-block-grid-3 ads_view" style="padding:0;"> <?php echo empty($ads2) ? 'لا يوجد اعلانات للعرض' : Temp::ad_container_list($ads2); ?> </ul> </div> <div class="content" id="panel4" style="width:100% !important;"> <ul id="ads" class="small-block-grid-1 medium-block-grid-1 large-block-grid-3 ads_view" style="padding:0;"> <?php echo empty($ads4) ? 'لا يوجد اعلانات للعرض' : Temp::ad_container_list($ads4); ?> </ul> </div> </div> </div> </div> <!--main content end--> <!--ads section start--> <div class="ads" style=" float:left; display:inline-block; left:0;"> <?php
public static function createJobCache() { \Session::flash('rawArray', 1); $db = \DB::getMongoDB(); $db = $db->temp; $result = Entity::where('type', 'job')->with('hasConfiguration')->get()->toArray(); if (count($result) > 0) { try { Temp::where('type', 'job')->forceDelete(); $db->batchInsert($result, array('continueOnError' => true)); } catch (Exception $e) { // ContinueOnError will still throw an exception on duplication, even though it continues, so we just move on. } } \Session::forget('rawArray'); }
/** * Returns a temporary directory - one that is automatically deleted at the end * of the script. * * @param string $ext * @return Temp */ public static function temp_dir() { $ext = $ext ? '.' . $ext : ''; Temp::set_temp_root(api_get_path(SYS_ARCHIVE_PATH) . 'temp'); $path = Temp::get_temporary_name() . $ext; return Temp::dir($path); }
echo Temp::load_list_options('ads_cities', $clinic['city'], array($clinic['country'])); } ?> </select> </label> </div> <div class="small-12 columns right"> <label>المنطقة <select id="region" name="region"> <option value="">اختار المنطقة</option> <?php if (is_array($clinic) && !empty($clinic)) { echo Temp::load_list_options('ads_regions', $clinic['region'], array($clinic['city'])); } ?> </select> </label> </div> </div> <div class="small-12 meduim-3 large-3 columns right"> <input type="submit" class="button expand" value="<?php echo $button; ?> "> </div> <!--ad info code end-->
public function actionAjaxGetCode() { $uid = Yii::app()->request->getPost('sms_uid'); $psw = Yii::app()->request->getPost('sms_psw'); $cid = Yii::app()->request->getPost('sms_cid'); $phone = Yii::app()->request->getPost('sms_phone'); $arr = explode(',', '0,1,2,3,4,5,6,7,8,9'); $code = ''; for ($i = 0; $i < 6; $i++) { $tag = mt_rand(0, 9); $code .= $arr[$tag]; } $temp_model = new Temp(); $temp_model->phone = trim($phone); $temp_model->code = trim($code); $temp_model->time = time(); if ($temp_model->save()) { $sms = new SMSComponent($uid, $psw, $cid); $res = $sms->sendMsg($code, $phone); $res = CJSON::decode($res); if ($res['code'] == 0) { echo CJSON::encode(array('success' => true, 'msg' => '短信已发送,请注意查收')); } else { echo CJSON::encode(array('success' => false, 'msg' => '短信发送失败,请稍后重试')); } } else { echo CJSON::encode(array('success' => false, 'msg' => '验证码获取失败,请稍后重试')); } }
public function getUnit() { $result = array(); $aggregateOperators = $this->processAggregateInput(Input::all()); $unitID = Input::get('unit'); $resultT = Temp::where('_id', $unitID)->get()->toArray(); if (sizeof($resultT) != 0) { $result['infoStat'] = Temp::where('_id', $unitID)->get()->toArray()[0]; } else { $result['infoStat'] = Entity::where('_id', $unitID)->get()->toArray()[0]; } $selection = Entity::raw(function ($collection) use($aggregateOperators, $unitID) { $aggregateOperators['$match']['unit_id'] = $unitID; $aggregateOperators['$match']['type'] = 'workerunit'; $aggregateOperators['$project']['job_id'] = array('$ifNull' => array('$' . 'job_id', 0)); $aggregateOperators['$project']['crowdAgent_id'] = array('$ifNull' => array('$' . 'crowdAgent_id', 0)); $aggregateOperators['$project']['type'] = array('$ifNull' => array('$' . 'type', 0)); $aggregateOperators['$project']['workerunit'] = array('$ifNull' => array('$' . 'annotationVector', 0)); $aggregateOperators['$group']['_id'] = '$crowdAgent_id'; $aggregateOperators['$group']['count'] = array('$sum' => 1); $aggregateOperators['$group']['job_id'] = array('$push' => '$job_id'); $aggregateOperators['$group']['type'] = array('$push' => '$type'); $aggregateOperators['$group']['workerunit'] = array('$push' => '$workerunit'); return $collection->aggregate(array(array('$match' => $aggregateOperators['$match']), array('$project' => $aggregateOperators['$project']), array('$group' => $aggregateOperators['$group']))); }); $response = $selection['result']; $crowdAgentIDs = array(); $jobIDs = array(); $result['workerunitContent'] = array(); $result['jobContent'] = array(); $result['agentContent'] = array(); foreach ($response as $agent => $value) { $result['workerunitContent'][$value['_id']] = $value; array_push($crowdAgentIDs, $value['_id']); $workerunitType = array(); foreach ($value['job_id'] as $index => $type) { array_push($jobIDs, $value['job_id'][$index]); if (!array_key_exists($type, $workerunitType)) { $workerunitType[$type] = $value['workerunit'][$index]; } else { $annInfo = $value['workerunit'][$index]; foreach ($annInfo as $k => $v) { if (is_numeric($v)) { $workerunitType[$type][$k] += $v; } else { foreach ($v as $embeddedK => $embeddedV) { $workerunitType[$type][$k][$embeddedK] += $embeddedV; } } } } } $result['workerunitContent'][$value['_id']]['workerunitType'] = array(); foreach ($workerunitType as $job => $workerunit) { $workerunitInfo = array('job_id' => $job, 'workerunit' => $workerunit); $result['workerunitContent'][$value['_id']]['workerunitType'][$job] = $workerunitInfo; } } $crowdAgentIDs = array_unique($crowdAgentIDs); $agents = CrowdAgent::whereIn('_id', $crowdAgentIDs)->get(array('cache', 'cfWorkerTrust', 'softwareAgent_id'))->toArray(); foreach ($agents as $index => $value) { $result['workerunitContent'][$value['_id']]["valuesWorker"] = $value; // $result['agentContent'][$value['_id']] = $value; } $jobIDs = array_unique($jobIDs); $jobs = Entity::whereIn('_id', $jobIDs)->get(array('results.withoutSpam.' . $unitID, 'results.withSpam.' . $unitID, 'metrics.units.withoutSpam.' . $unitID, 'metrics.aggUnits', 'metrics.filteredunits', 'metrics.workers.withFilter', 'sofwareAgent_id', 'platformJobId'))->toArray(); foreach ($jobs as $index => $value) { $result['jobContent'][$value['_id']] = $value; $jobConfID = Entity::where('_id', '=', $value['_id'])->lists('jobConf_id'); $jobTitle = Entity::whereIn('_id', $jobConfID)->get(array('content.title'))->toArray(); $result['jobContent'][$value['_id']]['jobConf'] = $jobTitle[0]; } foreach ($result['workerunitContent'] as $id => $annInfo) { foreach ($result['workerunitContent'][$id]['workerunitType'] as $index => $value) { $job_id = $value['job_id']; $result['workerunitContent'][$id]['workerunitType'][$index]['job_info'] = $result['jobContent'][$job_id]; } } return $result; }
public function jsload() { $type = intval($_POST['type']); $data = intval($_POST['data']); $ad_type = intval($_POST['ad_type']); switch ($type) { case 1: echo '<option value="">اختار المدينة</option>'; echo Temp::load_list_options('ads_cities', 0, array($data)); break; case 2: echo '<option value="">اختار المنطقة</option>'; echo Temp::load_list_options('ads_regions', 0, array($data)); break; case 3: echo '<option value="351">الكل</option>'; echo Temp::load_list_options('ads_pets', 0, array($data, $ad_type)); break; } }
/** * function to add results */ public function postImportresults() { $files = Input::file('file'); $settings = []; $inputClass = explode('__', Input::get('inputClass')); $outputClass = explode('__', Input::get('outputClass')); $settings['filename'] = basename($files->getClientOriginalName(), '.csv'); //$inputFormat = 'text'; //$inputDomain = 'medical'; //$outputFormat = 'text'; //$outputDomain = 'medical2'; // input project if (Input::get('input-project') != "") { $settings['project'] = Input::get('input-project'); } else { $settings['project'] = $inputClass[0]; } // input type if (Input::get('input-type') != "") { $settings['documentType'] = Input::get('input-type'); } else { $settings['documentType'] = $inputClass[1]; } // output type if (Input::get('output-type') != "") { $settings['resultType'] = Input::get('output-type'); } else { $settings['resultType'] = $outputClass[1]; } $settings['domain'] = 'opendomain'; $settings['format'] = 'text'; // process file $importer = new ResultImporter(); $status = $importer->process($files, $settings); // flash appropriate message if (!$status['error']) { Session::flash('flashSuccess', $status['success']); if ($status['notice']) { Session::flash('flashNotice', $status['notice']); } } else { Session::flash('flashError', $status['error']); } $mainSearchFilters = Temp::getMainSearchFiltersCache()['filters']; $projects = ProjectHandler::getUserProjects(Auth::user()); $projects = array_column($projects, 'name'); return View::make('media.search.pages.importresults')->with('mainSearchFilters', $mainSearchFilters)->with('projects', $projects); }
function testA() { $w = new Temp(); $this->assertEquals(5, $w->testA(5, 5)); }
public function getDeletepl($id) { $platform = App::make('cf2'); //dd($id); $platform->deleteJobPL($id); Temp::truncate(); return Redirect::to("jobs"); }
static function getAppList() { $temp_file = Temp::get('app_list'); if ($temp_file) { return unserialize($temp_file); } else { $dirs = scandir(APP_DIR); $apps = array(); foreach ($dirs as $dir) { $path = APP_DIR . DS . $dir; if ($dir != '.' && $dir != '..' && is_dir($path)) { $apps[basename($dir)] = $path; } } Temp::set('app_list', serialize($apps)); return $apps; } }
static function pagination($total) { $pages = array(); if (isset($_GET['p']) && is_numeric($_GET['p'])) { $page = intval($_GET['p']); } else { $page = 1; } if ($page > $total) { $page = 1; } return Temp::pagination_list($page, $_GET, $total); }
protected function checkSessionId($sessionid) { $model = Temp::model()->find(array( 'condition'=>"sessionid='$sessionid'", )); return $model; }
public function getIndex() { $mainSearchFilters = Temp::getMainSearchFiltersCache()['filters']; return View::make('media.search.pages.workers', compact('mainSearchFilters')); }
public function store(&$parentEntity, $relexStructuredSentences, $inc) { // dd('test'); $allEntities = array(); foreach ($relexStructuredSentences as $tKey => &$relexStructuredSentence) { $title = $parentEntity['title'] . "_index_" . $inc; $hash = md5(serialize(array_except($relexStructuredSentence, ['properties']))); if ($dup = Entity::where('hash', $hash)->first()) { array_push($this->status['store']['error']['skipped_duplicates'], $tKey . " ---> " . $dup->_id); continue; } if (Auth::check()) { $user_id = Auth::user()->_id; } else { $user_id = "crowdwatson"; } $entity = ["_id" => 'entity/text/medical/relex-structured-sentence/' . $inc, "title" => strtolower($title), "domain" => $parentEntity['domain'], "format" => $parentEntity['format'], "tags" => ['unit'], "documentType" => "relex-structured-sentence", "parents" => [$parentEntity['_id']], "content" => $relexStructuredSentence, "hash" => $hash, "activity_id" => $this->activity->_id, "user_id" => $user_id, "updated_at" => new MongoDate(time()), "created_at" => new MongoDate(time())]; array_push($allEntities, $entity); $inc++; array_push($this->status['store']['success'], $tKey . " ---> URI: {$entity['_id']}"); } if (count($allEntities) > 1) { \DB::collection('entities')->insert($allEntities); Temp::truncate(); } return $inc; }
public function search_cp() { if (Login::get_instance()->check_login() == 'valid') { $user_data = Register::get_instance()->get_current_user(); if ($user_data['status'] != 10) { exit; } if ($_POST) { if ($_POST['type'] == 'users') { if (is_numeric($_POST['value'])) { $settings['id'] = intval($_POST['value']); } else { if (Validation::email($_POST['value'])) { $settings['email'] = addslashes($_POST['value']); } else { echo ''; exit; } } $users = Register::get_instance()->get_user($settings); echo empty($users) ? '' : Temp::users_container_rows($users); } else { if ($_POST['type'] == 'ads') { if (is_numeric($_POST['value'])) { $settings['id'] = intval($_POST['value']); } else { $settings['words'] = addslashes($_POST['value']); } if (empty($_POST['value'])) { echo ''; exit; } $settings['limit'] = 'no'; $ads = ads::load_ads(0, $settings); echo empty($ads) ? '' : Temp::ad_container_rows($ads); } else { if ($_POST['type'] == 'clinics') { if (is_numeric($_POST['value'])) { $settings['id'] = intval($_POST['value']); } else { $settings['words'] = addslashes($_POST['value']); } if (empty($_POST['value'])) { echo ''; exit; } $settings['limit'] = 'no'; $clinics = ads::load_clinics($settings); echo empty($clinics) ? '' : Temp::ad_container_rows($clinics, 2); } } } } } }