예제 #1
0
 protected function process()
 {
     $this->line = remove_whitespace($this->line);
     foreach ($this->blocks as $block) {
         $this->{'block' . $block}();
     }
 }
예제 #2
0
파일: string.php 프로젝트: kbond/string
 /**
  * Truncates text to a length without breaking words.
  *
  * @param string $str
  * @param int    $length
  * @param string $suffix
  *
  * @return string
  */
 function truncate_word($str, $length = 255, $suffix = '...')
 {
     $output = remove_whitespace(trim($str));
     if (strlen($output) > $length) {
         $output = wordwrap($output, $length - strlen($suffix));
         $output = substr($output, 0, strpos($output, "\n"));
         $output .= $suffix;
     }
     return strlen($output) > $length ? '' : $output;
 }
예제 #3
0
function smarty_modifier_remove_whitespace($string)
{
    return remove_whitespace($string);
}
예제 #4
0
        file_put_contents($file, find_and_combine_css($url));
        $originalLength = filesize($file);
    }
} else {
    $inputSource = 'input';
    file_put_contents($file, $_POST['input']);
    $originalLength = filesize($file);
}
if ($originalLength == 0) {
    $originalLength = 1;
}
$originalFile = 'results/testing.txt';
file_put_contents($originalFile, file_get_contents($file));
// Actions. Not sure about what the best order is?
if ($_POST['removeWhiteSpace']) {
    remove_whitespace($file);
}
if ($_POST['removeComments']) {
    remove_comments($file);
}
?>

  <div class="grid-container">
    <section class="grid-parent grid-100">
      <div class="grid-100">
        <div class="header grid-40 push-30">
          <a href="index.php">
            <h1><span>CSS</span> OPTIMIZER</h1>
            <p>Let's get that CSS tidied up, shall we?</p>
          </a>
        </div>
 /**
  * Validates new projects being created by performing error checks on user input
  * @return boolean Returns false if user input fields threw an error
  */
 public function validateNewProject()
 {
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         array_htmlspecialchars($_POST);
         $this->project_name = $_POST['projectName'];
         $this->facilitator = $_POST['facilitator'];
         $this->project_due_date = $_POST['projectDueDate'];
         $this->project_description = trim($_POST['projectDescription']);
         // validate project name
         if (!ctype_alnum(remove_whitespace($this->project_name))) {
             $this->errors['project_name']['error'] = 1;
         } elseif ($this->projectAlreadyExists() == TRUE) {
             $this->errors['project_exists']['error'] = 1;
         }
         // validate instructor name
         if (validate_instructor($this->facilitator) == FALSE) {
             $this->errors['instructor']['error'] = 1;
         }
         // validate project description
         if (strlen($this->project_description) < 100) {
             $this->errors['project_description']['error'] = 1;
         }
         // validating due date field by attempting to make a DateTime object
         if (DateTime::createFromFormat("Y-m-d", $this->project_due_date) == false) {
             $this->errors['project_due_date_invalid']['error'] = 1;
         }
         // check for empty fields
         if (empty($this->project_name) or empty($this->facilitator)) {
             $this->errors['empty']['error'] = 1;
         }
         // check if a file was uploaded and if so run validation
         $this->confidentiality_agreement_file_validation();
         // run through the errors array and check if any errors are set to 1
         $error_exists = 0;
         foreach ($this->errors as $key => $value) {
             if ($this->errors[$key]['error'] == 1) {
                 $error_exists = 1;
             }
         }
         // return true if file was validated
         if ($error_exists == 0) {
             /**
              * insert project record to database depending on user type
              * 
              * note - professor accounts will update the claimed section automatically to 1
              * 		so that the project does not show up on the search results once claimed
              */
             if ($_SESSION['Account_Type'] == 'Professor') {
                 $this->insertNewProjectProfessor();
             } elseif ($_SESSION['Account_Type'] = 'Business') {
                 $this->insertNewProjectBusiness();
             }
             // save uploaded file to disk drive
             if (!empty($_SESSION['Create_New_Project'])) {
                 $this->saveFileToDisk();
             }
             // unset session variable
             unset($_SESSION['Create_New_Project']);
             // redirect user
             header('Location: create_project_success.php');
         } else {
             return false;
         }
     }
 }
function get_calendar_events($cal_url)
{
    $events1 = curl_download($cal_url);
    $events2 = parse_output($events1);
    $events3 = parse_events($events2);
    $events4 = remove_colors($events3);
    $events5 = remove_whitespace($events4);
    $events6 = get_key_values($events5);
    get_json_cal_events($events6);
}
예제 #7
0
        $data = file_get_contents($cachefile);
        if ($data != '') {
            $data = json_decode($data, true);
            echo template($data, $countitem);
            die;
        }
    }
}
$data = curl($rssurl);
if ($data != '') {
    $xml = simplexml_load_string($data);
    $items = $xml->channel->item;
    $items_list = array();
    if (count($items) > 0) {
        foreach ($items as $item) {
            $desc = remove_whitespace(strip_tags(htmlspecialchars_decode($item->description)));
            $desc = getPrewText($desc, $maxwords, $descrx);
            $title = getPrewText((string) $item->title, $maxwords, $linkx);
            $items_list[] = array('title' => $title, 'link' => (string) $item->link, 'desc' => $desc);
        }
        #Запись в кеш
        if (file_exists($cachefile)) {
            file_put_contents($cachefile, json_encode($items_list));
        }
        echo template($items_list, $countitem);
    }
} else {
    echo 'временно недоступно';
}
function curl($url)
{