function submit() { $this->load->library('form_validation'); $leave_start = $this->input->post('leave_start'); $leave_end = $this->input->post('leave_end'); $this->form_validation->set_rules('leave_start', 'Date From', 'required|callback_checkdates'); $this->form_validation->set_rules('leave_end', 'Date to', 'required'); $this->form_validation->set_error_delimiters('<span class="help-block" style="color:red">', '</span>'); if ($this->form_validation->run() == FALSE) { $this->index(); } else { $date1 = date('Y-m-d', strtotime(str_replace('/', '-', $leave_start))); $date2 = date('Y-m-d', strtotime(str_replace('/', '-', $leave_end))); $this->session->set_userdata('date1', $leave_start); $this->session->set_userdata('date2', $leave_end); $data['title'] = $this->m_setting->getSetting(); //$data['headform'] = $this->m_outsource->viewHeadForm($formid); $removetmp = $this->m_outsource->removeOTMP($date1, $date2); for ($i = 0; $i < Count($removetmp); $i++) { $dataattd = array('othour' => '0'); $this->db->where('userid', $removetmp[$i]['userid']); $this->db->where('date', $removetmp[$i]['date']); $this->db->update('attendance', $dataattd); } $this->session->set_userdata('noticebox', '5'); $this->index(); } }
function Styles_HostsIDs($Element) { /****************************************************************************/ $__args_types = array('string'); #----------------------------------------------------------------------------- $__args__ = Func_Get_Args(); eval(FUNCTION_INIT); /****************************************************************************/ $Result = array(); #----------------------------------------------------------------------------- $HostsIDs = $GLOBALS['HOST_CONF']['HostsIDs']; #----------------------------------------------------------------------------- if (isset($_COOKIE['StyleID'])) { Array_UnShift($HostsIDs, $_COOKIE['StyleID']); } #----------------------------------------------------------------------------- foreach ($HostsIDs as $HostID) { #--------------------------------------------------------------------------- $Path = SPrintF('%s/styles/%s/%s', SYSTEM_PATH, $HostID, $Element); #--------------------------------------------------------------------------- if (File_Exists($Path)) { $Result[] = $HostID; } } #----------------------------------------------------------------------------- if (Count($Result) < 1) { return ERROR | @Trigger_Error(SPrintF('[Styles_HostsIDs]: не удалось найти хосты для элемента (%s)', $Element)); } #----------------------------------------------------------------------------- return $Result; }
function get_MaxValueByControlId($ControlId) { $VariableObject = IPS_GetVariable($ControlId); $ProfileName = $VariableObject['VariableCustomProfile']; $ProfileObject = IPS_GetVariableProfile($ProfileName); $MaxValue = Count($ProfileObject['Associations']); return $MaxValue; }
public function loadIntoData($results, $location, $lat, $long) { foreach ($results->entry as $result) { $google = $result->children('http://base.google.com/ns/1.0'); //get location $twitter_location = $google->location; //get username $username = $result->author->name; //get date $created_date = $result->published; $time = strtotime($created_date); $myDate = date('y-m-d H:i:s', $time); //precompile hashtags for quick querying $array = explode(' ', $result->title); $array_size = Count($array); $i = 0; $perLineHashTag = ''; while ($i < $array_size) { if (startsWithX($array[$i], "#")) { $perLineHashTag = $perLineHashTag . $array[$i] . " "; } else { //not a hashtag } $i = $i + 1; } //enter data into table $query = "INSERT INTO `data` VALUES ('{$result->title}','{$username}','{$location}','{$long}','{$lat}','{$myDate}','{$twitter_location}','{$perLineHashTag}')"; mysql_query($query); //delete entries over one week old $query2 = "DELETE FROM `data` WHERE `date` < DATE_SUB(NOW(), INTERVAL 1 WEEK)"; mysql_query($query2); } }
function XML_Read($Object, $Level = 1) { #----------------------------------------------------------------------------- static $Index = 1; #----------------------------------------------------------------------------- $Md5 = Md5($Index++); #----------------------------------------------------------------------------- $Attribs = $Object->Attribs; #----------------------------------------------------------------------------- $Name = isset($Attribs['comment']) ? $Attribs['comment'] : $Object->Name; #----------------------------------------------------------------------------- $P = new Tag('P', array('class' => 'NodeName', 'onclick' => SPrintF("TreeSwitch('%s');", $Md5)), new Tag('IMG', array('align' => 'left', 'src' => 'SRC:{Images/Icons/Node.gif}')), new Tag('SPAN', $Name)); #----------------------------------------------------------------------------- $Node = new Tag('DIV', array('class' => 'Node'), $P); #----------------------------------------------------------------------------- if (Count($Attribs)) { #--------------------------------------------------------------------------- foreach (Array_Keys($Attribs) as $AttribID) { $Node->AddChild(new Tag('P', array('class' => 'NodeParam'), new Tag('SPAN', SPrintF('%s: ', $AttribID)), new Tag('SPAN', array('class' => 'NodeParam'), $Attribs[$AttribID]))); } } #----------------------------------------------------------------------------- if (Count($Childs = $Object->Childs)) { #--------------------------------------------------------------------------- $Content = new Tag('DIV', array('style' => 'display:none;'), array('id' => $Md5)); #--------------------------------------------------------------------------- foreach ($Childs as $Child) { $Content->AddChild(XML_Read($Child, $Level + 1)); } #--------------------------------------------------------------------------- $Node->AddChild($Content); } #----------------------------------------------------------------------------- return $Node; }
function Array_Cut(&$What, $Whom, $IsFull = FALSE) { /****************************************************************************/ $__args_types = array('array', 'array', 'boolean'); #----------------------------------------------------------------------------- $__args__ = Func_Get_Args(); eval(FUNCTION_INIT); /****************************************************************************/ foreach (Array_Keys($Whom) as $Key) { #--------------------------------------------------------------------------- if (isset($What[$Key])) { #------------------------------------------------------------------------- $ElementA =& $What[$Key]; $ElementB = $Whom[$Key]; #------------------------------------------------------------------------- if (Is_Array($ElementA) && Is_Array($ElementB)) { #----------------------------------------------------------------------- Array_Cut($ElementA, $ElementB, $IsFull); #----------------------------------------------------------------------- if ($IsFull && !Count($ElementA)) { unset($What[$Key]); } } else { unset($What[$Key]); } } } }
function submit() { $this->load->library('form_validation'); $app_comment = $this->input->post('app_comment'); $valueapp = $this->input->post('btn'); $this->form_validation->set_rules('app_comment', 'Approval Comment', 'required'); $this->form_validation->set_error_delimiters('<span class="help-block" style="color:red">', '</span>'); if ($this->form_validation->run() == FALSE) { $this->view($this->session->userdata('l_view')); } else { if ($this->session->userdata('leave') == 0) { //nampilih greenbox di view $this->session->set_userdata('noticebox', '6'); if ($valueapp == "approve") { $data = array('appv' => $this->session->userdata('userid'), 'docstatus' => '1', 'appv_comment' => $app_comment, 'app_date' => date('Y-m-d H:i:s')); $this->db->where('leaveid', $this->session->userdata('eleaveid')); $this->db->update('tr_leave', $data); $recordatt = $this->m_leave->attendanceleave($this->session->userdata('l_view')); for ($i = 0; $i < Count($recordatt); $i++) { $dataattd = array('leavetype' => $recordatt[$i]['leavetype'], 'leavetype_c' => '1', 'Form_docno' => $recordatt[$i]['leaveid'], 'Form_type' => 'L'); $this->db->where('userid', $recordatt[$i]['userid']); $this->db->where('date', $recordatt[$i]['date']); $this->db->update('attendance', $dataattd); } $this->index(); } else { if ($valueapp == "reject") { $data = array('appv' => $this->session->userdata('userid'), 'docstatus' => '2', 'appv_comment' => $app_comment, 'app_date' => date('Y-m-d H:i:s')); $this->db->where('leaveid', $this->session->userdata('eleaveid')); $this->db->update('tr_leave', $data); $this->index(); } } } else { if ($this->session->userdata('leave') == 1) { $this->session->set_userdata('noticebox', '6'); if ($valueapp == "approve") { $data = array('appv' => $this->session->userdata('userid'), 'docstatus' => '1', 'appv_comment' => $app_comment, 'app_date' => date('Y-m-d H:i:s')); $this->db->where('leaveid', $this->session->userdata('eleaveid')); $this->db->update('tr_leave', $data); $recordatt = $this->m_leave->getscheduletime($this->session->userdata('l_view')); for ($i = 0; $i < Count($recordatt); $i++) { $dataattd = array('remark_c' => '1', 'remark' => $recordatt[$i]['formtype'], 'Form_docno' => $recordatt[$i]['leaveid'], 'Form_type' => 'W'); $this->db->where('userid', $recordatt[$i]['userid']); $this->db->where('date', $recordatt[$i]['date']); $this->db->update('attendance', $dataattd); } $this->index(); } else { if ($valueapp == "reject") { $data = array('appv' => $this->session->userdata('userid'), 'docstatus' => '2', 'appv_comment' => $app_comment, 'app_date' => date('Y-m-d H:i:s')); $this->db->where('leaveid', $this->session->userdata('eleaveid')); $this->db->update('tr_leave', $data); $this->index(); } } } } } }
function GetLicenseText($DecodedString = false) { $Arr1 = array(); $License = array(); $DecodedString = trim($DecodedString); if (!$DecodedString) { return false; } $Arr1 = explode("\n", $DecodedString); for ($i = 0; $i < count($Arr1); $i++) { $Arr2 = explode("=", $Arr1[$i]); if (!is_array($Arr2) || Count($Arr2) < 2) { continue; } $License[$Arr2[0]] = str_replace("&equal;", "=", $Arr2[1]); } if (count($License) == 0) { return false; } if (!isset($License['ID'])) { return false; } if (!isset($License['V'])) { return false; } if (!isset($License['CL'])) { return false; } if (!isset($License['L'])) { return false; } //if (!isset($License['L2'])) return false; return $License; }
private function GetCurrentCollection() { $uri = preg_split('@/@', CommonController::GetCurrentUri(), NULL, PREG_SPLIT_NO_EMPTY); $CollectionId = $uri[Count($uri) - 1]; $WSCtrl = new WebServicesController(); return $WSCtrl->Call("Collection", "GET", [$CollectionId]); }
public function checkUserBecome($user_id, $blog_id) { $table = Engine_Api::_()->getDbTable('becomes', 'ynblog'); $name = $table->info('name'); $select = $table->select()->where("{$name}.user_id = ?", $user_id)->where("{$name}.blog_id = ?", $blog_id); $rows = $table->fetchAll($select); return Count($rows) > 0 ? false : true; }
public function login_users($nick, $password) { if (empty($nick)) { return false; } if (empty($password)) { return false; } $this->usuario = $this->modelo->obtenerUsuario($nick); /* //Verificar si el usuario está logueado $session_id = $this->usuario->GET('session_id'); if($session_id != "" && $session_id!= session_id()) { session_destroy(); return false; } */ //si existe el usuario if (Count($this->usuario) == 1) { if ($this->usuario->__GET('int_borrado') == 1) { return false; } $pass; switch ($this->metodo_encriptacion) { case 'sha1' | 'SHA1': $pass = sha1($password); break; case 'md5' | 'MD5': $pass = md5($password); break; case 'texto' | 'TEXTO': $pass = $password; break; default: trigger_error('El valor de la propiedad metodo_encriptacion no es válido. Utiliza MD5 o SHA1 o TEXTO', E_USER_ERROR); } if ($this->usuario->__GET('password') == $pass) { // @session_start(); //almacenamos en memoria los datos del usuario $_SESSION['USUARIO'] = array('user' => $this->usuario->__GET('correo'), 'nombre' => $this->usuario->__GET('nombre'), 'apellido' => $this->usuario->__GET('apellido'), 'cedula' => $this->usuario->__GET('id_user'), 'utype' => $this->usuario->__GET('user_type'), 'departamento' => $this->usuario->__GET('departamento'), 'codigo_usuario' => $this->usuario->__GET('codigo_usuario'), 'estado' => $this->usuario->__GET('estado'), 'tiempo' => date("H:i:s")); return true; //usuario y contraseña validadas /* echo $this->usuario->__GET('password')."<br>"; echo $this->usuario->__GET('primer_nombre')."<br>"; echo $this->usuario->__GET('segundo_nombre')."<br>"; echo $this->usuario->__GET('primer_apellido')."<br>"; echo $this->usuario->__GET('segundo_apellido')."<br>"; */ } } else { //@session_start(); //unset($_SESSION['USUARIO']); //destruimos la session activa al fallar el login por si existia return false; //no coincide la contraseña } }
function ArraySum($Array) { $N = 0; $Array = array_values($Array); for ($Count = Count($Array), $i = 0; $i < $Count; $i++) { $N = Summation($N, $Array[$i]); } return $N; }
function getNumberOfGalleries($limit = -1) { static $count; if ($count) { return $count; } else { return $count = Count(Get_Posts(array('post_type' => $this->post_type, 'post_status' => 'any', 'numberposts' => $limit))); } }
public static function reserveRoom($data) { $param_string = ''; foreach ($data as $key => $value) { $param_string .= $key . '=' . $value . '&'; } rtrim($param_string, '&'); $result = self::sendData('Rooms', $param_string, Count($data)); return $result; }
function Menu2($items) { global $sess; $this->perm_mbr = $sess[5]; $count = Count($items); for ($i = 0; $i < $count; $i++) { $this->names[] = $items['id'][$i]; $this->urls[] = $items['name'][$i]; } }
function index() { $fix = $this->m_patch->getErrorDaytype(); for ($i = 0; $i < Count($fix); $i++) { $dataattd = array('daytype' => $fix[$i]['typeday']); $this->db->where('userid', $fix[$i]['userid']); $this->db->where('date', $fix[$i]['Date']); $this->db->update('attendance', $dataattd); } $this->load->view('v_autopatch'); }
function buildInstagram() { global $instagramIndex, $instagramCount, $instagramKeyword, $instagramURL, $instaCachePath, $instaFileName; $instaArray = array(); // initialise array $continueRequest = true; $index = 0; while ($continueRequest == true && $index < 52) { $continueRequest = false; // assume that we're not going to do another request after this one $curl = curl_init($instagramURL); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); // For security, do not use the following settings in a production environment curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); /* In a production environment, you'll likely want to refer to a locally hosted PEM file. curl_setopt($curl, CURLOPT_CAINFO, getcwd() . "\cacert.pem"); curl_setopt($curl, CURLOPT_SSL_CIPHER_LIST, "ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:ECDHE-RSA-DES-CBC3-SHA:ECDHE-ECDSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:DES-CBC3-SHA:HIGH:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA"); */ $instaCall = curl_exec($curl); echo curl_error($curl); $instaArray[] = json_decode($instaCall, true); if (isset($instaArray[$index]["pagination"]["next_url"])) { $instagramURL = $instaArray[$index]["pagination"]["next_url"]; $continueRequest = true; // we found another page, so switch to true } set_time_limit(25); unset($instaCall); curl_close($curl); $index++; } // Add metadata //$instaArray["requestTime"] = time(); //$instaArray["success"] = true; $instaArrayLength = Count($instaArray); $orderedMetaData = array(); for ($i = 0; $i < $instaArrayLength; $i++) { $dataLength = Count($instaArray[$i]["data"]); for ($j = 0; $j < $dataLength; $j++) { $dataObject = array(); $dataObject["thumbnail"] = $instaArray[$i]["data"][$j]["images"]["thumbnail"]["url"]; $dataObject["standard_resolution"] = $instaArray[$i]["data"][$j]["images"]["standard_resolution"]["url"]; $dataObject["caption_text"] = $instaArray[$i]["data"][$j]["caption"]["text"]; $dataObject["username"] = $instaArray[$i]["data"][$j]["caption"]["from"]["username"]; $dataObject["link"] = $instaArray[$i]["data"][$j]["link"]; $orderedMetaData[] = $dataObject; } } $encodedJSON = json_encode($orderedMetaData); // output the JSON data echo $encodedJSON; }
public function __toString() { $display = ""; $display .= "---- " . $this->name . " ----\n"; $display .= $this->dough . "\n"; $display .= $this->sauce . "\n"; for ($i = 0; $i < Count($this->toppings); $i++) { $display .= $this->toppings[$i] . "\n"; } return $display; }
function test_SpoofChecker_issuesfound() { $checker = new SpoofChecker(); VS($checker->issuspicious("NAPKIN PEZ", $ret), true); VS($ret, Spoofchecker::WHOLE_SCRIPT_CONFUSABLE); VS($checker->issuspicious(u('f\\u0430\\u0441\\u0435b\\u043e\\u043ek'), $ret), true); VS($ret, SpoofChecker::MIXED_SCRIPT_CONFUSABLE); VS($checker->areconfusable("hello, world", "he11o, wor1d", $ret), true); VS($ret, SpoofChecker::SINGLE_SCRIPT_CONFUSABLE); return Count(true); }
function LimitWordCount($numWords = 26) { $this->value = Convert::xml2raw($this->value); $ret = explode(" ", $this->value, $numWords); if (Count($ret) < $numWords - 1) { $ret = $this->value; } else { array_pop($ret); $ret = implode(" ", $ret) . "..."; } return $ret; }
public function login() { $data = Input::all(); $log = Auth::attempt(array('email' => $data['email'], 'password' => $data['password'])); if ($log) { $search = $data['password']; $data = Result::where('regno', $search)->get(); $count = Count($data); return View::make('StudentReport')->with('results', $data); } else { return Redirect::Route('home')->with('fail', 'Bad combination of username and password'); } }
public function reset_pass($username, $code) { $user = UserModel::where('username', $username)->get()->first(); if (Count($user) == 1) { if ($user->forgotpass == $code && $code != '') { return view('user.reset_pass')->with('username', $username); } else { return redirect()->route('home')->with('error', 'Vui lòng kiểm tra lại liên kết trong email'); } } else { return redirect()->route('home')->with('error', 'Vui lòng kiểm tra lại liên kết trong email'); } }
public function Report() { $search = Input::get("search"); // $data=Student::where('sname',"LIKE",'%'.$search.'%')->with('result')->get(); $data = Result::where('regno', $search)->get(); //var_dump($data); $size = Count($data); if ($size > 0) { return View::make("StudentReport")->with('results', $data); //return View::make("StudentReport")->with('students',$data); } else { return Redirect::to('search')->with('empty', 'No data Match with your search index'); } }
function SendRemindEventAgent($iblockId, $taskId, $pathTemplate) { if (!CModule::IncludeModule("socialnetwork") && !CModule::IncludeModule("iblock")) { return; } $iblockId = IntVal($iblockId); $taskId = IntVal($taskId); if (!isset($GLOBALS["USER"]) || !is_object($GLOBALS["USER"])) { $bTmpUser = True; $GLOBALS["USER"] = new CUser(); } $arTasksCustomProps = array(); $dbTasksCustomProps = CIBlockProperty::GetList(array("sort" => "asc", "name" => "asc"), array("ACTIVE" => "Y", "IBLOCK_ID" => $iblockId, "CHECK_PERMISSIONS" => "N")); while ($arTasksCustomProp = $dbTasksCustomProps->Fetch()) { $ind = StrLen($arTasksCustomProp["CODE"]) > 0 ? $arTasksCustomProp["CODE"] : $arTasksCustomProp["ID"]; $arTasksCustomProps[StrToUpper($ind)] = $arTasksCustomProp; } $dbTasksList = CIBlockElement::GetList(array(), array("IBLOCK_ID" => $iblockId, "ACTIVE" => "Y", "ID" => $taskId, "CHECK_PERMISSIONS" => "N"), false, false, array("ID", "NAME", "IBLOCK_ID", "CREATED_BY", "PROPERTY_" . $arTasksCustomProps["TASKASSIGNEDTO"]["ID"])); while ($arTask = $dbTasksList->GetNext()) { $ar = array(); $dbElementSections = CIBlockElement::GetElementGroups($arTask["ID"]); while ($arElementSection = $dbElementSections->Fetch()) { if ($arElementSection["IBLOCK_ID"] == $iblockId) { $ar[] = $arElementSection["ID"]; } } if (Count($ar) <= 0) { continue; } $taskType = ""; $taskOwnerId = 0; $dbSectionsChain = CIBlockSection::GetNavChain($iblockId, $ar[0]); if ($arSect = $dbSectionsChain->Fetch()) { $taskType = $arSect["XML_ID"] == "users_tasks" ? "user" : "group"; $taskOwnerId = IntVal($taskType == "user" ? $arTask["PROPERTY_" . $arTasksCustomProps["TASKASSIGNEDTO"]["ID"] . "_VALUE"] : $arSect["XML_ID"]); } if (!In_Array($taskType, array("user", "group")) || $taskOwnerId <= 0) { continue; } $path2view = ($GLOBALS["APPLICATION"]->IsHTTPS() ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'] . CComponentEngine::MakePathFromTemplate($pathTemplate, array("owner_id" => $taskOwnerId, "task_id" => $arTask["ID"], "action" => "view")); $arMessageFields = array("=DATE_CREATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "MESSAGE_TYPE" => SONET_MESSAGE_SYSTEM, "FROM_USER_ID" => $arTask["CREATED_BY"], "TO_USER_ID" => $arTask["PROPERTY_" . $arTasksCustomProps["TASKASSIGNEDTO"]["ID"] . "_VALUE"], "MESSAGE" => str_replace(array("#URL_VIEW#", "#NAME#"), array($path2view, $arTask["NAME"]), GetMessage("INTE_REMIND_TASK_MESSAGE"))); CSocNetMessages::Add($arMessageFields); //CIBlockElement::SetPropertyValueCode($arTask["ID"], $arTasksCustomProps["TASKREMIND"]["ID"], false); } if ($bTmpUser) { unset($GLOBALS["USER"]); } //return "CIntranetTasks::SendRemindEventAgent($iblockId, $taskId, \"$pathTemplate\");"; }
public function expand($data_obj) { $html = null; for ($i = 0; $i < Count($data_obj); $i++) { $html .= <<<EOF \t\t\t\t<div id="{$data_obj[$i]["title_div_id"]}"> \t\t\t\t\t{$data_obj[$i]["title"]} \t\t\t\t</div> \t\t\t\t<div id="{$data_obj[$i]["content_div_id"]}"> \t\t\t\t\t{$data_obj[$i]["content"]} \t\t\t\t</div> EOF; } return $html; }
/** * testGetPhotoInformationFromServiceNearestPlacesWrongWay's method. * This method is testing, that following the wrong way, the getPhotoInformationFromServiceNearestPlaces method is working fine making a mock test on Instagram Services. */ public function testGetPhotoInformationFromServiceNearestPlacesWrongWay() { $response = Mockery::mock('Psr\\Http\\Message\\MessageInterface'); $response->shouldReceive('getBody')->andReturn($this->getPhotoInformationFromServiceNearestPlacesJson(false)); $client_mock = Mockery::mock('GuzzleHttp\\Client'); $client_mock->shouldReceive('request')->andReturn($response); $service = new InstagramInformationPhotoService($client_mock); $service_respose = $service->getPhotoInformationFromServiceNearestPlaces(31.4256195, 64.18760109999999, "token_id"); $this->assertNotEquals(200, $service->__get("code")); $is_empty = false; if (Count($service_respose) < 1) { $is_empty = true; } $this->assertEquals(true, $is_empty); }
function executeRandomArticle() { $post = new Article(); $arr = array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'); for ($i = 0; $i < 6; $i = $i + 1) { $index = rand(0, Count($arr)); $title = $title . $arr[$index]; } $post->setTitle($title); for ($i = 0; $i < 30; $i = $i + 1) { $index = rand(0, Count($arr)); $content = $content . $arr[$index]; } $post->setContent($content); $post->save(); $this->redirect('adminblog/index'); }
function CleanUpElem(&$elem_name, &$cfg_file, &$template) { // Fixes HEX strings to look like 0xABCDEF12345 rather than 0Xabc or 0xaf if (Preg_Match("/(0x)([a-fA-F0-9]+)/i", $elem_name, $matches)) { $elem_name = Preg_Replace("/(0x)([a-fA-F0-9]+)/i", "0x" . StrToUpper($matches[2]), $elem_name); } print " Cleaning up elem '{$elem_name}'\n"; $cfg_elem = FindConfigElem($cfg_file, $elem_name); $cfg_elem = array_change_key_case($cfg_elem, CASE_LOWER); $new_elem = array(); $last_label = 0; foreach ($template as $indice => $line) { if (Preg_Match('/\\[Label=([[:alnum:][:space:][:punct:]]+)\\]/', $line, $matches)) { if ($last_label) { unset($new_elem[$last_label]); } $matches[1] = Preg_Replace("/%s/i", " ", $matches[1]); $line = "//{$matches[1]}"; if ($indice > 1) { $line = "\n\t{$line}"; } $last_label = $line; $new_elem[$line] = array(""); continue; } else { $property = StrToLower($line); if ($cfg_elem[$property]) { $new_elem[$line] = $cfg_elem[$property]; unset($cfg_elem[$property]); $last_label = 0; } } } if (Count($cfg_elem) > 0) { $new_elem["\n\t//Custom Values"] = array(""); // Lines not in the template go at the end as custom values foreach ($cfg_elem as $key => $value) { $new_elem[$key] = $value; } } if ($last_label) { unset($new_elem[$last_label]); } return $new_elem; }
public function createOutput($location, $timeNum, $timeUnit, $resultLimit, $session) { $con = mysql_connect(localhost, "slidat_carlos", "cortes299940"); mysql_select_db("slidat_cps630") or die("Unable to select database"); //get hashtag rows from data; $query = "SELECT Hashtags FROM data WHERE Location = '{$location}' AND DATE > DATE_SUB( NOW( ) , INTERVAL {$timeNum} {$timeUnit})"; $response = mysql_query($query); $table_name = "table" . $session . ""; //echo $session; //temporary table $sql = "CREATE TEMPORARY TABLE {$table_name} (Text varchar(160), Count int)"; // Execute query mysql_query($sql); mysql_query("ALTER TABLE {$table_name} ADD UNIQUE (`Text`)"); while ($row = mysql_fetch_array($response, MYSQL_ASSOC)) { $HashtagsPerRow = $row["Hashtags"]; $array = explode(' ', $HashtagsPerRow); $array_size = Count($array); $i = 0; while ($i < $array_size) { if (startsWith($array[$i], "#")) { if (mysql_num_rows(mysql_query("SELECT Text FROM {$table_name} WHERE Text LIKE '{$array[$i]}'")) > 0) { $gethashtag = "UPDATE {$table_name} SET Count=Count+1 WHERE Text LIKE '{$array[$i]}'"; mysql_query($gethashtag); } else { mysql_query("INSERT INTO {$table_name} VALUES ('{$array[$i]}',1)"); } } $i = $i + 1; } } $sql2 = "SELECT Text, Count FROM {$table_name} ORDER BY Count DESC LIMIT 0, {$resultLimit}"; // Execute query $response2 = mysql_query($sql2); $row3 = array(); while ($row2 = mysql_fetch_array($response2, MYSQL_ASSOC)) { $row3[] = $row2; } $deletetable = "DROP TABLE {$table_name}"; mysql_query($deletetable); //mkdir("images/folder$session", 0777); //custom query returned to main mysql_close(); return $row3; }
function smarty_function_menu_left($params, $smarty) { $MenuPath = $params['MenuPath']; if (!$MenuPath) { return FALSE; } $XML = Styles_Menu($MenuPath); if (Is_Error($XML)) { return ERROR | @Trigger_Error(500); } $items = $XML['Items']; if (!Count($items)) { return FALSE; } //echo print_r($items); $smarty->assign('items', array_values($items)); $smarty->display('Menus/Left.tpl'); }