PHP reset Examples

PHP reset - 30 examples found. These are the top rated real world PHP examples of reset extracted from open source projects. You can rate examples to help us improve the quality of examples.
Example #1
1
 /**
  * 获取返回时的签名验证结果
  * @param $para_temp 通知返回来的参数数组
  * @param $sign 返回的签名结果
  * @return 签名验证结果
  */
 protected function getSignVeryfy($param, $sign)
 {
     //除去待签名参数数组中的空值和签名参数
     $param_filter = array();
     while (list($key, $val) = each($param)) {
         if ($key == "sign" || $key == "sign_type" || $val == "") {
             continue;
         } else {
             $param_filter[$key] = $param[$key];
         }
     }
     ksort($param_filter);
     reset($param_filter);
     //把数组所有元素,按照“参数=参数值”的模式用“&”字符拼接成字符串
     $prestr = "";
     while (list($key, $val) = each($param_filter)) {
         $prestr .= $key . "=" . $val . "&";
     }
     //去掉最后一个&字符
     $prestr = substr($prestr, 0, -1);
     $prestr = $prestr . $this->config['key'];
     $mysgin = md5($prestr);
     if ($mysgin == $sign) {
         return true;
     } else {
         return false;
     }
 }
 /**
  * Validates a partial array. Some data may be missing from the given $array, then it will be taken from the
  * full array.
  *
  * Since the array can be incomplete, this method does not validate required parameters.
  *
  * @param array $array
  * @param array $fullArray
  *
  * @return bool
  */
 public function validatePartial(array $array, array $fullArray)
 {
     $unvalidatedFields = array_flip(array_keys($array));
     // field validators
     foreach ($this->validators as $field => $validator) {
         unset($unvalidatedFields[$field]);
         // if the value is present
         if (isset($array[$field])) {
             // validate it if a validator is given, skip it otherwise
             if ($validator && !$validator->validate($array[$field])) {
                 $this->setError($validator->getError());
                 return false;
             }
         }
     }
     // check if any unsupported fields remain
     if ($unvalidatedFields) {
         reset($unvalidatedFields);
         $field = key($unvalidatedFields);
         $this->error($this->messageUnsupported, $field);
         return false;
     }
     // post validators
     foreach ($this->postValidators as $validator) {
         if (!$validator->validatePartial($array, $fullArray)) {
             $this->setError($validator->getError());
             return false;
         }
     }
     return true;
 }
 /**
  * {@inheritdoc}
  */
 public function prepare_form($request, $template, $user, $row, &$error)
 {
     $avatar_list = $this->get_avatar_list($user);
     $category = $request->variable('avatar_local_cat', key($avatar_list));
     foreach ($avatar_list as $cat => $null) {
         if (!empty($avatar_list[$cat])) {
             $template->assign_block_vars('avatar_local_cats', array('NAME' => $cat, 'SELECTED' => $cat == $category));
         }
         if ($cat != $category) {
             unset($avatar_list[$cat]);
         }
     }
     if (!empty($avatar_list[$category])) {
         $template->assign_vars(array('AVATAR_LOCAL_SHOW' => true));
         $table_cols = isset($row['avatar_gallery_cols']) ? $row['avatar_gallery_cols'] : 4;
         $row_count = $col_count = $avatar_pos = 0;
         $avatar_count = sizeof($avatar_list[$category]);
         reset($avatar_list[$category]);
         while ($avatar_pos < $avatar_count) {
             $img = current($avatar_list[$category]);
             next($avatar_list[$category]);
             if ($col_count == 0) {
                 ++$row_count;
                 $template->assign_block_vars('avatar_local_row', array());
             }
             $template->assign_block_vars('avatar_local_row.avatar_local_col', array('AVATAR_IMAGE' => $this->phpbb_root_path . $this->config['avatar_gallery_path'] . '/' . $img['file'], 'AVATAR_NAME' => $img['name'], 'AVATAR_FILE' => $img['filename'], 'CHECKED' => $img['file'] === $row['avatar']));
             $template->assign_block_vars('avatar_local_row.avatar_local_option', array('AVATAR_FILE' => $img['filename'], 'S_OPTIONS_AVATAR' => $img['filename'], 'CHECKED' => $img['file'] === $row['avatar']));
             $col_count = ($col_count + 1) % $table_cols;
             ++$avatar_pos;
         }
     }
     return true;
 }
