}
if($this->mimetype == 'application/pdf'){
- require_once 'System.php';
-
- $this->no_of_pages = 0;
-
- $pdfinfo = System::which('pdfinfo');
-
- if (!empty($pdfinfo)) {
-
- $cmd = "{$pdfinfo} {$file}";
-
- $ret = `$cmd`;
-
- $info = explode("\n", $ret);
-
- foreach ($info as $i){
-
- if(!preg_match('/^Pages:[\s]?([0-9]+)/', $i, $matches)){
- continue;
- }
- print_R($matches);exit;
- $ret = (empty($matches[1])) ? false : $matches[1];
- break;
- }
- }
-
+ $this->no_of_pages = $this->getPdfPages($file);
}
$this->filesize = filesize($file);
{
$opts = HTML_FlexyFramework::get()->Pman;
$fn = preg_replace('/[^a-z0-9\.]+/i', '_', $this->filename);
+ $opts = HTML_FlexyFramework::get()->Coba;
+
+ print_r($opts);exit;
return implode( '/', array(
$opts['storedir'], '_images_', date('Y/m', strtotime($this->created)), $this->id . '-'. $fn
));
$this->filesize = filesize($f);
+ if($this->mimetype == 'application/pdf'){
+ $this->no_of_pages = $this->getPdfPages($f);
+ }
+
$this->update($o);
return true;
return $base64;
}
+ function getPdfPages($file)
+ {
+ require_once 'System.php';
+
+ $page = 0;
+
+ $pdfinfo = System::which('pdfinfo');
+
+ if (!file_exists($file) || empty($pdfinfo)) {
+ return $page;
+ }
+
+ $cmd = "{$pdfinfo} {$file}";
+
+ $ret = `$cmd`;
+
+ $info = explode("\n", $ret);
+
+ foreach ($info as $i){
+
+ if(!preg_match('/^Pages:[\s]*([0-9]+)/', $i, $matches)){
+ continue;
+ }
+
+ $page = (empty($matches[1])) ? 0 : $matches[1];
+ }
+
+ return $page;
+ }
+
}