[go: up one dir, main page]

Menu

[r3]: / doc / bin / docmgr-thumb.php  Maximize  Restore  History

Download this file

106 lines (72 with data), 3.1 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
<?php
/******************************************************************************
Indexer script. It will only work if called from the root docmgr directory
******************************************************************************/
/******************************************************************************
preliminary configuration and variable setting
******************************************************************************/
//get our includes
//first call the config file to get our settings, call our base functions, and get our wrapper
include("config/config.php");
include("config/app-config.php");
//the rest of our includes with our base functions
include("header/callheader.php");
include("app/common.inc.php");
include("app/object.inc.php");
include("app/thumb_function.inc.php");
//set our path defines
define("DATA_DIR",FILE_DIR."/data");
define("THUMB_DIR",FILE_DIR."/thumbnails");
define("PREVIEW_DIR",FILE_DIR."/preview");
define("TMP_DIR",FILE_DIR."/tmp");
//set to use short tags
ini_set("short_open_tag","1");
//load our center modules to see the objects
$siteModArr = loadSiteStructure("modules/center/");
$_SESSION["siteModList"] = $siteModArr["list"];
$_SESSION["siteModInfo"] = $siteModArr["info"];
$siteModList = &$_SESSION["siteModList"];
$siteModInfo = &$_SESSION["siteModInfo"];
//load our objects so we can call their indexing functions
loadObjects();
//setup which apps are available to docmgr
setExternalApps();
//connect to the db
$conn = db_connect(DBHOST,DBUSER,DBPASSWORD,DBPORT,DBNAME);
//allow indexing of a certain objectId. This is for debugging only
if (in_array("--thumb-object",$argv)) {
//we are looking for the id passed after our parameter
$key = array_search("--thumb-object",$argv) + 1;
$obj = $argv[$key];
if ($obj) {
//index the item
echo "Thumbnailing and Creating preview for object ".$obj."\n";
runObjectThumb($conn,$obj);
} else echo "Invalid object id passed\n";
die;
}
/*******************************************************************************
Now it's time to process our batch. We continue to run until
there are no more batches left
*******************************************************************************/
while (1) {
//get the ids of all the objects in this batch
$sql = "SELECT * FROM dm_thumb_queue ORDER BY id";
$list = total_result($conn,$sql);
$objArr = &$list["object_id"];
debugMsg(1,"No objects found in the queue. Exiting");
//get out if there's nothing to do
if (!$list["count"]) exit;
debugMsg(1,$list["count"]." objects found in the queue. Proceeding to thumbnail");
for ($i=0;$i<$list["count"];$i++) {
$obj = $list["object_id"][$i];
$id = $list["id"][$i];
//index the item
runObjectThumb($conn,$obj);
//delete this item from the queue
$sql = "DELETE FROM dm_thumb_queue WHERE id='$id'";
db_query($conn,$sql);
}
//sleep 10 seconds before checking for another batch
sleep(5);
}