Example #4
1
 public static function up($html, $spruce)
 {
     self::$tokenizer = new PHP_CodeSniffer_Tokenizers_CSS();
     // TODO: parse $spruce to see if it's a path or a full Spruce string
     self::$tokens = self::$tokenizer->tokenizeString(file_get_contents($spruce));
     self::$tree = array();
     //print_r(self::tokens);
     reset(self::$tokens);
     while ($t = current(self::$tokens)) {
         if ($t['type'] != 'T_OPEN_TAG' && $t['type'] != 'T_DOC_COMMENT' && $t['type'] != 'T_COMMENT') {
             if ($t['type'] == 'T_ASPERAND') {
                 $temp = next(self::$tokens);
                 switch ($temp['content']) {
                     case 'import':
                         next(self::$tokens);
                         self::addImportRule();
                         //print_r($temp);
                         continue;
                     case 'media':
                         next(self::$tokens);
                         self::addMediaRule();
                         continue;
                 }
             } elseif ($t['type'] == 'T_STRING') {
                 self::addStatement();
             }
         }
         next(self::$tokens);
     }
     return self::$tree;
 }
Example #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;
 }
Example #6
1
function xfac_get_avatar($avatar = '', $id_or_email, $size = 96, $default = '', $alt = '')
{
    if (is_numeric($id_or_email)) {
        $wpUserId = (int) $id_or_email;
    } elseif (is_string($id_or_email) && ($user = get_user_by('email', $id_or_email))) {
        $wpUserId = $user->ID;
    } elseif (is_object($id_or_email) && !empty($id_or_email->user_id)) {
        $wpUserId = (int) $id_or_email->user_id;
    }
    if (empty($wpUserId)) {
        // cannot figure out the user id...
        return $avatar;
    }
    $apiRecords = xfac_user_getRecordsByUserId($wpUserId);
    if (empty($apiRecords)) {
        // no api records
        return $avatar;
    }
    $apiRecord = reset($apiRecords);
    if (empty($apiRecord->profile['links']['avatar'])) {
        // no avatar?
        return $avatar;
    }
    $avatar = $apiRecord->profile['links']['avatar'];
    $size = (int) $size;
    if (empty($alt)) {
        $alt = get_the_author_meta('display_name', $wpUserId);
    }
    $author_class = is_author($wpUserId) ? ' current-author' : '';
    $avatar = "<img alt='" . esc_attr($alt) . "' src='" . esc_url($avatar) . "' class='avatar avatar-{$size}{$author_class} photo' height='{$size}' width='{$size}' />";
    return $avatar;
}
Example #7
1
 /**
  * Constructs a file picker object.
  *
  * The following are possible options for the filepicker:
  *    - accepted_types  (*)
  *    - return_types    (FILE_INTERNAL)
  *    - env             (filepicker)
  *    - client_id       (uniqid)
  *    - itemid          (0)
  *    - maxbytes        (-1)
  *    - maxfiles        (1)
  *    - buttonname      (false)
  *
  * @param stdClass $options An object containing options for the file picker.
  */
 public function __construct(stdClass $options)
 {
     global $CFG, $USER, $PAGE;
     require_once $CFG->dirroot . '/repository/lib.php';
     $defaults = array('accepted_types' => '*', 'return_types' => FILE_INTERNAL, 'env' => 'filepicker', 'client_id' => uniqid(), 'itemid' => 0, 'maxbytes' => -1, 'maxfiles' => 1, 'buttonname' => false);
     foreach ($defaults as $key => $value) {
         if (empty($options->{$key})) {
             $options->{$key} = $value;
         }
     }
     $options->currentfile = '';
     if (!empty($options->itemid)) {
         $fs = get_file_storage();
         $usercontext = context_user::instance($USER->id);
         if (empty($options->filename)) {
             if ($files = $fs->get_area_files($usercontext->id, 'user', 'draft', $options->itemid, 'id DESC', false)) {
                 $file = reset($files);
             }
         } else {
             $file = $fs->get_file($usercontext->id, 'user', 'draft', $options->itemid, $options->filepath, $options->filename);
         }
         if (!empty($file)) {
             $options->currentfile = html_writer::link(moodle_url::make_draftfile_url($file->get_itemid(), $file->get_filepath(), $file->get_filename()), $file->get_filename());
         }
     }
     // initilise options, getting files in root path
     $this->options = initialise_filepicker($options);
     // copying other options
     foreach ($options as $name => $value) {
         if (!isset($this->options->{$name})) {
             $this->options->{$name} = $value;
         }
     }
 }
function sanitize_uri()
{
    global $PATH_INFO, $SCRIPT_NAME, $REQUEST_URI;
    if (isset($PATH_INFO) && $PATH_INFO != "") {
        $SCRIPT_NAME = $PATH_INFO;
        $REQUEST_URI = "";
    }
    if ($REQUEST_URI == "") {
        //necessary for some IIS installations (CGI in particular)
        $get = httpallget();
        if (count($get) > 0) {
            $REQUEST_URI = $SCRIPT_NAME . "?";
            reset($get);
            $i = 0;
            while (list($key, $val) = each($get)) {
                if ($i > 0) {
                    $REQUEST_URI .= "&";
                }
                $REQUEST_URI .= "{$key}=" . URLEncode($val);
                $i++;
            }
        } else {
            $REQUEST_URI = $SCRIPT_NAME;
        }
        $_SERVER['REQUEST_URI'] = $REQUEST_URI;
    }
    $SCRIPT_NAME = substr($SCRIPT_NAME, strrpos($SCRIPT_NAME, "/") + 1);
    if (strpos($REQUEST_URI, "?")) {
        $REQUEST_URI = $SCRIPT_NAME . substr($REQUEST_URI, strpos($REQUEST_URI, "?"));
    } else {
        $REQUEST_URI = $SCRIPT_NAME;
    }
}
Example #9
0
 /**
  * @param $tag
  * @return bool|mixed
  */
 function get_first_entry($tag)
 {
     if ($references = $this->get_references($tag, 1)) {
         return reset($references);
     }
     return false;
 }
 protected function preparePrimaryKeyDeleteStatement(DataSourceHandler $handler, DatasetMetaData $dataset, array $originalKeyColumnNames)
 {
     $sql = 'DROP PRIMARY KEY';
     // we need to use the fix only for first column in primary key
     $firstColumnName = reset($originalKeyColumnNames);
     return $this->fixForeignKeyProblem($handler, $dataset, $firstColumnName, TRUE, $sql) . ', ' . $this->fixDropPrimaryKeyColumnProblem($handler, $dataset, $originalKeyColumnNames);
 }
Example #11
0
 public function upload()
 {
     /** import upload library **/
     _wpl_import('assets.packages.ajax_uploader.UploadHandler');
     $kind = wpl_request::getVar('kind', 0);
     $params = array();
     $params['accept_ext'] = wpl_flex::get_field_options(301);
     $extentions = explode(',', $params['accept_ext']['ext_file']);
     $ext_str = '';
     foreach ($extentions as $extention) {
         $ext_str .= $extention . '|';
     }
     // remove last |
     $ext_str = substr($ext_str, 0, -1);
     $ext_str = rtrim($ext_str, ';');
     $custom_op = array('upload_dir' => wpl_global::get_upload_base_path(), 'upload_url' => wpl_global::get_upload_base_url(), 'accept_file_types' => '/\\.(' . $ext_str . ')$/i', 'max_file_size' => $params['accept_ext']['file_size'] * 1000, 'min_file_size' => 1, 'max_number_of_files' => null);
     $upload_handler = new UploadHandler($custom_op);
     $response = json_decode($upload_handler->json_response);
     if (isset($response->files[0]->error)) {
         return;
     }
     $attachment_categories = wpl_items::get_item_categories('attachment', $kind);
     // get item category with first index
     $item_cat = reset($attachment_categories)->category_name;
     $index = floatval(wpl_items::get_maximum_index(wpl_request::getVar('pid'), wpl_request::getVar('type'), $kind, $item_cat)) + 1.0;
     $item = array('parent_id' => wpl_request::getVar('pid'), 'parent_kind' => $kind, 'item_type' => wpl_request::getVar('type'), 'item_cat' => $item_cat, 'item_name' => $response->files[0]->name, 'creation_date' => date("Y-m-d H:i:s"), 'index' => $index);
     wpl_items::save($item);
 }
function CheckFilter($arFilterFields)
{
    global $lAdmin;
    $FilterArr = $arFilterFields;
    reset($FilterArr);
    foreach ($FilterArr as $f) {
        global ${$f};
    }
    $str = "";
    if (strlen(trim($find_timestamp_1)) > 0 || strlen(trim($find_timestamp_2)) > 0) {
        $date_1_ok = false;
        $date1_stm = MkDateTime(FmtDate($find_timestamp_1, "D.M.Y"), "d.m.Y");
        $date2_stm = MkDateTime(FmtDate($find_timestamp_2, "D.M.Y") . " 23:59", "d.m.Y H:i");
        if (!$date1_stm && strlen(trim($find_timestamp_1)) > 0) {
            $str .= GetMessage("MAIN_WRONG_TIMESTAMP_FROM") . "<br>";
        } else {
            $date_1_ok = true;
        }
        if (!$date2_stm && strlen(trim($find_timestamp_2)) > 0) {
            $str .= GetMessage("MAIN_WRONG_TIMESTAMP_TILL") . "<br>";
        } elseif ($date_1_ok && $date2_stm <= $date1_stm && strlen($date2_stm) > 0) {
            $str .= GetMessage("MAIN_FROM_TILL_TIMESTAMP") . "<br>";
        }
    }
    $lAdmin->AddFilterError($str);
    if (strlen($str) > 0) {
        return false;
    }
    return true;
}
Example #13
0
 public function refactor(RefactorFileset $fileset) {
     $tofunc = reset(explode('(',$this->to));
     $toargs = reset(explode(')',end(explode('(',$this->to))));
     $mod = array();
     foreach($fileset->files as $file) {
         if (file_exists($file.'.rf')) {
             $in = file_get_contents($file.'.rf');
         } else {
             $in = file_get_contents($file);
         }
         foreach($this->from as $from) {
             $func = reset(explode('(',$from));
             $args = reset(explode(')',end(explode('(',$from))));
             if ($args == $toargs) {
                 // Just change function names
                 $ref = str_replace($func.'(',$tofunc.'(',$in);
             }
         }
         if ($ref != $in) {
             $mod[] = $file;
             file_put_contents($file.'.rf', $ref);
         }
     }
     return $mod;
 }
 public function projectImport($api, $args)
 {
     $this->checkACL($api, $args);
     $this->requireArgs($args, array('module'));
     $bean = BeanFactory::getBean($args['module']);
     if (!$bean->ACLAccess('save') || !$bean->ACLAccess('import')) {
         throw new SugarApiExceptionNotAuthorized('EXCEPTION_NOT_AUTHORIZED');
     }
     if (isset($_FILES) && count($_FILES) === 1) {
         reset($_FILES);
         $first_key = key($_FILES);
         if (isset($_FILES[$first_key]['tmp_name']) && $this->isUploadedFile($_FILES[$first_key]['tmp_name']) && isset($_FILES[$first_key]['size']) && isset($_FILES[$first_key]['size']) > 0) {
             try {
                 $importerObject = new PMSEProjectImporter();
                 $name = $_FILES[$first_key]['name'];
                 $extension = pathinfo($name, PATHINFO_EXTENSION);
                 if ($extension == $importerObject->getExtension()) {
                     $data = $importerObject->importProject($_FILES[$first_key]['tmp_name']);
                     $results = array('project_import' => $data);
                 } else {
                     throw new SugarApiExceptionRequestMethodFailure('ERROR_UPLOAD_FAILED');
                 }
             } catch (SugarApiExceptionNotAuthorized $e) {
                 throw new SugarApiExceptionNotAuthorized('ERROR_UPLOAD_ACCESS_PD');
             } catch (Exception $e) {
                 throw new SugarApiExceptionRequestMethodFailure('ERROR_UPLOAD_FAILED');
             }
             return $results;
         }
     } else {
         throw new SugarApiExceptionMissingParameter('ERROR_UPLOAD_FAILED');
     }
 }
Example #15
0
 /**
  * Uploads a XLS file with all attribute texts.
  *
  * @param \stdClass $params Object containing the properties
  */
 public function uploadFile(\stdClass $params)
 {
     $this->checkParams($params, array('site'));
     $this->setLocale($params->site);
     if (($fileinfo = reset($_FILES)) === false) {
         throw new \Aimeos\Controller\ExtJS\Exception('No file was uploaded');
     }
     $config = $this->getContext()->getConfig();
     /** controller/extjs/attribute/import/text/standard/enablecheck
      * Enables checking uploaded files if they are valid and not part of an attack
      *
      * This configuration option is for unit testing only! Please don't disable
      * the checks for uploaded files in production environments as this
      * would give attackers the possibility to infiltrate your installation!
      *
      * @param boolean True to enable, false to disable
      * @since 2014.03
      * @category Developer
      */
     if ($config->get('controller/extjs/attribute/import/text/standard/enablecheck', true)) {
         $this->checkFileUpload($fileinfo['tmp_name'], $fileinfo['error']);
     }
     $fileext = pathinfo($fileinfo['name'], PATHINFO_EXTENSION);
     $dest = md5($fileinfo['name'] . time() . getmypid()) . '.' . $fileext;
     $fs = $this->getContext()->getFilesystemManager()->get('fs-admin');
     $fs->writef($dest, $fileinfo['tmp_name']);
     $result = (object) array('site' => $params->site, 'items' => array((object) array('job.label' => 'Attribute text import: ' . $fileinfo['name'], 'job.method' => 'Attribute_Import_Text.importFile', 'job.parameter' => array('site' => $params->site, 'items' => $dest), 'job.status' => 1)));
     $jobController = \Aimeos\Controller\ExtJS\Admin\Job\Factory::createController($this->getContext());
     $jobController->saveItems($result);
     return array('items' => $dest, 'success' => true);
 }
 /**
  * Run each managed process with up to $batchSize in parallel.
  *
  * @return void
  */
 public function start()
 {
     $finished = [];
     $running = [];
     $active = 0;
     while (!empty($this->processes)) {
         while ($active < $this->batchSize && !empty($this->processes)) {
             $p = array_shift($this->processes);
             array_push($running, $p->runAsync());
             $active++;
         }
         foreach ($running as $index => $p) {
             if (!$p->isAlive()) {
                 $active--;
                 array_push($finished, $p);
                 unset($running[$index]);
                 if (!empty($this->processes)) {
                     array_push($running, array_shift($this->processes)->runAsync());
                     $active++;
                 }
             }
         }
         reset($running);
     }
     unset($this->processes);
     $this->processes = $finished;
     unset($finished, $running);
 }
 /**
  * {@inheritdoc}
  */
 public function getSql(SqlWalker $sqlWalker)
 {
     $platform = $sqlWalker->getEntityManager()->getConnection()->getDatabasePlatform();
     $quoteStrategy = $sqlWalker->getEntityManager()->getConfiguration()->getQuoteStrategy();
     $dqlAlias = $this->pathExpression->identificationVariable;
     $assocField = $this->pathExpression->field;
     $qComp = $sqlWalker->getQueryComponent($dqlAlias);
     $class = $qComp['metadata'];
     $assoc = $class->associationMappings[$assocField];
     $targetEntity = $sqlWalker->getEntityManager()->getClassMetadata($assoc['targetEntity']);
     $joinColumn = reset($assoc['joinColumns']);
     if ($this->fieldMapping !== null) {
         if (!isset($targetEntity->fieldMappings[$this->fieldMapping])) {
             throw new QueryException(sprintf('Undefined reference field mapping "%s"', $this->fieldMapping));
         }
         $field = $targetEntity->fieldMappings[$this->fieldMapping];
         $joinColumn = null;
         foreach ($assoc['joinColumns'] as $mapping) {
             if ($mapping['referencedColumnName'] === $field['columnName']) {
                 $joinColumn = $mapping;
                 break;
             }
         }
         if ($joinColumn === null) {
             throw new QueryException(sprintf('Unable to resolve the reference field mapping "%s"', $this->fieldMapping));
         }
     }
     // The table with the relation may be a subclass, so get the table name from the association definition
     $tableName = $sqlWalker->getEntityManager()->getClassMetadata($assoc['sourceEntity'])->getTableName();
     $tableAlias = $sqlWalker->getSQLTableAlias($tableName, $dqlAlias);
     $columnName = $quoteStrategy->getJoinColumnName($joinColumn, $targetEntity, $platform);
     return $tableAlias . '.' . $columnName;
 }
Example #18
0
 public static function buildRows($filename)
 {
     $data = self::getCsv($filename);
     $header = array();
     $sid1 = array();
     $sid_sec = array();
     foreach ($data as $id => $d) {
         $header[$d[self::COL_DESC]] = $d[self::COL_DESC];
         $sid1[$d[self::COL_SID]] = $d[self::COL_SID];
         $sid_sec[$d[self::COL_SID]][][$d[self::COL_DESC]] = $d[self::COL_SEC];
     }
     $c = count($header);
     $sid_sec_2 = array();
     foreach ($sid_sec as $sid => $sec) {
         for ($i = 0; $i < count($sec); $i += $c) {
             for ($j = 0; $j < $c; $j++) {
                 $key = key($sec[$i + $j]);
                 $value = reset($sec[$i + $j]);
                 $sid_sec_2[$sid][$i][$key] = $value;
             }
         }
     }
     $i = 0;
     $rows = array();
     foreach ($sid_sec_2 as $sid => $tab) {
         foreach ($tab as $id => $m) {
             $i++;
             $rows[$i] = array('SID' => $sid);
             foreach ($header as $h) {
                 $rows[$i][$h] = $m[$h];
             }
         }
     }
     return $rows;
 }
Example #19
0
 function Explain($sql, $partial = false)
 {
     $save = $this->conn->LogSQL(false);
     if ($partial) {
         $sqlq = $this->conn->qstr($sql . '%');
         $arr = $this->conn->GetArray("select distinct distinct sql1 from adodb_logsql where sql1 like {$sqlq}");
         if ($arr) {
             foreach ($arr as $row) {
                 $sql = reset($row);
                 if (crc32($sql) == $partial) {
                     break;
                 }
             }
         }
     }
     $sql = str_replace('?', "''", $sql);
     $s = '<p><b>Explain</b>: ' . htmlspecialchars($sql) . '</p>';
     $rs = $this->conn->Execute('EXPLAIN ' . $sql);
     $this->conn->LogSQL($save);
     $s .= '<pre>';
     if ($rs) {
         while (!$rs->EOF) {
             $s .= reset($rs->fields) . "\n";
             $rs->MoveNext();
         }
     }
     $s .= '</pre>';
     $s .= $this->Tracer($sql, $partial);
     return $s;
 }
 /**
  * Process screen.
  *
  * @return CDiv (screen inside container)
  */
 public function get()
 {
     $screen = API::Screen()->get(array('screenids' => $this->screenitem['resourceid'], 'output' => API_OUTPUT_EXTEND, 'selectScreenItems' => API_OUTPUT_EXTEND));
     $screen = reset($screen);
     $screenBuilder = new CScreenBuilder(array('isFlickerfree' => $this->isFlickerfree, 'mode' => $this->mode == SCREEN_MODE_EDIT || $this->mode == SCREEN_MODE_SLIDESHOW ? SCREEN_MODE_SLIDESHOW : SCREEN_MODE_PREVIEW, 'timestamp' => $this->timestamp, 'screen' => $screen, 'period' => $this->timeline['period'], 'stime' => $this->timeline['stimeNow'], 'profileIdx' => $this->profileIdx, 'updateProfile' => false));
     return $this->getOutput($screenBuilder->show(), true);
 }
 function objectInfo($object_array)
 {
     reset($object_array);
     while (list($key, $value) = each($object_array)) {
         $this->{$key} = olc_db_prepare_input($value);
     }
 }
Example #22
0
 function Explain($sql, $partial = false)
 {
     if (strtoupper(substr(trim($sql), 0, 6)) !== 'SELECT') {
         return '<p>Unable to EXPLAIN non-select statement</p>';
     }
     $save = $this->conn->LogSQL(false);
     if ($partial) {
         $sqlq = $this->conn->qstr($sql . '%');
         $arr = $this->conn->GetArray("select distinct sql1 from adodb_logsql where sql1 like {$sqlq}");
         if ($arr) {
             foreach ($arr as $row) {
                 $sql = reset($row);
                 if (crc32($sql) == $partial) {
                     break;
                 }
             }
         }
     }
     $sql = str_replace('?', "''", $sql);
     if ($partial) {
         $sqlq = $this->conn->qstr($sql . '%');
         $sql = $this->conn->GetOne("select sql1 from adodb_logsql where sql1 like {$sqlq}");
     }
     $s = '<p><b>Explain</b>: ' . htmlspecialchars($sql) . '</p>';
     $rs = $this->conn->Execute('EXPLAIN ' . $sql);
     $s .= rs2html($rs, false, false, false, false);
     $this->conn->LogSQL($save);
     $s .= $this->Tracer($sql);
     return $s;
 }
 public function testGetFunctions()
 {
     $functions = $this->extension->getFunctions();
     $this->assertCount(1, $functions);
     $function = reset($functions);
     $this->assertEquals('check_ws', $function->getName());
 }
 public function validateForSubmission(EntryDistribution $entryDistribution, $action)
 {
     $validationErrors = parent::validateForSubmission($entryDistribution, $action);
     //validation of flavor format
     $flavorAsset = null;
     $flavorAssets = assetPeer::retrieveByIds(explode(',', $entryDistribution->getFlavorAssetIds()));
     // if we have specific flavor assets for this distribution, grab the first one
     if (count($flavorAssets)) {
         $flavorAsset = reset($flavorAssets);
         $fileExt = $flavorAsset->getFileExt();
         $allowedExts = explode(',', self::FLAVOR_VALID_FORMATS);
         if (!in_array($fileExt, $allowedExts)) {
             KalturaLog::debug('flavor asset id [' . $flavorAsset->getId() . '] does not have a valid extension [' . $fileExt . ']');
             $errorMsg = 'Flavor format must be one of [' . self::FLAVOR_VALID_FORMATS . ']';
             $validationError = $this->createValidationError($action, DistributionErrorType::INVALID_DATA);
             $validationError->setValidationErrorType(DistributionValidationErrorType::CUSTOM_ERROR);
             $validationError->setValidationErrorParam($errorMsg);
             $validationError->setDescription($errorMsg);
             $validationErrors[] = $validationError;
         }
     }
     $inListOrNullFields = array(IdeticDistributionField::GENRE => explode(',', self::GENRE_VALID_VALUES));
     $allFieldValues = $this->getAllFieldValues($entryDistribution);
     if (!$allFieldValues || !is_array($allFieldValues)) {
         KalturaLog::err('Error getting field values from entry distribution id [' . $entryDistribution->getId() . '] profile id [' . $this->getId() . ']');
         return $validationErrors;
     }
     $validationErrors = array_merge($validationErrors, $this->validateInListOrNull($inListOrNullFields, $allFieldValues, $action));
     //validating Slot is a whole number
     $validationErrors = array_merge($validationErrors, $this->validateIsWholeNumber(IdeticDistributionField::SLOT, $allFieldValues, $action));
     return $validationErrors;
 }
 public function getDefaultPhoto()
 {
     $this->setStart(0);
     $this->setLimit(1);
     $items = $this->items();
     return reset($items);
 }
Example #26
0
 function parse($data_str, $query)
 {
     $items = array('name' => 'Domain Name (UTF-8):', 'created' => 'Record created on', 'expires' => 'Record expires on', 'changed' => 'Record last updated on', 'status' => 'Record status:', 'handle' => 'Record ID:');
     while (list($key, $val) = each($data_str['rawdata'])) {
         $val = trim($val);
         if ($val != '') {
             if ($val == 'Domain servers in listed order:') {
                 while (list($key, $val) = each($data_str['rawdata'])) {
                     $val = trim($val);
                     if ($val == '') {
                         break;
                     }
                     $r['regrinfo']['domain']['nserver'][] = $val;
                 }
                 break;
             }
             reset($items);
             while (list($field, $match) = each($items)) {
                 if (strstr($val, $match)) {
                     $r['regrinfo']['domain'][$field] = trim(substr($val, strlen($match)));
                     break;
                 }
             }
         }
     }
     if (isset($r['regrinfo']['domain'])) {
         $r['regrinfo']['registered'] = 'yes';
     } else {
         $r['regrinfo']['registered'] = 'no';
     }
     $r['regyinfo'] = array('whois' => 'whois.nic.nu', 'referrer' => 'http://www.nunames.nu', 'registrar' => '.NU Domain, Ltd');
     format_dates($r, 'dmy');
     return $r;
 }
Example #27
0
 public function process(Vtiger_Request $request)
 {
     $recordId = $request->get('record');
     $qualifiedModuleName = $request->getModule(false);
     $mode = '';
     $selectedFieldsList = $allFieldsList = array();
     if ($recordId) {
         $recordModel = Settings_Webforms_Record_Model::getInstanceById($recordId, $qualifiedModuleName);
         $selectedFieldsList = $recordModel->getSelectedFieldsList();
         $allFieldsList = $recordModel->getAllFieldsList();
         $sourceModule = $recordModel->get('targetmodule');
         $mode = 'edit';
     } else {
         $recordModel = Settings_Webforms_Record_Model::getCleanInstance($qualifiedModuleName);
         $sourceModule = $request->get('sourceModule');
         if (!$sourceModule) {
             $sourceModule = reset(array_keys(Settings_Webforms_Module_Model::getSupportedModulesList()));
         }
         $allFieldsList = $recordModel->getAllFieldsList($sourceModule);
     }
     $recordStructure = Vtiger_RecordStructure_Model::getInstanceFromRecordModel($recordModel, Vtiger_RecordStructure_Model::RECORD_STRUCTURE_MODE_EDIT);
     $viewer = $this->getViewer($request);
     $viewer->assign('MODE', $mode);
     $viewer->assign('RECORD_ID', $recordId);
     $viewer->assign('RECORD_MODEL', $recordModel);
     $viewer->assign('MODULE', $qualifiedModuleName);
     $viewer->assign('QUALIFIED_MODULE', $qualifiedModuleName);
     $viewer->assign('SOURCE_MODULE', $sourceModule);
     $viewer->assign('ALL_FIELD_MODELS_LIST', $allFieldsList);
     $viewer->assign('SELECTED_FIELD_MODELS_LIST', $selectedFieldsList);
     $viewer->assign('RECORD_STRUCTURE_MODEL', $recordStructure);
     $viewer->assign('RECORD_STRUCTURE', $recordStructure->getStructure());
     $viewer->assign('USER_MODEL', Users_Record_Model::getCurrentUserModel());
     $viewer->view('EditView.tpl', $qualifiedModuleName);
 }
Example #28
0
 function tag()
 {
     $doc = JFactory::getDocument();
     $doc->addStyleSheet(ACYMAILING_CSS . 'frontendedition.css?v=' . filemtime(ACYMAILING_MEDIA . 'css' . DS . 'frontendedition.css'));
     JPluginHelper::importPlugin('acymailing');
     $dispatcher = JDispatcher::getInstance();
     $tagsfamilies = $dispatcher->trigger('acymailing_getPluginType');
     $defaultFamily = reset($tagsfamilies);
     $app = JFactory::getApplication();
     $fctplug = $app->getUserStateFromRequest(ACYMAILING_COMPONENT . ".tag", 'fctplug', $defaultFamily->function, 'cmd');
     ob_start();
     $defaultContents = $dispatcher->trigger($fctplug);
     $defaultContent = ob_get_clean();
     $js = 'function insertTag(){if(window.parent.insertTag(window.document.getElementById(\'tagstring\').value)) {acymailing_js.closeBox(true);}}';
     $js .= 'function setTag(tagvalue){window.document.getElementById(\'tagstring\').value = tagvalue;}';
     $js .= 'function showTagButton(){window.document.getElementById(\'insertButton\').style.display = \'inline\'; window.document.getElementById(\'tagstring\').style.display=\'inline\';}';
     $js .= 'function hideTagButton(){}';
     $js .= 'try{window.parent.previousSelection = window.parent.getPreviousSelection(); }catch(err){window.parent.previousSelection=false; }';
     $doc->addScriptDeclaration($js);
     $this->assignRef('fctplug', $fctplug);
     $type = JRequest::getString('type', 'news');
     $this->assignRef('type', $type);
     $this->assignRef('defaultContent', $defaultContent);
     $this->assignRef('tagsfamilies', $tagsfamilies);
     $app = JFactory::getApplication();
     $this->assignRef('app', $app);
     $ctrl = JRequest::getString('ctrl');
     $this->assignRef('ctrl', $ctrl);
 }
Example #29
0
 private function reset(&$array)
 {
     foreach ($array as $key => $value) {
         unset($array[$key]);
     }
     reset($array);
 }
 function _get_select()
 {
     $exclude = array();
     $wlk = $this->_tree_walk_preorder($this->node);
     while (!$wlk['recset']->EOF) {
         $row = $wlk['recset']->fields;
         $exclude[$row['id']] = 'yes';
         $wlk['recset']->MoveNext();
     }
     $mySelect = new CHAW_select($this->key);
     $node = $this->_tree_get_group_root_node($this->usergroup);
     $attributes = array('name');
     $wlk = $this->_tree_walk_preorder($node);
     while ($curr = $this->_tree_walk_next($wlk)) {
         $level = $this->_tree_walk_level($wlk);
         $spaces = str_repeat('--', $level - 1);
         $att = reset($attributes);
         while ($att) {
             if ($level == 0) {
                 $mySelect->add_option('(seleziona cartella)', $wlk['row']['id']);
             } elseif ($wlk['row']['file'] == '' && !isset($exclude[$wlk['row']['id']])) {
                 $mySelect->add_option($spaces . $wlk['row'][$att], $wlk['row']['id']);
             }
             $att = next($attributes);
         }
     }
     return $mySelect;
 }